mirror of
https://github.com/tuna/tunasync-scripts.git
synced 2025-04-20 04:12:42 +00:00
apt-sync: also support specify components for each codename, refactor code
Signed-off-by: Harry Chen <i@harrychen.xyz>
This commit is contained in:
parent
ddea9a858b
commit
19f6f97a0a
40
apt-sync.py
40
apt-sync.py
@ -322,31 +322,33 @@ def main():
|
|||||||
check_args("os_version", os_list)
|
check_args("os_version", os_list)
|
||||||
os_list = replace_os_template(os_list)
|
os_list = replace_os_template(os_list)
|
||||||
|
|
||||||
# generate lists of components
|
# generate a list of components and archs for each os codename
|
||||||
component_list = args.component.split(',')
|
def generate_list_for_oses(raw: str, name: str) -> List[List[str]]:
|
||||||
check_args("component", component_list)
|
n_os = len(os_list)
|
||||||
|
if ':' in raw:
|
||||||
|
# specify os codenames for each component
|
||||||
|
lists = []
|
||||||
|
for l in raw.split(':'):
|
||||||
|
list_for_os = l.split(',')
|
||||||
|
check_args(name, list_for_os)
|
||||||
|
lists.append(list_for_os)
|
||||||
|
assert len(lists) == n_os, f"{name} must be specified for each component"
|
||||||
|
else:
|
||||||
|
# use same os codenames for all components
|
||||||
|
l = raw.split(',')
|
||||||
|
check_args(name, l)
|
||||||
|
lists = [l] * n_os
|
||||||
|
return lists
|
||||||
|
|
||||||
# generate arch list for each os codename
|
component_lists = generate_list_for_oses(args.component)
|
||||||
if ';' in args.arch:
|
arch_lists = generate_list_for_oses(args.arch)
|
||||||
# specify arches for each os
|
|
||||||
arch_lists = []
|
|
||||||
for arches in args.arch.split(';'):
|
|
||||||
arch_list = arches.split(',')
|
|
||||||
check_args("arch", arch_list)
|
|
||||||
arch_lists.append(arch_list)
|
|
||||||
assert len(arch_lists) == len(os_list), "arches must be specified for each os"
|
|
||||||
else:
|
|
||||||
# use same arches for all os
|
|
||||||
arch_list = args.arch.split(',')
|
|
||||||
check_args("arch", arch_list)
|
|
||||||
arch_lists = [arch_list] * len(os_list)
|
|
||||||
|
|
||||||
args.working_dir.mkdir(parents=True, exist_ok=True)
|
args.working_dir.mkdir(parents=True, exist_ok=True)
|
||||||
failed = []
|
failed = []
|
||||||
deb_set = {}
|
deb_set = {}
|
||||||
|
|
||||||
for os, arch_list in zip(os_list, arch_lists):
|
for os, arch_list, comp_list in zip(os_list, arch_lists, component_lists):
|
||||||
for comp in component_list:
|
for comp in comp_list:
|
||||||
for arch in arch_list:
|
for arch in arch_list:
|
||||||
if apt_mirror(args.base_url, os, comp, arch, args.working_dir, deb_set=deb_set) != 0:
|
if apt_mirror(args.base_url, os, comp, arch, args.working_dir, deb_set=deb_set) != 0:
|
||||||
failed.append((os, comp, arch))
|
failed.append((os, comp, arch))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user