#!/usr/bin/env python
# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
+from __future__ import print_function
+
import sys, os, stat, time, re
sys.path.insert(0, os.environ['HOME']+'/pld-ftp-admin/modules')
from config import incoming_dir, default_to, ftp_archs
from ftptree import FtpTree, Pkg
import ftpio
-os.umask(022)
+os.umask(0o022)
def rm(file):
os.remove(file)
sm.close()
def move_noarch(f, arch, rpmfile, dstpkg):
- if dstpkg.noarch_arch.has_key(rpmfile):
- os.system("rpm -qlp %s | LC_ALL=C sort > %s/files.new" %
+ if rpmfile in dstpkg.noarch_arch:
+ os.system("LC_ALL=C rpm -qlp %s | LC_ALL=C sort > %s/files.new" %
(incoming_dir + arch + '/' + rpmfile, tmpdir))
os.system("rpm -qRp %s | LC_ALL=C sort | LC_ALL=C uniq > %s/reqs.new" %
(incoming_dir + arch + '/' + rpmfile, tmpdir))
(incoming_dir + arch + '/' + rpmfile, noarchcachedir, rpmfile))
os.system("rpm -qRp %s | LC_ALL=C sort | LC_ALL=C uniq > %s/%s.reqlist" %
(incoming_dir + arch + '/' + rpmfile, noarchcachedir, rpmfile))
- f.write("file:noarch:%s\ninfo:noarch_arch:%s:%s\n" % (rpmfile, rpmfile, arch))
+ if arch not in dstpkg.files:
+ f.write("file:noarch:%s\ninfo:noarch_arch:%s:%s\n" % (rpmfile, rpmfile, arch))
mv(incoming_dir + arch + '/' + rpmfile, default_to + 'noarch/RPMS')
def send_vr_msg(snvr, anvr, pkg, arch):
try:
ftpio.connect('from-incoming-pid-%s' % os.getpid())
except:
- print "Can't get ftpiod connection"
+ print("Can't get ftpiod connection")
sys.exit(1)
ftptree = BaseFtpTree(cval['default_to'])
if not ftpio.lock(cval['default_to']):
- print "Can't get lock: %s" % cval['default_to']
+ print("Can't get lock: %s" % cval['default_to'])
sys.exit(1)
moved_anything = False
continue
if ftptree.has_key(`pkg`):
- ftpio.log("%s already present in %s; removing newer files" % (srpm, ftptree))
- rm(incoming_dir + 'SRPMS/' + srpm)
+ ftpio.log("%s already present in %s; removing older files" % (srpm, ftptree))
+ rm(default_to + 'SRPMS/RPMS/' + srpm)
f = open(default_to + 'SRPMS/.metadata/' + srpm+'.info', 'a')
bid = pkg.build.keys()[0]
build = pkg.build[bid]
% (bid, build.requester, bid, build.requester_email))
f.close()
else:
- mv(incoming_dir + 'SRPMS/' + srpm, default_to + 'SRPMS/RPMS')
-
f = open(default_to + 'SRPMS/.metadata/' + srpm + '.info', 'w')
f.write(content)
f.close()
+ mv(incoming_dir + 'SRPMS/' + srpm, default_to + 'SRPMS/RPMS')
rm(incoming_dir + 'SRPMS/' + uploadinfo)
for arch in ftp_archs:
dstpkg = BasePkg(`srcpkg`, ftptree)
- if dstpkg.files.has_key(arch):
- ftpio.log("files from %s for arch %s already present in %s; removing newer files" % (`srcpkg`, arch, ftptree))
- for rpmfile in srcpkg.files['ARCH']:
+ if arch in dstpkg.files:
+ ftpio.log("files from %s for arch %s already present in %s; removing older files" % (`srcpkg`, arch, ftptree))
+ for rpmfile in dstpkg.files[arch]:
+ if is_debuginfo(rpmfile):
+ dstfile = default_to + arch + '/debuginfo'
+ else:
+ dstfile = default_to + arch + '/RPMS'
try:
- rm(incoming_dir + arch + '/'+rpmfile)
- except OSError, e:
- l = "Removing %s problem: %s" % (incoming_dir + arch + '/' + rpmfile, e)
+ rm(dstfile + '/' + rpmfile)
+ except OSError as e:
+ l = "Removing %s problem: %s" % (dstfile + '/' + rpmfile, e)
ftpio.log(l)
- print l
- rm(incoming_dir + arch + '/' + uploadinfo)
- continue
+ print(l)
f = open(default_to + 'SRPMS/.metadata/' + srpm + '.info', 'a')
for rpmfile in srcpkg.files['ARCH']:
moved_anything = True
- archnvr = renvr.match(rpmfile).groups()
- if srcnvr[1] != archnvr[1] or srcnvr[2] != archnvr[2]:
- send_vr_msg(srcnvr, archnvr, dstpkg, arch)
+# Too much noise, too little use
+# archnvr = renvr.match(rpmfile).groups()
+# if srcnvr[1] != archnvr[1] or srcnvr[2] != archnvr[2]:
+# send_vr_msg(srcnvr, archnvr, dstpkg, arch)
if rpmfile[-11:] == '.noarch.rpm' and config.separate_noarch:
move_noarch(f, arch, rpmfile, dstpkg)
else:
- f.write("file:%s:%s\n" % (arch, rpmfile))
+ if arch not in dstpkg.files:
+ f.write("file:%s:%s\n" % (arch, rpmfile))
srcfile = incoming_dir + arch + '/' + rpmfile
if is_debuginfo(rpmfile):
try:
mv(srcfile, dstfile)
- except OSError, e:
+ except OSError as e:
l = "Moving %s to %s problem: %s" % (srcfile, dstfile, e)
ftpio.log(l)
- print l
+ print(l)
f.close()
rm(incoming_dir + arch + '/' + uploadinfo)