soyle bisi
This commit is contained in:
+46
-17
@@ -8,10 +8,7 @@ import string
|
|||||||
import pisi.util as util
|
import pisi.util as util
|
||||||
from pisi.version import Version
|
from pisi.version import Version
|
||||||
|
|
||||||
def findUnneededFiles():
|
def findUnneededFiles(listdir):
|
||||||
listdir = map(lambda x: os.path.basename(x).split(".pisi")[0], glob.glob("/var/cache/pisi/packages/*.pisi"))
|
|
||||||
listdir.sort()
|
|
||||||
|
|
||||||
dict = {}
|
dict = {}
|
||||||
for f in listdir:
|
for f in listdir:
|
||||||
try:
|
try:
|
||||||
@@ -31,6 +28,35 @@ def findUnneededFiles():
|
|||||||
|
|
||||||
return listdir
|
return listdir
|
||||||
|
|
||||||
|
def doit(root, listdir, clean, suffix = ""):
|
||||||
|
print "Working in %s" % root
|
||||||
|
for f in listdir:
|
||||||
|
if os.path.exists("%s/%s%s" % (root, f, suffix)):
|
||||||
|
print "%s%s" % (f, suffix)
|
||||||
|
if clean == True:
|
||||||
|
try:
|
||||||
|
os.remove("%s/%s" % (root, f))
|
||||||
|
except OSError:
|
||||||
|
usage("Permission denied...")
|
||||||
|
|
||||||
|
|
||||||
|
def cleanPisis(clean, root):
|
||||||
|
# pisi packages
|
||||||
|
root = "/var/cache/pisi/packages"
|
||||||
|
list = map(lambda x: os.path.basename(x).split(".pisi")[0], glob.glob("%s/*.pisi" % root))
|
||||||
|
l = findUnneededFiles(list)
|
||||||
|
doit(root, l, clean, ".pisi")
|
||||||
|
|
||||||
|
def cleanBuilds(clean, root):
|
||||||
|
# Build remnant
|
||||||
|
root = "/var/tmp/pisi"
|
||||||
|
l = []
|
||||||
|
for f in os.listdir(root):
|
||||||
|
if os.path.isdir(os.path.join(root, f)):
|
||||||
|
l.append(f)
|
||||||
|
l = findUnneededFiles(list)
|
||||||
|
doit(root, l, clean)
|
||||||
|
|
||||||
def usage(msg):
|
def usage(msg):
|
||||||
print """
|
print """
|
||||||
Error: %s
|
Error: %s
|
||||||
@@ -48,18 +74,21 @@ if __name__ == "__main__":
|
|||||||
except IndexError:
|
except IndexError:
|
||||||
usage("Unsufficient arguments...")
|
usage("Unsufficient arguments...")
|
||||||
|
|
||||||
root = "/var/cache/pisi/packages"
|
if "--dry-run" in sys.argv:
|
||||||
|
print "Running in dry-run mode"
|
||||||
if sys.argv[1] == "--dry-run":
|
clean = False
|
||||||
for i in findUnneededFiles():
|
elif "--clean" in sys.argv:
|
||||||
if os.path.exists("%s/%s.pisi" % (root, i)):
|
print "Say bye bye to your files"
|
||||||
print "%s.pisi" % i
|
clean = True
|
||||||
elif sys.argv[1] == "--clean":
|
|
||||||
for i in findUnneededFiles():
|
|
||||||
if os.path.exists("%s/%s.pisi" % (root, i)):
|
|
||||||
try:
|
|
||||||
os.remove("%s/%s.pisi" % (root, i))
|
|
||||||
except OSError:
|
|
||||||
usage("Permission denied...")
|
|
||||||
else:
|
else:
|
||||||
usage("No command given...")
|
usage("No command given...")
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
if "builds" in sys.argv:
|
||||||
|
root = "/var/tmp/pisi"
|
||||||
|
cleanBuilds(clean, root)
|
||||||
|
|
||||||
|
else:
|
||||||
|
root = "/var/cache/pisi/packages"
|
||||||
|
cleanPisis(clean, root)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user