pld-ftp-admin: scripts/gen-indexes.py - add --index=[index, index, ...] support

glen glen at pld-linux.org
Tue Feb 1 20:54:14 CET 2011


Author: glen                         Date: Tue Feb  1 19:54:14 2011 GMT
Module: pld-ftp-admin                 Tag: HEAD
---- Log message:
- add --index=[index,index,...] support

---- Files affected:
pld-ftp-admin/scripts:
   gen-indexes.py (1.32 -> 1.33) 

---- Diffs:

================================================================
Index: pld-ftp-admin/scripts/gen-indexes.py
diff -u pld-ftp-admin/scripts/gen-indexes.py:1.32 pld-ftp-admin/scripts/gen-indexes.py:1.33
--- pld-ftp-admin/scripts/gen-indexes.py:1.32	Sat Jan 15 19:02:34 2011
+++ pld-ftp-admin/scripts/gen-indexes.py	Tue Feb  1 20:54:09 2011
@@ -10,7 +10,13 @@
 import ftpio
 
 try:
-    opts, args = getopt.getopt(sys.argv[1:], None, ["quiet", "nopoldek", "noyum", "norpmrepo", "poldek", "yum", "rpmrepo"])
+    opts, args = getopt.getopt(sys.argv[1:], 'q',
+        [
+            "quiet", "index=",
+            "nopoldek", "noyum", "norpmrepo",
+            "poldek", "yum", "rpmrepo"
+        ]
+    )
 except getopt.GetoptError:
     print >>sys.stderr, "ERR: not enough parameters given"
     print >>sys.stderr, "gen-indexes.py [--quiet] [--[no]poldek] [--[no]yum] [--[no]rpmrepo] tree [tree2...]"
@@ -19,7 +25,7 @@
 do_poldek = True
 do_yum = True
 do_rpmrepo = False
-do_quiet = False
+quiet = False
 
 for o, a in opts:
     if o == "--nopoldek":
@@ -36,8 +42,21 @@
     if o == "--rpmrepo":
         do_rpmrepo = True
 
-    if o == "--quiet":
-        do_quiet = True
+    if o == "-q" or o == "--quiet":
+        quiet = True
+
+    if o == "--index":
+        do_poldek = do_yum = do_rpmrepo = False
+        for v in a.split(','):
+            if v == 'poldek':
+                do_poldek = True
+            if v == 'yum':
+                do_yum = True
+            if v == 'rpmrepo':
+                do_rpmrepo = True
+
+if not quiet:
+    print "poldek: %s; yum: %s; rpmrepo: %s" % (do_poldek, do_yum, do_rpmrepo)
 
 if not do_poldek and not do_yum and not do_rpmrepo:
     print >>sys.stderr, "ERR: speciy at least one action"
@@ -56,7 +75,7 @@
     if ftpio.lock(tree, True):
         locked.append(tree)
     else:
-        if not do_quiet:
+        if not quiet:
             print >>sys.stderr, "ERR: %s tree already locked" % tree
         for i in locked:
             ftpio.unlock(i)
@@ -84,7 +103,7 @@
                     os.system('%s -s %s%s/%s/debuginfo/ --mkidxz --mkidx-type pdir' % (poldek, ftp_dir, tree, arch))
 
 if do_yum:
-    os.system('%s cd %s.stat/repodata && cvs %s up comps.xml' % ("" if do_quiet else "set -x;", ftp_dir, "" if do_quiet else "-Q"))
+    os.system('%s cd %s.stat/repodata && cvs %s up comps.xml' % ("" if quiet else "set -x;", ftp_dir, "" if quiet else "-Q"))
     yum = '%s.stat/bin/createrepo -d -g %s.stat/repodata/comps.xml' % (ftp_dir, ftp_dir)
     for tree in trees:
         print '\n-------------------------- %s --------------------------' % tree
@@ -92,23 +111,23 @@
         for arch in all_ftp_archs:
             print '\ngenerate repodata for %s using createrepo' % arch
             # Creating indexes for yum and other supporting xml repodata.
-            os.system('%s %s --cache %s-%s %s%s/%s/RPMS' % ("" if do_quiet else "time", yum, cachedir, arch, ftp_dir, tree, arch))
+            os.system('%s %s --cache %s-%s %s%s/%s/RPMS' % ("" if quiet else "time", yum, cachedir, arch, ftp_dir, tree, arch))
             if arch != 'noarch' and config.separate_debuginfo:
-                os.system('%s %s --cache %s-%s %s%s/%s/debuginfo' % ("" if do_quiet else "time", yum, cachedir, arch, ftp_dir, tree, arch))
+                os.system('%s %s --cache %s-%s %s%s/%s/debuginfo' % ("" if quiet else "time", yum, cachedir, arch, ftp_dir, tree, arch))
 
 if do_rpmrepo:
-    os.system('%s cd %s.stat/repodata && cvs %s up comps.xml' % ("" if do_quiet else "set -x;", ftp_dir, "" if do_quiet else "-Q"))
+    os.system('%s cd %s.stat/repodata && cvs %s up comps.xml' % ("" if quiet else "set -x;", ftp_dir, "" if quiet else "-Q"))
     for tree in trees:
         print '\n-------------------------- %s --------------------------' % tree
         for arch in all_ftp_archs:
             dir = '%s/%s/%s/RPMS' % (ftp_dir, tree, arch)
-            if not do_quiet:
+            if not quiet:
                 print '\ngenerate repodata for %s using rpmrepo (in %s)' % (arch, dir)
-            os.system('%s rpmrepo %s -o %s' % ("" if do_quiet else "set -x;", dir, dir))
-            if not do_quiet:
+            os.system('%s rpmrepo %s -o %s' % ("" if quiet else "set -x;", dir, dir))
+            if not quiet:
                 print 'copy comps.xml'
             comps = '%s.stat/repodata/comps.xml' % ftp_dir
-            os.system('%s cp -p %s %s/repodata' % ("" if do_quiet else "set -x;", comps, dir))
+            os.system('%s cp -p %s %s/repodata' % ("" if quiet else "set -x;", comps, dir))
 
 for tree in trees:
     ftpio.unlock(tree)
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/pld-ftp-admin/scripts/gen-indexes.py?r1=1.32&r2=1.33&f=u



More information about the pld-cvs-commit mailing list