CrossBuild/Speedup (pre-)install hooks.
authorJan-Simon Möller <jsmoeller@linuxfoundation.org>
Sat, 24 Apr 2010 11:01:56 +0000 (13:01 +0200)
committerJan-Simon Möller <jsmoeller@linuxfoundation.org>
Sun, 2 May 2010 16:44:45 +0000 (18:44 +0200)
Introduction of:
* "CBpreinstall:"  in prjconf - add only if emulator is used
  as preinstall packages.
* "CBinstall:" in prjconf - add only if emulator is used to
  installed packages.

Signed-off-by: Jan-Simon Möller <jsmoeller@linuxfoundation.org>
Build.pm
expanddeps
init_buildsystem

index 6072d45..3809371 100644 (file)
--- a/Build.pm
+++ b/Build.pm
@@ -132,6 +132,8 @@ sub read_config {
   delete $config->{'save_expanded'};
   $config->{'preinstall'} = [];
   $config->{'vminstall'} = [];
+  $config->{'cbpreinstall'} = [];
+  $config->{'cbinstall'} = [];
   $config->{'runscripts'} = [];
   $config->{'required'} = [];
   $config->{'support'} = [];
@@ -165,7 +167,7 @@ sub read_config {
       }
       next;
     }
-    if ($l0 eq 'preinstall:' || $l0 eq 'vminstall:' || $l0 eq 'required:' || $l0 eq 'support:' || $l0 eq 'keep:' || $l0 eq 'prefer:' || $l0 eq 'ignore:' || $l0 eq 'conflict:' || $l0 eq 'runscripts:') {
+    if ($l0 eq 'preinstall:' || $l0 eq 'vminstall:' || $l0 eq 'cbpreinstall:' || $l0 eq 'cbinstall:' || $l0 eq 'required:' || $l0 eq 'support:' || $l0 eq 'keep:' || $l0 eq 'prefer:' || $l0 eq 'ignore:' || $l0 eq 'conflict:' || $l0 eq 'runscripts:') {
       my $t = substr($l0, 0, -1);
       for my $l (@l) {
        if ($l eq '!*') {
@@ -222,7 +224,7 @@ sub read_config {
       warn("unknown keyword in config: $l0\n");
     }
   }
-  for my $l (qw{preinstall vminstall required support keep runscripts repotype patterntype}) {
+  for my $l (qw{preinstall vminstall cbpreinstall cbinstall required support keep runscripts repotype patterntype}) {
     $config->{$l} = [ unify(@{$config->{$l}}) ];
   }
   for my $l (keys %{$config->{'substitute'}}) {
@@ -353,6 +355,16 @@ sub get_vminstalls {
   return @{$config->{'vminstall'}};
 }
 
+sub get_cbpreinstalls {
+  my ($config) = @_;
+  return @{$config->{'cbpreinstall'}};
+}
+
+sub get_cbinstalls {
+  my ($config) = @_;
+  return @{$config->{'cbinstall'}};
+}
+
 sub get_runscripts {
   my ($config) = @_;
   return @{$config->{'runscripts'}};
index 90ab6fe..722f2ce 100755 (executable)
@@ -181,6 +181,8 @@ sub print_rpmlist
   }
   print "preinstall: @{$cf->{'preinstall'} || []}\n";
   print "vminstall: @{$cf->{'vminstall'} || []}\n";
+  print "cbpreinstall: @{$cf->{'cbpreinstall'} || []}\n"; # preinstall if is_emulator_arch
+  print "cbinstall: @{$cf->{'cbinstall'} || []}\n";       # install if is_emulator_arch
   print "runscripts: @{$cf->{'runscripts'} || []}\n";
   print "dist: $dist\n" if defined $dist;
 }
index 7124726..2ed6e7b 100755 (executable)
@@ -493,6 +493,7 @@ else
        while read PKG SRC ; do
           test "$PKG" = "preinstall:" && continue
           test "$PKG" = "runscripts:" && continue
+          test "$PKG" = "cbpreinstall:" && continue
           test "$PKG" = "vminstall:" && continue
           test "$PKG" = "dist:" && continue
           test "$PKG" = "rpmid:" && continue
@@ -523,6 +524,8 @@ else
     PACKAGES_TO_PREINSTALL=
     PACKAGES_TO_RUNSCRIPTS=
     PACKAGES_TO_VMINSTALL=
+    PACKAGES_TO_CBPREINSTALL=
+    PACKAGES_TO_CBINSTALL=
     RUNSCRIPTS_SEEN=
     GUESSED_DIST=unknown
     mkdir -p $BUILD_ROOT/.init_b_cache/rpms
@@ -535,6 +538,20 @@ else
            PACKAGES_TO_VMINSTALL=$SRC
            continue
        fi
+       # these additional preinstall / install values are only set for 
+       # emulated "CrossBuild" setups - thus CB(pre)install
+       if test "$PKG" = "cbpreinstall:" ; then
+           if is_emulator_arch ; then
+               PACKAGES_TO_CBPREINSTALL=$SRC
+           fi
+           continue
+       fi
+       if test "$PKG" = "cbinstall:" ; then
+           if is_emulator_arch ; then
+               PACKAGES_TO_CBINSTALL=$SRC
+           fi
+           continue
+       fi
        if test "$PKG" = "runscripts:" ; then
            RUNSCRIPTS_SEEN=true
            PACKAGES_TO_RUNSCRIPTS=$SRC
@@ -565,6 +582,8 @@ else
        PACKAGES_TO_INSTALL="$PACKAGES_TO_INSTALL $PKG"
     done < $RPMLIST
 
+    test -n "$PACKAGES_TO_CBPREINSTALL" && echo "cbpreinstall: $PACKAGES_TO_CBPREINSTALL"
+    test -n "$PACKAGES_TO_CBINSTALL" && echo "cbinstall   : $PACKAGES_TO_CBINSTALL"
     # compatibility...
     test -z "$RUNSCRIPTS_SEEN" && PACKAGES_TO_RUNSCRIPTS="$PACKAGES_TO_PREINSTALL"
 
@@ -603,6 +622,10 @@ if test ! -f $BUILD_ROOT/var/lib/rpm/packages.rpm -a ! -f $BUILD_ROOT/var/lib/rp
            preinstall ${PKG##*/}
        done
     fi
+    # add cbpreinstall if cross HOST != TARGET
+    for PKG in $PACKAGES_TO_CBPREINSTALL ; do
+        preinstall ${PKG##*/}
+    done
     if [ -w /root ]; then
            test -c $BUILD_ROOT/dev/null || create_devs
     fi
@@ -708,7 +731,7 @@ for PKG in $BUILD_ROOT/.init_b_cache/alreadyinstalled/* ; do
     test "$PKG" = "*" && continue
     ln $BUILD_ROOT/.init_b_cache/alreadyinstalled/$PKG $BUILD_ROOT/.init_b_cache/todelete/$PKG
 done
-for PKG in $PACKAGES_TO_INSTALL_FIRST $PACKAGES_TO_INSTALL ; do
+for PKG in $PACKAGES_TO_INSTALL_FIRST $PACKAGES_TO_INSTALL $PACKAGES_TO_CBINSTALL ; do
     rm -f $BUILD_ROOT/.init_b_cache/todelete/$PKG
 done
 for PKG in $BUILD_ROOT/.init_b_cache/todelete/* ; do
@@ -722,7 +745,7 @@ rm -rf $BUILD_ROOT/.init_b_cache/todelete
 
 rm -rf $BUILD_ROOT/.init_b_cache/preinstalls
 mkdir -p $BUILD_ROOT/.init_b_cache/preinstalls
-for PKG in $PACKAGES_TO_PREINSTALL ; do
+for PKG in $PACKAGES_TO_PREINSTALL $PACKAGES_TO_CBPREINSTALL; do
     touch "$BUILD_ROOT/.init_b_cache/preinstalls/$PKG"
 done
 
@@ -736,7 +759,7 @@ RPMCHECKOPTS_HOST=
 test -x $BUILD_ROOT/usr/bin/rpmsign && RPMCHECKOPTS="--nodigest --nosignature"
 test -x /usr/bin/rpmsign && RPMCHECKOPTS_HOST="--nodigest --nosignature"
 
-for PKG in $PACKAGES_TO_INSTALL_FIRST RUN_LDCONFIG $PACKAGES_TO_INSTALL ; do
+for PKG in $PACKAGES_TO_INSTALL_FIRST RUN_LDCONFIG $PACKAGES_TO_INSTALL $PACKAGES_TO_CBINSTALL; do
 
     case $PKG in
       RUN_LDCONFIG)
@@ -801,7 +824,10 @@ for PKG in $PACKAGES_TO_INSTALL_FIRST RUN_LDCONFIG $PACKAGES_TO_INSTALL ; do
        fi
        if test -e "$BUILD_ROOT/.init_b_cache/preinstalls/$PKG" ; then
            preinstall "$PKG"
-           test rpm = "$PKG" && chroot $BUILD_ROOT rpm --rebuilddb
+           # call for rpm-4.x and not rpm-devel
+           test -z "${PKG##rpm-[0-9]*}" && chroot $BUILD_ROOT rpm --rebuilddb
+           # also exec for exchanged rpm !  naming is rpm-x86-<target>-<ver>
+           test -z "${PKG##rpm-x86-*[0-9]*}" && chroot $BUILD_ROOT rpm --rebuilddb
        fi
     fi
     export ADDITIONAL_PARAMS=