pkg.py.patch
| pyeole/pkg.py | ||
|---|---|---|
| 63 | 63 | |
| 64 | 64 |
log = logging.getLogger(__name__) |
| 65 | 65 |
log.addHandler(logging.NullHandler()) |
| 66 |
class SourceKey: |
|
| 67 |
pass |
|
| 66 | 68 | |
| 69 |
class URLSourceKey(SourceKey): |
|
| 70 |
def __init__(self, url): |
|
| 71 |
self.url = url |
|
| 72 | ||
| 73 |
class FingerPrintSourceKey(SourceKey): |
|
| 74 |
def __init__(self, fingerprint): |
|
| 75 |
self.fingerprint = fingerprint |
|
| 76 | ||
| 77 |
class Deb822Source: |
|
| 78 |
def __init__(self, src_type, uri, suites, components, key): |
|
| 79 |
self.src_type = src_type |
|
| 80 |
self.uri = uri |
|
| 81 |
self.suites = suites if isinstance(suites, list) else [suites] |
|
| 82 |
self.components = components if isinstance(components, list) else [components] |
|
| 83 |
self.key = key |
|
| 67 | 84 |
try: |
| 68 | 85 |
import apt |
| 69 | 86 |
import apt_pkg |
| ... | ... | |
| 1645 | 1662 |
engine.process(file_info, ctx) |
| 1646 | 1663 |
_do_template_samba(ctx) |
| 1647 | 1664 | |
| 1648 |
def _do_template_additional(ctx): |
|
| 1665 |
def _do_template_additional(ctx, name):
|
|
| 1649 | 1666 |
"""Generate additional sources list file for the given context |
| 1650 | 1667 |
""" |
| 1651 |
file_info = {'name': _SOURCES_LISTS_ADDITIONAL,
|
|
| 1652 |
'source': os.path.join(templatedir, 'additional.list'), |
|
| 1668 |
source_sources_path = os.path.join(_SOURCES_LISTS_DIR, f"{name}.sources")
|
|
| 1669 |
file_info = {'name': source_sources_path,
|
|
| 1670 |
'source': os.path.join(templatedir, 'source.sources'), |
|
| 1653 | 1671 |
'full_name': os.path.join('/', ctx['path'],
|
| 1654 |
_SOURCES_LISTS_ADDITIONAL[1:]),
|
|
| 1672 |
source_sources_path[1:]),
|
|
| 1655 | 1673 |
'activate' : True, |
| 1656 | 1674 |
'del_comment': u'', |
| 1657 | 1675 |
'mkdir' : False, |
| ... | ... | |
| 1918 | 1936 |
rmtree(keyring_dir) |
| 1919 | 1937 |
raise AptProxyError(_('cannot export the fingerprint {}').format(signing_key_fingerprint))
|
| 1920 | 1938 |
if os.path.isfile(keyring): |
| 1921 |
cmd = ['apt-key', '--keyring', filename, 'add', keyring]
|
|
| 1939 |
cmd = ['gpg', '--dearmor', '-o', filename, keyring]
|
|
| 1922 | 1940 |
code, stdout, stderr = system_out(cmd) |
| 1923 | 1941 |
if code != 0: |
| 1924 | 1942 |
if os.path.isfile(filename): |
| 1925 | 1943 |
os.remove(filename) |
| 1926 | 1944 |
rmtree(keyring_dir) |
| 1927 | 1945 |
raise AptProxyError(_('cannot import the key {}').format(name))
|
| 1946 |
try: |
|
| 1947 |
if not creoled_not_available: |
|
| 1948 |
method, uri, suite, component, architecture = additional_repository_source[idx].split() |
|
| 1949 |
deb822_variables = {'_deb822_name': name,
|
|
| 1950 |
'_deb822_key': filename, |
|
| 1951 |
'_deb822_types': ['deb'], |
|
| 1952 |
'_deb822_uris': [uri], |
|
| 1953 |
'_deb822_suites': [suite], |
|
| 1954 |
'_deb822_components': [component], |
|
| 1955 |
'_deb822_architectures': [architecture], |
|
| 1956 |
} |
|
| 1957 |
engine.creole_variables_dict.update(deb822_variables) |
|
| 1958 |
_do_template_additional(rootctx, name) |
|
| 1959 |
if pkgmgr.is_container_mode(): |
|
| 1960 |
for group in groups['groups']: |
|
| 1961 |
container_infos = groups['group_infos'][group] |
|
| 1962 |
if group not in ['all', 'root'] and is_lxc_running(container_infos): |
|
| 1963 |
if not creoled_not_available: |
|
| 1964 |
_do_template_additional(container_infos, name) |
|
| 1965 |
except Exception as err: |
|
| 1966 |
if pkgmgr.ignore: |
|
| 1967 |
log.warning(_(f'cannot build {name}.sources use current one'))
|
|
| 1968 |
else: |
|
| 1969 |
raise err |
|
| 1970 |
|
|
| 1928 | 1971 | |
| 1929 | 1972 |
# delete old cache (#10186) |
| 1930 | 1973 |
pkgmgr.cache = None |
| pyeole/pkg.py | ||
|---|---|---|
| 63 | 63 | |
| 64 | 64 |
log = logging.getLogger(__name__) |
| 65 | 65 |
log.addHandler(logging.NullHandler()) |
| 66 |
class SourceKey: |
|
| 67 |
pass |
|
| 66 | 68 | |
| 69 |
class URLSourceKey(SourceKey): |
|
| 70 |
def __init__(self, url): |
|
| 71 |
self.url = url |
|
| 72 | ||
| 73 |
class FingerPrintSourceKey(SourceKey): |
|
| 74 |
def __init__(self, fingerprint): |
|
| 75 |
self.fingerprint = fingerprint |
|
| 76 | ||
| 77 |
class Deb822Source: |
|
| 78 |
def __init__(self, src_type, uri, suites, components, key): |
|
| 79 |
self.src_type = src_type |
|
| 80 |
self.uri = uri |
|
| 81 |
self.suites = suites if isinstance(suites, list) else [suites] |
|
| 82 |
self.components = components if isinstance(components, list) else [components] |
|
| 83 |
self.key = key |
|
| 67 | 84 |
try: |
| 68 | 85 |
import apt |
| 69 | 86 |
import apt_pkg |
| ... | ... | |
| 1645 | 1662 |
engine.process(file_info, ctx) |
| 1646 | 1663 |
_do_template_samba(ctx) |
| 1647 | 1664 | |
| 1648 |
def _do_template_additional(ctx): |
|
| 1665 |
def _do_template_additional(ctx, name):
|
|
| 1649 | 1666 |
"""Generate additional sources list file for the given context |
| 1650 | 1667 |
""" |
| 1651 |
file_info = {'name': _SOURCES_LISTS_ADDITIONAL,
|
|
| 1652 |
'source': os.path.join(templatedir, 'additional.list'), |
|
| 1668 |
source_sources_path = os.path.join(_SOURCES_LISTS_DIR, f"{name}.sources")
|
|
| 1669 |
file_info = {'name': source_sources_path,
|
|
| 1670 |
'source': os.path.join(templatedir, 'source.sources'), |
|
| 1653 | 1671 |
'full_name': os.path.join('/', ctx['path'],
|
| 1654 |
_SOURCES_LISTS_ADDITIONAL[1:]),
|
|
| 1672 |
source_sources_path[1:]),
|
|
| 1655 | 1673 |
'activate' : True, |
| 1656 | 1674 |
'del_comment': u'', |
| 1657 | 1675 |
'mkdir' : False, |
| ... | ... | |
| 1831 | 1849 |
try: |
| 1832 | 1850 |
_do_template(rootctx) |
| 1833 | 1851 |
_do_template_eolehub(rootctx) |
| 1834 |
if not creoled_not_available: |
|
| 1835 |
_do_template_additional(rootctx) |
|
| 1836 |
#_do_template_aptproxy(rootctx) |
|
| 1837 | 1852 |
if pkgmgr.is_container_mode(): |
| 1838 | 1853 |
for group in groups['groups']: |
| 1839 | 1854 |
container_infos = groups['group_infos'][group] |
| ... | ... | |
| 1841 | 1856 |
_do_template(container_infos) |
| 1842 | 1857 |
if not creoled_not_available: |
| 1843 | 1858 |
_do_template_aptproxy(container_infos) |
| 1844 |
_do_template_additional(container_infos) |
|
| 1845 | 1859 |
except Exception as err: |
| 1846 | 1860 |
if pkgmgr.ignore: |
| 1847 | 1861 |
log.warning(_('cannot build sources.list use current one'))
|
| ... | ... | |
| 1918 | 1932 |
rmtree(keyring_dir) |
| 1919 | 1933 |
raise AptProxyError(_('cannot export the fingerprint {}').format(signing_key_fingerprint))
|
| 1920 | 1934 |
if os.path.isfile(keyring): |
| 1921 |
cmd = ['apt-key', '--keyring', filename, 'add', keyring]
|
|
| 1935 |
cmd = ['gpg', '--dearmor', '-o', filename, keyring]
|
|
| 1922 | 1936 |
code, stdout, stderr = system_out(cmd) |
| 1923 | 1937 |
if code != 0: |
| 1924 | 1938 |
if os.path.isfile(filename): |
| 1925 | 1939 |
os.remove(filename) |
| 1926 | 1940 |
rmtree(keyring_dir) |
| 1927 | 1941 |
raise AptProxyError(_('cannot import the key {}').format(name))
|
| 1942 |
try: |
|
| 1943 |
if not creoled_not_available: |
|
| 1944 |
method, uri, suite, component, architecture = additional_repository_source[idx].split() |
|
| 1945 |
deb822_variables = {'_deb822_name': name,
|
|
| 1946 |
'_deb822_key': filename, |
|
| 1947 |
'_deb822_types': ['deb'], |
|
| 1948 |
'_deb822_uris': [uri], |
|
| 1949 |
'_deb822_suites': [suite], |
|
| 1950 |
'_deb822_components': [component], |
|
| 1951 |
'_deb822_architectures': [architecture], |
|
| 1952 |
} |
|
| 1953 |
engine.creole_variables_dict.update(deb822_variables) |
|
| 1954 |
_do_template_additional(rootctx, name) |
|
| 1955 |
if pkgmgr.is_container_mode(): |
|
| 1956 |
for group in groups['groups']: |
|
| 1957 |
container_infos = groups['group_infos'][group] |
|
| 1958 |
if group not in ['all', 'root'] and is_lxc_running(container_infos): |
|
| 1959 |
if not creoled_not_available: |
|
| 1960 |
_do_template_additional(container_infos, name) |
|
| 1961 |
except Exception as err: |
|
| 1962 |
if pkgmgr.ignore: |
|
| 1963 |
log.warning(_(f'cannot build {name}.sources use current one'))
|
|
| 1964 |
else: |
|
| 1965 |
raise err |
|
| 1966 |
|
|
| 1928 | 1967 | |
| 1929 | 1968 |
# delete old cache (#10186) |
| 1930 | 1969 |
pkgmgr.cache = None |