From d25c284095f25142012399fa24c1df53c4dc0443 Mon Sep 17 00:00:00 2001 From: Olav Vitters Date: Tue, 21 Apr 2020 10:47:22 +0200 Subject: implement mgagnome cleanup, needs improvement --- mgagnome | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/mgagnome b/mgagnome index 63ea8e5..e472ea0 100755 --- a/mgagnome +++ b/mgagnome @@ -1299,15 +1299,36 @@ def cmd_group_owner(options, parser): def cmd_cleanup(options, parser): root = os.path.expanduser(Downstream.PKGROOT) - packages = set(Downstream().packages) +# packages = set(Downstream().packages) dirs = set((o for o in os.listdir(root) if os.path.isdir(os.path.join(root, o)))) - dirs = dirs - packages +# dirs = dirs - packages - dirs = (o for o in dirs if os.path.exists(os.path.join(root, o, "SPECS"))) + import pysvn + dirs = [o for o in dirs if os.path.exists(os.path.join(root, o, "SOURCES", 'sha1.lst'))] - print("\n".join(sorted(dirs))) + for path in dirs: + try: + binaries = set([l.split(' ', 1)[1] for l in open(os.path.join(root, path, 'SOURCES', 'sha1.lst')).read().splitlines()]) + except IndexError: + print(os.path.join(root, path, 'SOURCES', 'sha1.lst')) +# shutil.rmtree(os.path.join(root, path)) +# Downstream.co(path) + continue + + c2 = pysvn.Client() + stats = [stat for stat in c2.status(os.path.join(root, path, 'SOURCES'), depth=pysvn.depth.immediates) if stat.text_status == pysvn.wc_status_kind.unversioned and os.path.basename(stat.path) not in binaries] + + if len(stats): + print (path) + print (", ".join(os.path.basename(stat.path) for stat in stats)) + print (stats) + for stat in stats: + if os.path.isfile(stat.path): + os.remove(stat.path) + elif os.path.isdir(stat.path): + shutil.rmtree(stat.path) def cmd_ls(options, parser): streams = join_streams(show_version=options.show_version, only_diff_version=options.diff) -- cgit v1.2.1