]> git.pld-linux.org Git - projects/pld-ftp-admin.git/commitdiff
- raw python version... in case ep09 explodes
authorMariusz Mazur <mmazur@pld-linux.org>
Sun, 14 Nov 2004 22:03:01 +0000 (22:03 +0000)
committerMariusz Mazur <mmazur@pld-linux.org>
Sun, 14 Nov 2004 22:03:01 +0000 (22:03 +0000)
Changed files:
    bin/config.py -> 1.1
    bin/pfa-mvpkg -> 1.1

bin/config.py [new file with mode: 0644]
bin/pfa-mvpkg [new file with mode: 0644]

diff --git a/bin/config.py b/bin/config.py
new file mode 100644 (file)
index 0000000..7866145
--- /dev/null
@@ -0,0 +1,21 @@
+# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
+
+import string, os
+
+f=open(os.environ['HOME']+'/.ftpadmrc', 'r')
+
+value={}
+
+for line in f.readlines():
+    if line[0] == '#' or string.find(line, '=') == -1:
+        continue
+    tuple=string.split(string.strip(line), '=')
+    if tuple[1][0] == '"':
+        value[string.strip(tuple[0])]=tuple[1][1:-1]
+    else:
+        value[string.strip(tuple[0])]=string.strip(tuple[1])
+    
+
+f.close()
+
+
diff --git a/bin/pfa-mvpkg b/bin/pfa-mvpkg
new file mode 100644 (file)
index 0000000..4324aa1
--- /dev/null
@@ -0,0 +1,135 @@
+#!/usr/bin/env python
+# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
+
+import sys, os, config, string, urllib, re
+
+def fileexists(path):
+    try:
+        os.stat(path)
+    except OSError, (errno, errmsg):
+        return False
+    else:
+        return True
+
+
+if len(sys.argv) < 4:
+    print "Not enough parameters given"
+    print "move.py src-tree dst-tree package1 [package2...]"
+    sys.exit(1)
+
+srctree=config.value['ftp_dir']+'/'+sys.argv[1]
+dsttree=config.value['ftp_dir']+'/'+sys.argv[2]
+errnum=0
+
+if not fileexists(srctree):
+    print srctree + " does not exist" 
+    sys.exit(1)
+
+if not fileexists(dsttree):
+    print dsttree + " does not exist"
+    sys.exit(1)
+
+def normalizenames(pkgname):
+    found=string.find(pkgname, '.src.rpm')
+    if found==-1:
+        return pkgname
+    else:
+        return pkgname[:found]
+        
+
+pkgnames=map(normalizenames, sys.argv[3:])
+
+class Pkg:
+    def __init__(self, name, tree):
+        self.file={}
+        self.info={}
+        f=open(tree+'/SRPMS/.metadata/'+name+'.src.rpm.info', 'r')
+        for entry in f.readlines():
+            i=string.split(string.strip(entry), ':')
+            if i[0] == 'info':
+                if len(i)==3:
+                    if i[1]=='buildid':
+                        if not self.info.has_key(i[1]):
+                            self.info['buildid']=[i[2]]
+                        else:
+                            self.info['buildid'].append(i[2])
+                    else:
+                        self.info[i[1]]=i[2]
+                else:
+                    self.info[i[1]]=i[2:]
+            elif i[0] == 'file':
+                if not self.file.has_key(i[1]):
+                    self.file[i[1]]=[]
+                self.file[i[1]].append(i[2])
+        f.close()
+
+pkglist={}
+
+for name in pkgnames:
+    if not fileexists(srctree+'/SRPMS/.metadata/'+name+'.src.rpm.info'):
+        errnum=errnum+1
+        print name+" was not found in source tree"
+    else:
+        pkglist[name]=Pkg(name, srctree)
+
+if not errnum == 0:
+    print "%d error(s) encountered... aborting" % errnum
+    sys.exit(1)
+
+#f=urllib.urlopen('http://ep09.pld-linux.org/~builderth/queue.txt')
+f=open('queue.txt')
+
+requests={}
+reid=re.compile(r'^.*id=(.*) pri.*$')
+
+for i in re.findall(re.compile(r'^group:.*$|builders:.*$', re.M), f.read()):
+    if i[0]=='g':
+        id=reid.sub(r'\1', i)
+        requests[id]=""
+    elif i[0]=='b':
+        requests[id]=requests[id]+i
+
+f.close()
+
+for pkg in pkglist.keys():
+    for bid in pkglist[pkg].info['buildid']:
+        if requests.has_key(bid) and not requests[bid].find('?') == -1:
+            errnum=errnum+1
+            print "Building of package %s (buildid %s) not finished" % (pkg,bid)
+
+if not errnum == 0:
+    print "%d error(s) encountered... aborting" % errnum
+    sys.exit(1)
+
+dsttreefiles=map(normalizenames, os.listdir(dsttree+'/SRPMS/.metadata/'))
+
+
+def find_other_pkgs(pkg):
+    ziewre=re.compile(string.join(pkg.split('-')[:-2], '-')+'-[^-]*-[^-]*$')
+    def filter_other_pkgs(x):
+        if ziewre.match(x):
+            return x
+        else:
+            return None
+    return filter(filter_other_pkgs, dsttreefiles)
+
+for pkg in pkglist.keys():
+    otherpkgnames=find_other_pkgs(pkg)
+    curarchs=[]
+    missingarchs=[]
+    for somepkg in otherpkgnames:
+        curarchs.extend(Pkg(somepkg, dsttree).file.keys())
+    for arch in curarchs:
+        if arch not in pkglist[pkg].file.keys():
+            missingarchs.append(arch)
+
+    if missingarchs:
+        errnum=errnum+1
+        print 'Moving pkg %s would remove archs: %s' % (pkg, missingarchs)
+
+if not errnum == 0:
+    print "%d error(s) encountered... aborting" % errnum
+    sys.exit(1)
+
+
+
This page took 0.039111 seconds and 4 git commands to generate.