pld-ftp-admin: scripts/gen-indexes.py - add options --nopoldek and...

arekm arekm at pld-linux.org
Wed Sep 26 20:46:38 CEST 2007


Author: arekm                        Date: Wed Sep 26 18:46:38 2007 GMT
Module: pld-ftp-admin                 Tag: HEAD
---- Log message:
- add options --nopoldek and --noyum

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

---- Diffs:

================================================================
Index: pld-ftp-admin/scripts/gen-indexes.py
diff -u pld-ftp-admin/scripts/gen-indexes.py:1.15 pld-ftp-admin/scripts/gen-indexes.py:1.16
--- pld-ftp-admin/scripts/gen-indexes.py:1.15	Thu Jun 21 22:33:06 2007
+++ pld-ftp-admin/scripts/gen-indexes.py	Wed Sep 26 20:46:33 2007
@@ -1,6 +1,7 @@
 #!/usr/bin/env python
 # vi: encoding=utf-8 ts=8 sts=4 sw=4 et
 
+import getopt
 import sys, os
 sys.path.insert(0, os.environ['HOME']+'/pld-ftp-admin/modules')
 from common import checkdir
@@ -8,12 +9,27 @@
 import config
 import ftpio
 
-if len(sys.argv) < 2:
+try:
+    opts, args = getopt.getopt(sys.argv[1:], None, ["nopoldek", "noyum"])
+except getopt.GetoptError:
     print "ERR: not enough parameters given"
-    print "gen-indexes.py tree [tree2...]"
+    print "gen-indexes.py [--nopoldek] [--noyum] tree [tree2...]"
     sys.exit(1)
 
-trees=sys.argv[1:]
+do_poldek = True
+do_yum = True
+
+for o, a in opts:
+    if o == "--nopoldek":
+        do_poldek = False
+    if o == "--noyum":
+        do_yum = False
+
+if not do_poldek and not do_yum:
+    print "ERR: option --nopoldek conflicts with --noyum"
+    sys.exit(1)
+
+trees=args
 
 for tree in trees:
     checkdir(tree)
@@ -35,27 +51,30 @@
 
 os.umask(022)
 
-for tree in trees:
-    print '-------------------------- %s --------------------------' % tree
-    for arch in all_ftp_archs:
-        print 'ARCHITECTURE: %s' % arch
-        if config.old_poldek:
-            os.system('%s.stat/bin/poldek --cachedir=%s/tmp/poldek -c %s.stat/etc/poldek.conf -s %s%s/%s/RPMS/ --mkidxz' %
-                (ftp_dir,home,ftp_dir,ftp_dir,tree,arch))
-        else:
-            if config.poldek_indexes != "old":
-                os.system('%s.stat/bin/poldek-new --cachedir=%s/tmp/poldek --conf %s.stat/etc/poldek.conf -s %s%s/%s/RPMS/ --mkidxz --mkidx-type pndir' %
-                        (ftp_dir,home,ftp_dir,ftp_dir,tree,arch))
-            if config.poldek_indexes != "new":
-                os.system('%s.stat/bin/poldek-new --cachedir=%s/tmp/poldek --conf %s.stat/etc/poldek.conf -s %s%s/%s/RPMS/ --mkidxz --mkidx-type pdir' %
-                        (ftp_dir,home,ftp_dir,ftp_dir,tree,arch))
-for tree in trees:
-    print '-------------------------- %s --------------------------' % tree
-    for arch in all_ftp_archs:
-        print 'ARCHITECTURE: %s' % arch
-        # Creating indexes for yum and other supporting xml repodata.
-        os.system('%s.stat/bin/createrepo --cache %s/tmp/createrepo/%s-%s %s%s/%s/RPMS' %
-                (ftp_dir,home,tree,arch,ftp_dir,tree,arch))
+if do_poldek:
+    for tree in trees:
+        print '-------------------------- %s --------------------------' % tree
+        for arch in all_ftp_archs:
+            print 'ARCHITECTURE: %s' % arch
+            if config.old_poldek:
+                os.system('%s.stat/bin/poldek --cachedir=%s/tmp/poldek -c %s.stat/etc/poldek.conf -s %s%s/%s/RPMS/ --mkidxz' %
+                    (ftp_dir,home,ftp_dir,ftp_dir,tree,arch))
+            else:
+                if config.poldek_indexes != "old":
+                    os.system('%s.stat/bin/poldek-new --cachedir=%s/tmp/poldek --conf %s.stat/etc/poldek.conf -s %s%s/%s/RPMS/ --mkidxz --mkidx-type pndir' %
+                            (ftp_dir,home,ftp_dir,ftp_dir,tree,arch))
+                if config.poldek_indexes != "new":
+                    os.system('%s.stat/bin/poldek-new --cachedir=%s/tmp/poldek --conf %s.stat/etc/poldek.conf -s %s%s/%s/RPMS/ --mkidxz --mkidx-type pdir' %
+                            (ftp_dir,home,ftp_dir,ftp_dir,tree,arch))
+
+if do_yum:
+    for tree in trees:
+        print '-------------------------- %s --------------------------' % tree
+        for arch in all_ftp_archs:
+            print 'ARCHITECTURE: %s' % arch
+            # Creating indexes for yum and other supporting xml repodata.
+            os.system('%s.stat/bin/createrepo --cache %s/tmp/createrepo/%s-%s %s%s/%s/RPMS' %
+                    (ftp_dir,home,tree,arch,ftp_dir,tree,arch))
 
 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.15&r2=1.16&f=u



More information about the pld-cvs-commit mailing list