repo.py: avoid arch conflict and minor update

This commit is contained in:
JerryXiao 2019-04-03 19:28:23 +08:00
parent 5f0b1d7a54
commit 27c3311f28
Signed by: Jerry
GPG key ID: 9D9CE43650FF2BAA

11
repo.py
View file

@ -110,9 +110,9 @@ def filter_old_pkg(fpaths, keep_new=1, archive=False, recycle=False):
pkgs_vers = dict() pkgs_vers = dict()
for fpath in fpaths: for fpath in fpaths:
pkg = get_pkg_details_from_name(fpath.name) pkg = get_pkg_details_from_name(fpath.name)
pkgs_vers.setdefault(pkg.pkgname, list()).append(pkg) pkgs_vers.setdefault(pkg.pkgname + pkg.arch, list()).append(pkg)
for pkgname in pkgs_vers: for pkgname_arch in pkgs_vers:
family = pkgs_vers[pkgname] family = pkgs_vers[pkgname_arch]
# new packages first # new packages first
family = sorted(family, reverse=True) family = sorted(family, reverse=True)
if len(family) > keep_new: if len(family) > keep_new:
@ -133,10 +133,13 @@ def filter_old_pkg(fpaths, keep_new=1, archive=False, recycle=False):
throw_away(sigpath) throw_away(sigpath)
return (new_pkgs, old_pkgs) return (new_pkgs, old_pkgs)
def _clean_archive(keep_new=3): def _clean_archive(keep_new=3):
logger.info('starting clean')
basedir = Path('archive') basedir = Path('archive')
dir_list = [fpath for fpath in basedir.iterdir() if fpath.name.endswith(PKG_SUFFIX)] dir_list = [fpath for fpath in basedir.iterdir() if fpath.name.endswith(PKG_SUFFIX)]
filter_old_pkg(dir_list, keep_new=keep_new, recycle=True) filter_old_pkg(dir_list, keep_new=keep_new, recycle=True)
logger.info('finished clean')
def _regenerate(target_archs=ARCHS, just_symlink=False): def _regenerate(target_archs=ARCHS, just_symlink=False):
if just_symlink: if just_symlink:
@ -214,6 +217,7 @@ def _regenerate(target_archs=ARCHS, just_symlink=False):
for rfile in repo_files_essential: for rfile in repo_files_essential:
if rfile not in repo_files_count: if rfile not in repo_files_count:
logger.error(f'{rfile} does not exist in {arch}!') logger.error(f'{rfile} does not exist in {arch}!')
logger.info('finished regenerate')
def _update(): def _update():
logger.info('starting update') logger.info('starting update')
@ -258,6 +262,7 @@ def _update():
else: else:
logger.warning(f"{other} is garbage!") logger.warning(f"{other} is garbage!")
throw_away(other) throw_away(other)
logger.info('finished update')
if __name__ == '__main__': if __name__ == '__main__':
try: try: