- add release workaround for kernel folks
authorMichael Schröder <mls@suse.de>
Wed, 14 May 2008 18:13:15 +0000 (18:13 +0000)
committerMichael Schröder <mls@suse.de>
Wed, 14 May 2008 18:13:15 +0000 (18:13 +0000)
- support --debug

build
getoptflags
substitutedeps

diff --git a/build b/build
index 3038162..97d8921 100755 (executable)
--- a/build
+++ b/build
@@ -52,6 +52,7 @@ NOROOTFORBUILD=
 LOGFILE=
 KILL=
 CHANGELOG=
+BUILD_DEBUG=
 
 export PATH=$BUILD_DIR:$PATH
 
@@ -142,6 +143,9 @@ Known Parameters:
   --icecream N
               use N parallel build jobs with icecream
 
+  --debug
+              enable creation of a debuginfo package
+
 Remember to have fun!
 
 [*] Maximum RPM: http://www.rpm.org/max-rpm/
@@ -625,6 +629,9 @@ while test -n "$1"; do
       --ccache)
         ccache=1
       ;;
+      --debug)
+        BUILD_DEBUG=1
+      ;;
       ----noarg)
         echo "$ARG does not take an argument"
         cleanup_and_exit
@@ -1020,9 +1027,20 @@ for SPECFILE in "${SPECFILES[@]}" ; do
        substitutedeps $RELEASE --dist "$BUILD_DIST" --archpath "$BUILD_ARCH" --configdir "$BUILD_DIR/configs" $CHANGELOGARGS "$BUILD_ROOT$TOPDIR/SOURCES/$SPECFILE" "$BUILD_ROOT/.spec.new" || cleanup_and_exit 1
        # extract macros from configuration
        getmacros --dist "$BUILD_DIST" --archpath "$BUILD_ARCH" --configdir "$BUILD_DIR/configs" > $BUILD_ROOT/root/.rpmmacros
+       if test -n "$BUILD_DEBUG" ; then
+           echo '
+%prep %?_suse_insert_debug_package%%prep
+%package %?_suse_insert_debug_package%%package
+%suse_insert_debug_package \
+  %global _suse_insert_debug_package \\\
+    %%undefine _suse_insert_debug_package \\\
+    %%debug_package
+
+' >> $BUILD_ROOT/root/.rpmmacros
+       fi
        test $BUILD_USER = abuild && cp -p $BUILD_ROOT/root/.rpmmacros $BUILD_ROOT/home/abuild/.rpmmacros
        # extract optflags from configuration
-       getoptflags --dist "$BUILD_DIST" --configdir "$BUILD_DIR/configs" --archpath "$BUILD_ARCH" > $BUILD_ROOT/root/.rpmrc
+       getoptflags --dist "$BUILD_DIST" --configdir "$BUILD_DIR/configs" --archpath "$BUILD_ARCH" ${BUILD_DEBUG:+--debug} > $BUILD_ROOT/root/.rpmrc
        test $BUILD_USER = abuild && cp -p $BUILD_ROOT/root/.rpmrc $BUILD_ROOT/home/abuild/.rpmrc
     fi
     if test -f $BUILD_ROOT/.spec.new ; then
@@ -1087,6 +1105,10 @@ for SPECFILE in "${SPECFILES[@]}" ; do
                rpmbopts[${#rpmbopts[@]}]='--eval'
                rpmbopts[${#rpmbopts[@]}]="%define jobs $BUILD_JOBS"
        fi
+       if [ -n "$BUILD_DEBUG" ]; then
+               rpmbopts[${#rpmbopts[@]}]='--eval'
+               rpmbopts[${#rpmbopts[@]}]="%suse_insert_debug_package"
+       fi
        rpmbuild=rpmbuild
 
        test -x $BUILD_ROOT/usr/lib/rpm/rpmi || rpmbuild=rpm
index 69f134a..8031bf9 100755 (executable)
@@ -8,7 +8,7 @@ use strict;
 
 use Build;
 
-my ($dist, $archs, $configdir);
+my ($dist, $archs, $configdir, $debug);
 
 while (@ARGV)  {
   if ($ARGV[0] eq '--dist') {
@@ -26,6 +26,11 @@ while (@ARGV)  {
     $configdir = shift @ARGV;
     next;
   }
+  if ($ARGV[0] eq '--debug') {
+    shift @ARGV;
+    $debug = 1;
+    next;
+  }
   last;
 }
 
@@ -35,6 +40,7 @@ my $cf = Build::read_config_dist($dist, $archs, $configdir);
 exit 0 unless $cf->{'optflags'};
 my $all = $cf->{'optflags'}->{'*'};
 $all = defined($all) && $all ne '' ? " $all" : '';
+$all .= " -g" if $debug;
 for (sort keys %{$cf->{'optflags'}}) {
   next if $_ eq '*';
   print "optflags: $_ $cf->{'optflags'}->{$_}$all\n";
index 426ae7d..93d6153 100755 (executable)
@@ -80,7 +80,13 @@ for my $l (@$xspec) {
     next;
   }
 
-  $l =~ s/^(Release:\s*).*/$1$release/i if $release;
+  if ($release) {
+    if ($l =~ /^Release:/i) {
+      if (!($l =~ s/<RELEASE>/$release/g)) {
+       $l =~ s/^(Release:\s*).*/$1$release/i;
+      }
+    }
+  }
 
   if (!$used || ($l !~ /^(?:Build)?Requires:/i)) {
     print F "$l\n";