amprolla is an apt repository merger originally intended for use with the Devuan infrastructure. This version is the third iteration of the software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

61 lines
2.0 KiB

#!/usr/bin/env python3
"""
Amprolla main module
"""
import sys
from os.path import join
from time import time
from lib.package import (write_packages, load_packages_file,
merge_packages_many)
from lib.config import banpkgs
roots = {
'devuan': 'spool/devuan/dists/jessie',
'debian': 'spool/debian/dists/jessie',
'debian-sec': 'spool/dists/jessie/updates',
}
#devuan_release_contents = open(join(roots['devuan'], 'Release')).read()
#debian_release_contents = open(join(roots['debian'], 'Release')).read()
#devuan_release = parse_release(devuan_release_contents)
#debian_release = parse_release(debian_release_contents)
#devuan_files = list(filter(lambda x: x.endswith('Packages.gz') and 'armhf' in x, devuan_release.keys()))
#debian_files = list(filter(lambda x: x.endswith('Packages.gz') and 'armhf' in x, debian_release.keys()))
#packages_file = 'main/binary-armhf/Packages.gz'
packages_file = sys.argv[1]
t1 = time()
print('Loading packages: %s' % packages_file)
devuan = load_packages_file(join(roots['devuan'], packages_file))
debian = load_packages_file(join(roots['debian'], packages_file))
debian_sec = load_packages_file(join(roots['debian-sec'], packages_file))
all_repos = [{'name': 'devuan', 'packages': devuan},
{'name': 'debian-sec', 'packages': debian_sec},
{'name': 'debian', 'packages': debian}]
def devuan_rewrite(pkg, repo_name):
"""
Function to be called when including a certain package. Allows for changing
any attributes. Currently only changes the filename if we include a package
when repo_name == 'devuan'.
"""
if repo_name == 'devuan':
pkg['Filename'] = pkg['Filename'].replace('pool/', 'pool/%s/' %
repo_name.upper())
return pkg
print('Merging packages')
new_pkgs = merge_packages_many(all_repos, banned_packages=banpkgs, rewriter=devuan_rewrite)
print('Writing packages')
write_packages(new_pkgs, 'Packages.merged')
t2 = time()
print('time:', t2-t1)