Sprout from master 2008-08-28 14:20:38 UTC Elan Ruusamäe <glen@pld-linux.org> '- copy from svn: http://svn.pld-linux.org/cgi-bin/viewsvn/anaconda/comps.xml?rev=9152&view=markup'
Delete:
bin/pfa-dump-locks
bin/pfa-from-incoming
bin/pfa-genindex
bin/pfa-maintainer
bin/pfa-mvpkg
bin/pfa-rmpkg
bin/pfa-signpkg
bin/pfa-testmvpkg
bin/pfa-unlocktree
cgi-bin/index.py
doc/README
ftpiod/ftpiod.py
html/footer.html
html/header.html
html/layout.css
html/loggedinmenu.html
html/menufooter.html
html/regform.html
modules/.cvsignore
modules/baseftptree.py
modules/cmds.py
modules/common.py
modules/config.py
modules/cons.py
modules/ftpio.py
modules/ftptree.py
modules/mailer.py
modules/user.py
modules/wwwcmds.py
modules/wwwiface.py
shell/bash_profile
shell/bashrc
ucred/make.sh
ucred/setup.py
ucred/ucred.c
+++ /dev/null
-#!/usr/bin/env python
-# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
-
-import sys, os
-sys.path.insert(0, os.environ['HOME']+'/pld-ftp-admin/modules')
-import ftptree
-import ftpio
-import config
-
-ftpio.connect()
-ftpio.locks_dump()
+++ /dev/null
-#!/usr/bin/env python
-# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
-
-import sys, os, stat, time
-sys.path.insert(0, os.environ['HOME']+'/pld-ftp-admin/modules')
-from config import incoming_dir, default_to, ftp_archs
-import config
-from common import noarchcachedir, tmpdir, fileexists
-from baseftptree import BaseFtpTree, BasePkg
-cval=config.value
-import ftpio
-
-try:
- ftpio.connect('from-incoming-pid-%s' % os.getpid())
-except:
- sys.exit(0)
-
-def rm(file):
- os.remove(file)
- #print 'rm: '+file
-
-def mv(src, dst):
- os.rename(src, dst+'/'+src.split('/')[-1])
- #print "mv: %s %s" % (src, dst+'/'+src.split('/')[-1])
-
-def findfiles(dir):
- def filterinfos(x):
- if x[-11:]=='.uploadinfo':
- return True
- else:
- return False
- return filter(filterinfos, os.listdir(dir))
-
-def getcontent(file):
- f=open(file, 'r')
- content=f.read()
- f.close()
- if not content[-5:]=='\nEND\n':
- return None
- else:
- return content[:-4]
-
-ftptree=BaseFtpTree(cval['default_to'])
-
-if not ftpio.lock(cval['default_to']):
- sys.exit(0)
-
-for uploadinfo in findfiles(incoming_dir+'SRPMS'):
- content=getcontent(incoming_dir+'SRPMS/'+uploadinfo)
- if not content:
- continue # Uploading not finished
-
- pkg=BasePkg(uploadinfo[:-19], content=content)
- srpm=pkg.files['SRPMS'][0]
-
- if ftptree.has_key(`pkg`):
- ftpio.log("%s already present in %s; removing newer files" %
- (srpm, ftptree))
- rm(incoming_dir+'SRPMS/'+srpm)
- f=open(default_to+'SRPMS/.metadata/'+srpm+'.info', 'a')
- bid=pkg.build.keys()[0]
- build=pkg.build[bid]
- f.write("info:build:%s:requester:%s\ninfo:build:%s:requester_email:%s\n"
- % (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()
-
- rm(incoming_dir+'SRPMS/'+uploadinfo)
-
-def send_noarch_msg(files_differ, reqs_differ, pkg, rpm, arch):
- req_email=pkg.build[pkg.lastbid].requester_email
- req_bid=pkg.lastbid
- cc_list=[]
- if 'logs_list' in cval:
- cc_list.append(cval['logs_list'])
- m_subject="Noarch error: %s files differ among builders" % rpm
- bids=pkg.build.keys()
- if len(bids)>1:
- for bid in bids:
- newcc=pkg.build[bid].requester_email
- if req_email!=newcc and newcc not in cc_list:
- cc_list.append(newcc)
-
- msg="From: %s\nTo: %s\n" % (cval['from_field'], req_email)
- if cc_list:
- msg=msg+"Cc: %s\n" % ", ".join(cc_list)
- msg=msg+"""X-PLD-Builder: %s
-References: <%s@pld.src.builder>
-In-Reply-To: <%s@pld.src.builder>
-Subject: %s
-
-""" % (cval['xpldbuilder'], req_bid, req_bid, m_subject)
-
- sm = os.popen("/usr/sbin/sendmail -t", "w")
-
- sm.write(msg)
-
- if files_differ:
- f=open("%s/files.diff" % tmpdir, 'r')
- sm.write("Difference between %s (currently in %s) and %s FILES\n" %
- (pkg.noarch_arch[rpm], `ftptree`, arch)),
- for line in f.readlines(True)[2:]:
- sm.write(line)
- f.close()
-
- sm.write('\n')
-
- if reqs_differ:
- f=open("%s/reqs.diff" % tmpdir, 'r')
- sm.write("Difference between %s (currently in %s) and %s REQS\n" %
- (pkg.noarch_arch[rpm], `ftptree`, arch)),
- for line in f.readlines(True)[2:]:
- sm.write(line)
- f.close()
-
- sm.close()
-
-
-
-def move_noarch(f, arch, rpm, dstpkg):
- if dstpkg.noarch_arch.has_key(rpm):
- os.system("rpm -qlp %s > %s/files.new" %
- (incoming_dir+arch+'/'+rpm, tmpdir))
- os.system("rpm -qRp %s |sort|uniq > %s/reqs.new" %
- (incoming_dir+arch+'/'+rpm, tmpdir))
-
- files_differ=False
- reqs_differ=False
-
- if os.system("diff -u %s/%s.filelist %s/files.new > %s/files.diff" %
- (noarchcachedir, rpm, tmpdir, tmpdir)):
- files_differ=True
- if os.system("diff -u %s/%s.reqlist %s/reqs.new > %s/reqs.diff" %
- (noarchcachedir, rpm, tmpdir, tmpdir)):
- reqs_differ=True
-
- if files_differ or reqs_differ:
- send_noarch_msg(files_differ, reqs_differ, dstpkg, rpm, arch)
-
- rm(incoming_dir+arch+'/'+rpm)
- else:
- os.system("rpm -qlp %s > %s/%s.filelist" %
- (incoming_dir+arch+'/'+rpm, noarchcachedir, rpm))
- os.system("rpm -qRp %s |sort|uniq > %s/%s.reqlist" %
- (incoming_dir+arch+'/'+rpm, noarchcachedir, rpm))
- f.write("file:noarch:%s\ninfo:noarch_arch:%s:%s\n" % (rpm, rpm, arch))
- mv(incoming_dir+arch+'/'+rpm, default_to+'noarch/RPMS')
-
-for arch in ftp_archs:
- for uploadinfo in findfiles(incoming_dir+arch):
- content=getcontent(incoming_dir+arch+'/'+uploadinfo)
- if not content:
- continue # Uploading not finished
-
- srcpkg=BasePkg(uploadinfo[:-19], content=content)
- srpm=srcpkg.files['SRPMS'][0]
-
- if not ftptree.has_key(`srcpkg`):
- continue # We require the src.rpm to be present
-
- 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 rpm in srcpkg.files['ARCH']:
- try:
- rm(incoming_dir+arch+'/'+rpm)
- except OSError, e:
- l = "Removing %s problem: %s" % (incoming_dir+arch+'/'+rpm, e)
- ftpio.log(l)
- print l
- rm(incoming_dir+arch+'/'+uploadinfo)
- continue
-
- f=open(default_to+'SRPMS/.metadata/'+srpm+'.info', 'a')
- for rpm in srcpkg.files['ARCH']:
- if rpm[-11:]=='.noarch.rpm' and config.separate_noarch:
- move_noarch(f, arch, rpm, dstpkg)
- else:
- f.write("file:%s:%s\n" % (arch, rpm))
- try:
- mv(incoming_dir+arch+'/'+rpm, default_to+arch+'/RPMS')
- except OSError, e:
- l = "Moving %s to %s problem: %s" % (incoming_dir+arch+'/'+rpm, default_to+arch+'/RPMS', e)
- ftpio.log(l)
- print l
- f.close()
-
- rm(incoming_dir+arch+'/'+uploadinfo)
-
-ftpio.unlock(cval['default_to'])
-
+++ /dev/null
-#!/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
-from config import ftp_dir,all_ftp_archs
-import config
-import ftpio
-
-try:
- opts, args = getopt.getopt(sys.argv[1:], None, ["nopoldek", "noyum"])
-except getopt.GetoptError:
- print "ERR: not enough parameters given"
- print "gen-indexes.py [--nopoldek] [--noyum] tree [tree2...]"
- sys.exit(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)
-
-ftpio.connect('gen-indexes')
-
-locked=[]
-
-for tree in trees:
- if ftpio.lock(tree, True):
- locked.append(tree)
- else:
- print "ERR: %s tree already locked" % tree
- for i in locked:
- ftpio.unlock(i)
- sys.exit(1)
-
-home=os.environ['HOME']
-
-os.umask(022)
-os.nice(19)
-
-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 -d -g %s.stat/comps.xml --cache %s/tmp/createrepo/%s-%s %s%s/%s/RPMS' %
- (ftp_dir,ftp_dir,home,tree,arch,ftp_dir,tree,arch))
-
-for tree in trees:
- ftpio.unlock(tree)
-
+++ /dev/null
-#!/usr/bin/env python
-# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
-
-import sys, os
-sys.path.insert(0, os.environ['HOME']+'/pld-ftp-admin/modules')
-import time
-from config import test_builds_dir, ftp_archs
-
-def clean_dir(path, max):
- curtime=time.time()
- for i in os.listdir(path):
- if curtime - os.path.getmtime(path+'/'+i) > max:
- os.unlink(path+'/'+i)
-
-for arch in ftp_archs + ['SRPMS']:
- clean_dir(test_builds_dir+arch, 60*60*24*3)
-
+++ /dev/null
-#!/usr/bin/env python
-# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
-
-import sys, os
-sys.path.insert(0, os.environ['HOME']+'/pld-ftp-admin/modules')
-import ftptree
-from common import checkdir
-import ftpio
-from mailer import Message
-import config
-cval=config.value
-
-nocheckbuild=False
-if len(sys.argv) > 4 and sys.argv[1]=='-nb':
- nocheckbuild=True
- sys.argv=sys.argv[1:]
-
-if len(sys.argv) < 4:
- print "ERR: not enough parameters given"
- print "move.py [options] src-tree dst-tree package [package2 package3 ...]"
- print "\nOptions:"
- print " -nb Do not check if builds are finished.\n"
- sys.exit(1)
-
-checkdir(sys.argv[1])
-checkdir(sys.argv[2])
-
-ftpio.connect('move')
-
-if not ftpio.lock(sys.argv[1], True):
- print "ERR: %s tree already locked" % sys.argv[1]
- sys.exit(1)
-
-if not ftpio.lock(sys.argv[2], True):
- ftpio.unlock(sys.argv[1])
- print "ERR: %s tree already locked" % sys.argv[2]
- sys.exit(1)
-
-try:
- srctree=ftptree.FtpTree(sys.argv[1], loadall=True)
- dsttree=ftptree.FtpTree(sys.argv[2])
- if nocheckbuild:
- srctree.do_checkbuild=False
- srctree.mark4moving(sys.argv[3:])
-
- srctree.movepkgs(dsttree)
-except ftptree.SomeError:
- # In case of problems we need to unlock the trees before exiting
- ftpio.unlock(sys.argv[1])
- ftpio.unlock(sys.argv[2])
- sys.exit(1)
-
-ftpio.unlock(sys.argv[1])
-ftpio.unlock(sys.argv[2])
-
-if 'logs_list' not in cval:
- sys.exit(0)
-
-print 'Sending mail notification...',
-
-pkgs={}
-
-for pkg in srctree.marked4moving:
- requesters=[]
- for bid in pkg.build.keys():
- if pkg.build[bid].requester not in requesters:
- requesters.append(pkg.build[bid].requester)
- pkgs[pkg.nvr]=requesters
-
-m=Message()
-m.set_headers(to=cval['logs_list'], subject='MOVED: %s => %s... %d packages' %
- (sys.argv[1], sys.argv[2], len(pkgs)))
-m.write(('SrcTree: %s DstTree: %s\n' +
- 'Amount: %d\n\n---- Moved:\n\n') % (sys.argv[1], sys.argv[2], len(pkgs)))
-
-for nvr in sorted(pkgs.keys()):
- m.write_line('%s ---- %s' % (nvr, ', '.join(pkgs[nvr])))
-
-m.send()
-
-print 'done.'
-
+++ /dev/null
-#!/usr/bin/env python
-# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
-
-import sys, os
-sys.path.insert(0, os.environ['HOME']+'/pld-ftp-admin/modules')
-import ftptree
-from common import checkdir
-import ftpio
-
-if len(sys.argv) < 3:
- print "ERR: not enough parameters given"
- print "remove.py tree package1 [package2...]"
- sys.exit(1)
-
-checkdir(sys.argv[1])
-
-ftpio.connect('remove')
-
-if not ftpio.lock(sys.argv[1], True):
- print "ERR: %s tree already locked" % sys.argv[1]
- sys.exit(1)
-
-try:
- tree=ftptree.FtpTree(sys.argv[1])
- tree.mark4removal(sys.argv[2:])
- tree.removepkgs()
-except ftptree.SomeError:
- # In case of problems we need to unlock the tree before exiting
- ftpio.unlock(sys.argv[1])
- sys.exit(1)
-
-ftpio.unlock(sys.argv[1])
-
+++ /dev/null
-#!/usr/bin/env python
-# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
-
-import sys, os
-sys.path.insert(0, os.environ['HOME']+'/pld-ftp-admin/modules')
-import ftptree
-from common import checkdir
-import ftpio
-
-if len(sys.argv) < 3:
- print "ERR: not enough parameters given"
- print "sign.py tree package1 [package2...]"
- sys.exit(1)
-
-checkdir(sys.argv[1])
-
-ftpio.connect('sign')
-
-if not ftpio.lock(sys.argv[1], True):
- print "ERR: %s tree already locked" % sys.argv[1]
- sys.exit(1)
-
-# TODO: implement signpkg() from:
-# http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/pld-ftp-admin/shell/bashrc
-
-try:
- tree=ftptree.FtpTree(sys.argv[1])
-# tree.mark4removal(sys.argv[2:])
-# tree.removepkgs()
-except ftptree.SomeError:
- # In case of problems we need to unlock the tree before exiting
- ftpio.unlock(sys.argv[1])
- sys.exit(1)
-
-ftpio.unlock(sys.argv[1])
-
+++ /dev/null
-#!/usr/bin/env python
-# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
-
-import sys, os
-sys.path.insert(0, os.environ['HOME']+'/pld-ftp-admin/modules')
-import ftptree
-from common import checkdir
-import ftpio
-
-if len(sys.argv) < 4:
- print "ERR: not enough parameters given"
- print "test-move.py src-tree dst-tree package [package2 package3 ...]"
- sys.exit(1)
-
-checkdir(sys.argv[1])
-checkdir(sys.argv[2])
-
-ftpio.connect('test-move')
-
-if not ftpio.lock(sys.argv[1], True):
- print "ERR: %s tree already locked" % sys.argv[1]
- sys.exit(1)
-
-if not ftpio.lock(sys.argv[2], True):
- ftpio.unlock(sys.argv[1])
- print "ERR: %s tree already locked" % sys.argv[2]
- sys.exit(1)
-
-try:
- srctree=ftptree.FtpTree(sys.argv[1], loadall=True)
- dsttree=ftptree.FtpTree(sys.argv[2])
- srctree.mark4moving(sys.argv[3:])
-except ftptree.SomeError:
- # In case of problems we need to unlock the trees before exiting
- ftpio.unlock(sys.argv[1])
- ftpio.unlock(sys.argv[2])
- sys.exit(1)
-
-# We don't 'try' as in move.py cause this function doesn't force exit
-srctree.testmove(dsttree)
-
-ftpio.unlock(sys.argv[1])
-ftpio.unlock(sys.argv[2])
-
+++ /dev/null
-#!/usr/bin/env python
-# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
-
-import sys, os
-sys.path.insert(0, os.environ['HOME']+'/pld-ftp-admin/modules')
-import ftptree
-import ftpio
-import config
-
-if len(sys.argv) < 2:
- print "ERR: not enough parameters given"
- print "unlock.py tree"
- sys.exit(1)
-
-ftpio.connect()
-print ftpio.unlock(sys.argv[1])
+++ /dev/null
-#!/usr/bin/env python
-# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
-
-# Printing errors (no SyntaxErrors though, but that's not a problem)
-import sys, os
-sys.stderr=sys.stdout
-
-contenttypesent=False
-
-def myexceptionhandler(type, value, traceback):
- if contenttypesent:
- print '<pre>'
- sys.__excepthook__(type, value, traceback)
- print '</pre>'
- else:
- print "Content-Type: text/plain\n"
- sys.__excepthook__(type, value, traceback)
- sys.exit(1)
-
-sys.excepthook=myexceptionhandler
-# End printing errors
-
-sys.path.insert(0, '../modules')
-
-import wwwiface, user
-
-opts, cks = wwwiface.getopts()
-u=user.User(cks, opts)
-
-if u.loggedin:
- wwwiface.addheader('Logged in: '+u.login)
- wwwiface.addmenu(file='loggedinmenu')
- import wwwcmds
- wwwcmds.handlecmds(opts)
-else:
- wwwiface.addheader('Login form')
- wwwiface.addcontent(file='regform')
-
-wwwiface.sendhttpheaders()
-contenttypesent=True
-
-wwwiface.sendhtml()
-
+++ /dev/null
-You can find a comprehensive description of current features at
-http://cvs.pld-linux.org/cgi-bin/cvsweb/PLD-doc/PLD_2.0_ftp_administration
-
+++ /dev/null
-#!/usr/bin/env python
-# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
-
-import sys, os
-sys.path.insert(0, os.environ['HOME']+'/pld-ftp-admin/modules')
-import cons
-
-def daemonize():
- sys.stdin.close()
- sys.stdout.close()
- sys.stderr.close()
- for fd in range(256):
- try:
- os.close(fd)
- except:
- pass
- pid=os.fork()
- if pid!=0:
- sys.exit(0)
- os.setsid()
-
-
-#daemonize()
-
-
-while True:
- for readable in cons.readables():
- if readable==cons.privlistener:
- newsock,addr=readable.accept()
- cons.add(cons.Connection(newsock, True))
- elif readable==cons.publistener:
- newsock,addr=readable.accept()
- cons.add(cons.Connection(newsock, False))
- else:
- readable.handleinput()
-
+++ /dev/null
-</body>
-</html>
-
+++ /dev/null
-<html>
-
-<head>
-<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
-<title>PLD ftp manager - Th</title>
-<style type="text/css" media="all">@import "../html/layout.css";</style>
-</head>
-
-<body>
-
+++ /dev/null
-body {\r
- margin:0px;\r
- padding:0px;\r
- font-family:verdana, arial, helvetica, sans-serif;\r
- color:#333;\r
- background-color:white;\r
- }\r
-h1 {\r
- margin:0px 0px 15px 0px;\r
- padding:0px;\r
- font-size:28px;\r
- line-height:28px;\r
- font-weight:900;\r
- color:#ccc;\r
- }\r
-p {\r
- font:11px/20px verdana, arial, helvetica, sans-serif;\r
- margin:0px 0px 16px 0px;\r
- padding:0px;\r
- }\r
-#Content>p {margin:0px;}\r
-#Content>p+p {text-indent:30px;}\r
-\r
-a {\r
- color:#09c;\r
- font-size:11px;\r
- text-decoration:none;\r
- font-weight:600;\r
- font-family:verdana, arial, helvetica, sans-serif;\r
- }\r
-a:link {color:#09c;}\r
-a:visited {color:#07a;}\r
-a:hover {background-color:#eee;}\r
-\r
-#Header {\r
- margin:25px 0px 10px 0px;\r
- padding:17px 0px 0px 20px;\r
- /* For IE5/Win's benefit height = [correct height] + [top padding] + [top and bottom border widths] */\r
- height:33px; /* 14px + 17px + 2px = 33px */\r
- border-style:solid;\r
- border-color:black;\r
- border-width:1px 0px; /* top and bottom borders: 1px; left and right borders: 0px */\r
- line-height:11px;\r
- background-color:#eee;\r
-\r
-/* Here is the ugly brilliant hack that protects IE5/Win from its own stupidity. \r
-Thanks to Tantek Celik for the hack and to Eric Costello for publicizing it. \r
-IE5/Win incorrectly parses the "\"}"" value, prematurely closing the style \r
-declaration. The incorrect IE5/Win value is above, while the correct value is \r
-below. See http://glish.com/css/hacks.asp for details. */\r
- voice-family: "\"}\"";\r
- voice-family:inherit;\r
- height:14px; /* the correct height */\r
- }\r
-/* I've heard this called the "be nice to Opera 5" rule. Basically, it feeds correct \r
-length values to user agents that exhibit the parsing error exploited above yet get \r
-the CSS box model right and understand the CSS2 parent-child selector. ALWAYS include\r
-a "be nice to Opera 5" rule every time you use the Tantek Celik hack (above). */\r
-body>#Header {height:14px;}\r
-\r
-#Content {\r
- margin:0px 50px 50px 200px;\r
- padding:10px;\r
- }\r
-\r
-#Menu {\r
- position:absolute;\r
- top:100px;\r
- left:20px;\r
- width:172px;\r
- padding:10px;\r
- background-color:#eee;\r
- border:1px dashed #999;\r
- line-height:17px;\r
-/* Again, the ugly brilliant hack. */\r
- voice-family: "\"}\"";\r
- voice-family:inherit;\r
- width:150px;\r
- }\r
-/* Again, "be nice to Opera 5". */\r
-body>#Menu {width:150px;}\r
-\r
+++ /dev/null
-<a href="index.py?action=logout">Logout</a><br/>
+++ /dev/null
-<a href="http://bugs.pld-linux.org/index.php?tasks=all&project=3">Th bugs</a><br/>
-<a href="http://buildlogs.pld-linux.org/">Buildlogs</a><br/>
+++ /dev/null
-<form action="index.py" method="post">
-<input type="hidden" name="action" value="register">
-<label for="login">Username:</label>
-<input type="text" name="login"><br>
-<label for="pass">Password:</label>
-<input type="password" name="pass"><br>
-<input type="submit" value="Log in">
-</form>
+++ /dev/null
-# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
-
-import string, config
-from common import fileexists
-
-class Build:
- def __init__(self):
- self.requester=''
- self.requester_email=''
-
-class BasePkg:
- def __init__(self, nvr, tree=None, content=None):
- self.files={}
- self.info={}
- self.build={}
- self.noarch_arch={}
- self.tree=tree
- self.nvr=nvr
- self.load(content)
-
- def __repr__(self):
- return self.nvr
-
- def load(self, content=None):
- if content:
- lines=content.splitlines()
- else:
- f=open("%s/SRPMS/.metadata/%s.src.rpm.info" %
- (self.tree.basedir, self.nvr), 'r')
- lines=f.readlines()
- f.close()
-
- for entry in lines:
- i=string.split(string.strip(entry), ':')
- if i[0] == 'info':
- if len(i)==3:
- self.info[i[1]]=i[2]
- elif i[1]=='build':
- if not self.build.has_key(i[2]):
- self.build[i[2]]=Build()
- self.lastbid=i[2]
- if i[3]=='requester':
- self.build[i[2]].requester=i[4]
- elif i[3]=='requester_email':
- self.build[i[2]].requester_email=i[4]
- elif i[1]=='noarch_arch':
- self.noarch_arch[i[2]]=i[3]
- else:
- self.info[i[1]]=i[2:]
- elif i[0] == 'file':
- if not self.files.has_key(i[1]):
- self.files[i[1]]=[]
- self.files[i[1]].append(i[2])
-
-class BaseFtpTree:
- def __init__(self, tree):
- self.basedir=config.value['ftp_dir']+'/'+tree
- self.treename=tree
-
- def __repr__(self):
- return self.treename
-
- def has_key(self, key):
- if fileexists(self.basedir+'/SRPMS/.metadata/'+key+'.src.rpm.info'):
- return True
- else:
- return False
-
+++ /dev/null
-# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
-
-import os
-import time
-import config
-import common
-import md5
-import ftptree
-
-
-def parse(con):
- if '\0' not in con.data:
- return
- cmds=con.data.split('\0')[:-1]
-
- for cmd in cmds:
- con.data=con.data[len(cmd)+1:]
- cmdname=cmd[:4]
- if not con.authorized and cmdname not in ('linp', 'linc', 'name'):
- raise BailOut
- # TODO: log unauthorized access
- if cmdname in cmdlist_noargs:
- if len(cmd)==4:
- cmdlist_noargs[cmdname](con)
- else:
- pass
- # TODO: log malicious msg
- elif cmdname in cmdlist_args:
- if len(cmd)>5:
- cmdlist_args[cmdname](con, cmd[5:])
- else:
- pass
- # TODO: log malicious msg
- else:
- raise BailOut
- # TODO: log this
-
-
-def lock(con, arg, hard):
- if arg not in locks:
- locks[arg]={'hard': hard, 'name': con.name, 'time': int(time.time())}
- con.sock.send("OK")
- elif locks[arg]['hard']:
- con.sock.send("HARD") # Hard lock - you can go get a cup of tea
- else:
- con.sock.send("SOFT") # Soft lock - try in a second or two
-
-
-def cmd_unlock(con, arg):
- if arg in locks:
- del locks[arg]
- con.sock.send("OK")
- else:
- con.sock.send("FAIL")
-
-def cmd_lock_soft(con, arg):
- lock(con, arg, False)
-
-def cmd_lock_hard(con, arg):
- lock(con, arg, True)
-
-def cmd_show_locks(con):
- cmd_log(con, "Dumping locks data:");
- if len(locks):
- for lockdata in locks.iteritems():
- tree, data = lockdata
- cmd_log(con, "Tree: %s, Conn name: %s, Hard Lock: %s, Time: %s"
- % (tree, data['name'], data['hard'], time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(data['time']))))
- else:
- cmd_log(con, "No locks found.");
-
-def cmd_log(con, msg):
- logfile.write('%s [%s] -- %s\n' % (time.strftime('%Y-%m-%d %H:%M:%S'),
- con.name, msg))
- logfile.flush()
-
-def cmd_name(con, name):
- con.name=name
-
-def load_creds():
- global users, cookies
- users={}
- cookies={}
- if not common.fileexists(common.ftpadmdir+'var/passwd'):
- return
- else:
- f=open(common.ftpadmdir+'var/passwd', 'r')
- for line in f.xreadlines():
- x=line.strip().split(':')
- if len(x)>=2:
- users[x[0]]=x[1]
- f.close()
- if not common.fileexists(common.ftpadmdir+'var/cookies'):
- return
- else:
- f=open(common.ftpadmdir+'var/cookies', 'r')
- for line in f.xreadlines():
- x=line.strip().split(':')
- if len(x)>=2:
- users[x[0]]=x[1]
- f.close()
-
-def write_cookies():
- f=open(common.ftpadmdir+'var/cookies', 'w')
- for key in cookies.keys():
- f.write('%s:%s\n' % (key, cookies[key]))
- f.close()
-
-def cmd_login_passwd(con, data):
- tmp=data.split('\n')
- if len(tmp)!=2:
- raise BailOut
- login=tmp[0]
- passwd=tmp[1]
- md5pass=md5.new(passwd).hexdigest()
- if login in users and users[login]==md5pass:
- cookie=`time.time()`.split('.')[0]+'_'+md5.new(md5pass+salt).hexdigest()
- cookies[cookie]=login
- write_cookies()
- con.username=login
- con.authorized=True
- con.sock.send('OK '+cookie)
- else:
- # TODO: log this
- con.sock.send('FAIL')
- raise BailOut
-
-def cmd_login_cookie(con, cookie):
- if cookie in cookies:
- con.cookie=cookie
- con.authorized=True
- con.username=cookies[cookie]
- con.sock.send('OK '+cookies[cookie])
- else:
- # TODO: log this (or not)
- con.sock.send('FAIL')
-
-def cmd_logout(con):
- if con.cookie in cookies:
- del cookies[con.cookie]
- write_cookies()
-
-def reloadftptree():
- global srctree, pkglist
- srctree=ftptree.FtpTree(config.value['default_to'], loadall=True)
- pkglist=srctree.keys()
- pkglist.sort()
-
-def cmd_gettree(con):
- buf=''
- for pkgnvr in pkglist:
- # TODO: show only user's own pkgs
- pkg=srctree[pkgnvr]
- line=pkgnvr
- if pkg.marked4moving:
- line=line+'\n1'
- else:
- line=line+'\n0'
- if pkg.marked4removal:
- line=line+'\n1'
- else:
- line=line+'\n0'
- buf=buf+'\0'+line
- if buf:
- con.sock.send('%.6d' % (len(buf)-1))
- con.sock.send(buf[1:])
- else:
- con.sock.send('000000')
-
-
-cmdlist_args={'lcks':cmd_lock_soft, 'lckh':cmd_lock_hard, 'ulck':cmd_unlock,
- 'log1':cmd_log, 'name':cmd_name, 'linp':cmd_login_passwd,
- 'linc':cmd_login_cookie}
-
-cmdlist_noargs={'lout':cmd_logout, 'gett':cmd_gettree, 'slck':cmd_show_locks}
-
-# Global stuff and initializations
-
-BailOut="BailOut"
-locks={}
-logfile=open(common.ftpadmdir+'var/log', 'a')
-load_creds()
-reloadftptree()
-salt=md5.new(`time.time()`).hexdigest()
-
+++ /dev/null
-# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
-
-import os, sys, config
-
-def fileexists(path):
- if path[0]=='/':
- fullpath=path
- else:
- fullpath=config.ftp_dir+path
- return os.path.exists(fullpath)
-
-def checkdir(dir):
- if not fileexists(dir):
- print 'ERR: ' + config.value['ftp_dir']+'/' + dir + " does not exist"
- sys.exit(1)
-
-if 'HOME' in os.environ:
- ftpadmdir=os.environ['HOME']+'/pld-ftp-admin/'
-else:
- ftpadmdir='../'
-noarchcachedir=ftpadmdir+'var/noarch-cache/'
-tmpdir=ftpadmdir+'var/tmp/'
-
+++ /dev/null
-# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
-
-import string, os
-
-value={}
-
-if os.environ.has_key('HOME'):
- path=os.environ['HOME']
-else:
- path='../../' # cgi-bin interface
-
-f=open(path+'/.ftpadmrc', 'r')
-
-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()
-
-default_to=value['ftp_dir']+'/'+value['default_to']+'/'
-ftp_dir=value['ftp_dir']+'/'
-incoming_dir=value['ftp_dir']+'/'+value['incoming_dir']+'/'
-test_builds_dir=value['ftp_dir']+'/'+value['test_builds_dir']+'/'
-ftp_archs=value['ftp_archs'].split(' ')
-
-builderqueue=value['builderqueue']
-
-if 'old_poldek' in value and value['old_poldek']=='yes':
- old_poldek=True
-else:
- old_poldek=False
-
-if 'poldek_indexes' in value:
- poldek_indexes=value['poldek_indexes']
-else:
- poldek_indexes='old'
-
-if value['separate_noarch']=='yes':
- separate_noarch=True
-else:
- separate_noarch=False
-
-if separate_noarch:
- all_ftp_archs=['noarch'] + ftp_archs
-else:
- all_ftp_archs=ftp_archs
-
+++ /dev/null
-# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
-
-import socket
-import os
-import select
-from common import fileexists
-import ftpio
-import cmds
-
-class Connection:
- def __init__(self, sock, authorized):
- sock.setblocking(False)
- self.sock=sock
- self.authorized=authorized
- self.fileno=sock.fileno
- self.name=""
- self.data=""
- def destroy(self):
- self.sock.close()
- rm(self)
- def handleinput(self):
- try:
- newdata=self.sock.recv(8192)
- except:
- self.destroy()
- if not newdata:
- self.destroy()
- self.data=self.data+newdata
- try:
- cmds.parse(self)
- except cmds.BailOut:
- self.destroy()
-
-def add(con):
- cons.append(con)
-
-def rm(con):
- cons.remove(con)
-
-def readables():
- lst=cons[:]
- lst.append(privlistener)
- lst.append(publistener)
- inlst,outlst,errlst = select.select(lst, [], [], 0.1)
- return inlst
-
-def createlistener(path):
- if fileexists(path):
- os.remove(path)
-
- s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
- s.setblocking(False)
- s.bind(path)
- if path==ftpio.pubsock:
- os.chmod(path, 0606)
- else:
- os.chmod(path, 0600)
- s.listen(3)
- return s
-
-cons=[]
-
-privlistener=createlistener(ftpio.privsock)
-publistener=createlistener(ftpio.pubsock)
-
-
-
+++ /dev/null
-# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
-
-import os
-import sys
-import socket
-import time
-import config
-
-pubsock=config.value['pubsock']
-
-if os.environ.has_key('HOME'):
- privsock=os.environ['HOME']+'/pld-ftp-admin/var/privsock'
- socketname=privsock
-else:
- socketname=pubsock
-
-def connect(name=None):
- global sock
- sock=socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
- sock.connect(socketname)
- if not name:
- name = "pid_%d_name_%s" % (os.getpid(), sys.argv[0])
- sock.send('name %s\0' % name)
-
-def login_passwd(login, passwd):
- 'Return cookie if ok'
- sock.send('linp %s\n%s\0' % (login, passwd))
- retval=sock.recv(256)
- if retval=='FAIL':
- return ''
- else:
- return retval[3:]
-
-def login_cookie(cookie):
- 'Return login if ok'
- sock.send('linc %s\0' % cookie)
- retval=sock.recv(256)
- if retval=='FAIL':
- return ''
- else:
- return retval[3:]
-
-def logout():
- sock.send('lout\0')
-
-def lock(path, hard=False):
- def dolock():
- if hard:
- sock.send('lckh %s\0' % path)
- else:
- sock.send('lcks %s\0' % path)
- return sock.recv(20)
- for i in range(3):
- retcode=dolock()
- if retcode=="OK":
- return True
- elif retcode=="HARD":
- return False
- if i!=2:
- time.sleep(1)
- return False
-
-def unlock(path):
- sock.send('ulck %s\0' % path)
- ret = sock.recv(20)
- if ret == "OK":
- return True
- return False
-
-def log(msg):
- sock.send('log1 %s\0' % msg)
-
-def locks_dump():
- sock.send('slck\0')
-
-def gettree():
- sock.send('gett\0')
- pkgs=[]
- len=int(sock.recv(6))
- if len:
- for pkg in sock.recv(len).split('\0'):
- tmp=pkg.split('\n')
- pkgs.append((tmp[0], int(tmp[1]), int(tmp[2])))
- return pkgs
-
+++ /dev/null
-# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
-
-import os, config, string, urllib, re, rpm
-from common import fileexists, noarchcachedir
-from baseftptree import BasePkg, BaseFtpTree
-errnum=0
-
-quietmode=False
-
-class SomeError(Exception):
- def __init__(self):
- return
-
- def __str__(self):
- print "","An Error occured!"
-
-def bailoutonerror():
- if not errnum == 0:
- print "%d error(s) encountered... aborting" % errnum
- raise SomeError
-
-def pinfo(msg):
- print 'INFO: ' + msg
-
-def perror(msg):
- global errnum
- errnum=errnum+1
- print 'ERR: ' + msg
-
-def pwarning(msg):
- print 'WARN: ' + msg
-
-def rm(file, test=False):
- if test:
- if not os.path.exists(file):
- pinfo("TEST os.remove(%s): file doesn't exists" % file)
- else:
- try:
- os.remove(file)
- except OSError, e:
- pinfo("os.remove(%s): %s" % (file, e))
- raise
-
-def mv(src, dst, test=False):
- fsrc = src
- fdst = dst+'/'+src.split('/')[-1]
- if test:
- if not os.path.exists(src):
- pinfo("TEST os.rename(%s, %s): source doesn't exists" % (fsrc, fdst))
- else:
- try:
- os.rename(fsrc, fdst)
- except OSError, e:
- pinfo("os.rename(%s, %s): %s" % (fsrc, fdst, e))
- raise
-
-class Pkg(BasePkg):
- def __init__(self, nvr, tree):
- BasePkg.__init__(self, nvr, tree)
- self.name=string.join(nvr.split('-')[:-2], '-')
- self.version=nvr.split('-')[-2]
- self.release=nvr.split('-')[-1]
- self.marked4removal=False
- self.marked4moving=False
- self.marked4movingpool=[]
- self.errors=[]
- self.warnings=[]
-
- def __cmp__(self, pkg):
- if self.name > pkg.name:
- return 1
- elif self.name < pkg.name:
- return -1
- else:
- return rpm.labelCompare(('0', self.version, self.release),
- ('0', pkg.version, pkg.release))
-
- def mark4moving(self):
- if not self.marked4moving:
- # Only one pkg in this pool can be marked for moving
- for pkg in self.marked4movingpool:
- pkg.unmark4moving()
- self.tree.marked4moving.append(self)
- self.marked4moving=True
-
- def unmark4moving(self):
- if self.marked4moving:
- self.tree.marked4moving.remove(self)
- self.marked4moving=False
-
- def mark4removal(self):
- if not self.marked4removal:
- self.tree.marked4removal.append(self)
- self.marked4removal=True
-
- def error(self, msg):
- self.errors.append(msg)
- if not quietmode:
- perror('%s %s' % (self.nvr, msg))
-
- def warning(self, msg):
- self.warnings.append(msg)
- if not quietmode:
- pwarning('%s %s' % (self.nvr, msg))
-
- def load(self, content=None):
- BasePkg.load(self, content)
- if self.info.has_key('move'):
- self.mark4moving()
-
- def writeinfo(self):
- f=open(self.tree.basedir+'/SRPMS/.metadata/'+self.nvr+'.src.rpm.info', 'w')
- for bid in self.build.keys():
- f.write("info:build:%s:requester:%s\ninfo:build:%s:requester_email:%s\n" % (bid, self.build[bid].requester, bid, self.build[bid].requester_email))
- for key in self.info.keys():
- f.write("info:%s:%s\n" % (key, string.join(self.info[key], ':')))
- for arch in self.files.keys():
- for rpm in self.files[arch]:
- f.write("file:%s:%s\n" % (arch, rpm))
-
- def remove(self, test=False):
- for arch in self.files.keys():
- for rpm in self.files[arch]:
- rm(self.tree.basedir+'/'+arch+'/RPMS/'+rpm, test)
- if arch=='noarch':
- if fileexists(noarchcachedir+rpm+'.filelist'):
- rm(noarchcachedir+rpm+'.filelist', test)
- if fileexists(noarchcachedir+rpm+'.reqlist'):
- rm(noarchcachedir+rpm+'.reqlist', test)
- rm(self.tree.basedir+'/SRPMS/.metadata/'+self.nvr+'.src.rpm.info', test)
-
- def move(self, dsttree, test=False):
- if dsttree.has_key(self.nvr):
- movedany=False
- for arch in self.files.keys():
- if arch in dsttree[self.nvr].files.keys():
- msg = ""
- if test:
- msg = "TEST "
- pinfo("%sArch %s for %s is already present in dest tree; removing from srctree" % (msg, arch, self.nvr))
- for rpm in self.files[arch]:
- rm(self.tree.basedir+'/'+arch+'/RPMS/'+rpm, test)
- else:
- movedany=True
- dsttree[self.nvr].files[arch]=self.files[arch]
- for rpm in self.files[arch]:
- mv(self.tree.basedir+'/'+arch+'/RPMS/'+rpm, dsttree.basedir+'/'+arch+'/RPMS/', test)
- if not test and movedany:
- for bid in self.build.keys():
- dsttree[self.nvr].build[bid]=self.build[bid]
- dsttree[self.nvr].writeinfo()
- rm(self.tree.basedir+'/SRPMS/.metadata/'+self.nvr+'.src.rpm.info', test)
- else:
- for arch in self.files.keys():
- for rpm in self.files[arch]:
- mv(self.tree.basedir+'/'+arch+'/RPMS/'+rpm, dsttree.basedir+'/'+arch+'/RPMS/', test)
- mv(self.tree.basedir+'/SRPMS/.metadata/'+self.nvr+'.src.rpm.info', dsttree.basedir+'/SRPMS/.metadata/', test)
-
-
-class FtpTree(BaseFtpTree):
- def __init__(self, tree, loadall=False):
- BaseFtpTree.__init__(self, tree)
- self.loadedpkgs={}
- self.marked4removal=[]
- self.marked4moving=[]
- self.pkgnames=[]
- self.__loadpkgnames()
- if loadall:
- for pkgname in self.pkgnames:
- self.loadedpkgs[pkgname]=Pkg(pkgname, self)
- # Tests:
- self.do_checkbuild=True
-
- def __getitem__(self, key):
- if self.loadedpkgs.has_key(key):
- return self.loadedpkgs[key]
- elif key in self.pkgnames:
- pkg=Pkg(key, self)
- self.loadedpkgs[key]=pkg
- return pkg
- else:
- raise KeyError, key
-
- def has_key(self, key):
- if key in self.pkgnames:
- return True
- else:
- return False
-
- def keys(self):
- return self.pkgnames
-
- def values(self):
- return self.loadedpkgs.values()
-
- def checktree(self, dsttree):
- self.__checkbuild(self.loadedpkgs.values())
- self.__checkarchs(dsttree, self.loadedpkgs.values())
-
- def testmove(self, dsttree):
- self.__checkbuild(self.marked4moving)
- self.__checkarchs(dsttree, self.marked4moving)
-
- self.__rmolderfromsrc(test=True)
- self.__rmotherfromdst(dsttree, test=True)
-
- for pkg in self.marked4moving:
- pkg.move(dsttree, test=True)
-
- def movepkgs(self, dsttree):
- if self.do_checkbuild:
- self.__checkbuild(self.marked4moving)
- bailoutonerror()
- self.__checkarchs(dsttree, self.marked4moving)
- bailoutonerror()
- self.__rmolderfromsrc()
- self.__rmotherfromdst(dsttree)
-
- for pkg in self.marked4moving:
- pkg.move(dsttree)
-
- def removepkgs(self):
- if self.do_checkbuild:
- self.__checkbuild(self.marked4removal)
- bailoutonerror()
- for pkg in self.marked4removal:
- pkg.remove()
-
- def mark4removal(self, wannabepkgs):
- self.__mark4something(wannabepkgs, Pkg.mark4removal)
-
- def mark4moving(self, wannabepkgs):
- self.__mark4something(wannabepkgs, Pkg.mark4moving)
-
-
- # Internal functions below
-
- def __loadpkgnames(self):
- def checkfiletype(name):
- if name[-13:]=='.src.rpm.info':
- return True
- else:
- return False
- list=filter(checkfiletype, os.listdir(self.basedir+'/SRPMS/.metadata'))
- self.pkgnames=map((lambda x: x[:-13]), list)
-
- def __mark4something(self, wannabepkgs, markfunction):
- def chopoffextension(pkg):
- found=pkg.find('.src.rpm')
- if found==-1:
- return pkg
- else:
- return pkg[:found]
- for wannabepkg in wannabepkgs:
- pkgname=chopoffextension(wannabepkg)
- if pkgname in self.pkgnames:
- if not pkgname in self.loadedpkgs.keys():
- self.loadedpkgs[pkgname]=Pkg(pkgname, self)
- markfunction(self.loadedpkgs[pkgname])
- else:
- perror('%s not found in source tree' % pkgname)
- bailoutonerror()
-
- def __checkbuild(self, marked):
- f=urllib.urlopen(config.builderqueue)
- #f=open('queue.txt')
- requests={}
- reid=re.compile(r'^.*id=(.*) pri.*$')
- regb=re.compile(r'^group:.*$|builders:.*$', re.M)
- for i in re.findall(regb, 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 marked:
- for bid in pkg.build.keys():
- if requests.has_key(bid) and not requests[bid].find('?') == -1:
- pkg.error("(buildid %s) building not finished" % bid)
-
- def __checkarchs(self, dsttree, marked):
- for pkg in marked:
- if len(pkg.files.keys()) <= 1:
- pkg.error('has only src.rpm built')
- continue
- otherpkgnames=self.__find_other_pkgs(pkg, dsttree)
- if otherpkgnames: # check if we're not removing some archs
- curarchs=[]
- missingarchs=[]
- for somepkg in otherpkgnames:
- curarchs.extend(Pkg(somepkg, dsttree).files.keys())
- for arch in curarchs:
- if arch not in pkg.files.keys():
- missingarchs.append(arch)
- if missingarchs:
- pkg.error('moving would remove archs: %s' % missingarchs)
- else: # warn if a package isn't built for all archs
- if (config.separate_noarch and 'noarch' in pkg.files.keys() and
- len(pkg.files.keys())==2):
- continue
- elif len(pkg.files.keys()) != len(config.ftp_archs)+1:
- missingarchs=[]
- for arch in config.ftp_archs:
- if arch not in pkg.files.keys():
- missingarchs.append(arch)
- pkg.warning('not built for archs: %s' % missingarchs)
-
- def __rmolderfromsrc(self, test=False):
- for pkg in self.marked4moving:
- olderpkgnames=self.__find_older_pkgs(pkg)
- for i in olderpkgnames:
- Pkg(i, self).remove(test)
-
- def __rmotherfromdst(self, dsttree, test=False):
- for pkg in self.marked4moving:
- pkgnames=self.__find_other_pkgs(pkg, dsttree)
- for i in pkgnames:
- Pkg(i, dsttree).remove(test)
-
- # Used more than once filter functions
-
- def __find_other_pkgs(self, pkg, tree):
- escapedpkgname=pkg.name.replace('.', '\.').replace('+', '\+')
- ziewre=re.compile(escapedpkgname+'-[^-]*-[^-]*$')
- def filter_other_pkgs(x):
- if ziewre.match(x) and not x == pkg.nvr:
- return True
- else:
- return False
- return filter(filter_other_pkgs, tree.pkgnames)
-
- def __find_older_pkgs(self, pkg):
- def filter_older_pkgs(x):
- c=x.split('-')
- rc = rpm.labelCompare(('0', pkg.version, pkg.release),
- ('0', c[-2], c[-1]))
- if rc == 1: # pkg > x
- return True
- else:
- return False
- return filter(filter_older_pkgs, self.__find_other_pkgs(pkg, self))
-
+++ /dev/null
-# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
-
-import time
-import os
-import sys
-import StringIO
-
-import config
-cval=config.value
-
-class Message:
- def __init__(self):
- self.headers = {}
- self.body = StringIO.StringIO()
- self.__set_std_headers()
-
- def set_header(self, n, v):
- self.headers[n] = v
-
- def set_headers(self, to = None, cc = None, subject = None):
- if to != None:
- self.set_header("To", to)
- if cc != None:
- self.set_header("Cc", cc)
- if subject != None:
- self.set_header("Subject", subject)
-
- def write_line(self, l):
- self.body.write("%s\n" % l)
-
- def write(self, s):
- self.body.write(s)
-
- def send(self):
- send_sendmail = "/usr/sbin/sendmail -t"
- f = os.popen(send_sendmail, "w")
- self.__write_to(f)
- f.close()
-
- def __set_std_headers(self):
- self.headers["Date"] = time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime())
- self.headers["Message-ID"] = "<pld-builder.%f.%d@%s>" \
- % (time.time(), os.getpid(), os.uname()[1])
- self.headers["From"] = cval['from_field']
- self.headers["X-PLD-Builder"] = cval['xpldbuilder']
-
- def __write_to(self, f):
- for k, v in self.headers.items():
- f.write("%s: %s\n" % (k, v))
- f.write("\n")
- self.body.seek(0)
- self.__sendfile(self.body, f)
-
- def __sendfile(self, src, dst):
- cnt = 0
- while 1:
- s = src.read(10000)
- if s == "": break
- cnt += len(s)
- dst.write(s)
- return cnt
-
-
+++ /dev/null
-# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
-
-import Cookie, time, ftpio
-
-UserNotLoggedIn="UserNotLoggedIn"
-
-class User:
- def __init__(self, cookies, options):
- self.loggedin=False
- ftpio.connect('wwwiface')
- if 'ftpsessid' in cookies and cookies['ftpsessid']:
- self.login=ftpio.login_cookie(cookies['ftpsessid'])
- if self.login:
- self.loggedin=True
-
- if 'action' in options:
- if options['action'] == 'register':
- self.checkloginpass(options)
- elif options['action'] == 'logout':
- self.logout()
-
- def checkloginpass(self, options):
- if 'login' not in options or 'pass' not in options:
- return
- self.cookie=ftpio.login_passwd(options['login'], options['pass'])
- if self.cookie:
- self.login=options['login']
- self.loggedin=True
- C = Cookie.SimpleCookie()
- C['ftpsessid']=self.cookie
- #C['ftpsessid']['expires']=time.strftime(
- #"%a, %d-%b-%y %H:%M:%S GMT",
- #time.gmtime(time.time()+86400))
- print C
-
- def logout(self):
- self.loggedin=False
- ftpio.logout()
- C = Cookie.SimpleCookie()
- C['ftpsessid']=''
- C['ftpsessid']['expires']=time.strftime("%a, %d-%b-%y %H:%M:%S GMT",
- time.gmtime(time.time()-31536000))
- print C
-
+++ /dev/null
-# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
-
-import wwwiface, ftpio
-
-
-def handlecmds(options):
- def chkbox(pkgname, value):
- retval='<input type="checkbox" name="%s"' % pkgname
- if value:
- retval=retval+' checked="yes"'
- retval=retval+'>'
- return retval
-
- if 'action' in options and options['action'] in actions:
- pass
- else:
- wwwiface.addcontent('<form action="index.py" method="post"><table border="1">')
- wwwiface.addcontent('<tr><td>Mv</td><td>Rm</td><td>Package</td></tr>')
- for pkg in ftpio.gettree():
- wwwiface.addcontent('<tr><td>%s</td><td>%s</td><td>%s</td></tr>' % (chkbox(pkg[0], pkg[1]), chkbox(pkg[0], pkg[2]), pkg[0]))
- wwwiface.addcontent('<tr><td> </td><td> </td><td><input type="submit" value="Commit"></td></tr>')
- wwwiface.addcontent('</table></form>')
-
-
-actions={}
-
+++ /dev/null
-# vi: encoding=utf-8 ts=8 sts=4 sw=4 et
-
-import cgi, Cookie, os
-
-menu=[]
-content=[]
-header=[]
-
-def getfile(file):
- f=open("../html/" + file + ".html", 'r')
- s=f.read()
- f.close()
- return s
-
-def catfile(file):
- f=open("../html/" + file + ".html", 'r')
- print f.read()
- f.close()
-
-def sendhttpheaders():
- print "Content-Type: text/html\n"
-
-def getopts():
- form = cgi.FieldStorage()
- opts = {}
- for key in form.keys():
- opts[key] = form[key].value
-
- cookies = {}
-
- if os.environ.has_key('HTTP_COOKIE'):
- c = Cookie.SimpleCookie()
- c.load(os.environ['HTTP_COOKIE'])
- for key in c.keys():
- cookies[key] = c[key].value
-
- return (opts, cookies)
-
-def sendhtml():
- catfile('header')
-
- print '<div id="Header">'
- for i in header:
- print i
- print '</div>'
-
- print '<div id="Menu">'
- for i in menu:
- print i
- catfile('menufooter')
- print '</div>'
-
- print '<div id="Content">'
- for i in content:
- print i
- print '</div>'
-
- catfile('footer')
-
-def addmenu(text=None, file=None):
- if text:
- menu.append(text)
- else:
- menu.append(getfile(file))
-
-def addheader(text=None, file=None):
- if text:
- header.append(text)
- else:
- header.append(getfile(file))
-
-def addcontent(text=None, file=None):
- if text:
- content.append(text)
- else:
- content.append(getfile(file))
-
+++ /dev/null
-# .bash_profile - file executed when logging in
-
-export EDITOR=vim
-
-# glen ;)
-if [ "${SSH_CONNECTION%% *}" = "194.106.120.90" ]; then
- export TZ=EET
- case $(id -un) in
- pldth)
- echo -ne "\033kth@ftp\033\\"
- ;;
- pldac)
- echo -ne "\033kac@ftp\033\\"
- ;;
- esac
-fi
+++ /dev/null
-# .bashrc - file executed when executing bash
-
-# Put your local aliases here
-alias rmpkg=~/pld-ftp-admin/scripts/remove.py
-alias gen-indexes=~/pld-ftp-admin/scripts/gen-indexes.py
-alias dump-locks=~/pld-ftp-admin/scripts/dump-locks.py
-
-testmvpkg() {
- ~/pld-ftp-admin/scripts/test-move.py "$@" || return $?
- shift 2
- echo >&2 "Checking signatures"
- testsignpkg "$@" || return $?
-}
-
-mvpkg() {
- __wrap_signpkg() {
- shift 2
- testsignpkg "$@" || return $?
- }
- __wrap_signpkg "$@" || return $?
- ~/pld-ftp-admin/scripts/move.py "$@" || return $?
-}
-
-alias ls='ls --color=auto -BFN --show-control-chars'
-alias l='ls -lh'
-alias la='ls -la'
-alias du='du -h'
-alias df='df -Th'
-alias vi='vim'
-alias h='history $(($LINES-6))'
-
-# glen ;)
-if [ "${SSH_CONNECTION%% *}" = "194.106.120.90" ]; then
- [ -f ~/okas/bashrc ] && . ~/okas/bashrc
- [ -x ~/okas/cvsstat ] && alias cvsstat=~/okas/cvsstat
-fi
-
-cp-kde-i18n() {
- sarch=amd64
- info=$1
- if [ ! -f $info ]; then
- echo >&2 "cp-kde-i18n: Specify existing info file"
- return
- fi
-
- for arch in alpha athlon i386 i586 i686 ppc sparc; do
- awk -F: -vsarch=$sarch '/^file:/ && $2 == sarch {print $3}' $info | xargs -ri cp -al ../../$sarch/RPMS/{} ../../$arch/RPMS
- awk -F: -vsarch=$sarch -varch=$arch '/^file:/ && $2 == sarch {printf("%s:%s:%s\n", $1, arch, $3)}' $info >> $info
- done
-}
-
-touchpkg() {
- local pkg=$1
- if [ ! -f $pkg ]; then
- echo >&2 "touchpkg: Specify existing info file"
- return
- fi
- awk -F: '/^file:/{arch=$2; file=$3; printf("../../%s/RPMS/%s\n", arch, file)}' "$@" | \
- xargs -l512 -r touch
-}
-
-signpkg() {
- local pkg=$1
- if [ ! -f $pkg ]; then
- echo >&2 "signpkg: Specify existing info file"
- return
- fi
- echo "$@" | xargs awk -F: '/^file:/{arch=$2; file=$3; printf("../../%s/RPMS/%s\n", arch, file)}' | \
- xargs -l1 -I '%{F}' rpm --nodigest --nosignature -qp --qf '%|SIGGPG?{}:{%{F}\n}|' '%{F}' | \
- xargs -r rpm --resign
-}
-
-testsignpkg() {
- local pkg=$1
- if [ ! -f $pkg ]; then
- echo >&2 "testsignpkg: Specify existing info file"
- return
- fi
- local out
- out=$(
- awk -F: '/^file:/{arch=$2; file=$3; printf("../../%s/RPMS/%s\n", arch, file)}' "$@" | \
- xargs -l512 \
- rpm -qp --qf '%{name}-%{version}-%{release}.%{arch} %{siggpg}\n' 2>/dev/null | \
- fgrep '(none)' | \
- sed -e 's,^,ERR: ,;s,(none),is not signed,'
- )
-
- if [ "$out" ]; then
- echo "$out"
- return 1
- else
- return 0
- fi
-}
-
-unlocktree() {
- local tree="$1"
- (
- cd ~/pld-ftp-admin/modules
- python -c "
-import ftpio
-ftpio.connect()
-ftpio.unlock('$tree')
-"
- )
-}
+++ /dev/null
-#!/bin/sh
-
-python setup.py build --build-lib ../modules
-
+++ /dev/null
-from distutils.core import setup, Extension
-setup(name="ucred",#version="1.0",
- ext_modules=[Extension("ucred", ["ucred.c"])])
-
+++ /dev/null
-#include <Python.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <signal.h>
-
-PyObject *g_socketerror; // socket.error
-
-static PyObject *ucred_sendcreds(PyObject *self, PyObject *args, PyObject *keywds);
-static PyObject *ucred_recvcreds(PyObject *self, PyObject *args, PyObject *keywds);
-
-static PyMethodDef ucredMethods[] = {
- {"sendcreds", (PyCFunction)ucred_sendcreds, METH_VARARGS|METH_KEYWORDS, NULL},
- {"recvcreds", (PyCFunction)ucred_recvcreds, METH_VARARGS|METH_KEYWORDS, NULL},
- {NULL, NULL, 0, NULL}
-};
-
-void initucred(void) {
- PyObject *module;
- module = Py_InitModule("ucred", ucredMethods);
-
- if(-1 == PyModule_AddIntConstant(module, "SO_PASSCRED", SO_PASSCRED)) {
- return;
- }
-
- module = PyImport_ImportModule("socket");
- if(!module) {
- return;
- }
- g_socketerror = PyObject_GetAttrString(module, "error");
- if(!g_socketerror) {
- return;
- }
-}
-
-static PyObject *ucred_sendcreds(PyObject *self, PyObject *args, PyObject *keywds) {
- int fd;
- int ret;
- int pid=-1, uid=-1, gid=-1;
- struct msghdr msg;
- struct iovec iov[1];
- struct ucred uc;
- unsigned char control[CMSG_SPACE(sizeof(struct ucred))];
- struct cmsghdr *cur;
-
- static char *kwlist[] = {"fd",
- "pid",
- "uid",
- "gid",
- NULL};
-
-// kill(0, SIGTRAP);
- if (!PyArg_ParseTupleAndKeywords(args, keywds, "i|iii", kwlist,
- &fd,
- &pid,
- &uid,
- &gid)) {
- return NULL;
- }
-// kill(0, SIGTRAP);
-
- if(pid!=-1)
- uc.pid=pid;
- else
- uc.pid=getpid();
- if(uid!=-1)
- uc.uid=uid;
- else
- uc.uid=getuid();
- if(gid!=-1)
- uc.gid=gid;
- else
- uc.gid=getgid();
-
- iov[0].iov_base="SCM_CREDENTIALS";
- iov[0].iov_len=15;
-
- memset(&msg, 0, sizeof(msg));
- msg.msg_iov = iov;
- msg.msg_iovlen = 1;
- msg.msg_control = &control;
- msg.msg_controllen = sizeof(control);
-
- cur = CMSG_FIRSTHDR(&msg);
- cur->cmsg_level = SOL_SOCKET;
- cur->cmsg_type = SCM_CREDENTIALS;
- cur->cmsg_len = CMSG_SPACE(sizeof(struct ucred));
- memcpy(CMSG_DATA(cur), &uc, sizeof(struct ucred));
-
- ret = sendmsg(fd, &msg, 0);
- if(ret < 0) {
- PyErr_SetFromErrno(g_socketerror);
- return NULL;
- }
-
- return Py_BuildValue("i", ret);
-}
-
-static PyObject *ucred_recvcreds(PyObject *self, PyObject *args, PyObject *keywds) {
- int fd;
- int flags=0;
- size_t maxsize=1024;
- char control[CMSG_SPACE(sizeof(struct ucred))];
- int ret;
- int pid=-1, uid=-1, gid=-1;
- struct msghdr msg;
- struct iovec iov[1];
- struct cmsghdr *cur;
- struct ucred *uc;
-
-
- static char *kwlist[] = {"fd", "flags", "maxsize", NULL};
-
- if (!PyArg_ParseTupleAndKeywords(args, keywds, "i|ii", kwlist,
- &fd, &flags, &maxsize)) {
- return NULL;
- }
-
- memset(&msg, 0, sizeof(msg));
-
- iov[0].iov_len = maxsize;
- iov[0].iov_base = malloc(maxsize);
- if (!iov[0].iov_base) {
- PyErr_NoMemory();
- return NULL;
- }
- msg.msg_iov = iov;
- msg.msg_iovlen = 1;
-
- msg.msg_control = &control;
- msg.msg_controllen = sizeof(control);
-
- ret = recvmsg(fd, &msg, flags);
- if (ret < 0) {
- PyErr_SetFromErrno(g_socketerror);
- free(iov[0].iov_base);
- return NULL;
- }
-
- cur=CMSG_FIRSTHDR(&msg);
-
- if(cur && cur->cmsg_type==SCM_CREDENTIALS && cur->cmsg_level==SOL_SOCKET)
- {
- assert(cur->cmsg_len >= sizeof(struct cmsghdr));
- // no null ancillary data messages?
-
- uc=(struct ucred*)CMSG_DATA(cur);
- pid=uc->pid;
- uid=uc->uid;
- gid=uc->gid;
- }
-
- {
- PyObject *r;
- r = Py_BuildValue("s#iii",
- iov[0].iov_base, ret,
- pid, uid, gid);
- free(iov[0].iov_base);
- return r;
- }
-}
-
-