summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlav Vitters <olav@vitters.nl>2020-10-02 21:50:41 +0200
committerOlav Vitters <olav@vitters.nl>2020-10-02 21:50:41 +0200
commit0819c447bc8ac213a8038acc0b1a27647c66b998 (patch)
tree85c735e23ce45d5189dbc6c0f295e35e90473f09
parent373fc498b4c34b41fad0563185b39daa5234c92c (diff)
downloadmgagnome-master.tar
mgagnome-master.tar.gz
mgagnome-master.tar.bz2
mgagnome-master.tar.xz
mgagnome-master.zip
cleanup: actually make it workHEADmaster
-rwxr-xr-xmgagnome33
1 files changed, 29 insertions, 4 deletions
diff --git a/mgagnome b/mgagnome
index 2a04350..7db0aa7 100755
--- a/mgagnome
+++ b/mgagnome
@@ -1864,22 +1864,47 @@ def cmd_cleanup(_):
# dirs = dirs - packages
import pysvn # pylint: disable=import-outside-toplevel
- dirs = [path for path in dirs if path.joinpath('SOURCES', 'sha1.lst').exists()]
+ dirs = [path for path in dirs if path.joinpath('SOURCES', 'sha1.lst').exists()
+ and path.joinpath('SPECS', '%s.spec' % path.name).exists()]
+
+ curtime = time.time()
+ curtime_recent = curtime - (36 * 60 * 60)
+ curtime_ancient = curtime - (180 * 24 * 60 * 60)
for path in dirs:
+ # Only select the packages which have not been modified for 36 hours
+ mtime = path.joinpath('SPECS', '%s.spec' % path.name).stat().st_mtime
+ if mtime > curtime_recent:
+ print('INFO: Package was too recently modified: %s' % path.name)
+ continue
+
+ # Remove any packages not touched for 180 days
+ if mtime < curtime_ancient:
+ print('INFO: Package is ancient, removing: %s' % path.name)
+ shutil.rmtree(path)
+ continue
+
+
+ # Cleanup BUILD and BUILDROOT directories
+ for cleanup_dir in ('BUILD', 'BUILDROOT'):
+ for cleanup_path in ((cleanup_path for cleanup_path in path.joinpath(cleanup_dir).glob('*') \
+ if cleanup_path.is_dir() \
+ and cleanup_path.stat().st_mtime < curtime_recent)):
+ shutil.rmtree(cleanup_path)
+
try:
binaries = set((l.split(' ', 1)[1]
for l in path.joinpath('SOURCES', 'sha1.lst').open().read().splitlines()))
except IndexError:
- print('ERROR: Problem parsing the sha1.lst of package %s' % path.basename(), file=sys.stderr)
+ print('ERROR: Problem parsing the sha1.lst of package %s' % path.name, file=sys.stderr)
# shutil.rmtree(path)
# Downstream.package(path).checkout()
continue
vcs = pysvn.Client()
- stats = [stat for stat in vcs.status(path.joinpath('SOURCES'), depth=pysvn.depth.immediates) # pylint: disable=no-member
+ stats = [stat for stat in vcs.status(str(path.joinpath('SOURCES')), depth=pysvn.depth.immediates) # pylint: disable=no-member
if stat.text_status == pysvn.wc_status_kind.unversioned # pylint: disable=no-member
- and stat.path.name not in binaries] # pylint: disable=no-member
+ and Path(stat.path).name not in binaries] # pylint: disable=no-member
if stats:
print(path)