From ccafc53c03852163cd67a63ce45577209da3ab20 Mon Sep 17 00:00:00 2001 From: Michael Hanson Date: Tue, 21 Feb 2012 13:47:57 -0800 Subject: mp.py: Fix greedy deletes and false negatives when using --rmold option. PKGVER must only contain numbers [0-9] or periods [.] when PKGVER is different from the pervious PKGVER. --- build_tools/bin/mp.py | 52 ++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/build_tools/bin/mp.py b/build_tools/bin/mp.py index 0fc4cfb..20835f0 100755 --- a/build_tools/bin/mp.py +++ b/build_tools/bin/mp.py @@ -1,5 +1,5 @@ #!/usr/bin/env python2 -# Version 0.7 +# Version 0.7.1 import os import sys @@ -243,13 +243,15 @@ def update_repo(): print "Package file:",TOTALPKG # Remove old package(s) from local copy - pv = re.compile('[\d]+[\w.]+') + oldpkgcheck = re.compile( i + "-" + epoch + '(pkgver|[\d.]+)' + "-" + '(?!pkgrel)' ) 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") + if not oldpkgcheck.search(n): + print n,"does not match" + continue + else: + OLDPKG = glob.glob(oldpkgcheck.search(n).group() + "*.pkg.tar.?z") print "OLDPKG =",OLDPKG if OLDPKG: for DELPKG in OLDPKG: @@ -273,28 +275,48 @@ def update_repo(): def update_src_pkg(): print "---------------------------------SRC------------------------------" - print "SRCPKG:",SRCPKG - OLDSRCPKG = [] + os.chdir(SRCPKGHOME + "/" + REPO) + + print + print "INFO: Changed working dir to",SRCPKGHOME + "/" + REPO + print + + if pkgbase: + SRCPKG = pkgbase + "-" + epoch + pkgver + "-" + pkgrel + ".src.tar.gz" + i = pkgbase + else: + SRCPKG = pkgname + "-" + epoch + pkgver + "-" + pkgrel + ".src.tar.gz" + i = pkgname + print "Source package will be:",SRCPKG + + if not SRCPKGHOME + "/" + REPO + "/" + SRCPKG: + print "ERROR in function update_repo: Couldn't find the new package",SRCPKGHOME + "/" + REPO + "/" + SRCPKG + sys.exit(2) + + print "SRCPKG:",SRCPKG + oldpkgcheck = re.compile( i + "-" + epoch + '(pkgver|[\d.]+)' + "-" + '(?!pkgrel)' ) dirlist = os.listdir(SRCPKGHOME + "/" + REPO) - #pv = re.compile('[\d]+[.]*[\d]*[.]*[\d]*[.]*[\d]*[.]*[\d]*') - pv = re.compile('[\d]+[\w.]+') if pkgbase: # 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") + if not oldpkgcheck.search(n): + print n,"does not match" + continue + else: + OLDSRCPKG = glob.glob(oldpkgcheck.search(n).group() + "*.src.tar.gz") else: # 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 not oldpkgcheck.search(n): + print n,"does not match" + continue + else: + OLDSRCPKG = glob.glob(oldpkgcheck.search(n).group() + "*.src.tar.gz") if OLDSRCPKG: print "OLDSRCPKG =",OLDSRCPKG for DELSRCPKG in OLDSRCPKG: -- cgit v0.12