- add --kill
authorMichael Schröder <mls@suse.de>
Tue, 5 Dec 2006 03:18:56 +0000 (03:18 +0000)
committerMichael Schröder <mls@suse.de>
Tue, 5 Dec 2006 03:18:56 +0000 (03:18 +0000)
- update 10.2 config
- extend spec/dsc parser

Build.pm
build
configs/sl10.1.conf
configs/sl10.2.conf
configs/sles10.conf
expanddeps

index be3db56..d2eeaf7 100644 (file)
--- a/Build.pm
+++ b/Build.pm
@@ -19,7 +19,7 @@ sub unify {
 
 sub read_config {
   my ($arch, $cfile) = @_;
-  return undef unless !defined($cfile) || -e $cfile;
+  return undef unless !defined($cfile) || ref($cfile) || -e $cfile;
   my @macros = split("\n", $std_macros);
   push @macros, "%define _target_cpu $arch";
   push @macros, "%define _target_os linux";
@@ -34,11 +34,12 @@ sub read_config {
   $config->{'ignore'} = [];
   $config->{'conflict'} = [];
   $config->{'substitute'} = {};
+  $config->{'optflags'} = {};
   my $inmacro = 0;
   for my $l (@spec) {
     if ($inmacro) {
       my $m = ref($l) ? $l->[0] : $l;
-      $m =~ s/^%/%define /;
+      $m =~ s/^%/%define / unless @macros && $macros[-1] =~ /\\$/;
       push @macros, $m;
       next;
     }
@@ -133,7 +134,7 @@ sub get_build {
   @deps = grep {!$ndeps{"-$_"}} @deps;
   @deps = do_subst($config, @deps);
   @deps = grep {!$ndeps{"-$_"}} @deps;
-  @deps = expand($config, @deps);
+  @deps = expand($config, @deps, @ndeps);
   return @deps;
 }
 
@@ -259,6 +260,7 @@ sub expand {
     my @error = ();
     my @uerror = ();
     my @usolve = ();
+    my @rerror = ();
     for my $p (splice @p) {
       for my $r (@{$requires->{$p} || [$p]}) {
        next if $ignore->{"$p:$r"} || $xignore{"$p:$r"};
@@ -270,10 +272,11 @@ sub expand {
        @q = grep {!$aconflicts{$_}} @q;
        if (!@q) {
          if ($r eq $p) {
-           return undef, "nothing provides $r";
+           push @rerror, "nothing provides $r";
          } else {
-           return undef, "nothing provides $r needed by $p";
+           push @rerror, "nothing provides $r needed by $p";
          }
+         next;
        }
        if (@q > 1 && grep {$conflicts->{$_}} @q) {
          # delay this one as some conflict later on might
@@ -317,6 +320,9 @@ sub expand {
        @error = ();
       }
     }
+    if (@rerror) {
+      return undef, @rerror;
+    }
     if (!$didsomething && @error) {
       return undef, @error;
     }
@@ -457,14 +463,17 @@ sub expr {
 }
 
 sub read_spec {
-  my ($config, $specfile, $xspec) = @_;
+  my ($config, $specfile, $xspec, $ifdeps) = @_;
 
   my $packname;
   my $packvers;
+  my $packrel;
+  my $exclarch;
   my @subpacks;
   my @packdeps;
   my $hasnfb;
   my %macros;
+  my $ret = {};
 
   my $specdata;
   local *SPEC;
@@ -474,16 +483,19 @@ sub read_spec {
     $specdata = [ @$specfile ];
   } elsif (!open(SPEC, '<', $specfile)) {
     warn("$specfile: $!\n");
-    return (undef, "open: $!", undef);
+    $ret->{'error'} = "open $specfile: $!";
+    return $ret;
   }
   my @macros = @{$config->{'macros'}};
   my $skip = 0;
   my $main_preamble = 1;
   my $inspec = 0;
+  my $hasif = 0;
   while (1) {
     my $line;
     if (@macros) {
       $line = shift @macros;
+      $hasif = 0 unless @macros;
     } elsif ($specdata) {
       $inspec = 1;
       last unless @$specdata;
@@ -514,7 +526,7 @@ sub read_spec {
        $expandedline .= $1;
        $line = $4;
        my $macname = defined($3) ? $3 : $2;
-        my $macorig = $2;
+       my $macorig = $2;
        my $mactest = 0;
        if ($macname =~ /^\!\?/ || $macname =~ /^\?\!/) {
          $mactest = -1;
@@ -522,6 +534,7 @@ sub read_spec {
          $mactest = 1;
        }
        $macname =~ s/^[\!\?]+//;
+       $macname =~ s/ .*//;
        my $macalt;
        ($macname, $macalt) = split(':', $macname, 2);
        if ($macname eq '%') {
@@ -540,6 +553,26 @@ sub read_spec {
          }
          $line = '';
          last;
+       } elsif ($macname eq 'defined' || $macname eq 'with' || $macname eq 'undefined' || $macname eq 'without' || $macname eq 'bcond_with' || $macname eq 'bcond_without') {
+         my @args;
+         if ($macorig =~ /^\{(.*)\}$/) {
+           @args = split(' ', $1);
+           shift @args;
+         } else {
+           @args = split(' ', $line);
+           $line = '';
+         }
+         next unless @args;
+         if ($macname eq 'bcond_with') {
+           $macros{"with_$args[0]"} = 1 if exists $macros{"_with_$args[0]"};
+           next;
+         }
+         if ($macname eq 'bcond_without') {
+           $macros{"with_$args[0]"} = 1 unless exists $macros{"_without_$args[0]"};
+           next;
+         }
+         $args[0] = "with_$args[0]" if $macname eq 'with' || $macname eq 'without';
+         $line = ((exists($macros{$args[0]}) ? 1 : 0) ^ ($macname eq 'undefined' || $macname eq 'without' ? 1 : 0)).$line;
        } elsif (exists($macros{$macname})) {
          if (!defined($macros{$macname})) {
            $line = 'MACRO';
@@ -569,6 +602,7 @@ sub read_spec {
 
     if ($skip) {
       $xspec->[-1] = [ $xspec->[-1], undef ] if $xspec;
+      $$ifdeps = 1 if $ifdeps && ($line =~ /^(BuildRequires|BuildConflicts|\#\!BuildIgnore):\s*(\S.*)$/i);
       next;
     }
 
@@ -576,30 +610,35 @@ sub read_spec {
       my $arch = $macros{'_target_cpu'} || 'unknown';
       my @archs = grep {$_ eq $arch} split(/\s+/, $1);
       $skip = 1 if !@archs;
+      $hasif = 1;
       next;
     }
     if ($line =~ /^\s*%ifnarch(.*)$/) {
       my $arch = $macros{'_target_cpu'} || 'unknown';
       my @archs = grep {$_ eq $arch} split(/\s+/, $1);
       $skip = 1 if @archs;
+      $hasif = 1;
       next;
     }
     if ($line =~ /^\s*%ifos(.*)$/) {
       my $os = $macros{'_target_os'} || 'unknown';
       my @oss = grep {$_ eq $os} split(/\s+/, $1);
       $skip = 1 if !@oss;
+      $hasif = 1;
       next;
     }
     if ($line =~ /^\s*%ifnos(.*)$/) {
       my $os = $macros{'_target_os'} || 'unknown';
       my @oss = grep {$_ eq $os} split(/\s+/, $1);
       $skip = 1 if @oss;
+      $hasif = 1;
       next;
     }
     if ($line =~ /^\s*%if(.*)$/) {
       my ($v, $r) = expr($1);
       $v = 0 if $v && $v eq '\"\"';
       $skip = 1 unless $v;
+      $hasif = 1;
       next;
     }
     if ($main_preamble && ($line =~ /^Name:\s*(\S+)/i)) {
@@ -610,9 +649,17 @@ sub read_spec {
       $packvers = $1;
       $macros{'version'} = $packvers;
     }
+    if ($main_preamble && ($line =~ /^Release:\s*(\S+)/i)) {
+      $packrel = $1;
+      $macros{'release'} = $packrel;
+    }
+    if ($main_preamble && ($line =~ /^ExclusiveArch:\s*(\S+)/i)) {
+      $exclarch = $1;
+    }
     if ($main_preamble && ($line =~ /^(BuildRequires|BuildConflicts|\#\!BuildIgnore):\s*(\S.*)$/i)) {
       my $what = $1;
       my $deps = $2;
+      $$ifdeps = 1 if $ifdeps && $hasif;
       my @deps = $deps =~ /([^\s\[\(,]+)(\s+[<=>]+\s+[^\s\[,]+)?(\s+\[[^\]]+\])?[\s,]*/g;
       if (defined($hasnfb)) {
         next unless $xspec;
@@ -687,18 +734,33 @@ sub read_spec {
     }
   }
   unshift @subpacks, $packname;
-  return ($packname, $packvers, \@subpacks, @packdeps);
+  $ret->{'name'} = $packname;
+  $ret->{'version'} = $packvers;
+  $ret->{'release'} = $packrel if defined $packrel;
+  $ret->{'subpacks'} = \@subpacks;
+  $ret->{'exclarch'} = $exclarch if defined $exclarch;
+  $ret->{'deps'} = \@packdeps;
+  return $ret;
 }
 
 ###########################################################################
 
 sub read_dsc {
   my ($bconf, $fn) = @_;
-  local *F;
-  open(F, '<', $fn) || return ();
-  my @control = <F>;
-  close F;
-  chomp @control;
+  my $ret;
+  my @control;
+  if (ref($fn) eq 'ARRAY') {
+    @control = @$fn;
+  } else {
+    local *F;
+    if (!open(F, '<', $fn)) {
+      $ret->{'error'} = "$fn: $!";
+      return $ret;
+    }
+    @control = <F>;
+    close F;
+    chomp @control;
+  }
   splice(@control, 0, 3) if @control > 3 && $control[0] =~ /^-----BEGIN/;
   my $name;
   my $version;
@@ -729,7 +791,10 @@ sub read_dsc {
       push @deps, map {"-$_"} @d;
     }
   }
-  return ($name, $version, undef, @deps);
+  $ret->{'name'} = $name;
+  $ret->{'version'} = $version;
+  $ret->{'deps'} = \@deps;
+  return $ret;
 }
 
 ###########################################################################
diff --git a/build b/build
index c69b654..ab4dab4 100755 (executable)
--- a/build
+++ b/build
@@ -7,16 +7,15 @@
 #
 # (c) 1997-2006 SuSE GmbH Nuernberg, Germany
 
+test -z "$BUILD_DIR" && BUILD_DIR=/usr/lib/build
 test -z "$BUILD_ROOT" && BUILD_ROOT=/var/tmp/build-root
 test -z "$BUILD_RPMS" && BUILD_RPMS=/media/dvd/suse
 test -z "$BUILD_ARCH" && {
     BUILD_ARCH=`uname -m`
     test i686 = "$BUILD_ARCH" && BUILD_ARCH=i586
 }
-export BUILD_ARCH BUILD_ROOT BUILD_RPMS
+export BUILD_ARCH BUILD_ROOT BUILD_RPMS BUILD_DIR
 
-export BUILD_DIR=/usr/lib/build
-#export BUILD_DIR=/suse/mls/xenbuild
 export PATH=$BUILD_DIR:$PATH
 
 # This is for insserv
@@ -178,6 +177,7 @@ RELEASE=
 REASON=
 NOROOTFORBUILD=
 LOGFILE=
+KILL=
 
 if test "$0" = "/.build/build" ; then
     BUILD_ROOT=/
@@ -233,6 +233,9 @@ while test -n "$1"; do
       *-clean)
         CLEAN_BUILD=true
       ;;
+      *-kill)
+        KILL=true
+      ;;
       *-rpms)
         BUILD_RPMS="$ARG"
        if [ -z "$BUILD_RPMS" ] ; then
@@ -334,6 +337,26 @@ test -z "$LIST_STATE" -a "$UID" != 0 && {
     cleanup_and_exit 1
 }
 
+if test -n "$KILL" ; then
+    test -z "$SRCDIR" || usage
+    if test -z "$XENIMAGE" ; then
+       if ! $BUILD_DIR/killchroot -s 9 $BUILD_ROOT ; then
+           echo "could not kill build in $BUILD_ROOT"
+           exit 1
+       fi
+    else
+       XENID="${XENIMAGE%/root}"
+       XENID="${XENID##*/}"
+       if xm list "$XENID" >/dev/null 2>&1 ; then
+           if ! xm destroy "$XENID" ; then
+               echo "could not kill xen build $XENID"
+               exit 1
+           fi
+       fi
+    fi
+    exit 0
+fi
+
 case $BUILD_ARCH in
 i686) BUILD_ARCH="i686:i586:i486:i386" ;;
 i586) BUILD_ARCH="i586:i486:i386" ;;
index 14c5e7c..7bc5473 100644 (file)
@@ -185,7 +185,7 @@ Macros:
 %fillup_prereq fillup coreutils
 %suseconfig_fonts_prereq perl aaa_base
 %install_info_prereq info
-%suse_version 1001
+%suse_version 1010
 %sles_version 0
 %ul_version 0
 %do_profiling 1
index 11f7d10..9b0ded5 100644 (file)
@@ -1,15 +1,17 @@
 Preinstall: aaa_base acl attr bash bzip2 coreutils db diffutils
 Preinstall: filesystem fillup glibc grep insserv libacl libattr
-Preinstall: libgcc libnscd libxcrypt m4 ncurses pam
+Preinstall: libgcc41 libnscd libxcrypt m4 ncurses pam
 Preinstall: permissions popt pwdutils readline rpm sed tar zlib
 
-Required: autoconf automake binutils bzip2 db gcc gdbm gettext glibc
-Required: libtool ncurses perl rpm zlib
+Required: autoconf automake binutils bzip2 db gcc gcc41
+Required: gdbm gettext glibc libtool ncurses perl rpm zlib
 
-Support: bind-libs bind-utils bison cpio cpp cracklib cvs cyrus-sasl
+Support: audit-libs bind-libs
+Support: bind-utils bison cpio cpp cpp41 cracklib cvs cyrus-sasl
 Support: e2fsprogs file findutils flex gawk gdbm-devel gettext-devel
 Support: glibc-devel glibc-locale gpm groff gzip info klogd less
-Support: libcom_err libstdc++ libzio make man mktemp module-init-tools
+Support: libcom_err libltdl libmudflap41 libstdc++41 libzio
+Support: linux-kernel-headers make man mktemp module-init-tools
 Support: ncurses-devel net-tools netcfg openldap2-client openssl
 Support: pam-modules patch procinfo procps psmisc rcs strace sysvinit
 Support: tcpd texinfo timezone unzip util-linux vim zlib-devel
@@ -140,15 +142,17 @@ Ignore: gnome-panel:tomboy
 %ifnarch s390 s390x ppc ia64
 Substitute: java2-devel-packages java-1_4_2-sun-devel update-alternatives
 %else
- %ifnarch s390x
+ %ifnarch s390 ppc
 Substitute: java2-devel-packages java-1_4_2-ibm-devel update-alternatives
- %else
+ %endif
+ %ifarch s390x
 Substitute: java2-devel-packages java-1_4_2-ibm-devel xorg-x11-libs-32bit update-alternatives
  %endif
+ %ifarch ia64
+Substitute: java2-devel-packages java-1_5_0-bea-devel update-alternatives
+ %endif
 %endif
 
-Substitute: yast2-devel-packages docbook-xsl-stylesheets doxygen libxslt perl-XML-Writer popt-devel sgml-skel update-desktop-files yast2 yast2-devtools yast2-packagemanager-devel yast2-perl-bindings yast2-testsuite
-
 %ifarch x86_64 ppc64 s390x sparc64
 Substitute: glibc-devel-32bit glibc-devel-32bit glibc-32bit
 %else
@@ -186,7 +190,8 @@ Macros:
 %fillup_prereq fillup coreutils
 %suseconfig_fonts_prereq perl aaa_base
 %install_info_prereq info
-%suse_version 1001
+%kernel_module_package_buildreq kernel-source kernel-syms
+%suse_version 1020
 %sles_version 0
 %ul_version 0
 %do_profiling 1
index b40d719..8c285a5 100644 (file)
@@ -185,7 +185,7 @@ Macros:
 %fillup_prereq fillup coreutils
 %suseconfig_fonts_prereq perl aaa_base
 %install_info_prereq info
-%suse_version 1001
+%suse_version 1010
 %sles_version 10
 %ul_version 0
 %do_profiling 1
index b75712f..825429e 100755 (executable)
@@ -159,11 +159,16 @@ my ($packname, $packvers, $subpacks, @packdeps);
 $subpacks = [];
 
 if ($spec) {
+  my $d;
   if ($spec =~ /\.dsc$/) {
-    ($packname, $packvers, $subpacks, @packdeps) = Build::read_dsc($cf, $spec);
+    $d = Build::read_dsc($cf, $spec);
   } else {
-    ($packname, $packvers, $subpacks, @packdeps) = Build::read_spec($cf, $spec);
+    $d = Build::read_spec($cf, $spec);
   }
+  $packname = $d->{'name'};
+  $packvers = $d->{'version'};
+  $subpacks = $d->{'subpacks'};
+  @packdeps = @{$d->{'deps'} || []};
 }
 
 my %repo;