From 26e01bf98c72bb6ddef44a96764c07547979be03 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Michael=20Schr=C3=B6der?= Date: Fri, 9 Feb 2007 20:49:59 +0000 Subject: [PATCH] - add --test option to changelog2spec to make it die on unordered dates - preinstall device-mapper in xen builds - preinstall mount in xen builds (mandriva & debian) - create emtpy /etc/default/rcS (debian) - create empty /etc/fstab to get rid of some error messages - order packages in host system, not guest system, works around a bug in Fedora's rpm package - add hostname to /etc/hosts - fix sles10 config - fix personality switching to use right syscall on i586 - add support for "needsrootforbuild" - lock root account if building as user abuild - fix macro expansion to allow simple macros starting with ? or ! --- Build.pm | 2 +- build | 21 ++++++++++++++++----- changelog2spec | 14 +++++++++++++- configs/sles10.conf | 2 ++ init_buildsystem | 44 +++++++++++++++++++++++++++++++++----------- 5 files changed, 65 insertions(+), 18 deletions(-) diff --git a/Build.pm b/Build.pm index d8675c6..b21b0d9 100644 --- a/Build.pm +++ b/Build.pm @@ -582,7 +582,7 @@ sub read_spec { my $expandedline = ''; if (!$skip) { my $tries = 0; - while ($line =~ /^(.*?)%(\{([^\}]+)\}|[0-9a-zA-Z_]+|%|\()(.*?)$/) { + while ($line =~ /^(.*?)%(\{([^\}]+)\}|[\?\!]*[0-9a-zA-Z_]+|%|\()(.*?)$/) { if ($tries++ > 1000) { $line = 'MACRO'; last; diff --git a/build b/build index 05f91a7..5569bd9 100755 --- a/build +++ b/build @@ -212,6 +212,7 @@ if test "$0" = "/.build/build" ; then swapon -v "$XENSWAP" || exit 1 fi set "/.build-srcdir/$SPECFILE" + HOST="$MYHOSTNAME" fi while test -n "$1"; do @@ -479,6 +480,7 @@ fi # # say hello # +test -z "$HOST" && HOST=`hostname` echo $HOST started \"build $SPECFILES\" at `date`. echo test -n "$REASON" && echo "$REASON" @@ -567,7 +569,13 @@ for SPECFILE in $SPECFILES ; do echo "CREATE_BASELIBS='$CREATE_BASELIBS'" >> $BUILD_ROOT/.build/build.data echo "REASON='${REASON//\'/$Q}'" >> $BUILD_ROOT/.build/build.data test -n "$XENSWAP" && echo "XENSWAP='/dev/hda2'" >> $BUILD_ROOT/.build/build.data - PERSONALITY=`perl -e 'print syscall(135, 0)."\n"'` + PERSONALITY_SYSCALL= + PERSONALITY=0 + case `perl -V:archname` in + *x86_64*) PERSONALITY_SYSCALL=135 ;; + *i?86*) PERSONALITY_SYSCALL=136 ;; + esac + test -n "$PERSONALITY_SYSCALL" && PERSONALITY=`perl -e 'print syscall('$PERSONALITY_SYSCALL', 0)."\n"'` echo "PERSONALITY='$PERSONALITY'" >> $BUILD_ROOT/.build/build.data echo "MYHOSTNAME='`hostname`'" >> $BUILD_ROOT/.build/build.data umount $BUILD_ROOT @@ -584,7 +592,7 @@ for SPECFILE in $SPECFILES ; do XENID="${XENID##*/}" if test "$PERSONALITY" != 0 ; then # have to switch back to PER_LINUX to make xm work - perl -e 'syscall(135, 0); exec(@ARGV) || die("$ARGV[0]: $!\n")' xm create -c $BUILD_DIR/xen.conf name="build:$XENID" $XENMEMORY $XMROOT $XMSWAP extra="init=/.build/build panic=1" + perl -e 'syscall('$PERSONALITY_SYSCALL', 0); exec(@ARGV) || die("$ARGV[0]: $!\n")' xm create -c $BUILD_DIR/xen.conf name="build:$XENID" $XENMEMORY $XMROOT $XMSWAP extra="init=/.build/build panic=1" else xm create -c $BUILD_DIR/xen.conf name="build:$XENID" $XENMEMORY $XMROOT $XMSWAP extra="init=/.build/build panic=1" fi @@ -632,10 +640,12 @@ for SPECFILE in $SPECFILES ; do # check if we want to build with the abuild user # BUILD_USER=root - test -n "$NOROOTFORBUILD" && BUILD_USER=abuild - if egrep '^#[ ]*norootforbuild[ ]*$' >/dev/null <$SPECFILE; then - BUILD_USER=abuild + if test "$BUILD_USER" = abuild ; then + egrep '^#[ ]*needsrootforbuild[ ]*$' >/dev/null <$SPECFILE && BUILD_USER=root + else + egrep '^#[ ]*norootforbuild[ ]*$' >/dev/null <$SPECFILE && BUILD_USER=abuild fi + test -n "$NOROOTFORBUILD" && BUILD_USER=abuild if test $BUILD_USER = abuild ; then if ! egrep '^abuild:' >/dev/null <$BUILD_ROOT/etc/passwd ; then echo 'abuild::99:99:Autobuild:/home/abuild:/bin/bash' >>$BUILD_ROOT/etc/passwd @@ -643,6 +653,7 @@ for SPECFILE in $SPECFILES ; do mkdir -p $BUILD_ROOT/home/abuild chown 99:99 $BUILD_ROOT/home/abuild fi + sed -e "s@^root::@root:*:@" < $BUILD_ROOT/etc/shadow > $BUILD_ROOT/etc/shadow.t && mv $BUILD_ROOT/etc/shadow.t $BUILD_ROOT/etc/shadow else if egrep '^abuild:' >/dev/null <$BUILD_ROOT/etc/passwd ; then egrep -v '^abuild:' <$BUILD_ROOT/etc/passwd >$BUILD_ROOT/etc/passwd.new diff --git a/changelog2spec b/changelog2spec index 88cc461..60dac7b 100755 --- a/changelog2spec +++ b/changelog2spec @@ -35,6 +35,12 @@ if (@ARGV == 2 && $ARGV[0] eq '--spec') { my $ok; my $zone; +my $test; +if ($ARGV[0] eq '--test') { + $test = 1; + shift @ARGV; +} +my $lastt; while (<>) { chomp; next if (/^--------------/); @@ -69,7 +75,13 @@ while (<>) { $tdt = str2time("$year-1-1"); } $tdt += 12 * 3600 unless $dt =~ /\d:\d/; # 12:00 if not specified - my @gm = gmtime($tdt + ($zone || 0)); + $tdt += ($zone || 0); + if (defined($lastt) && $lastt < $tdt) { + die("changes file not incremental: $_\n") if $test; + warn("changes file not incremental: $_\n"); + } + $lastt = $tdt; + my @gm = gmtime($tdt); printf("* %s %s %2d %4d %s\n", $wday[$gm[6]], $mon[$gm[4]], $gm[3], $gm[5] + 1900, $who); $ok = 1; next; diff --git a/configs/sles10.conf b/configs/sles10.conf index 8783ac9..a4a1b3e 100644 --- a/configs/sles10.conf +++ b/configs/sles10.conf @@ -26,6 +26,7 @@ Prefer: unixODBC libsoup glitz java-1_4_2-sun gnome-panel Prefer: desktop-data-SuSE gnome2-SuSE mono-nunit gecko-sharp2 Prefer: apache2-prefork openmotif-libs ghostscript-mini gtk-sharp Prefer: glib-sharp libzypp-zmd-backend mDNSResponder +Prefer: novell-NLDAPsdk zaptel-kmp-default Prefer: gnome-sharp2:art-sharp2 gnome-sharp:art-sharp Prefer: ifolder3:gnome-sharp2 ifolder3:gconf-sharp2 @@ -34,6 +35,7 @@ Prefer: gconf-sharp2:glade-sharp2 gconf-sharp:glade-sharp Prefer: tomboy:gconf-sharp tomboy:gnome-sharp Prefer: zmd:libzypp-zmd-backend Prefer: yast2-packagemanager-devel:yast2-packagemanager +Prefer: glitz-32bit:Mesa-32bit Prefer: -libgcc-mainline -libstdc++-mainline -gcc-mainline-c++ Prefer: -libgcj-mainline -viewperf -compat -compat-openssl097g diff --git a/init_buildsystem b/init_buildsystem index 34ec4d4..add042e 100755 --- a/init_buildsystem +++ b/init_buildsystem @@ -338,8 +338,10 @@ else test "$PACKAGES_TO_PREINSTALL" = "${PACKAGES_TO_PREINSTALL/util-linux}" && PACKAGES_TO_PREINSTALL="$PACKAGES_TO_PREINSTALL util-linux" test "$PACKAGES_TO_PREINSTALL" = "${PACKAGES_TO_PREINSTALL/perl}" && PACKAGES_TO_PREINSTALL="$PACKAGES_TO_PREINSTALL perl" test "$PACKAGES_TO_PREINSTALL" = "${PACKAGES_TO_PREINSTALL/libvolume_id}" -a "$PACKAGES_TO_INSTALL" != "${PACKAGES_TO_INSTALL/libvolume_id}" && PACKAGES_TO_PREINSTALL="$PACKAGES_TO_PREINSTALL libvolume_id" + test "$PACKAGES_TO_PREINSTALL" = "${PACKAGES_TO_PREINSTALL/device-mapper}" -a "$PACKAGES_TO_INSTALL" != "${PACKAGES_TO_INSTALL/device-mapper}" && PACKAGES_TO_PREINSTALL="$PACKAGES_TO_PREINSTALL device-mapper" test $PSUF = deb -a "$PACKAGES_TO_PREINSTALL" = "${PACKAGES_TO_PREINSTALL/binutils}" && PACKAGES_TO_PREINSTALL="$PACKAGES_TO_PREINSTALL binutils" test $PSUF = deb -a "$PACKAGES_TO_PREINSTALL" = "${PACKAGES_TO_PREINSTALL/mount}" && PACKAGES_TO_PREINSTALL="$PACKAGES_TO_PREINSTALL mount" + test "$PACKAGES_TO_PREINSTALL" = "${PACKAGES_TO_PREINSTALL/mount}" -a "$PACKAGES_TO_INSTALL" != "${PACKAGES_TO_INSTALL/ mount }" && PACKAGES_TO_PREINSTALL="$PACKAGES_TO_PREINSTALL mount" fi fi @@ -355,11 +357,12 @@ if test ! -f $BUILD_ROOT/var/lib/rpm/packages.rpm -a ! -f $BUILD_ROOT/var/lib/rp if test $PSUF = deb ; then mkdir -p $BUILD_ROOT/var/lib/dpkg mkdir -p $BUILD_ROOT/var/log - mkdir -p $BUILD_ROOT/etc + mkdir -p $BUILD_ROOT/etc/default :> $BUILD_ROOT/var/lib/dpkg/status :> $BUILD_ROOT/var/lib/dpkg/available :> $BUILD_ROOT/var/log/dpkg.log :> $BUILD_ROOT/etc/ld.so.conf + :> $BUILD_ROOT/etc/default/rcS fi for PKG in $PACKAGES_TO_RUNSCRIPTS ; do : > $BUILD_ROOT/.init_b_cache/scripts/$PKG.run @@ -368,6 +371,7 @@ if test ! -f $BUILD_ROOT/var/lib/rpm/packages.rpm -a ! -f $BUILD_ROOT/var/lib/rp preinstall ${PKG##*/} done test -c $BUILD_ROOT/dev/null || create_devs + test -e $BUILD_ROOT/etc/fstab || touch $BUILD_ROOT/etc/fstab test -e $BUILD_ROOT/etc/ld.so.conf || cp $BUILD_ROOT/etc/ld.so.conf.in $BUILD_ROOT/etc/ld.so.conf if test -z "$PREPARE_XEN" ; then preinstall '' true @@ -378,15 +382,22 @@ fi if test -n "$PREPARE_XEN" ; then mkdir -p $BUILD_ROOT/.build - echo "PACKAGES_TO_INSTALL='${PACKAGES_TO_INSTALL//\'/\'\\\'\'}'" > $BUILD_ROOT/.build/init_buildsystem.data - echo "PACKAGES_TO_RUNSCRIPTS='${PACKAGES_TO_RUNSCRIPTS//\'/\'\\\'\'}'" >> $BUILD_ROOT/.build/init_buildsystem.data - echo "PSUF='$PSUF'" >> $BUILD_ROOT/.build/init_buildsystem.data echo "copying packages..." for PKG in $PACKAGES_TO_INSTALL ; do rm -f $BUILD_ROOT/.init_b_cache/$PKG.$PSUF cp $BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF $BUILD_ROOT/.init_b_cache/$PKG.$PSUF || cleanup_and_exit 1 ln -s -f ../$PKG.$PSUF $BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF done + # alreadyinstalled check will not work, but we have to live with + # that... + echo -n 'reordering...' + REORDER_MISSED= + PACKAGES_TO_INSTALL=`reorder $PACKAGES_TO_INSTALL` + echo 'done' + test -n "$REORDER_MISSED" && echo "WARNING: reorder missed$REORDER_MISSED" + echo "PACKAGES_TO_INSTALL='${PACKAGES_TO_INSTALL//\'/\'\\\'\'}'" > $BUILD_ROOT/.build/init_buildsystem.data + echo "PACKAGES_TO_RUNSCRIPTS='${PACKAGES_TO_RUNSCRIPTS//\'/\'\\\'\'}'" >> $BUILD_ROOT/.build/init_buildsystem.data + echo "PSUF='$PSUF'" >> $BUILD_ROOT/.build/init_buildsystem.data rm -f $BUILD_IS_RUNNING exit 0 fi @@ -408,14 +419,16 @@ if test -f $BUILD_ROOT/var/lib/rpm/packages.rpm -o -f $BUILD_ROOT/var/lib/rpm/Pa fi # -# reorder packages +# reorder packages (already done in XEN continuation) # -echo -n 'reordering...' -REORDER_MISSED= -PACKAGES_TO_INSTALL_FIRST=`reorder $PACKAGES_TO_INSTALL_FIRST` -PACKAGES_TO_INSTALL=`reorder $PACKAGES_TO_INSTALL` -echo 'done' -test -n "$REORDER_MISSED" && echo "WARNING: reorder missed$REORDER_MISSED" +if ! test -e $BUILD_ROOT/.build/init_buildsystem.data ; then + echo -n 'reordering...' + REORDER_MISSED= + PACKAGES_TO_INSTALL_FIRST=`reorder $PACKAGES_TO_INSTALL_FIRST` + PACKAGES_TO_INSTALL=`reorder $PACKAGES_TO_INSTALL` + echo 'done' + test -n "$REORDER_MISSED" && echo "WARNING: reorder missed$REORDER_MISSED" +fi # # delete all packages we don't want @@ -633,6 +646,15 @@ if test -e $BUILD_ROOT/usr/share/zoneinfo/UTC ; then chroot $BUILD_ROOT zic -l UTC fi +HOST=`hostname` +if ! grep -F "127.0.0.1 $HOST" $BUILD_ROOT/etc/hosts ; then + # this makes a reverse lookup on 127.0.0.1 return the host name, + # which is bad, but 127.0.0.2 does not work on all unix systems + echo "127.0.0.1 $HOST" > $BUILD_ROOT/etc/hosts.new + test -f $BUILD_ROOT/etc/hosts && cat $BUILD_ROOT/etc/hosts >> $BUILD_ROOT/etc/hosts.new + mv $BUILD_ROOT/etc/hosts.new $BUILD_ROOT/etc/hosts +fi + if test -x $BUILD_ROOT/bin/rpm -a ! -f $BUILD_ROOT/var/lib/rpm/packages.rpm -a ! -f $BUILD_ROOT/var/lib/rpm/Packages ; then echo "initializing rpm db..." chroot $BUILD_ROOT rpm --initdb || cleanup_and_exit 1 -- 2.7.4