]> TLD Linux GIT Repositories - tld-ftp-admin.git/blobdiff - bin/pfa-genindex
- merged PLD changes
[tld-ftp-admin.git] / bin / pfa-genindex
index a5133c5296cd9a87f4242b2d74af1dcb0c01a166..01ff1ee51ed65a77a5f467a5cf020dc67ddbc184 100755 (executable)
@@ -1,6 +1,8 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # vi: encoding=utf-8 ts=8 sts=4 sw=4 et
 
+from __future__ import print_function
+
 import getopt
 import sys, os
 sys.path.insert(0, os.environ['HOME']+'/tld-ftp-admin/modules')
@@ -18,8 +20,8 @@ try:
         ]
     )
 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...]"
+    print("ERR: not enough parameters given", file=sys.stderr)
+    print("gen-indexes.py [--quiet] [--[no]poldek] [--[no]yum] [--[no]rpmrepo] tree [tree2...]", file=sys.stderr)
     sys.exit(1)
 
 do_poldek = True
@@ -58,10 +60,10 @@ for o, a in opts:
                 do_rpmrepo = True
 
 if not quiet:
-    print "poldek: %s; yum: %s; rpmrepo: %s" % (do_poldek, do_yum, do_rpmrepo)
+    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"
+    print("ERR: speciy at least one action", file=sys.stderr)
     sys.exit(1)
 
 trees = args
@@ -77,25 +79,24 @@ for tree in trees:
     if ftpio.lock(tree, True):
         locked.append(tree)
     else:
-        if not quiet:
-            print >>sys.stderr, "ERR: %s tree already locked" % tree
+        print("ERR: %s tree already locked" % tree, file=sys.stderr)
         for i in locked:
             ftpio.unlock(i)
         sys.exit(1)
 
 home = os.environ['HOME']
 
-os.umask(022)
+os.umask(0o022)
 os.nice(19)
 
 if do_poldek:
     poldek = '%s.stat/bin/poldek-new --cachedir=%s/tmp/poldek --conf %s.stat/etc/poldek.conf --mkidxz' % (ftp_dir, home, ftp_dir)
 
     for tree in trees:
-        print '\n-------------------------- %s --------------------------' % tree
+        print('\n-------------------------- %s --------------------------' % tree)
         for arch in all_ftp_archs:
-            print '\ngenerate poldek index for %s' % arch
-            print '%s -s %s%s/%s/RPMS/ --mkidxz --mkidx-type pndir' % (poldek, ftp_dir, tree, arch)
+            print('\ngenerate poldek index for %s' % arch)
+            print('%s -s %s%s/%s/RPMS/ --mkidxz --mkidx-type pndir' % (poldek, ftp_dir, tree, arch))
             os.system('%s -s %s%s/%s/RPMS/ --mkidxz --mkidx-type pndir' % (poldek, ftp_dir, tree, arch))
             if arch != 'noarch' and config.separate_debuginfo:
                 os.system('%s -s %s%s/%s/debuginfo/ --mkidxz --mkidx-type pndir' % (poldek, ftp_dir, tree, arch))
@@ -105,20 +106,20 @@ if do_yum:
     yum = '%s.stat/bin/createrepo -d -v --update --checkts --skip-stat --workers=12 -g %s.stat/repodata/comps.xml' % (ftp_dir, ftp_dir)
     comps_file = '%s.stat/repodata/comps.xml' % ftp_dir
     for tree in trees:
-        print '\n-------------------------- %s --------------------------' % tree
+        print('\n-------------------------- %s --------------------------' % tree)
         cachedir = '%s/tmp/createrepo/%s' % (home, tree)
         treedir = "%s%s" % (ftp_dir, tree)
         for arch in all_ftp_archs:
-            print '\ngenerate repodata for %s using createrepo' % arch
+            print('\ngenerate repodata for %s using createrepo' % arch)
             archdir = "%s/%s" % (treedir, arch)
             poldek_idx = "%s/RPMS/packages.ndir.md" % archdir
             repodata_idx = "%s/RPMS/repodata/repomd.xml" % archdir
             if freshen and os.path.exists(poldek_idx) and os.path.exists(repodata_idx) \
                 and not os.path.getmtime(comps_file) > os.path.getmtime(repodata_idx) \
                 and not os.path.getmtime(poldek_idx) > os.path.getmtime(repodata_idx):
-                print "repodata indexes already fresh"
+                print("repodata indexes already fresh")
                 continue
-            print ('%s %s --cache %s-%s %s/RPMS' % ("" if quiet else "time", yum, cachedir, arch, archdir))
+            print('%s %s --cache %s-%s %s/RPMS' % ("" if quiet else "time", yum, cachedir, arch, archdir))
             os.system('%s %s --cache %s-%s %s/RPMS' % ("" if quiet else "time", yum, cachedir, arch, archdir))
             if arch != 'noarch' and config.separate_debuginfo:
                 os.system('%s %s --cache %s-%s %s/debuginfo' % ("" if quiet else "time", yum, cachedir, arch, archdir))
@@ -126,14 +127,14 @@ if do_yum:
 if do_rpmrepo:
     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
+        print('\n-------------------------- %s --------------------------' % tree)
         for arch in all_ftp_archs:
             dir = '%s/%s/%s/RPMS' % (ftp_dir, tree, arch)
             if not quiet:
-                print '\ngenerate repodata for %s using rpmrepo (in %s)' % (arch, dir)
+                print('\ngenerate repodata for %s using rpmrepo (in %s)' % (arch, dir))
             os.system('%s rpmrepo %s -o %s' % ("" if quiet else "set -x;", dir, dir))
             if not quiet:
-                print 'copy comps.xml'
+                print('copy comps.xml')
             comps = '%s.stat/repodata/comps.xml' % ftp_dir
             os.system('%s cp -p %s %s/repodata' % ("" if quiet else "set -x;", comps, dir))