summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlav Vitters <olav@vitters.nl>2020-04-21 10:47:22 +0200
committerOlav Vitters <olav@vitters.nl>2020-04-21 10:47:22 +0200
commitd25c284095f25142012399fa24c1df53c4dc0443 (patch)
treecc5c833100113413f1c8e8222eb2c290773cb4d6
parentd030c0d3de9e1788c2eef1a8305bf24ef597f8c3 (diff)
downloadmgagnome-d25c284095f25142012399fa24c1df53c4dc0443.tar
mgagnome-d25c284095f25142012399fa24c1df53c4dc0443.tar.gz
mgagnome-d25c284095f25142012399fa24c1df53c4dc0443.tar.bz2
mgagnome-d25c284095f25142012399fa24c1df53c4dc0443.tar.xz
mgagnome-d25c284095f25142012399fa24c1df53c4dc0443.zip
implement mgagnome cleanup, needs improvement
-rwxr-xr-xmgagnome29
1 files 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)