Make arches a dict for specifying repository_url per arch
This commit is contained in:
parent
b7d8e87629
commit
9abd492a3c
@ -64,7 +64,10 @@ class CB:
|
|||||||
|
|
||||||
self.log_level = getattr(logging, cfg.get('log_level', 'INFO').upper())
|
self.log_level = getattr(logging, cfg.get('log_level', 'INFO').upper())
|
||||||
|
|
||||||
self._repository_url = cfg.get('repository_url', 'file:///space/ALT')
|
self._repository_url = cfg.get('repository_url',
|
||||||
|
'file:///space/ALT/{branch}')
|
||||||
|
|
||||||
|
self.bad_arches = cfg.get('bad_arches', [])
|
||||||
|
|
||||||
self._packages = cfg.get('packages', {})
|
self._packages = cfg.get('packages', {})
|
||||||
self._services = cfg.get('services', {})
|
self._services = cfg.get('services', {})
|
||||||
@ -76,6 +79,9 @@ class CB:
|
|||||||
self.key = '{:X}'.format(self.key)
|
self.key = '{:X}'.format(self.key)
|
||||||
self._images = cfg['images']
|
self._images = cfg['images']
|
||||||
self._branches = cfg['branches']
|
self._branches = cfg['branches']
|
||||||
|
for _, branch in self._branches.items():
|
||||||
|
branch['arches'] = {k: {} if v is None else v
|
||||||
|
for k, v in branch['arches'].items()}
|
||||||
except KeyError as e:
|
except KeyError as e:
|
||||||
msg = f'Required parameter {e} does not set in config'
|
msg = f'Required parameter {e} does not set in config'
|
||||||
print(msg, file=sys.stderr)
|
print(msg, file=sys.stderr)
|
||||||
@ -94,9 +100,12 @@ class CB:
|
|||||||
def remote(self, branch: str) -> str:
|
def remote(self, branch: str) -> str:
|
||||||
return self._remote.format(branch=branch)
|
return self._remote.format(branch=branch)
|
||||||
|
|
||||||
def repository_url(self, branch: str) -> str:
|
def repository_url(self, branch: str, arch: str) -> str:
|
||||||
return self._branches[branch].get('repository_url',
|
url = self._branches[branch]['arches'][arch].get('repository_url')
|
||||||
self._repository_url)
|
if url is None:
|
||||||
|
url = self._branches[branch].get('repository_url',
|
||||||
|
self._repository_url)
|
||||||
|
return url.format(branch=branch, arch=arch)
|
||||||
|
|
||||||
def run_script(self, name: str, args: Optional[List[str]] = None) -> None:
|
def run_script(self, name: str, args: Optional[List[str]] = None) -> None:
|
||||||
path = self.scripts_dir + name
|
path = self.scripts_dir + name
|
||||||
@ -165,7 +174,7 @@ class CB:
|
|||||||
os.makedirs(apt_dir, exist_ok=True)
|
os.makedirs(apt_dir, exist_ok=True)
|
||||||
for branch in self.branches:
|
for branch in self.branches:
|
||||||
for arch in self.arches_by_branch(branch):
|
for arch in self.arches_by_branch(branch):
|
||||||
repo = self.repository_url(branch)
|
repo = self.repository_url(branch, arch)
|
||||||
with open(f'{apt_dir}/apt.conf.{branch}.{arch}', 'w') as f:
|
with open(f'{apt_dir}/apt.conf.{branch}.{arch}', 'w') as f:
|
||||||
apt_conf = f'''
|
apt_conf = f'''
|
||||||
Dir::Etc::main "/dev/null";
|
Dir::Etc::main "/dev/null";
|
||||||
@ -178,10 +187,9 @@ Dir::Etc::preferencesparts "/var/empty";
|
|||||||
f.write(apt_conf)
|
f.write(apt_conf)
|
||||||
|
|
||||||
with open(f'{apt_dir}/sources.list.{branch}.{arch}', 'w') as f:
|
with open(f'{apt_dir}/sources.list.{branch}.{arch}', 'w') as f:
|
||||||
sources_list = f'''
|
sources_list = f'rpm {repo} {arch} classic'
|
||||||
rpm {repo}/{branch} {arch} classic
|
if arch not in self.bad_arches:
|
||||||
rpm {repo}/{branch} noarch classic
|
sources_list += f'\nrpm {repo} noarch classic'
|
||||||
'''
|
|
||||||
f.write(sources_list)
|
f.write(sources_list)
|
||||||
|
|
||||||
def escape_branch(self, branch: str) -> str:
|
def escape_branch(self, branch: str) -> str:
|
||||||
@ -249,7 +257,7 @@ rpm {repo}/{branch} noarch classic
|
|||||||
return list(self._branches.keys())
|
return list(self._branches.keys())
|
||||||
|
|
||||||
def arches_by_branch(self, branch: str) -> List[str]:
|
def arches_by_branch(self, branch: str) -> List[str]:
|
||||||
return self._branches[branch]['arches']
|
return list(self._branches[branch]['arches'].keys())
|
||||||
|
|
||||||
def branding_by_branch(self, branch: str) -> str:
|
def branding_by_branch(self, branch: str) -> str:
|
||||||
return self._branches[branch].get('branding', '')
|
return self._branches[branch].get('branding', '')
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
---
|
---
|
||||||
remote: remote:/pub/images/{branch}/cloud
|
remote: remote:/pub/images/{branch}/cloud
|
||||||
key: 0x00000000
|
key: 0x00000000
|
||||||
repository_url: file:///space/ALT
|
repository_url: file:///space/ALT/{branch}
|
||||||
|
log_level: info
|
||||||
|
bad_arches:
|
||||||
|
- armh
|
||||||
|
|
||||||
images:
|
images:
|
||||||
opennebula:
|
opennebula:
|
||||||
@ -20,17 +23,19 @@ images:
|
|||||||
- tar.xz
|
- tar.xz
|
||||||
|
|
||||||
branches:
|
branches:
|
||||||
Sisyphus:
|
Sisyphus:
|
||||||
arches:
|
arches:
|
||||||
- i586
|
i586:
|
||||||
- x86_64
|
x86_64:
|
||||||
- aarch64
|
aarch64:
|
||||||
p8:
|
armh:
|
||||||
arches:
|
repository_url: file:///space/ALT/{branch}-{arch}
|
||||||
- i586
|
p8:
|
||||||
- x86_64
|
arches:
|
||||||
branding: alt-starterkit
|
i586:
|
||||||
repository_url: file:///space/ALT
|
x86_64:
|
||||||
|
branding: alt-starterkit
|
||||||
|
repository_url: file:///space/ALT/{branch}
|
||||||
|
|
||||||
# services:
|
# services:
|
||||||
# sshd:
|
# sshd:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user