On Tue, 2007-02-20 at 13:43 -0500, Chris Lumens wrote: > Could you make maketreeinfo.py not be interactive? If the script's not > provided with information it requires, I'd rather see it use a > reasonable default or blow up with an informative error message. That > way when the tree build is busted the next day, we'll have something in > the build logs that helps us straighten things out. Okay - it's been changed to be non-interactive, and instead just emits warning messages if you don't set flags. Patch is attached. -w
diff -Naur --exclude=CVS --exclude='*.swp' --exclude='.#*' anaconda/scripts/buildinstall anaconda-ww/scripts/buildinstall --- anaconda/scripts/buildinstall 2007-02-15 10:55:15.000000000 -0500 +++ anaconda-ww/scripts/buildinstall 2007-02-15 16:04:15.000000000 -0500 @@ -30,6 +30,10 @@ PRODUCTSTR=$2 shift; shift ;; + --variant) + VARIANT=$2 + shift; shift + ;; --prodpath) PRODUCTPATH=$2 shift; shift @@ -101,6 +105,7 @@ UPD_INSTROOT=$BUILDINSTDIR/upd-instroot MK_IMAGES=$BUILDINSTDIR/mk-images +MK_TREEINFO=$BUILDINSTDIR/maketreeinfo.py MK_STAMP=$BUILDINSTDIR/makestamp.py BUILDINSTALL=$BUILDINSTDIR/buildinstall @@ -114,10 +119,11 @@ UPD_INSTROOT=./upd-instroot MK_IMAGES=./mk-images +MK_TREEINFO=./maketreeinfo.py MK_STAMP=./makestamp.py BUILDINSTALL=./buildinstall -for f in $UPD_INSTROOT $MK_IMAGES $MK_STAMP $BUILDINSTALL; do +for f in $UPD_INSTROOT $MK_IMAGES $MK_STAMP $MK_TREEINFO $BUILDINSTALL; do if [ ! -f $f ]; then cp -a $BUILDINSTDIR/usr/lib/anaconda-runtime/$f* $BUILDINSTDIR/ else @@ -127,6 +133,7 @@ UPD_INSTROOT=$BUILDINSTDIR/upd-instroot MK_IMAGES=$BUILDINSTDIR/mk-images +MK_TREEINFO=$BUILDINSTDIR/maketreeinfo.py MK_STAMP=$BUILDINSTDIR/makestamp.py BUILDINSTALL=$BUILDINSTDIR/buildinstall @@ -142,6 +149,9 @@ PYTHONPATH=$TREEDIR/instimage/usr/lib/anaconda $TREEDIR/instimage/usr/lib/anaconda-runtime/pkgorder $p $BUILDARCH $PRODUCTPATH > $PKGORDER fi +echo "Writing .treeinfo file..." +$MK_TREEINFO --family="$PRODUCTSTR" ${VARIANT:+--variant="$VARIANT"} --version=$VERSION --arch=$BUILDARCH --packagedir=${PKGDIR#$p/} --outfile=$p/.treeinfo + echo "Making images..." $MK_IMAGES $DEBUGSTR $NOGRSTR $PKGDIR $p $TREEDIR/image-template $TREEDIR/instimage $BUILDARCH "$PRODUCTSTR" $VERSION $PRODUCTPATH "$BUGURL" diff -Naur --exclude=CVS --exclude='*.swp' --exclude='.#*' anaconda/scripts/Makefile anaconda-ww/scripts/Makefile --- anaconda/scripts/Makefile 2006-05-16 17:33:48.000000000 -0400 +++ anaconda-ww/scripts/Makefile 2007-02-15 10:47:37.000000000 -0500 @@ -14,6 +14,7 @@ install -m 755 pkgorder $(DESTDIR)/$(RUNTIMEDIR) install -m 755 getkeymaps $(DESTDIR)/$(RUNTIMEDIR) install -m 755 makestamp.py $(DESTDIR)/$(RUNTIMEDIR) + install -m 755 maketreeinfo.py $(DESTDIR)/$(RUNTIMEDIR) install -m 755 fixmtime.py $(DESTDIR)/$(RUNTIMEDIR) install -m 755 yumcache $(DESTDIR)/$(RUNTIMEDIR) install -m 755 pyrc.py $(DESTDIR)/$(RUNTIMEDIR) diff -Naur --exclude=CVS --exclude='*.swp' --exclude='.#*' anaconda/scripts/maketreeinfo.py anaconda-ww/scripts/maketreeinfo.py --- anaconda/scripts/maketreeinfo.py 1969-12-31 19:00:00.000000000 -0500 +++ anaconda-ww/scripts/maketreeinfo.py 2007-02-20 16:34:47.000000000 -0500 @@ -0,0 +1,100 @@ +#!/usr/bin/python +# +# makes a .treeinfo file. if information isn't provided, it emits some warnings. +# Author: Will Woods <wwoods@xxxxxxxxxx> +# Copyright 2007 Red Hat, Inc. +# +# License: GPL +# + +import os,sys,string +import getopt +import time +import ConfigParser + + +def usage(): + args = "" + for key in data: + args = "%s [--%s=%s]" %(args, key, key) + print "%s: %s" % (sys.argv[0], args) + sys.exit(1) + +# TODO: add composeid, images, etc. +# TODO: take releasestr as an option and break it up into family/variant/version? + +data = {"timestamp": time.time(), + "family": None, + "variant": None, + "version": None, + "arch": None, + "discnum": None, + "totaldiscs": None, + "packagedir": None, + "outfile": None} +allDiscs = None + +opts = [] +for key in data.keys(): + opts.append("%s=" % (key,)) +opts.append("allDiscs") + +(args, extra) = getopt.getopt(sys.argv[1:], '', opts) +if len(extra) > 0: + print "had extra args: %s" % extra + usage() + +for (str, arg) in args: + if str[2:] in data.keys(): + data[str[2:]] = arg + elif str == "--allDiscs": + allDiscs = 1 + else: + print "unknown str of ", str + usage() + +# Make sure timestamp is actually a float +if type(data["timestamp"]) != float: + data["timestamp"] = float(data["timestamp"]) + +if data["family"] is None: + print >> sys.stderr, "--family missing! This is probably bad!" + data["family"] = "" + +if data["variant"] is None: + print >> sys.stderr, "--variant missing, but that's OK." + data["version"] = "" + +if data["version"] is None: + print >> sys.stderr, "--version missing! This is probably bad!" + data["version"] = "" + +if data["arch"] is None: + print >> sys.stderr, "--arch missing! This is probably bad!" + data["arch"] = "" + +if data["discnum"] is None and allDiscs is None: + print >> sys.stderr, "--discnum missing; assuming disc 1" + data["discnum"] = "1" + +if data["totaldiscs"] is None and allDiscs is None: + print >> sys.stderr, "--totaldiscs missing; assuming 1" + data["totaldiscs"] = "1" + +if data["packagedir"] is None: + print >> sys.stderr, "--packagedir missing. This might cause some weirdness." + data["packagedir"] = "" + + +if data["outfile"] is None: + f = sys.stdout +else: + f = open(data["outfile"], "w") + +section='general' +c=ConfigParser.ConfigParser() +c.add_section(section) +for k,v in data.items(): + if k != 'outfile': + c.set(section,k,v) +c.write(f)
Attachment:
signature.asc
Description: This is a digitally signed message part