kadischi/livecd_generator kadischi.py,1.20,1.21
Chitlesh GOORAH (chitlesh)
fedora-extras-commits at redhat.com
Tue Jul 4 14:44:51 UTC 2006
Author: chitlesh
Update of /cvs/devel/kadischi/livecd_generator
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv26597/livecd_generator
Modified Files:
kadischi.py
Log Message:
new
Index: kadischi.py
===================================================================
RCS file: /cvs/devel/kadischi/livecd_generator/kadischi.py,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- kadischi.py 4 Jul 2006 13:04:08 -0000 1.20
+++ kadischi.py 4 Jul 2006 14:44:49 -0000 1.21
@@ -1,331 +1,323 @@
#!/usr/bin/python -tt
-import os
-import sys
-import string
+import os, rpm, sys
import optparse
+import string
import shutil
-import rpm
from shvar import shvarFile
from functions import *
-version = '2.4'
-
-builddir = ''
-confdir = ''
-bindir = ''
-
-isoimage = ''
-force = False
-method = ''
-anaconda_args = ''
-buildstamp = ''
-product_path = ''
-kernel_version = ''
-kernel_version_smp = ''
-
-# OK, we`re starting
-flc_log ('Starting kadischi...')
-
-
-# setup dirs
-bindir = sys.path [0]
-confdir = normalize_path(['/etc/kadischi'])
-
-
-# process command line options
-usage = 'usage: %prog [options] <path-to-the-repository> <destination-iso-image-file>\n\npath-to-the-repository can be a path on the local file system (without any prefixes) but can also be a path to a http, ftp or some other type of repository. For details, consult the documentation at http://fedoraproject.org/wiki/Kadischi/Documentation'
-version = '%prog ' + version
-parser = optparse.OptionParser (usage=usage, version=version)
-parser.add_option ("-f", "--force", dest="force", action="store_true", default=False, help="overwrite destination iso image file, if such exists.")
-parser.add_option ("-C", "--cmdline", dest="cmdline", action="store_true", default=False, help="run anaconda in command line mode (runs without interface, but requires complete kickstart file)")
-parser.add_option ("-T", "--text", dest="text", action="store_true", default=False, help="run anaconda in TUI mode")
-parser.add_option ("", "--graphical", dest="graphical", action="store_true", default=False, help="run anaconda in GUI mode")
-parser.add_option ("", "--kickstart", dest="ksfile", help="supply anaconda with kickstart file")
-parser.add_option ("", "--buildstamp", dest="buildstamp", help="buildstamp file (if not set, using the default buildstamp from the config directory)")
-parser.add_option ("", "--anaconda_option", dest="anaconda_options", action="append", help="Pass options to Anaconda (example: --anaconda_option={--test,--vnc,--lowres})")
-
-flc_log ('Parsing command line arguments')
-(options, args) = parser.parse_args ()
-
-force = options.force
-
-if options.ksfile != None:
- anaconda_args = anaconda_args + ' --kickstart=' + options.ksfile
-
-if options.buildstamp != None:
- buildstamp = options.buildstamp
-else:
- buildstamp = normalize_path ([confdir, 'buildstamp'])
-
-
-# set display mode
-display_mode = ''
-
-if options.graphical:
- display_mode = ' --graphical'
-if options.text:
- display_mode = ' -T'
-if options.cmdline:
- display_mode = ' -C'
-
-if options.anaconda_options:
- opt = ''
- for option in options.anaconda_options:
- opt = ' ' + option
- anaconda_args = opt + anaconda_args
-
-anaconda_args = display_mode + anaconda_args
-
-
-### check if everything looks OK
-# checking arguments
-if len (args) < 2:
- flc_log ('Not enough arguments.\n')
- parser.parse_args (['-h'])
-
-if len (args) > 2:
- flc_log ('Too many arguments.\n')
- parser.parse_args (['-h'])
-
-method = args [0]
-isoimage = normalize_path ([args [1]])
+import logging
+import subprocess
+import tempfile
+
+import urlgrabber.grabber as grabber
+
+# variables related to building the image
+myname = "Kadischi Contributor"
+distname = "Fedora Core 5 Bordeaux (Live CD)"
+postscriptdir = "/usr/local/share/kadischi/post_install_scripts"
+
+version = "2.5"
+
+def main():
+ force = False
+ # setup dirs
+ bindir = sys.path [0]
+ confdir = normalize_path(['/etc/kadischi'])
+
+ global builddir, postscriptdir, buildstamp
+
+ # check for Requires
+ print "[kadischi]: Checking dependencies for Kadischi"
+ requirements()
+
+ # checking UID - must be root
+ print "[kadischi]: Checking UID for root access"
+ if os.getuid() != 0:
+ print >> sys.stderr, "[kadischi]: You must be root to build a live CD."
+ sys.exit(1)
+
+ # OK, we're starting
+ print "[kadischi]: Starting kadischi with root access..."
+
+ # Parsing command line arguments
+ (options, args) = parse_args ()
+ if len(args) != 2:
+ print >> sys.stderr, "[kadischi]: Invalid arguments!"
+ return 1
+
+ force = options.force
+ anaconda_args = ["/usr/sbin/anaconda"]
+ if options.ksfile is not None:
+ anaconda_args.append("--kickstart=%s" % (options.ksfile,))
+
+ if options.graphical:
+ anaconda_args.append("--graphical")
+ elif options.text:
+ anaconda_args.append("--text")
+ elif options.cmdline:
+ anaconda_args.append("--cmdline")
+ if options.extra:
+ anaconda_args.extend(options.extra.split())
+ if options.tempdir:
+ builddir = os.path.normpath(options.tempdir)
+ else:
+ builddir = tempfile.mkdtemp(prefix="/tmp/kadischi.")
-# checking UID - must be root
-flc_log ('Checking UID')
-
-if os.getuid () != 0:
- flc_log ('You have to be root to run this application. Please restart with root permissions.\n')
- sys.exit (1)
-
-
-# check if we can open buildstamp file
-if not os.access(buildstamp, os.R_OK):
- flc_log ('Can`t open buildstamp file %s. ' % buildstamp)
- sys.exit (1)
-
-
-# loading productPath from buildstamp
-flc_log ('Using buildstamp file %s. ' % buildstamp)
-
-f = open(buildstamp, "r")
-lines = f.readlines()
-if len(lines) >= 4:
- product_path = lines[3][:-1]
- flc_log ('Product path set to %s. ' % product_path)
-else:
- flc_log ('Product path can`t be found in buildstamp file %s (Product path should be on the 4th line of the file)' % buildstamp)
- sys.exit (1)
-
-
-# validating the repository
-flc_log ('Now we are going to try to validate your repository (for now, only http, ftp and local repositories can be checked)')
-
-valid = True
-
-if method.find (':') == -1:
- method = normalize_path ([method])
- valid = path_exists (method) and path_exists (method + '/' + product_path) and path_exists (method + '/' + product_path + '/' + 'base') and path_exists (method + '/' + product_path + '/' + 'RPMS')
-elif method.find ('http') == 0 or method.find ('ftp') == 0:
- method = method.rstrip('/')
- valid = url_exists (method) and url_exists (method + '/' + product_path) and url_exists (method + '/' + product_path + '/' + 'base') and url_exists (method + '/' + product_path + '/' + 'RPMS')
+ if options.scriptdir:
+ postscriptdir = os.path.normpath(options.scriptdir)
-if valid:
- flc_log ('Repository seems to be OK.')
-else:
- flc_log ('Repository validation failed. Aborting execution.')
- sys.exit (1)
+ if options.buildstamp != None:
+ buildstamp = options.buildstamp
+ else:
+ buildstamp = normalize_path ([confdir, 'buildstamp'])
+ # validating the repository
+ print "[kadischi]: Trying to validate your repository"
+ method = args [0]
+ isoimage = os.path.normpath (args [1])
+ method = method_check(method)
+ if method is None:
+ return 2
+
+ # checking if everything is OK with destination (iso image) file
+ if os.path.isfile(isoimage) and not options.force:
+ print >> sys.stderr, "[kadischi]: Trying to overwrite existing image %s without --force. Exiting" % (isoimage,)
+ return 3
+
+ # prepare dirs
+ sysdir = normalize_path([builddir, 'system'])
+ csysdir = normalize_path([builddir, 'compressed'])
+ os.makedirs (sysdir)
+
+ # loading productPath from buildstamp for anaconda
+ print "[kadischi]: Using buildstamp file %s. " % buildstamp
+ buildstamping(builddir)
+
+ # run anaconda
+ print "\n[kadischi] : running anaconda \n"
+ anaconda_args.append("--rootpath=%s" % sysdir)
+ anaconda_args.append("--method=%s" % method)
+ execute(anaconda_args)
+ print "\n[kadischi] : anaconda has finished its job \n"
+
+ # run post_install_scripts
+ print "[kadischi]: running post installation scripts"
+ run_scripts(sysdir)
+
+ ### Calculate size of result ISO image by known ratios for SquashFS (anywhere from 2.5 to 2.7)
+ size = 0
+ stepsize = 0
+
+ ts = rpm.TransactionSet(sysdir)
+ mi = ts.dbMatch()
+ for hdr in mi:
+ size = (hdr['size'])
+ stepsize = (size + stepsize)
+
+ totalsize = stepsize
+ estimate0 = (totalsize / 2.5) ## Observed ratio for SquashFS
+ estimate1 = (totalsize / 2.7) ## Observed ratio for SquashFS
+
+ print ("Estimated %s size is between %s and %s bytes" % (isoimage, estimate1, estimate0))
+
+ # make initrd image and pickup kernel version cause when we move files arround, it will be late
+ print "[kadischi]: making initrd image"
+ kernel_smp = (['kernel-smp'])
+ kernel = (['kernel'])
+ has_no_kernel_smp = check_installed_rpms(sysdir, kernel_smp, False)
+ has_no_kernel = check_installed_rpms(sysdir, kernel, False)
+
+ kernel_version = get_kernel_version (sysdir)
+ kernel_version_smp = string.join([kernel_version, 'smp'], '')
+ mkinit = normalize_path([bindir, 'livecd-mkinitrd.sh'])
+ if has_no_kernel and has_no_kernel_smp:
+ print "[kadischi]: Couldnt determine the kernel versions, bailing!"
+ sys.exit(1)
+ elif has_no_kernel and not has_no_kernel_smp:
+ string.split(kernel_version, 'smp')
+ string.join([kernel_version, 'smp'], '')
+ elif not has_no_kernel and not has_no_kernel_smp:
+ args = [mkinit, sysdir, kernel_version_smp]
+ execute (args)
+ args = [mkinit, sysdir, kernel_version]
+ execute (args)
+
+ # move files
+ print "[kadischi]: moving files that should be on tmpfs"
+ move = normalize_path([bindir, 'movefiles.py'])
+ args = [move, sysdir]
+ execute (args)
+
+ # compress the tree
+ print "[kadischi]: compressing the tree (order a pizza 'cause this will take a while)"
+ # kadischi.sqsh is a file that we mount loopback. So we need to create supporting
+ # files and directories outside of the compressed tree.
+ os.makedirs (os.path.join(csysdir, 'boot/isolinux'))
+ os.makedirs (normalize_path([csysdir, '/livecd']))
+ touch = file(normalize_path([csysdir, '.livecd']), 'w')
+ touch.close()
+
+ # Make the SquashFS image
+ ctree = normalize_path([csysdir, 'kadischi.sqsh'])
+ args = ["/sbin/mksquashfs", sysdir, ctree]
+ execute (args)
+
+ # install boot
+ print "[kadischi]: installing boot & config files in compressed tree"
+ boot = normalize_path([bindir, 'install-boot.sh'])
+ args = [boot, sysdir, csysdir, kernel_version]
+ execute(args)
+
+ # conf files in compressed tree (they shoudn't be compressed)
+ tarball = normalize_path([sysdir, '/livecd/kadischi.tar.gz'])
+ dest_tarball = normalize_path([csysdir, '/livecd/kadischi.tar.gz'])
+ args = ["cp", "-f", tarball, dest_tarball]
+ execute(args)
+
+ # delete sysdir - we don`t need it anymore
+ print "[kadischi]: removing uncompressed tree"
+ cleanup(sysdir)
+
+ # create iso image
+ print "[kadischi]: creating iso image %s" % isoimage
+ args = ["/usr/bin/mkisofs", "-quiet", "-z", "-R",
+ "-V", distname,
+ "-b", "boot/isolinux/isolinux.bin",
+ "-c", "boot/isolinux/boot.cat",
+ "-p", myname,
+ "-x", "lost+found",
+ "-no-emul-boot", "-boot-load-size", "4", "-boot-info-table",
+ "-o", isoimage,
+ csysdir]
+ execute (args)
+
+ # delete builddir
+ print "[kadischi]: removing builddir."
+ cleanup (builddir)
+
+ # Done!
+ print "[kadischi]: Finished successfully."
+ return 0
+
+
+
+def requirements():
+ """ Searches which Requires has not yet installed """
+ required_rpms = ('anaconda', 'busybox-anaconda', 'mkisofs', 'syslinux', 'e2fsprogs', 'squashfs-tools')
+ missing_rpms = check_installed_rpms ('/', required_rpms, False)
+
+ if len (missing_rpms) != 0:
+ print >> sys.stderr, "[kadischi]: Required packages:"
+ for rpm in missing_rpms:
+ print " %s" % rpm
+ print >> sys.stderr, " are missing. Aborting execution."
+ sys.exit (1)
-# format method string the way anaconda likes it
-if method.find (':') == -1:
- method = 'nfs:/' + method
+def parse_args():
+ """ process command line options for anaconda """
+ usage = 'usage: %prog [options] <path-to-the-repository> <destination-iso-image-file>\n\npath-to-the-repository can be a path on the local file system (without any prefixes) but can also be a path to a http, ftp or some other type of repository. For details, consult the documentation at http://fedoraproject.org/wiki/Kadischi/Documentation'
+ verstr = '%prog ' + version
+ parser = optparse.OptionParser(usage=usage, version=verstr)
+ parser.add_option ("-f", "--force", dest="force", action="store_true", default=False, help="overwrite destination iso image file, if such exists.")
+ parser.add_option ("-C", "--cmdline", dest="cmdline", action="store_true", default=False, help="run anaconda in command line mode (runs without interface, but requires complete kickstart file)")
+ parser.add_option ("-T", "--text", dest="text", action="store_true", default=False, help="run anaconda in TUI mode")
+ parser.add_option ("", "--graphical", dest="graphical", action="store_true", default=False, help="run anaconda in GUI mode")
+ parser.add_option ("", "--kickstart", dest="ksfile", help="supply anaconda with kickstart file")
+ parser.add_option ("-x", "--extra", dest="extra", help="extra args to pass to anaconda")
+ parser.add_option ("", "--tempdir", dest="tempdir", help="temporary directory to use for building the image template")
+ parser.add_option ("", "--scriptdir", dest="scriptdir", help="location of post-installation scripts (default: %s)" %(postscriptdir,))
+ parser.add_option ("", "--buildstamp", dest="buildstamp", help="buildstamp file (if not set, using the default buildstamp from the config directory)")
+ return parser.parse_args()
+
+
+def buildstamping(builddir):
+ """ check if we can open buildstamp file """
+ if not os.access(buildstamp, os.R_OK):
+ print "[kadischi]: Can't open buildstamp file %s. " % buildstamp
+ sys.exit (1)
-# checking if everything is OK with destination (iso image) file
-if os.path.isfile (isoimage):
- flc_log ('File %s already exists. ' % isoimage)
- if force:
- flc_log ('It will be overwritten.')
+ f = open(buildstamp, "r")
+ lines = f.readlines()
+ if len(lines) >= 4:
+ product_path = lines[3][:-1]
+ print "[kadischi]: Product path set to %s. " % product_path
else:
- flc_log ('Please choose some other file name, or use -f option to overwrite the existing file.')
+ print "[kadischi]: Product path can't be found in buildstamp file %s (Product path should be on the 4th line of the file)" % buildstamp
sys.exit (1)
-elif not os.path.isdir (os.path.dirname (isoimage)):
- os.makedirs (os.path.dirname (isoimage))
-
-
-# check for installed rpms
-flc_log ('Checking required packages')
-required_rpms = ('anaconda', 'busybox-anaconda', 'mkisofs', 'syslinux', 'e2fsprogs', 'squashfs-tools')
-missing_rpms = check_installed_rpms ('/', required_rpms, False)
-
-if len (missing_rpms) != 0:
- flc_log ('Required packages:')
- for rpm in missing_rpms:
- flc_log (' %s' % rpm)
- flc_log ('are missing. Aborting execution.')
- sys.exit (1)
-
-
-# check for the config file
-flc_log ('Looking for config file')
-
-if not os.path.isfile (normalize_path([confdir, 'kadischi.conf'])):
- flc_log ('Can`t find config file %s.' % normalize_path([confdir, 'kadischi.conf']))
- sys.exit (1)
-
-
-# load config file options
-flc_log ('Loading config file options')
-
-buildconf = shvarFile (normalize_path([confdir, 'kadischi.conf']), True)
-builddir = buildconf ["BUILDDIR"]
-
-buildnum = str (int (buildconf ["BUILDNUM"]) + 1)
-buildconf ["BUILDNUM"] = buildnum
-buildconf.write ()
-
-if builddir == '' or builddir == None:
- flc_log ('No build dir defined. Please, edit config file option BUILDDIR.')
- sys.exit(1)
-
-
-# prepare dirs
-buildsubdir = 'livecd-build_no' + buildnum
-builddir = normalize_path ([builddir, buildsubdir])
-sysdir = normalize_path([builddir, 'system'])
-csysdir = normalize_path([builddir, 'compressed'])
-os.makedirs (sysdir)
-# we shouldn`t create csysdir because mkzftree wants to create it by it self
-# os.makedirs (csysdir)
-
-
-# Moving the buildstamp file to /tmp/product/.buildstamp so anaconda can find it
-if not os.path.exists ('/tmp/product'):
- os.makedirs ('/tmp/product')
-elif not os.path.isdir ('/tmp/product'):
- flc_log ('Path /tmp/product is not a directory, temporarly moving to %s' % normalize_path([builddir, 'product']))
- shutil.move ('/tmp/product', normalize_path([builddir, 'product']))
- os.makedirs ('/tmp/product')
-elif os.path.exists ('/tmp/product/.buildstamp'):
- flc_log ('Path /tmp/product/.buildstamp already exists, temporarly moving to %s' % normalize_path([builddir, '.buildstamp']))
- shutil.move ('/tmp/product/.buildstamp', normalize_path([builddir, '.buildstamp']))
-
-shutil.copy2 (buildstamp, '/tmp/product/.buildstamp')
-
-
-# run anaconda
-flc_log ('\n *** running anaconda *** \n')
-run ("/usr/sbin/anaconda %s --rootpath=%s --method=%s" % (anaconda_args, sysdir, method), builddir)
-flc_log ('\n *** anaconda has finished the job *** \n')
-
-
-###
-### Calculate size of result ISO image by known ratios for SquashFS (anywhere from 2.5 to 2.7)
-size = 0
-stepsize = 0
-
-
-ts = rpm.TransactionSet(sysdir)
-
-mi = ts.dbMatch()
-for hdr in mi:
- size = (hdr['size'])
- stepsize = (size + stepsize)
-
-totalsize = stepsize
-estimate0 = (totalsize / 2.5) ## Observed ratio for SquashFS
-estimate1 = (totalsize / 2.7) ## Observed ratio for SquashFS
-
-print ("Estimated %s size is between %s and %s bytes" % (isoimage, estimate1, estimate0))
-
-
-# now`s the time to pickup kernel version cause when we move files arround, it will be late
-# Borrow some functions to do logic processing
-kernel_version = get_kernel_version (sysdir)
-kernel_version_smp = string.join([kernel_version, 'smp'], '')
-
-
-
-# run post_install_scripts
-flc_log ('running post installation scripts')
-scripts = []
-
-for root, dirs, files in os.walk (normalize_path([bindir, 'post_install_scripts'])):
- for filename in files:
- filename = normalize_path([bindir, 'post_install_scripts', filename])
- if os.access(filename, 1):
- scripts.append (filename)
-
-scripts.sort()
-
-for script in scripts:
- flc_log ('%s' % script)
- run ("%s %s %s" % (script, sysdir, anaconda_args), builddir)
-
-
-# make initrd image
-# Borrow some more functions to do our logic
-flc_log ('making initrd image')
-kernel_smp = (['kernel-smp'])
-kernel = (['kernel'])
-has_no_kernel_smp = check_installed_rpms(sysdir, kernel_smp, False)
-has_no_kernel = check_installed_rpms(sysdir, kernel, False)
-
-
-
-if has_no_kernel and has_no_kernel_smp:
- flc_log('Couldnt determine the kernel versions, bailing!')
- sys.exit(1)
-elif has_no_kernel and not has_no_kernel_smp:
- string.split(kernel_version, 'smp')
- string.join([kernel_version, 'smp'], '')
- run ("%s %s %s" % (normalize_path([bindir, 'livecd-mkinitrd.sh']), sysdir, kernel_version), builddir)
-elif not has_no_kernel and not has_no_kernel_smp:
- run ("%s %s %s" % (normalize_path([bindir, 'livecd-mkinitrd.sh']), sysdir, kernel_version), builddir)
- run ("%s %s %s" % (normalize_path([bindir, 'livecd-mkinitrd.sh']), sysdir, kernel_version_smp), builddir)
-else:
- run ("%s %s %s" % (normalize_path([bindir, 'livecd-mkinitrd.sh']), sysdir, kernel_version), builddir)
-
-# move files
-flc_log ('moving files that should be on tmpfs')
-run ("%s %s" % (normalize_path([bindir, 'movefiles.py']), sysdir), builddir)
-
-
-# compress the tree
-flc_log ('compressing the tree (order a pizza `cause this will take a while)')
-# kadischi.sqsh is a file that we mount loopback. So we need to create supporting
-# files and directories outside of the compressed tree.
-os.makedirs (os.path.join(csysdir, 'boot/isolinux'))
-os.makedirs (normalize_path([csysdir, '/livecd']))
-touch = file(normalize_path([csysdir, '.livecd']), 'w')
-touch.close()
-# Make the SquashFS image
-run("/sbin/mksquashfs %s %s" % (sysdir, normalize_path([csysdir, 'kadischi.sqsh'])))
-
-
-# install boot & conf files in compressed tree (they shoudn`t be compressed)
-flc_log ('installing boot & config files in compressed tree')
-run ("%s %s %s %s" % (normalize_path([bindir, 'install-boot.sh']), sysdir, csysdir, kernel_version), builddir)
-run ("cp -f %s %s" % (normalize_path([sysdir, '/livecd/kadischi.tar.gz']), normalize_path([csysdir, '/livecd/kadischi.tar.gz'])), builddir)
-
-
-# delete sysdir - we don`t need it anymore
-flc_log ('removing uncompressed tree')
-clean_directory (sysdir)
-
-
-# create iso image
-flc_log ('creating iso image %s' % isoimage)
-run ("%s %s %s" % (normalize_path([bindir, 'create-iso.sh']), csysdir, isoimage), builddir)
-
-
-# delete builddir
-flc_log ('removing builddir')
-cleanup (builddir)
-
-# Done!
-flc_log ('Finished.')
-sys.exit (0)
+ """ Moving the buildstamp file to /tmp/product/.buildstamp so anaconda can find it """
+ if not os.path.exists ('/tmp/product'):
+ os.makedirs ('/tmp/product')
+ elif not os.path.isdir ('/tmp/product'):
+ print "[kadischi]: Path /tmp/product is not a directory, temporarly moving to %s" % normalize_path([builddir, 'product'])
+ shutil.move ('/tmp/product', normalize_path([builddir, 'product']))
+ os.makedirs ('/tmp/product')
+ elif os.path.exists ('/tmp/product/.buildstamp'):
+ print "[kadischi]: Path /tmp/product/.buildstamp already exists, temporarly moving to %s" % normalize_path([builddir, '.buildstamp'])
+ shutil.move ('/tmp/product/.buildstamp', normalize_path([builddir, '.buildstamp']))
+
+ shutil.copy2 (buildstamp, '/tmp/product/.buildstamp')
+
+
+def run_scripts(sysdir):
+ scripts = []
+ for file in os.listdir(postscriptdir):
+ # ignore common editor backups
+ if file.endswith("~") or file.endswith(".swp"):
+ continue
+ f = "%s/%s" % (postscriptdir, file)
+ if os.access(f, os.X_OK):
+ scripts.append(f)
+ scripts.sort()
+ for s in scripts:
+ rc = subprocess.call([s, sysdir])
+ if rc != 0:
+ logging.warn("script %s exited abnormally" %(os.path.basename(s),))
+
+def method_check(method):
+ def exists(url):
+ try:
+ u = grabber.urlopen(url, retry=5)
+ u.close()
+ print "[kadischi]: Repository seems to be OK."
+ return True
+ except grabber.URLGrabError, e:
+ print "[kadischi]: Repository validation failed. Aborting execution."
+ logging.debug("[kadischi]: Unable to find %s: %s" %(url, e))
+ return False
+
+ if method.startswith("http://") or method.startswith("ftp://") or method.find(":") == -1:
+ if not exists("%s/repodata/repomd.xml" %(method,)):
+ return None
+ if method.find(":") == -1:
+ method = "nfs:/%s" %(method,)
+ return method
+ print >> sys.stderr, "Unable to determine how to use method"
+ return None
+
+def execute (args):
+ if not os.access(args[0], os.X_OK):
+ print >> sys.stderr, "[kadischi]: unable to access", args[0]
+ cleanup(builddir)
+ rc = subprocess.call(args)
+ if rc:
+ raise RuntimeError, "Failed to execute", args[0]
+ cleanup(builddir)
+
+if __name__ == "__main__":
+ try:
+ rc = main()
+ except KeyboardInterrupt, e:
+ print >> sys.stderr, "\n\n[kadischi]: Exiting on user cancel.(ctrl+c)"
+ cleanup(builddir)
+ sys.exit(1)
+ except RuntimeError, e:
+ print >> sys.stderr, "\n\nError! ", e
+ cleanup(builddir)
+ sys.exit(1)
+ cleanup(builddir)
+ sys.exit(rc)
\ No newline at end of file
More information about the fedora-extras-commits
mailing list