#!/usr/bin/python # packmanrobot.py # # Copyright (C) 2001 Hendrik Muhs # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # python modules import os, sys, time, getopt, re, getpass, urllib, urllib2, string # global variables #defaults, put your own settings in ~/.packmanrobot (without '"') packmanuser="" packmanpassword="" mantra="" rpmbin="/bin/rpm" rpmtopdir="/usr/src/packages" gpgbin="/usr/bin/gpg" scpbin="/usr/bin/scp" sshbin="/usr/bin/ssh" target="i586" distversion="10.0" #PACKAGER="Leon Freitag " #PACKAGER_NAME="Leon Freitag" #VENDOR="Packman" build=1 upload=1 sign=1 remove=0 forceremove=0 # packman adminpage adminpage='https://packman.links2linux.de/admin/index.php' def usage(): print '''Options: packmanrobot.py [options]... [spec-file]... -h, --help show this helpscreen -b, --build only build, no sign, no upload -s, --sign only sign, no build, no upload -u --upload only upload -r --remove look for old files and ask for deletion -f --forceremove use together with --remove, delete without asking -t {arch}, --target={arch} -d {Distversion} --dist={Distversion} ''' def error(message): print "Error: " + message sys.exit(1) def runcommand(command, opt, password): pid, fd = os.forkpty() # If Child; execute external process if pid == 0: os.execv(command, [command]+opt) #if parent, read/write with child through file descriptor else: time.sleep(2) # need authentification? try: # Get password prompt; ignore out = os.read(fd, 1000) sys.stdout.write (out) #write password os.write(fd, password + "\n") #read response from child process out = os.read(fd,len(password) ) # do not show the mantra on the screen out = os.read(fd,100 ) while out: sys.stdout.write (out) try: out = os.read(fd, 100) except : out="" except: pass # get the exit status pid, rc = os.waitpid(pid,0) os.close(fd) return rc def get_pkg_nr(): params = urllib.urlencode({'module':'edit_package'}) f=urllib2.urlopen(adminpage,params) content=f.read() regpkg = re.escape(packmanpackagename) package_regex=re.compile('