From a4efc29087d39a35023e222ad8bd8d40a6b055bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=2E=C3=87a=C4=9Flar=20Onur?= Date: Fri, 22 Sep 2006 21:25:12 +0000 Subject: [PATCH] =?UTF-8?q?Verilen=20depouyu=20gez=20fazla=20olan=20tarbal?= =?UTF-8?q?lar=C4=B1=20sil,=20buildfarm=20ile=20ftp'yi=20senkron=20tutmak?= =?UTF-8?q?=20i=C3=A7in?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/cleanArchives.py | 63 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100755 scripts/cleanArchives.py diff --git a/scripts/cleanArchives.py b/scripts/cleanArchives.py new file mode 100755 index 00000000..ecc1271f --- /dev/null +++ b/scripts/cleanArchives.py @@ -0,0 +1,63 @@ +#!/usr/bin/python +# +# Copyright (C) 2005, TUBITAK/UEKAE +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free +# Software Foundation; either version 2 of the License, or (at your option) +# any later version. +# +# Please read the COPYING file. + +import os +import sys + +import pisi.uri +import pisi.specfile + +def scanPSPEC(folder): + packages = [] + for root, dirs, files in os.walk(folder): + if "pspec.xml" in files: + packages.append(root) + # dont walk into the versioned stuff + if ".svn" in dirs: + dirs.remove(".svn") + return packages + +def cleanArchives(file): + try: + os.remove("/var/cache/pisi/archives/%s" % file) + except OSError: + print("Permission denied...") + +if __name__ == "__main__": + try: + packages = scanPSPEC(sys.argv[1]) + except: + print "Usage: cleanArchives.py path2repo" + sys.exit(1) + + if "--dry-run" in sys.argv: + clean = False + elif "--clean" in sys.argv: + clean = True + else: + sys.exit(0) + + files = [] + for package in packages: + spec = pisi.specfile.SpecFile() + spec.read(os.path.join(package, "pspec.xml")) + + URI = pisi.uri.URI(spec.source.archive.uri) + files.append(URI.filename()) + + archiveFiles = os.listdir("/var/cache/pisi/archives/") + unneededFiles = set(archiveFiles) - set(files) + + for i in unneededFiles: + if not clean: + print("/var/cache/pisi/archives/%s" % i) + else: + cleanArchives("/var/cache/pisi/archives/%s" % i)