From 8e37f385aac5165f965a1cd45a424519be51ba46 Mon Sep 17 00:00:00 2001 From: Michael Hanson Date: Mon, 11 Apr 2011 16:52:09 -0700 Subject: mp.py: Made pkg REMOVAL dependent on new option, --rmold. Experts only! --- build_tools/bin/mp.py | 71 ++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 50 insertions(+), 21 deletions(-) diff --git a/build_tools/bin/mp.py b/build_tools/bin/mp.py index 2c5974a..6c9e246 100755 --- a/build_tools/bin/mp.py +++ b/build_tools/bin/mp.py @@ -1,5 +1,5 @@ #!/usr/bin/env python2 -# Version 0.6.5 +# Version 0.6.6 import os import sys @@ -109,6 +109,7 @@ def commandline(): clparser.add_option("--pkg", action="store", help="Only build listed packages from a split package.") clparser.add_option("--noconfirm", action="store_true", default=False, help="(Passed to pacman) Prevent pacman from waiting for user input before proceeding with operations.") clparser.add_option("--noprogressbar", action="store_true", default=False, help="(Passed to pacman) Prevent pacman from displaying a progress bar.") + clparser.add_option("--rmold", action="store_true", default=False, help="BETA: Remove old src and software packages from repos. Use with caution. False positives may occur (i.e. nvidia pkgs)!") (options, args) = clparser.parse_args() @@ -116,7 +117,8 @@ def commandline(): options2 = ['asroot', 'ignorearch', 'bump', 'clean', 'cleancache', 'nodeps', 'noextract', 'force', 'forcever', 'geninteg', 'skipinteg', 'holdver', 'install', 'log', 'nocolor', 'nobuild', 'rmdeps', 'repackage', - 'syncdeps', 'allsource', 'source', 'noconfirm', 'noprogressbar'] + 'syncdeps', 'allsource', 'source', 'noconfirm', 'noprogressbar', + 'rmold'] for o in options1: cmd1 = eval('options.'+o) @@ -140,6 +142,9 @@ def commandline(): # Remove bump option from makepkg command if it exists if "--bump" in makepkg_cmd: makepkg_cmd.remove("--bump") + # Remove rmold option from makepkg command if it exists + if "--rmold" in makepkg_cmd: + makepkg_cmd.remove("--rmold") # Remove "--geninteg" option (if it exists) from makepkg command. # Checking for *sums is done automaticly by mp.py if "--geninteg" in makepkg_cmd: @@ -225,20 +230,28 @@ def update_repo(): else: print "ERROR in function update_repo: Couldn't find the new package ",TOTALPKG sys.exit(2) + # Remove old package(s) from local copy - OLDPKG = glob.glob(i + "-" + "[0-9]*" + "-*-" + CARCH + ".pkg.tar.?z") - print "OLDPKG =",OLDPKG - if OLDPKG: - for DELPKG in OLDPKG: - print "Deleting old package:",DELPKG - os.remove(DELPKG) - # Remove any symlinks to old packages - # We make it conditional on "--force" because force will overwrite - # an existing package and we want the symlink to stay, pointing to - # the newly built package with the same pkgrel. - if "--force" not in makepkg_cmd: - if os.path.islink(mydir + "/" + DELPKG): - os.remove(mydir + "/" + DELPKG) + pv = re.compile('[\d]+[\w.]+') + dirlist = os.listdir(DOCROOT) + for n in dirlist: + if n.startswith(i): + num = len(i) + 1 + print "Bytes to seek ahead:",num + OLDPKG = glob.glob(i + "-" + pv.search(n,num).group() + "-[0-9]*.pkg.tar.?z") + print "OLDPKG =",OLDPKG + if OLDPKG: + for DELPKG in OLDPKG: + if "--rmold" in cli_list: + print "Deleting old package:",DELPKG + os.remove(DELPKG) + # Remove any symlinks to old packages + # We make it conditional on "--force" because force will overwrite + # an existing package and we want the symlink to stay, pointing to + # the newly built package with the same pkgrel. + if "--force" not in makepkg_cmd: + if os.path.islink(mydir + "/" + DELPKG): + os.remove(mydir + "/" + DELPKG) # Copy in new package print "############################################" print "Updating " + DOCROOT + " with " + TOTALPKG @@ -250,17 +263,33 @@ def update_repo(): def update_src_pkg(): print "---------------------------------SRC------------------------------" print "SRCPKG:",SRCPKG + OLDSRCPKG = [] os.chdir(SRCPKGHOME + "/" + REPO) + dirlist = os.listdir(SRCPKGHOME + "/" + REPO) + #pv = re.compile('[\d]+[.]*[\d]*[.]*[\d]*[.]*[\d]*[.]*[\d]*') + pv = re.compile('[\d]+[\w.]+') if pkgbase: - OLDSRCPKG = glob.glob(pkgbase + "-" + "[0-9]*" + "-*.src.tar.?z") + # Remove old src package(s) from local copy + if "--rmold" in cli_list: + for n in dirlist: + if n.startswith(pkgbase): + num = len(pkgbase) + 1 + print "Bytes to seek ahead:",num + OLDSRCPKG = glob.glob(pkgbase + "-" + pv.search(n,num).group() + "-*.src.tar.?z") else: - OLDSRCPKG = glob.glob(pkgname + "-" + "[0-9]*" + "-*.src.tar.?z") - print "OLDSRCPKG =",OLDSRCPKG + # Remove old src package(s) from local copy + if "--rmold" in cli_list: + for n in dirlist: + if n.startswith(pkgname): + num = len(pkgname) + 1 + print "Bytes to seek ahead:",num + OLDSRCPKG = glob.glob(pkgname + "-" + pv.search(n,num).group() + "-*.src.tar.?z") if OLDSRCPKG: + print "OLDSRCPKG =",OLDSRCPKG for DELSRCPKG in OLDSRCPKG: - print "Removing old source package",DELSRCPKG - os.remove(SRCPKGHOME + "/" + REPO + "/" + DELSRCPKG) - print "Copying source package to",SRCPKGHOME + "/" + REPO + "/" + SRCPKG + print "Deleting old source package",DELSRCPKG + os.remove(DELSRCPKG) + print "Copying new source package to",SRCPKGHOME + "/" + REPO + "/" + SRCPKG shutil.copy2(PKGHOME + "/" + SRCPKG, SRCPKGHOME + "/" + REPO + "/") def dup_check(): -- cgit v0.12