From dce9810df03065eb9e100b1fc2c70c4ade1318ea Mon Sep 17 00:00:00 2001 From: karltk Date: Wed, 21 Jul 2004 14:23:56 +0000 Subject: [PATCH] Updated to 0.5 svn path=/; revision=112 --- trunk/src/epkgmove/ChangeLog | 5 ++++ trunk/src/epkgmove/README | 2 +- trunk/src/epkgmove/epkgmove | 53 ++++++++++++++++++++++++++---------- 3 files changed, 44 insertions(+), 16 deletions(-) diff --git a/trunk/src/epkgmove/ChangeLog b/trunk/src/epkgmove/ChangeLog index 30f1664..f5920cd 100644 --- a/trunk/src/epkgmove/ChangeLog +++ b/trunk/src/epkgmove/ChangeLog @@ -1,3 +1,8 @@ +2004-07-21 Karl Trygve Kalleberg + * Updated epkgmove to 0.5, as availble on + http://dev.gentoo.org/~port001/DevTools/epkgmove/epkgmove-0.5.py + 2004-04-02 Karl Trygve Kalleberg * Updated epkgmove to 0.4, as availble on http://dev.gentoo.org/~port001/DevTools/epkgmove/epkgmove-0.4.py + diff --git a/trunk/src/epkgmove/README b/trunk/src/epkgmove/README index 18946e0..4668fa3 100644 --- a/trunk/src/epkgmove/README +++ b/trunk/src/epkgmove/README @@ -1,6 +1,6 @@ Package : epkgmove -Version : 0.4 +Version : 0.5 Author : See AUTHORS MOTIVATION diff --git a/trunk/src/epkgmove/epkgmove b/trunk/src/epkgmove/epkgmove index 08cb33b..585569c 100644 --- a/trunk/src/epkgmove/epkgmove +++ b/trunk/src/epkgmove/epkgmove @@ -8,6 +8,13 @@ # # ChangeLog: # +# 4 Jun 2004 - epkgmove-0.5 +# - Fixed bug where epkgmove would fail if files/ contained subdirectories +# - Add the package to its new location before removing it from the original +# - Filter out non-update files in profiles/updates +# - Backup to /tmp/__productname__/package and make a little extra effort to keep clean +# - Small input validation fix +# # 12 Feb 2004 - epkgmove-0.4, # - Set PORTDIR to pwd if not in PORTDIR # - Formatting fixes @@ -49,7 +56,7 @@ from output import * __author__ = "Ian Leitch" __email__ = "port001@gentoo.org" __productname__ = "epkgmove" -__version__ = "0.4" +__version__ = "0.5" __description__ = "A simple tool for moving packages in CVS" def main(): @@ -76,8 +83,8 @@ def main(): CheckArgs() print "%s Moving %s to %s..." % (green(" *"), turquoise(location), yellow(destination)) BackupPkg() - RemovePackage() AddPackage() + RemovePackage() AddUpdate() CleanUp() print "%s %s successfully moved to %s." % (green(" *"), turquoise(location), yellow(destination)) @@ -146,7 +153,12 @@ def CheckArgs(): global fulllocation, location, fulldestination, destination, locategory, lopkg, decategory - (locategory, lopkg) = sys.argv[1].strip('/').split('/') + try: + (locategory, lopkg) = sys.argv[1].strip('/').split('/') + except: + err("'%s' Invalid 'category/pkg'." % (sys.argv[1])) + sys.exit(1) + location = os.path.join(locategory, lopkg) decategory = sys.argv[2].strip('/') fulllocation = os.path.join(portdir, location) @@ -181,8 +193,10 @@ def CheckArgs(): def BackupPkg(): - print "%s Backing-up %s to /tmp..." % (green(" *"), turquoise(location)) - docmd("cp -R %s /tmp" % (fulllocation)) + print "%s Backing-up %s to /tmp/%s..." % (green(" *"), turquoise(location), __productname__) + if not os.path.exists("/tmp/%s" % __productname__): + os.mkdir("/tmp/%s" % __productname__) + docmd("cp -R %s /tmp/%s/%s" % (fulllocation, __productname__, lopkg)) def RemovePackage(): @@ -216,19 +230,22 @@ def AddPackage(): def AddFiles(arg, dir, files): global dirhi dirhi = "" + dest = "" if os.path.basename(dir) not in ignore: if os.path.basename(dir) != lopkg: - (rubbish, dirhi) = dir.split("tmp/%s/" % (lopkg)) + (rubbish, dirhi) = dir.split("tmp/%s/%s/" % (__productname__, lopkg)) print " >>> %s/" % (dirhi) os.mkdir(os.path.join(fulldestination, dirhi)) - docmd("%s %s" % (cvsaddcmd, os.path.basename(dir))) - os.chdir(os.path.join(fulldestination, dirhi)) + docmd("%s %s" % (cvsaddcmd, dirhi)) for file in files: if not os.path.isdir(os.path.join(dir, file)): - print " >>> %s" % (os.path.join(dirhi, os.path.basename(file))) - docmd("cp %s ." % (os.path.join(dir, file))) - docmd("%s %s" % (cvsaddcmd, file)) - os.chdir(fulldestination) + print " >>> %s" % (os.path.join(dirhi, os.path.basename(file))) + if dirhi: + dest = dirhi + else: + dest = "." + docmd("cp %s %s" % (os.path.join(dir, file), dest)) + docmd("%s %s" % (cvsaddcmd, os.path.join(dirhi, file))) print "%s Adding %s to CVS:" % (green(" *"), turquoise(destination)) @@ -237,7 +254,7 @@ def AddPackage(): os.mkdir(lopkg) docmd("%s %s" % (cvsaddcmd,lopkg)) os.chdir(lopkg) - os.path.walk("/tmp/%s" % (lopkg), AddFiles , None) + os.path.walk("/tmp/%s/%s" % (__productname__, lopkg), AddFiles , None) os.chdir(fulldestination) print "%s Running 'echangelog 'Moved from %s to %s.''..." % (green(" *"), location, destination) docmd("echangelog 'Moved from %s to %s.' %s" % (location, destination, devnull)) @@ -250,13 +267,17 @@ def AddPackage(): def AddUpdate(): updatefiles = [] + fileregex = "^[\d]Q-[\d]{4}$" + + p_fileregex = re.compile(fileregex) print "%s Logging move in 'profiles/updates'..." % (green(" *")) os.chdir(os.path.join(portdir, "profiles/updates")) docmd(cvsupcmd) for file in os.listdir("."): - if file not in ignore: + o_fileregex = p_fileregex.match(file) + if file not in ignore and o_fileregex: (q, y) = file.split("-") updatefiles.append(y + "-" + q) @@ -277,7 +298,9 @@ def AddUpdate(): def CleanUp(): print "%s Removing back-up..." % (green(" *")) - docmd("rm -rf /tmp/%s" % (lopkg)) + docmd("rm -rf /tmp/%s/%s" % (__productname__, lopkg)) + if len(os.listdir("/tmp/%s" % __productname__)) == 0: + docmd("rmdir /tmp/%s" % __productname__) if __name__ == "__main__": main() -- 2.26.2