[Mageia-sysadm] [342] add binrepo remove function

root at mageia.org root at mageia.org
Tue Jan 25 19:14:00 CET 2011


Revision: 342
Author:   boklm
Date:     2011-01-25 19:14:00 +0100 (Tue, 25 Jan 2011)
Log Message:
-----------
add binrepo remove function

Modified Paths:
--------------
    build_system/mgarepo/trunk/MgaRepo/binrepo.py
    build_system/mgarepo/trunk/MgaRepo/commands/del.py
    build_system/mgarepo/trunk/MgaRepo/rpmutil.py

Modified: build_system/mgarepo/trunk/MgaRepo/binrepo.py
===================================================================
--- build_system/mgarepo/trunk/MgaRepo/binrepo.py	2011-01-25 17:00:15 UTC (rev 341)
+++ build_system/mgarepo/trunk/MgaRepo/binrepo.py	2011-01-25 18:14:00 UTC (rev 342)
@@ -287,7 +287,8 @@
         entries = parse_sources(path)
     f = open(path, "w") # open before calculating hashes
     for name in removed:
-        entries.pop(removed)
+	if name in entries:
+           del entries[name]
     for added_path in added:
         name = os.path.basename(added_path)
         entries[name] = file_hash(added_path)
@@ -301,6 +302,29 @@
     t.join()
     return t
 
+def remove(path, message=None, commit=True):
+    from MgaRepo.rpmutil import getpkgtopdir
+    svn = SVN()
+    if not os.path.exists(path):
+        raise Error, "not found: %s" % path
+    bpath = os.path.basename(path)
+    topdir = getpkgtopdir()
+    bintopdir = translate_topdir(topdir)
+    update = update_sources_threaded(topdir, removed=[bpath])
+    sources = sources_path(topdir)
+    silent = config.get("log", "ignore-string", "SILENT")
+    if not message:
+        message = "%s: delete binary file %s" % (silent, bpath)
+    if commit:
+        svn.commit(topdir + " " + sources, log=message, nonrecursive=True)
+    binlink = os.path.join(topdir, "SOURCES", bpath)
+    if os.path.islink(binlink):
+        os.unlink(binlink)
+    binpath = os.path.join(topdir, BINARIES_CHECKOUT_NAME, bpath)
+    svn.remove(binpath)
+    if commit:
+       svn.commit(binpath, log=message)
+
 def upload(path, message=None):
     from MgaRepo.rpmutil import getpkgtopdir
     svn = SVN()

Modified: build_system/mgarepo/trunk/MgaRepo/commands/del.py
===================================================================
--- build_system/mgarepo/trunk/MgaRepo/commands/del.py	2011-01-25 17:00:15 UTC (rev 341)
+++ build_system/mgarepo/trunk/MgaRepo/commands/del.py	2011-01-25 18:14:00 UTC (rev 342)
@@ -7,18 +7,13 @@
 
 Remove a given file from the binary sources repository.
 
-Changes in the sources file will be left uncommited.
-
 Options:
-    -c      automatically commit the 'sources' file
     -h      help
 
 """
 
 def parse_options():
     parser = OptionParser(help=HELP)
-    parser.add_option("-c", dest="commit", default=False,
-            action="store_true")
     opts, args = parser.parse_args()
     if len(args):
         opts.paths = args

Modified: build_system/mgarepo/trunk/MgaRepo/rpmutil.py
===================================================================
--- build_system/mgarepo/trunk/MgaRepo/rpmutil.py	2011-01-25 17:00:15 UTC (rev 341)
+++ build_system/mgarepo/trunk/MgaRepo/rpmutil.py	2011-01-25 18:14:00 UTC (rev 342)
@@ -666,16 +666,10 @@
         binrepo.upload(path)
 
 def binrepo_delete(paths, commit=False):
-    #TODO handle files tracked by svn
     refurl = binrepo.svn_root(paths[0])
     if not binrepo.enabled(refurl):
         raise Error, "binary repository is not enabled for %s" % refurl
-    added, deleted = binrepo.remove(paths)
-    if commit:
-        svn = SVN()
-        spath = binrepo.sources_path(paths[0])
-        log = _sources_log(added, deleted)
-        svn.commit(spath, log=log)
+    binrepo.remove(paths[0])
 
 def switch(mirrorurl=None):
     svn  = SVN()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/mageia-sysadm/attachments/20110125/7a91e184/attachment-0001.html>


More information about the Mageia-sysadm mailing list