Log In
Log In
Places
All Projects
Status Monitor
Collapse sidebar
obs:server:fedora:2.6
build
_service:gitpkg:0001-Add-support-for-using-Scra...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:gitpkg:0001-Add-support-for-using-Scratchbox2-together-with-OBS-.patch of Package build
From aae669ef9dfaeaf14a0eddc01d793589a3161f7c Mon Sep 17 00:00:00 2001 From: Carsten Munk <carsten.munk@gmail.com> Date: Thu, 9 Feb 2012 13:37:25 +0100 Subject: [PATCH] Add support for using Scratchbox2 together with OBS as an alternative cross compile approach Signed-off-by: Carsten Munk <carsten.munk@gmail.com> --- Build.pm | 15 +++- Makefile | 2 + build | 124 +++++++++++++++---------- build-pkg | 6 +- build-pkg-arch | 18 ++-- build-pkg-deb | 56 ++++++------ build-pkg-rpm | 74 +++++++-------- build-recipe-dsc | 6 +- build-recipe-spec | 62 ++++++------- build-vm | 14 +-- build-vm-sb2 | 48 ++++++++++ common_functions | 153 +++++++++++++++++++++++++++++++ expanddeps | 1 + getsb2flags | 41 +++++++++ init_buildsystem | 263 +++++++++++++++++++++++++++++++----------------------- initscript_sb2 | 23 +++++ 16 files changed, 627 insertions(+), 279 deletions(-) create mode 100644 build-vm-sb2 create mode 100644 getsb2flags create mode 100644 initscript_sb2 diff --git a/Build.pm b/Build.pm index b75c0fa..30a3428 100644 --- a/Build.pm +++ b/Build.pm @@ -215,6 +215,7 @@ sub read_config { $config->{'vminstall'} = []; $config->{'cbpreinstall'} = []; $config->{'cbinstall'} = []; + $config->{'sb2install'} = []; $config->{'runscripts'} = []; $config->{'required'} = []; $config->{'support'} = []; @@ -225,6 +226,7 @@ sub read_config { $config->{'substitute'} = {}; $config->{'substitute_vers'} = {}; $config->{'optflags'} = {}; + $config->{'sb2flags'} = {}; $config->{'order'} = {}; $config->{'exportfilter'} = {}; $config->{'publishfilter'} = []; @@ -253,7 +255,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:' || $l0 eq 'expandflags:' || $l0 eq 'buildflags:') { + if ($l0 eq 'preinstall:' || $l0 eq 'vminstall:' || $l0 eq 'sb2install:' || $l0 eq 'required:' || $l0 eq 'support:' || $l0 eq 'keep:' || $l0 eq 'prefer:' || $l0 eq 'ignore:' || $l0 eq 'conflict:' || $l0 eq 'runscripts:' || $l0 eq 'expandflags:' || $l0 eq 'buildflags:') { my $t = substr($l0, 0, -1); for my $l (@l) { if ($l eq '!*') { @@ -294,6 +296,10 @@ sub read_config { next unless @l; $ll = shift @l; $config->{'optflags'}->{$ll} = join(' ', @l); + } elsif ($l0 eq 'sb2flags:') { + next unless @l; + $ll = shift @l; + $config->{'sb2flags'}->{$ll} = join(' ', @l); } elsif ($l0 eq 'order:') { for my $l (@l) { if ($l eq '!*') { @@ -340,7 +346,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 sb2install required support keep runscripts repotype patterntype}) { $config->{$l} = [ unify(@{$config->{$l}}) ]; } for my $l (keys %{$config->{'substitute'}}) { @@ -651,6 +657,11 @@ sub get_vminstalls { return @{$config->{'vminstall'}}; } +sub get_sb2installs { + my ($config) = @_; + return @{$config->{'sb2install'}}; +} + sub get_runscripts { my ($config) = @_; return @{$config->{'runscripts'}}; diff --git a/Makefile b/Makefile index 1946086..876c93d 100644 --- a/Makefile +++ b/Makefile @@ -38,9 +38,11 @@ install: extractbuild \ getbinaryid \ killchroot \ + getsb2flags \ queryconfig \ common_functions \ init_buildsystem \ + initscript_sb2 \ substitutedeps \ debtransform \ debtransformbz2 \ diff --git a/build b/build index bd93201..629ff4a 100755 --- a/build +++ b/build @@ -35,7 +35,7 @@ test -z "$BUILD_DIR" && BUILD_DIR=/usr/lib/build test -z "$BUILD_ROOT" && BUILD_ROOT=/var/tmp/build-root test -z "$CONFIG_DIR" && CONFIG_DIR="$BUILD_DIR/configs" -export BUILD_ARCH BUILD_HOST_ARCH BUILD_ROOT BUILD_RPMS BUILD_DIR BUILD_DEBUG +export BUILD_ARCH BUILD_HOST_ARCH BUILD_TARGET BUILD_ROOT BUILD_SB2FLAGS BUILD_RPMS BUILD_DIR BUILD_DEBUG VM_TYPE export BUILD_DIST icecream=0 @@ -364,6 +364,7 @@ cleanup_and_exit () { if test -n "$RUNNING_IN_VM" ; then echo "$1" > /.build/_exitcode test -n "$browner" && chown "$browner" $BUILD_ROOT + cleanup_sb2 vm_shutdown "$1" else umount -n $BUILD_ROOT/proc/sys/fs/binfmt_misc 2> /dev/null || true @@ -435,7 +436,7 @@ setupicecream() { return 0 fi - if ! chroot "$BUILD_ROOT" rpm -q icecream >/dev/null 2>/dev/null; then + if ! enter_target needroot rpm -q icecream >/dev/null 2>/dev/null; then echo "*** icecream package not installed ***" return 1 fi @@ -473,7 +474,7 @@ setupicecream() { return 1 fi echo "creating new env in '$icecreamdir'" - chroot $BUILD_ROOT bash -c "cd $icecreamdir; $createenv" || cleanup_and_exit 1 + enter_target needroot bash -c "cd $icecreamdir; $createenv" || cleanup_and_exit 1 icecc_vers=(`shopt -s nullglob; echo $BUILD_ROOT/$icecreamdir/*.tar.{bz2,gz}`) icecc_vers=${icecc_vers//$BUILD_ROOT/} echo "created icecream environment $icecc_vers" @@ -523,7 +524,7 @@ create_baselibs() { if test -e $BUILD_ROOT$TOPDIR/SOURCES/baselibs.conf ; then BASELIBS_CFG="-c $TOPDIR/SOURCES/baselibs.conf" fi - if test -e $BUILD_ROOT/usr/lib/build/baselibs_global.conf; then + if test -e $BUILD_TARGET/usr/lib/build/baselibs_global.conf; then BASELIBS_GLOBAL="-c /usr/lib/build/baselibs_global.conf" fi pkgs=($RPMS) @@ -538,7 +539,7 @@ create_baselibs() { # $BUILD_DIR is set to /.build when using a vm. So we need to # hardcode /usr/lib/build instead of $BUILD_DIR to prefer # mkbaselibs from the distro. - if test -f $BUILD_ROOT$mkbaselibs; then + if test -f $BUILD_TARGET$mkbaselibs; then if test -z "$BASELIBS_CFG" -a -e $BUILD_ROOT/usr/lib/build/baselibs.conf ; then BASELIBS_CFG="-c /usr/lib/build/baselibs.conf" fi @@ -550,28 +551,28 @@ create_baselibs() { # use external version whichone=" (external)" mkbaselibs="/.mkbaselibs/mkbaselibs" - rm -rf "$BUILD_ROOT/.mkbaselibs" - mkdir -p "$BUILD_ROOT/.mkbaselibs" - cp -f $BUILD_DIR/mkbaselibs $BUILD_ROOT/.mkbaselibs/ + rm -rf "$BUILD_TARGET/.mkbaselibs" + mkdir -p "$BUILD_TARGET/.mkbaselibs" + cp -f $BUILD_DIR/mkbaselibs $BUILD_TARGET/.mkbaselibs/ if test "$BUILDTYPE" == "dsc" ; then - cp -f $BUILD_DIR/baselibs_global-deb.conf $BUILD_ROOT/.mkbaselibs/baselibs_g.conf - cp -f $BUILD_ROOT$TOPDIR/SOURCES/baselibs-deb.conf $BUILD_ROOT/.mkbaselibs/baselibs-deb.conf + cp -f $BUILD_DIR/baselibs_global-deb.conf $BUILD_TARGET/.mkbaselibs/baselibs_g.conf + cp -f $BUILD_ROOT$TOPDIR/SOURCES/baselibs-deb.conf $BUILD_TARGET/.mkbaselibs/baselibs-deb.conf BASELIBS_CFG="-c /.mkbaselibs/baselibs-deb.conf" else - cp -f $BUILD_DIR/baselibs_global.conf $BUILD_ROOT/.mkbaselibs/baselibs_g.conf + cp -f $BUILD_DIR/baselibs_global.conf $BUILD_TARGET/.mkbaselibs/baselibs_g.conf if test -z "$BASELIBS_CFG" -a -e $BUILD_DIR/baselibs.conf; then - cp -f $BUILD_DIR/baselibs.conf $BUILD_ROOT/.mkbaselibs/baselibs.conf + cp -f $BUILD_DIR/baselibs.conf $BUILD_TARGET/.mkbaselibs/baselibs.conf BASELIBS_CFG="-c /.mkbaselibs/baselibs.conf" fi fi - if test -e $BUILD_ROOT/.mkbaselibs/baselibs_g.conf; then + if test -e $BUILD_TARGET/.mkbaselibs/baselibs_g.conf; then BASELIBS_GLOBAL="-c /.mkbaselibs/baselibs_g.conf" fi fi echo "... creating baselibs$whichone" while read line do - chroot $BUILD_ROOT su -c "$mkbaselibs $BASELIBS_GLOBAL $BASELIBS_CFG $line" - $BUILD_USER || cleanup_and_exit 1 + enter_target needuser $mkbaselibs $BASELIBS_GLOBAL $BASELIBS_CFG $line || cleanup_and_exit 1 done < <(IFS=$'\n'; echo "${pkgs[*]#$BUILD_ROOT}" | xargs -n 1024) rm -rf "$BUILD_ROOT/.mkbaselibs" } @@ -582,11 +583,11 @@ copy_oldpackages() { local dest test -z "$RUNNING_IN_VM" || return 0 if test -z "$old_packages" ; then - rm -rf "$BUILD_ROOT"/.build.oldpackages* + rm -rf "$BUILD_TARGET"/.build.oldpackages* return 0 fi for d in "${old_packages[@]}"; do - dest="$BUILD_ROOT/.build.oldpackages" + dest="$BUILD_TARGET/.build.oldpackages" test "$i" = 0 || dest="$dest$i" if test -d "$d" -a "$d" != "$dest" ; then rm -rf "$dest" @@ -638,8 +639,8 @@ mkdir_build_root() { copy_overlay() { if test -d "$OVERLAY"; then pushd $OVERLAY - echo "Copying overlay to BUILD_ROOT" - tar -cpf - . | (cd $BUILD_ROOT ; tar -xvf -) + echo "Copying overlay to BUILD_TARGET" + tar -cpf - . | (cd $BUILD_TARGET ; tar -xvf -) popd else echo "OVERLAY ($OVERLAY) is no directory - skipping" @@ -649,13 +650,13 @@ copy_overlay() { run_rsync() { if test -n "$RSYNCDEST" ; then if test -d "$RSYNCSRC" ; then - if ! test -d "$BUILD_ROOT/$RSYNCDEST" ; then - echo "ATTENTION! Creating missing target directory ($BUILD_ROOT/$RSYNCDEST)." - mkdir -p $BUILD_ROOT/$RSYNCDEST + if ! test -d "$BUILD_TARGET/$RSYNCDEST" ; then + echo "ATTENTION! Creating missing target directory ($BUILD_TARGET/$RSYNCDEST)." + mkdir -p $BUILD_TARGET/$RSYNCDEST fi echo "Running rsync ..." - rsync -av $RSYNCSRC/* $BUILD_ROOT/$RSYNCDEST/ - chown -R "$ABUILD_UID:$ABUILD_GID" "$BUILD_ROOT/$RSYNCDEST" + rsync -av $RSYNCSRC/* $BUILD_TARGET/$RSYNCDEST/ + chown -R "$ABUILD_UID:$ABUILD_GID" "$BUILD_TARGET/$RSYNCDEST" RSYNCDONE=true echo "... done" else @@ -917,6 +918,15 @@ while test -n "$1"; do esac done +set_build_arch + +BUILD_SB2FLAGS=`getsb2flags --dist "$BUILD_DIST" --configdir "$BUILD_DIR/configs" --archpath "$BUILD_ARCH"` + +if [ -n "$BUILD_SB2FLAGS" -a -z "$VM_TYPE" ]; then + echo "Cannot do SB2 with chroot, switching to vm type sb2" + VM_TYPE="sb2" +fi + if test -n "$KILL" ; then test -z "$SRCDIR" || usage if test -n "$VM_IMAGE" -a -n "$VM_SWAP" -a -n "$VM_TYPE"; then @@ -954,7 +964,18 @@ else repos=() fi -set_build_arch + +BUILD_TARGET=$BUILD_ROOT + +if [ -n "$BUILD_SB2FLAGS" ]; then + echo "Will build with SB2, flags: $BUILD_SB2FLAGS" + echo "Switching BUILD_TARGET to $BUILD_ROOT/target" + if test -z "$RUNNING_IN_VM"; then + BUILD_TARGET=$BUILD_ROOT/target + else + BUILD_TARGET=/target + fi +fi expand_recipe_directories @@ -980,6 +1001,10 @@ fi mkdir_build_root +if test "$BUILD_ROOT" != "$BUILD_TARGET" ; then + mkdir -p "$BUILD_TARGET" +fi + if test "$BUILD_ROOT" = / ; then browner="$(stat -c %u /)" fi @@ -1037,6 +1062,7 @@ test -z "$HOST" && HOST=`hostname` if test -z "$RUNNING_IN_VM" ; then echo Using BUILD_ROOT=$BUILD_ROOT + echo Using BUILD_TARGET=$BUILD_TARGET test -n "$BUILD_RPMS" && echo Using BUILD_RPMS=$BUILD_RPMS echo Using BUILD_ARCH=$BUILD_ARCH test -n "$VM_TYPE" && echo "Doing $VM_TYPE build${VM_IMAGE:+ in $VM_IMAGE}" @@ -1163,8 +1189,8 @@ for RECIPEFILE in "${RECIPEFILES[@]}" ; do # check if we want to build with the abuild user # BUILD_USER=abuild - if test -x $BUILD_ROOT/bin/rpm ; then - SUSE_VERSION=`chroot $BUILD_ROOT /bin/rpm --eval '%{?suse_version}' 2>/dev/null` + if test -x $BUILD_TARGET/bin/rpm ; then + SUSE_VERSION=`enter_target needroot /bin/rpm --eval '%{?suse_version}' 2>/dev/null` test -n "$SUSE_VERSION" -a "${SUSE_VERSION:-0}" -le 1020 && BUILD_USER=root fi if test "$BUILD_USER" = abuild ; then @@ -1182,44 +1208,44 @@ for RECIPEFILE in "${RECIPEFILES[@]}" ; do # fixup passwd/group if test $BUILD_USER = abuild ; then - if ! egrep '^abuild:' >/dev/null <$BUILD_ROOT/etc/passwd ; then - echo "abuild:x:${ABUILD_UID}:${ABUILD_GID}:Autobuild:/home/abuild:/bin/bash" >>$BUILD_ROOT/etc/passwd - echo 'abuild:*:::::::' >>$BUILD_ROOT/etc/shadow # This is needed on Mandriva 2009 - echo 'abuild:*::' >>$BUILD_ROOT/etc/gshadow # This is needed on Ubuntu - echo "abuild:x:${ABUILD_GID}:" >>$BUILD_ROOT/etc/group + if ! egrep '^abuild:' >/dev/null <$BUILD_TARGET/etc/passwd ; then + echo "abuild:x:${ABUILD_UID}:${ABUILD_GID}:Autobuild:/home/abuild:/bin/bash" >>$BUILD_TARGET/etc/passwd + echo 'abuild:*:::::::' >>$BUILD_TARGET/etc/shadow # This is needed on Mandriva 2009 + echo 'abuild:*::' >>$BUILD_TARGET/etc/gshadow # This is needed on Ubuntu + echo "abuild:x:${ABUILD_GID}:" >>$BUILD_TARGET/etc/group mkdir -p $BUILD_ROOT/home/abuild chown "$ABUILD_UID:$ABUILD_GID" $BUILD_ROOT/home/abuild else - if ! egrep "^abuild:x?:${ABUILD_UID}:${ABUILD_GID}" >/dev/null <$BUILD_ROOT/etc/passwd ; then - echo "abuild user present in the buildroot ($BUILD_ROOT) but uid:gid does not match" + if ! egrep "^abuild:x?:${ABUILD_UID}:${ABUILD_GID}" >/dev/null <$BUILD_TARGET/etc/passwd ; then + echo "abuild user present in the build target ($BUILD_TARGET) but uid:gid does not match" echo "buildroot currently using:" - egrep "^abuild:" <$BUILD_ROOT/etc/passwd + egrep "^abuild:" <$BUILD_TARGET/etc/passwd echo "build script attempting to use:" echo "abuild::${ABUILD_UID}:${ABUILD_GID}:..." echo "build aborting" cleanup_and_exit 1 fi fi - if test -f $BUILD_ROOT/etc/shadow ; then - sed -i -e "s@^root::@root:*:@" $BUILD_ROOT/etc/shadow + if test -f $BUILD_TARGET/etc/shadow ; then + sed -i -e "s@^root::@root:*:@" $BUILD_TARGET/etc/shadow fi - if test -f $BUILD_ROOT/etc/gshadow ; then - sed -i -e "s@^root::@root:*:@" $BUILD_ROOT/etc/gshadow + if test -f $BUILD_TARGET/etc/gshadow ; then + sed -i -e "s@^root::@root:*:@" $BUILD_TARGET/etc/gshadow fi BUILD_USER_ABUILD_USED=true else # building as root ABUILD_UID=0 ABUILD_GID=0 - if egrep '^abuild:' >/dev/null <$BUILD_ROOT/etc/passwd ; then + if egrep '^abuild:' >/dev/null <$BUILD_TARGET/etc/passwd ; then rm -rf "$BUILD_ROOT/home/abuild" - sed -i -e '/^abuild:/d' $BUILD_ROOT/etc/passwd - sed -i -e '/^abuild:/d' $BUILD_ROOT/etc/group - if test -f $BUILD_ROOT/etc/shadow ; then - sed -i -e '/^abuild:/d' $BUILD_ROOT/etc/shadow + sed -i -e '/^abuild:/d' $BUILD_TARGET/etc/passwd + sed -i -e '/^abuild:/d' $BUILD_TARGET/etc/group + if test -f $BUILD_TARGET/etc/shadow ; then + sed -i -e '/^abuild:/d' $BUILD_TARGET/etc/shadow fi - if test -f $BUILD_ROOT/etc/gshadow ; then - sed -i -e '/^abuild:/d' $BUILD_ROOT/etc/gshadow + if test -f $BUILD_TARGET/etc/gshadow ; then + sed -i -e '/^abuild:/d' $BUILD_TARGET/etc/gshadow fi fi fi @@ -1231,7 +1257,7 @@ for RECIPEFILE in "${RECIPEFILES[@]}" ; do mkdir -p $BUILD_ROOT/dev/shm mount -n -ttmpfs none $BUILD_ROOT/dev/shm 2> /dev/null - if test -n "$RUNNING_IN_VM" ; then + if test -n "$RUNNING_IN_VM" -a "$VM_TYPE" != "sb2" ; then if test -x /sbin/ip ; then ip addr add 127.0.0.1/8 dev lo ip addr add ::1/128 dev lo @@ -1324,7 +1350,7 @@ if test -n "$RPMS" -a -n "$BUILD_USER_ABUILD_USED" ; then recipe_check_file_owners fi -if test -n "$RPMS" -a -d "$BUILD_ROOT/usr/lib/build/checks" ; then +if test -n "$RPMS" -a -d "$BUILD_TARGET/usr/lib/build/checks" ; then export DO_RPM_REMOVE=true # find package name export PNAME= @@ -1332,7 +1358,7 @@ if test -n "$RPMS" -a -d "$BUILD_ROOT/usr/lib/build/checks" ; then test -f "$SRPM" && PNAME=`rpm --nodigest --nosignature -qp --qf "%{NAME}" $SRPM` done mount -n -tproc none $BUILD_ROOT/proc 2> /dev/null - for CHECKSCRIPT in $BUILD_ROOT/usr/lib/build/checks/* ; do + for CHECKSCRIPT in $BUILD_TARGET/usr/lib/build/checks/* ; do echo "... running ${CHECKSCRIPT##*/}" $CHECKSCRIPT || cleanup_and_exit 1 done @@ -1355,7 +1381,7 @@ exitcode=0 # post build work # TODO: don't hardcode. instead run scripts in a directory as it's done for the checks -if test -n "$RPMS" -a -d "$BUILD_ROOT/.build.oldpackages" ; then +if test -n "$RPMS" -a -d "$BUILD_TARGET/.build.oldpackages" ; then recipe_compare_oldpackages # no need to create deltas if the build is the same if test ! -e $BUILD_ROOT/.build/.same_result_marker ; then diff --git a/build-pkg b/build-pkg index 4ffcfb1..83739f5 100644 --- a/build-pkg +++ b/build-pkg @@ -67,9 +67,9 @@ pkg_autodetect_type() { cleanup_and_exit 1 fi PSUF= - test -e $BUILD_ROOT/.init_b_cache/rpms/rpm.rpm && PSUF=rpm - test -e $BUILD_ROOT/.init_b_cache/rpms/dpkg.deb && PSUF=deb - test -e $BUILD_ROOT/.init_b_cache/rpms/pacman.arch && PSUF=arch + test -e $BUILD_TARGET/.init_b_cache/rpms/rpm.rpm && PSUF=rpm + test -e $BUILD_TARGET/.init_b_cache/rpms/dpkg.deb && PSUF=deb + test -e $BUILD_TARGET/.init_b_cache/rpms/pacman.arch && PSUF=arch if test -z "$PSUF" ; then echo "could not autodetect package type" >&2 cleanup_and_exit 1 diff --git a/build-pkg-arch b/build-pkg-arch index eadab2b..1fb77d0 100644 --- a/build-pkg-arch +++ b/build-pkg-arch @@ -22,10 +22,10 @@ ################################################################ pkg_initdb_arch() { - mkdir -p $BUILD_ROOT/var/lib/pacman/sync - touch $BUILD_ROOT/var/lib/pacman/sync/core.db - touch $BUILD_ROOT/var/lib/pacman/sync/extra.db - touch $BUILD_ROOT/var/lib/pacman/sync/community.db + mkdir -p $BUILD_TARGET/var/lib/pacman/sync + touch $BUILD_TARGET/var/lib/pacman/sync/core.db + touch $BUILD_TARGET/var/lib/pacman/sync/extra.db + touch $BUILD_TARGET/var/lib/pacman/sync/community.db } pkg_prepare_arch() { @@ -47,7 +47,7 @@ pkg_cumulate_arch() { pkg_install_arch() { # -d -d disables deps checking - ( cd $BUILD_ROOT && chroot $BUILD_ROOT pacman -U --force -d -d --noconfirm .init_b_cache/$PKG.$PSUF 2>&1 || touch $BUILD_ROOT/exit ) | \ + ( cd $BUILD_TARGET && enter_target needroot pacman -U --force -d -d --noconfirm .init_b_cache/$PKG.$PSUF 2>&1 || touch $BUILD_ROOT/exit ) | \ perl -ne '$|=1;/^(warning: could not get filesystem information for |loading packages|looking for inter-conflicts|Targets |Total Installed Size: |Net Upgrade Size: |Proceed with installation|checking package integrity|loading package files|checking for file conflicts|checking keyring|Packages \(\d+\):|:: Proceed with installation|checking available disk space|installing |upgrading |warning:.*is up to date -- reinstalling|Optional dependencies for| )/||/^$/||print' } @@ -56,7 +56,7 @@ pkg_finalize_arch() { } pkg_preinstall_arch() { - $TAR -f "$BUILD_ROOT/.init_b_cache/rpms/$PKG.arch" + $TAR -f "$BUILD_TARGET/.init_b_cache/rpms/$PKG.arch" if test -f .INSTALL ; then cat .INSTALL > ".init_b_cache/scripts/$PKG.post" echo 'type post_install >/dev/null 2>&1 && post_install' >> ".init_b_cache/scripts/$PKG.post" @@ -65,9 +65,9 @@ pkg_preinstall_arch() { } pkg_runscripts_arch() { - if test -e "$BUILD_ROOT/.init_b_cache/scripts/$PKG.post" ; then + if test -e "$BUILD_TARGET/.init_b_cache/scripts/$PKG.post" ; then echo "running $PKG postinstall script" - ( cd $BUILD_ROOT && chroot $BUILD_ROOT ".init_b_cache/scripts/$PKG.post" < /dev/null ) - rm -f "$BUILD_ROOT/.init_b_cache/scripts/$PKG.post" + ( cd $BUILD_TARGET && enter_target needroot ".init_b_cache/scripts/$PKG.post" < /dev/null ) + rm -f "$BUILD_TARGET/.init_b_cache/scripts/$PKG.post" fi } diff --git a/build-pkg-deb b/build-pkg-deb index 83a4afe..73d55b5 100644 --- a/build-pkg-deb +++ b/build-pkg-deb @@ -22,24 +22,24 @@ ################################################################ deb_setup() { - mkdir -p $BUILD_ROOT/var/lib/dpkg - mkdir -p $BUILD_ROOT/var/log - 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 + mkdir -p $BUILD_TARGET/var/lib/dpkg + mkdir -p $BUILD_TARGET/var/log + mkdir -p $BUILD_TARGET/etc/default + :>> $BUILD_TARGET/var/lib/dpkg/status + :>> $BUILD_TARGET/var/lib/dpkg/available + :>> $BUILD_TARGET/var/log/dpkg.log + :>> $BUILD_TARGET/etc/ld.so.conf + :>> $BUILD_TARGET/etc/default/rcS } pkg_initdb_deb() { deb_setup # force dpkg into database to make epoch test work - if ! test "$BUILD_ROOT/.init_b_cache/rpms/dpkg.deb" -ef "$BUILD_ROOT/.init_b_cache/dpkg.deb" ; then - rm -f $BUILD_ROOT/.init_b_cache/dpkg.deb - cp $BUILD_ROOT/.init_b_cache/rpms/dpkg.deb $BUILD_ROOT/.init_b_cache/dpkg.deb || cleanup_and_exit 1 + if ! test "$BUILD_TARGET/.init_b_cache/rpms/dpkg.deb" -ef "$BUILD_TARGET/.init_b_cache/dpkg.deb" ; then + rm -f $BUILD_TARGET/.init_b_cache/dpkg.deb + cp $BUILD_TARGET/.init_b_cache/rpms/dpkg.deb $BUILD_TARGET/.init_b_cache/dpkg.deb || cleanup_and_exit 1 fi - chroot $BUILD_ROOT dpkg -i --force all .init_b_cache/dpkg.deb >/dev/null 2>&1 + enter_target needroot dpkg -i --force all .init_b_cache/dpkg.deb >/dev/null 2>&1 } pkg_prepare_deb() { @@ -49,26 +49,26 @@ pkg_prepare_deb() { pkg_install_deb() { export DEBIAN_FRONTEND=noninteractive export DEBIAN_PRIORITY=critical - ( cd $BUILD_ROOT && chroot $BUILD_ROOT dpkg --install --force all .init_b_cache/$PKG.deb 2>&1 || touch $BUILD_ROOT/exit ) | \ + ( cd $BUILD_TARGET && enter_target needroot dpkg --install --force all .init_b_cache/$PKG.deb 2>&1 || touch $BUILD_ROOT/exit ) | \ perl -ne '$|=1;/^(Configuration file|Installing new config file|Selecting previously deselected|Selecting previously unselected|\(Reading database|Unpacking |Setting up|Creating config file|Preparing to replace dpkg|Preparing to unpack )/||/^$/||print' # ugly workaround for upstart system. some packages (procps) try # to start a service in their configure phase. As we don't have # a running upstart, we just link the start binary to /bin/true - if test -e "$BUILD_ROOT/sbin/start"; then - if test "$BUILD_ROOT/sbin/start" -ef "$BUILD_ROOT/sbin/initctl" ; then + if test -e "$BUILD_TARGET/sbin/start"; then + if test "$BUILD_TARGET/sbin/start" -ef "$BUILD_TARGET/sbin/initctl" ; then echo "linking /sbin/start to /bin/true" - mv "$BUILD_ROOT/sbin/start" "$BUILD_ROOT/sbin/start.disabled" - ln -s "/bin/true" "$BUILD_ROOT/sbin/start" + mv "$BUILD_TARGET/sbin/start" "$BUILD_TARGET/sbin/start.disabled" + ln -s "/bin/true" "$BUILD_TARGET/sbin/start" fi fi # another workaround, see bug bnc#733699 - rm -f "$BUILD_ROOT/var/run/init.upgraded" + rm -f "$BUILD_TARGET/var/run/init.upgraded" } pkg_erase_deb() { export DEBIAN_FRONTEND=noninteractive export DEBIAN_PRIORITY=critical - ( cd $BUILD_ROOT && chroot $BUILD_ROOT dpkg --purge --force all $PKG 2>&1 || touch $BUILD_ROOT/exit ) | \ + ( cd $BUILD_TARGET && enter_target needroot dpkg --purge --force all $PKG 2>&1 || touch $BUILD_ROOT/exit ) | \ perl -ne '$|=1;/^(\(Reading database|Removing |Purging configuration files for )/||/^$/||print' } @@ -85,14 +85,14 @@ pkg_finalize_deb() { # configure all packages after complete installation, not for each package like rpm does # We need to run this twice, because of cyclic dependencies as it does not succeed on most # debian based distros in the first attempt. - if ! chroot $BUILD_ROOT dpkg --configure --pending 2>&1; then + if ! enter_target needroot dpkg --configure --pending 2>&1; then echo "first configure attempt failed, trying again..." - chroot $BUILD_ROOT dpkg --configure --pending 2>&1 || cleanup_and_exit 1 + enter_target needroot dpkg --configure --pending 2>&1 || cleanup_and_exit 1 fi } pkg_preinstall_deb() { - ar x "$BUILD_ROOT/.init_b_cache/rpms/$PKG.deb" + ar x "$BUILD_TARGET/.init_b_cache/rpms/$PKG.deb" mkdir -p .init_b_cache/scripts/control $TAR -C .init_b_cache/scripts/control -z -f control.tar.gz if test -f "data.tar.gz" ; then @@ -111,14 +111,14 @@ pkg_runscripts_deb() { if ! test -e $BUILD_ROOT/var/lib/dpkg/status ; then deb_setup fi - if test -e "$BUILD_ROOT/.init_b_cache/scripts/$PKG.pre" ; then + if test -e "$BUILD_TARGET/.init_b_cache/scripts/$PKG.pre" ; then echo "running $PKG preinstall script" - (cd $BUILD_ROOT && chroot $BUILD_ROOT ".init_b_cache/scripts/$PKG.pre" install < /dev/null ) - rm -f "$BUILD_ROOT/.init_b_cache/scripts/$PKG.pre" + (cd $BUILD_TARGET && enter_target needroot ".init_b_cache/scripts/$PKG.pre" install < /dev/null ) + rm -f "$BUILD_TARGET/.init_b_cache/scripts/$PKG.pre" fi - if test -e "$BUILD_ROOT/.init_b_cache/scripts/$PKG.post" ; then + if test -e "$BUILD_TARGET/.init_b_cache/scripts/$PKG.post" ; then echo "running $PKG postinstall script" - (cd $BUILD_ROOT && chroot $BUILD_ROOT ".init_b_cache/scripts/$PKG.post" configure '' < /dev/null ) - rm -f "$BUILD_ROOT/.init_b_cache/scripts/$PKG.post" + (cd $BUILD_TARGET && enter_target needroot ".init_b_cache/scripts/$PKG.post" configure '' < /dev/null ) + rm -f "$BUILD_TARGET/.init_b_cache/scripts/$PKG.post" fi } diff --git a/build-pkg-rpm b/build-pkg-rpm index fc6a421..a4e62b9 100644 --- a/build-pkg-rpm +++ b/build-pkg-rpm @@ -24,20 +24,20 @@ pkg_initdb_rpm() { echo "initializing rpm db..." - mkdir -p $BUILD_ROOT/var/lib/rpm + mkdir -p $BUILD_TARGET/var/lib/rpm # rpm v5 does not have initdb - if ! test -e $BUILD_ROOT/usr/lib/rpm/cpuinfo.yaml ; then - if test -x $BUILD_ROOT/usr/bin/rpmdb ; then - chroot $BUILD_ROOT /usr/bin/rpmdb --initdb || cleanup_and_exit 1 + if ! test -e $BUILD_TARGET/usr/lib/rpm/cpuinfo.yaml ; then + if test -x $BUILD_TARGET/usr/bin/rpmdb ; then + enter_target needroot /usr/bin/rpmdb --initdb || cleanup_and_exit 1 else - chroot $BUILD_ROOT rpm --initdb || cleanup_and_exit 1 + enter_target needroot rpm --initdb || cleanup_and_exit 1 fi fi # hack: add nofsync to db config to speed up install - mkdir -p $BUILD_ROOT/root - DBI_OTHER=`chroot $BUILD_ROOT rpm --eval '%{?__dbi_other}'` - echo "%__dbi_other $DBI_OTHER nofsync" > $BUILD_ROOT/.rpmmacros - echo "%__dbi_other $DBI_OTHER nofsync" > $BUILD_ROOT/root/.rpmmacros + mkdir -p $BUILD_TARGET/root + DBI_OTHER=`enter_target needroot rpm --eval '%{?__dbi_other}'` + echo "%__dbi_other $DBI_OTHER nofsync" > $BUILD_TARGET/.rpmmacros + echo "%__dbi_other $DBI_OTHER nofsync" > $BUILD_TARGET/root/.rpmmacros } pkg_prepare_rpm() { @@ -46,7 +46,7 @@ pkg_prepare_rpm() { } pkg_erase_rpm() { - chroot $BUILD_ROOT rpm --nodeps -e $PKG 2>&1 | { + enter_target needroot rpm --nodeps -e $PKG 2>&1 | { local retry while read line; do case "$line" in @@ -61,7 +61,7 @@ pkg_erase_rpm() { done if test -n "$retry" ; then echo "re-try deleting $PKG using --noscripts" - chroot $BUILD_ROOT rpm --nodeps --noscripts -e $PKG || true + enter_target needroot rpm --nodeps --noscripts -e $PKG || true fi } } @@ -79,14 +79,14 @@ rpm_init_cumulate() { CUMULATED_PIDS=() CUMULATED_HMD5=() DO_CUMULATE= - typeset -ri suse_version=$(chroot $BUILD_ROOT rpm --eval '%{?suse_version}' 2>/dev/null) + typeset -ri suse_version=$(enter_target needroot rpm --eval '%{?suse_version}' 2>/dev/null) if ((suse_version > 1220)) ; then DO_CUMULATE=true fi } pkg_verify_installed_rpm() { - chroot $BUILD_ROOT rpm --verify $PKG 2>&1 | tee $TMPFILE + enter_target needroot rpm --verify $PKG 2>&1 | tee $TMPFILE if grep ^missing $TMPFILE > /dev/null ; then return 1 fi @@ -97,7 +97,7 @@ pkg_cumulate_rpm() { test "$DO_CUMULATE" = true || return 1 # work around for cross-build installs, we must not overwrite the running rpm if test "$PKG" = rpm ; then - for i in $BUILD_ROOT/.init_b_cache/preinstalls/rpm-x86-* ; do + for i in $BUILD_TARGET/.init_b_cache/preinstalls/rpm-x86-* ; do test -e "$i" && return 1 done fi @@ -115,11 +115,11 @@ pkg_install_rpm() { fi # work around for cross-build installs, we must not overwrite the running rpm if test "$PKG" = rpm ; then - for i in $BUILD_ROOT/.init_b_cache/preinstalls/rpm-x86-* ; do + for i in $BUILD_TARGET/.init_b_cache/preinstalls/rpm-x86-* ; do test -e "$i" && ADDITIONAL_PARAMS="$ADDITIONAL_PARAMS --justdb" done fi - ( cd $BUILD_ROOT && chroot $BUILD_ROOT rpm --ignorearch --nodeps -U --oldpackage --ignoresize $RPMCHECKOPTS \ + ( cd $BUILD_TARGET && enter_target needroot rpm --ignorearch --nodeps -U --oldpackage --ignoresize $RPMCHECKOPTS \ $ADDITIONAL_PARAMS .init_b_cache/$PKG.rpm 2>&1 || \ touch $BUILD_ROOT/exit ) | \ grep -v "^warning:.*saved as.*rpmorig$" @@ -131,16 +131,16 @@ pkg_finalize_rpm() { for ((num=0; num<=cumulate; num++)) ; do echo ${CUMULATED_LIST[$num]} PKG=${CUMULATED_LIST[$num]##*/} - test "$BUILD_ROOT/.init_b_cache/rpms/$PKG" -ef "$BUILD_ROOT/${CUMULATED_LIST[$num]}" && continue - rm -f $BUILD_ROOT/${CUMULATED_LIST[$num]} - cp $BUILD_ROOT/.init_b_cache/rpms/$PKG $BUILD_ROOT/${CUMULATED_LIST[$num]} || cleanup_and_exit 1 - done > $BUILD_ROOT/.init_b_cache/manifest - ( cd $BUILD_ROOT && chroot $BUILD_ROOT rpm --ignorearch --nodeps -Uh --oldpackage --ignoresize --verbose $RPMCHECKOPTS \ - $ADDITIONAL_PARAMS .init_b_cache/manifest 2>&1 || touch $BUILD_ROOT/exit ) + test "$BUILD_TARGET/.init_b_cache/rpms/$PKG" -ef "$BUILD_TARGET/${CUMULATED_LIST[$num]}" && continue + rm -f $BUILD_TARGET/${CUMULATED_LIST[$num]} + cp $BUILD_TARGET/.init_b_cache/rpms/$PKG $BUILD_TARGET/${CUMULATED_LIST[$num]} || cleanup_and_exit 1 + done > $BUILD_TARGET/.init_b_cache/manifest + cd $BUILD_TARGET && enter_target needroot rpm --ignorearch --nodeps -Uh --oldpackage --ignoresize --verbose $RPMCHECKOPTS \ + $ADDITIONAL_PARAMS .init_b_cache/manifest 2>&1 || touch $BUILD_ROOT/exit for ((num=0; num<=cumulate; num++)) ; do - rm -f $BUILD_ROOT/${CUMULATED_LIST[$num]} + rm -f $BUILD_TARGET/${CUMULATED_LIST[$num]} done - rm -f $BUILD_ROOT/.init_b_cache/manifest + rm -f $BUILD_TARGET/.init_b_cache/manifest check_exit for ((num=0; num<=cumulate; num++)) ; do PKG=${CUMULATED_LIST[$num]##*/} @@ -153,7 +153,7 @@ pkg_finalize_rpm() { pkg_preinstall_rpm() { PAYLOADDECOMPRESS=cat - case `rpm -qp --nodigest --nosignature --qf "%{PAYLOADCOMPRESSOR}\n" "$BUILD_ROOT/.init_b_cache/rpms/$PKG.rpm"` in + case `rpm -qp --nodigest --nosignature --qf "%{PAYLOADCOMPRESSOR}\n" "$BUILD_TARGET/.init_b_cache/rpms/$PKG.rpm"` in lzma) rpm --showrc | egrep 'PayloadIsLzma|_lzma' > /dev/null || PAYLOADDECOMPRESS="lzma -d" ;; xz) rpm --showrc | egrep 'PayloadIsXz|_xz' > /dev/null || PAYLOADDECOMPRESS="xz -d" ;; esac @@ -168,13 +168,13 @@ pkg_preinstall_rpm() { fi fi if test "$PAYLOADDECOMPRESS" = cat ; then - rpm2cpio "$BUILD_ROOT/.init_b_cache/rpms/$PKG.rpm" | $CPIO + rpm2cpio "$BUILD_TARGET/.init_b_cache/rpms/$PKG.rpm" | $CPIO else - rpm2cpio "$BUILD_ROOT/.init_b_cache/rpms/$PKG.rpm" | $PAYLOADDECOMPRESS | $CPIO + rpm2cpio "$BUILD_TARGET/.init_b_cache/rpms/$PKG.rpm" | $PAYLOADDECOMPRESS | $CPIO fi if test -e ".init_b_cache/scripts/$PKG.run" ; then - rpm -qp --nodigest --nosignature --qf "%{PREIN}" "$BUILD_ROOT/.init_b_cache/rpms/$PKG.rpm" > ".init_b_cache/scripts/$PKG.pre" - rpm -qp --nodigest --nosignature --qf "%{POSTIN}" "$BUILD_ROOT/.init_b_cache/rpms/$PKG.rpm" > ".init_b_cache/scripts/$PKG.post" + rpm -qp --nodigest --nosignature --qf "%{PREIN}" "$BUILD_TARGET/.init_b_cache/rpms/$PKG.rpm" > ".init_b_cache/scripts/$PKG.pre" + rpm -qp --nodigest --nosignature --qf "%{POSTIN}" "$BUILD_TARGET/.init_b_cache/rpms/$PKG.rpm" > ".init_b_cache/scripts/$PKG.post" echo -n '(none)' > .init_b_cache/scripts/.none cmp -s ".init_b_cache/scripts/$PKG.pre" .init_b_cache/scripts/.none && rm -f ".init_b_cache/scripts/$PKG.pre" cmp -s ".init_b_cache/scripts/$PKG.post" .init_b_cache/scripts/.none && rm -f ".init_b_cache/scripts/$PKG.post" @@ -183,21 +183,21 @@ pkg_preinstall_rpm() { # hack for rpm erasures if test -d "$BUILD_ROOT/installed-pkg" ; then # call for rpm-4.x and not rpm-devel - test -z "${PKG##rpm-[0-9]*}" && chroot $BUILD_ROOT rpm --rebuilddb + test -z "${PKG##rpm-[0-9]*}" && enter_target needroot 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 + test -z "${PKG##rpm-x86-*[0-9]*}" && enter_target needroot rpm --rebuilddb fi } pkg_runscripts_rpm() { - if test -e "$BUILD_ROOT/.init_b_cache/scripts/$PKG.pre" ; then + if test -e "$BUILD_TARGET/.init_b_cache/scripts/$PKG.pre" ; then echo "running $PKG preinstall script" - (cd $BUILD_ROOT && chroot $BUILD_ROOT sh ".init_b_cache/scripts/$PKG.pre" 0) - rm -f "$BUILD_ROOT/.init_b_cache/scripts/$PKG.pre" + cd $BUILD_TARGET && enter_target needroot sh ".init_b_cache/scripts/$PKG.pre" 0 + rm -f "$BUILD_TARGET/.init_b_cache/scripts/$PKG.pre" fi - if test -e "$BUILD_ROOT/.init_b_cache/scripts/$PKG.post" ; then + if test -e "$BUILD_TARGET/.init_b_cache/scripts/$PKG.post" ; then echo "running $PKG postinstall script" - (cd $BUILD_ROOT && chroot $BUILD_ROOT sh ".init_b_cache/scripts/$PKG.post" 1) - rm -f "$BUILD_ROOT/.init_b_cache/scripts/$PKG.post" + cd $BUILD_TARGET && enter_target needroot sh ".init_b_cache/scripts/$PKG.post" 1 + rm -f "$BUILD_TARGET/.init_b_cache/scripts/$PKG.post" fi } diff --git a/build-recipe-dsc b/build-recipe-dsc index 7ac8bf1..fc8488f 100644 --- a/build-recipe-dsc +++ b/build-recipe-dsc @@ -67,11 +67,11 @@ recipe_prepare_dsc() { for DEB_DSCFILE in $BUILD_ROOT/$DEB_SOURCEDIR/*.dsc ; do : ; done DEB_DSCFILE="${DEB_DSCFILE##*/}" fi - chroot $BUILD_ROOT su -c "dpkg-source -x $DEB_SOURCEDIR/$DEB_DSCFILE $TOPDIR/BUILD" - $BUILD_USER + enter_target needuser dpkg-source -x $DEB_SOURCEDIR/$DEB_DSCFILE $TOPDIR/BUILD # Alternative to debtransform: apply OBS release number if tag OBS-DCH-RELEASE is set. if test -z "$DEB_TRANSFORM" && grep -Eq '^OBS-DCH-RELEASE: 1' $BUILD_ROOT$TOPDIR/SOURCES/$RECIPEFILE; then - chroot $BUILD_ROOT su -c /bin/sh <<EOF + enter_target needroot /bin/sh <<EOF cd $TOPDIR/BUILD [ ! -f debian/changelog ] && exit 0 # avoid devscripts dependency and mimic dch @@ -126,7 +126,7 @@ dsc_move_build_result() { recipe_build_dsc() { - dsc_build "$BUILD_ROOT" + dsc_build "$BUILD_TARGET" dsc_move_build_result } diff --git a/build-recipe-spec b/build-recipe-spec index 340a9ea..37f04e1 100644 --- a/build-recipe-spec +++ b/build-recipe-spec @@ -22,7 +22,7 @@ ################################################################ recipe_setup_spec() { - TOPDIR=`chroot $BUILD_ROOT su -c "rpm --eval '%_topdir'" - $BUILD_USER` + TOPDIR=`enter_target needuser rpm --eval '%_topdir'` if test -z "$TOPDIR"; then echo "Error: TOPDIR empty" cleanup_and_exit 1 @@ -45,17 +45,17 @@ recipe_prepare_spec() { # fixup specfile CHANGELOGARGS= test -n "$CHANGELOG" -a -f "$BUILD_ROOT/.build-changelog" && CHANGELOGARGS="--changelog $BUILD_ROOT/.build-changelog" - substitutedeps "${args[@]}" --root "$BUILD_ROOT" --dist "$BUILD_DIST" --archpath "$BUILD_ARCH" --configdir "$CONFIG_DIR" $CHANGELOGARGS "$BUILD_ROOT$TOPDIR/SOURCES/$RECIPEFILE" "$BUILD_ROOT/.spec.new" || cleanup_and_exit 1 + substitutedeps "${args[@]}" --root "$BUILD_ROOT" --dist "$BUILD_DIST" --archpath "$BUILD_ARCH" --configdir "$CONFIG_DIR" $CHANGELOGARGS "$BUILD_ROOT$TOPDIR/SOURCES/$RECIPEFILE" "$BUILD_TARGET/.spec.new" || cleanup_and_exit 1 # fix rpmrc if we are compiling for i686 - test -f $BUILD_ROOT/usr/lib/rpm/rpmrc_i586 && mv $BUILD_ROOT/usr/lib/rpm/rpmrc_i586 $BUILD_ROOT/usr/lib/rpm/rpmrc - if test -e $BUILD_ROOT/usr/lib/rpm/rpmrc -a "$BUILD_ARCH" != "${BUILD_ARCH#i686}" ; then - mv $BUILD_ROOT/usr/lib/rpm/rpmrc $BUILD_ROOT/usr/lib/rpm/rpmrc_i586 - sed -e 's/^buildarchtranslate: athlon.*/buildarchtranslate: athlon: i686/' -e 's/^buildarchtranslate: i686.*/buildarchtranslate: i686: i686/' < $BUILD_ROOT/usr/lib/rpm/rpmrc_i586 > $BUILD_ROOT/usr/lib/rpm/rpmrc + test -f $BUILD_TARGET/usr/lib/rpm/rpmrc_i586 && mv $BUILD_TARGET/usr/lib/rpm/rpmrc_i586 $BUILD_TARGET/usr/lib/rpm/rpmrc + if test -e $BUILD_TARGET/usr/lib/rpm/rpmrc -a "$BUILD_ARCH" != "${BUILD_ARCH#i686}" ; then + mv $BUILD_TARGET/usr/lib/rpm/rpmrc $BUILD_TARGET/usr/lib/rpm/rpmrc_i586 + sed -e 's/^buildarchtranslate: athlon.*/buildarchtranslate: athlon: i686/' -e 's/^buildarchtranslate: i686.*/buildarchtranslate: i686: i686/' < $BUILD_TARGET/usr/lib/rpm/rpmrc_i586 > $BUILD_TARGET/usr/lib/rpm/rpmrc fi # extract macros from configuration - queryconfig rawmacros --dist "$BUILD_DIST" --archpath "$BUILD_ARCH" --configdir "$CONFIG_DIR" > $BUILD_ROOT/root/.rpmmacros + queryconfig rawmacros --dist "$BUILD_DIST" --archpath "$BUILD_ARCH" --configdir "$CONFIG_DIR" > $BUILD_TARGET/root/.rpmmacros if test -n "$BUILD_DEBUG" ; then echo ' %prep %{?!__debug_package:%{?_build_create_debug:%?_build_insert_debug_package}}%%prep @@ -65,20 +65,20 @@ recipe_prepare_spec() { %undefine _enable_debug_packages \ %debug_package -' >> $BUILD_ROOT/root/.rpmmacros +' >> $BUILD_TARGET/root/.rpmmacros fi if test -n "$BUILD_JOBS" ; then - cat >> $BUILD_ROOT/root/.rpmmacros <<-EOF + cat >> $BUILD_TARGET/root/.rpmmacros <<-EOF %jobs $BUILD_JOBS %_smp_mflags -j$BUILD_JOBS EOF fi - test $BUILD_USER = abuild && cp -p $BUILD_ROOT/root/.rpmmacros $BUILD_ROOT/home/abuild/.rpmmacros + test $BUILD_USER = abuild && cp -p $BUILD_TARGET/root/.rpmmacros $BUILD_ROOT/home/abuild/.rpmmacros # extract optflags from configuration - queryconfig --dist "$BUILD_DIST" --configdir "$CONFIG_DIR" --archpath "$BUILD_ARCH" optflags ${BUILD_DEBUG:+debug} > $BUILD_ROOT/root/.rpmrc - test $BUILD_USER = abuild && cp -p $BUILD_ROOT/root/.rpmrc $BUILD_ROOT/home/abuild/.rpmrc + queryconfig --dist "$BUILD_DIST" --configdir "$CONFIG_DIR" --archpath "$BUILD_ARCH" optflags ${BUILD_DEBUG:+debug} > $BUILD_TARGET/root/.rpmrc + test $BUILD_USER = abuild && cp -p $BUILD_TARGET/root/.rpmrc $BUILD_ROOT/home/abuild/.rpmrc if test -z "$ABUILD_TARGET"; then ABUILD_TARGET=$(queryconfig target --dist "$BUILD_DIST" --configdir "$CONFIG_DIR" --archpath "$BUILD_ARCH" ) @@ -86,17 +86,17 @@ recipe_prepare_spec() { fi # report specfile changes - if test -f $BUILD_ROOT/.spec.new ; then - if ! cmp -s $BUILD_ROOT$TOPDIR/SOURCES/$RECIPEFILE $BUILD_ROOT/.spec.new ; then + if test -f $BUILD_TARGET/.spec.new ; then + if ! cmp -s $BUILD_ROOT$TOPDIR/SOURCES/$RECIPEFILE $BUILD_TARGET/.spec.new ; then echo ----------------------------------------------------------------- echo "I have the following modifications for $RECIPEFILE:" - sed -e "/^%changelog/q" $BUILD_ROOT$TOPDIR/SOURCES/$RECIPEFILE > $BUILD_ROOT/.spec.t1 - sed -e "/^%changelog/q" $BUILD_ROOT/.spec.new > $BUILD_ROOT/.spec.t2 - diff $BUILD_ROOT/.spec.t1 $BUILD_ROOT/.spec.t2 - rm -f $BUILD_ROOT/.spec.t1 $BUILD_ROOT/.spec.t2 - mv $BUILD_ROOT/.spec.new $BUILD_ROOT$TOPDIR/SOURCES/$RECIPEFILE + sed -e "/^%changelog/q" $BUILD_ROOT$TOPDIR/SOURCES/$RECIPEFILE > $BUILD_TARGET/.spec.t1 + sed -e "/^%changelog/q" $BUILD_ROOT/.spec.new > $BUILD_TARGET/.spec.t2 + diff $BUILD_TARGET/.spec.t1 $BUILD_TARGET/.spec.t2 + rm -f $BUILD_TARGET/.spec.t1 $BUILD_TARGET/.spec.t2 + mv $BUILD_TARGET/.spec.new $BUILD_ROOT$TOPDIR/SOURCES/$RECIPEFILE else - rm -f $BUILD_ROOT/.spec.new + rm -f $BUILD_TARGET/.spec.new fi fi } @@ -143,13 +143,13 @@ recipe_build_spec() { "${definesnstuff[@]}" \ "${rpmbopts[@]}" \ "$TOPDIR/SOURCES/$RECIPEFILE" \ - > $BUILD_ROOT/.build.command - chmod 755 $BUILD_ROOT/.build.command + > $BUILD_TARGET/.build.command + chmod 755 $BUILD_TARGET/.build.command check_exit if test -n "$RUN_SHELL"; then - chroot $BUILD_ROOT su - + enter_target needroot bash else - chroot $BUILD_ROOT su -c /.build.command - $BUILD_USER < /dev/null && BUILD_SUCCEEDED=true + enter_target needuser /.build.command < /dev/null && BUILD_SUCCEEDED=true fi } @@ -188,7 +188,7 @@ recipe_check_file_owners() { } recipe_run_rpmlint() { - if ! test -x "$BUILD_ROOT/opt/testing/bin/rpmlint" ; then + if ! test -x "$BUILD_TARGET/opt/testing/bin/rpmlint" ; then return fi LINT_RPM_FILE_LIST=($(find $BUILD_ROOT/$TOPDIR/RPMS \ @@ -204,7 +204,7 @@ recipe_run_rpmlint() { rm -f "$BUILD_ROOT$rpmlint_logfile" ret=0 mount -n -tproc none $BUILD_ROOT/proc 2> /dev/null - chroot $BUILD_ROOT su -s /opt/testing/bin/rpmlint "$BUILD_USER" -- \ + enter_target needscript /opt/testing/bin/rpmlint \ --info ${LINT_RPM_FILE_LIST[*]#$BUILD_ROOT} \ ${SRPM_FILE_LIST[*]#$BUILD_ROOT} > "$BUILD_ROOT$rpmlint_logfile" || ret=1 cat "$BUILD_ROOT$rpmlint_logfile" @@ -216,11 +216,11 @@ recipe_run_rpmlint() { } recipe_compare_oldpackages() { - if test -x "$BUILD_ROOT/usr/lib/build/same-build-result.sh" ; then + if test -x "$BUILD_TARGET/usr/lib/build/same-build-result.sh" ; then echo "... comparing built packages with the former built" mount -n -tproc none $BUILD_ROOT/proc 2> /dev/null - if chroot $BUILD_ROOT /usr/lib/build/same-build-result.sh /.build.oldpackages "$TOPDIR/RPMS" "$TOPDIR/SRPMS"; then - chroot $BUILD_ROOT touch /.build/.same_result_marker + if enter_target needroot /usr/lib/build/same-build-result.sh /.build.oldpackages "$TOPDIR/RPMS" "$TOPDIR/SRPMS"; then + touch $BUILD_ROOT/.build/.same_result_marker # XXX: dirty build service hack. fix bs_worker. Search for # 'same_result_marker' for traces of a first try to get rid of this if test -n "$REASON" -a -n "$DISTURL" ; then @@ -232,9 +232,9 @@ recipe_compare_oldpackages() { } recipe_create_deltarpms() { - if test -x "$BUILD_ROOT/usr/bin/makedeltarpm" -a -x $BUILD_ROOT/usr/lib/build/mkdrpms ; then + if test -x "$BUILD_TARGET/usr/bin/makedeltarpm" -a -x $BUILD_TARGET/usr/lib/build/mkdrpms ; then echo "... creating delta rpms" ds=("$BUILD_ROOT/$TOPDIR"/RPMS/* "$BUILD_ROOT$TOPDIR/SRPMS") - chroot $BUILD_ROOT /usr/lib/build/mkdrpms /.build.oldpackages "${ds[@]#$BUILD_ROOT}" + enter_target needroot /usr/lib/build/mkdrpms /.build.oldpackages "${ds[@]#$BUILD_ROOT}" fi } diff --git a/build-vm b/build-vm index a25c6de..436281b 100644 --- a/build-vm +++ b/build-vm @@ -63,7 +63,7 @@ HUGETLBFSPATH= # emulator specific? EMULATOR_SCRIPT= -for i in ec2 emulator kvm lxc openstack qemu uml xen zvm docker ; do +for i in ec2 emulator kvm lxc openstack qemu uml xen zvm docker sb2 ; do . "$BUILD_DIR/build-vm-$i" done @@ -267,7 +267,7 @@ vm_shutdown() { fi exec >&0 2>&0 # so that the logging tee finishes sleep 1 # wait till tee terminates - test "$VM_TYPE" = lxc -o "$VM_TYPE" = docker && exit $1 + test "$VM_TYPE" = lxc -o "$VM_TYPE" = docker -o "$VM_TYPE" = sb2 && exit $1 kill -9 -1 # goodbye cruel world if ! test -x /sbin/halt ; then test -e /proc/sysrq-trigger || mount -n -tproc none /proc @@ -450,7 +450,7 @@ vm_detect_2nd_stage() { fi RUNNING_IN_VM=true test -e /proc/version || mount -orw -n -tproc none /proc - if test "$VM_TYPE" != lxc -a "$VM_TYPE" != docker ; then + if test "$VM_TYPE" != lxc -a "$VM_TYPE" != docker -a "$VM_TYPE" != sb2 ; then mount -n ${VMDISK_MOUNT_OPTIONS},remount,rw / fi umount /run >/dev/null 2>&1 @@ -724,7 +724,7 @@ vm_first_stage() { ppc|ppcle|s390) PERSONALITY=8 ;; # ppc/s390 kernel never tells us if a 32bit personality is active, assume we run on 64bit aarch64) test "$BUILD_ARCH" != "${BUILD_ARCH#armv}" && PERSONALITY=8 ;; # workaround, to be removed esac - test "$VM_TYPE" = lxc -o "$VM_TYPE" = docker && PERSONALITY=0 + test "$VM_TYPE" = lxc -o "$VM_TYPE" = docker -o "$VM_TYPE" = sb2 && PERSONALITY=0 echo "PERSONALITY='$PERSONALITY'" >> $BUILD_ROOT/.build/build.data echo "MYHOSTNAME='`hostname`'" >> $BUILD_ROOT/.build/build.data echo -n "definesnstuff=(" >> $BUILD_ROOT/.build/build.data @@ -752,7 +752,11 @@ vm_first_stage() { vm_init_script="/.build/build" if check_use_emulator ; then - vm_init_script="/.build/$INITVM_NAME" + if test -n "$BUILD_SB2FLAGS" -a -e "$BUILD_DIR/initscript_sb2" ; then + vm_init_script="/.build/initscript_sb2" + else + vm_init_script="/.build/$INITVM_NAME" + fi fi if test -n "$VM_IMAGE" ; then # copy out kernel & initrd (if they exist) during unmounting VM image diff --git a/build-vm-sb2 b/build-vm-sb2 new file mode 100644 index 0000000..c638ed6 --- /dev/null +++ b/build-vm-sb2 @@ -0,0 +1,48 @@ +# +# SB2 specific functions +# +# (C) 2014 Jolla Oy +# + +vm_verify_options_sb2() { + VM_IMAGE= + VM_SWAP= +} + +vm_startup_sb2() { + echo "rootfs / rootfs rw 0 0" > $BUILD_ROOT/etc/mtab + touch $BUILD_ROOT/.sb2chroot + chroot $BUILD_ROOT "$vm_init_script" + BUILDSTATUS="$?" + test "$BUILDSTATUS" != 255 || BUILDSTATUS=3 + cleanup_and_exit "$BUILDSTATUS" +} + +vm_kill_sb2() { + : +} + +vm_fixup_sb2() { + : +} + +vm_attach_root_sb2() { + : +} + +vm_attach_swap_sb2() { + : +} + +vm_detach_root_sb2() { + : +} + +vm_detach_swap_sb2() { + : +} + +vm_cleanup_sb2() { + : +} + diff --git a/common_functions b/common_functions index 92b257c..95ba903 100755 --- a/common_functions +++ b/common_functions @@ -84,6 +84,157 @@ check_exit() { fi } +internal_set_sb2_settings() { + SB2_TOOLCHAIN="/unknown" + SB2_INSTALLMODE="obs-rpm-install" + SB2_DEFAULTMODE="obs-rpm-build" + SB2_SYSROOT="-C --sysroot=/ -L --sysroot=/" + SB2_MAPPING_METHOD="both" + SB2_DEBUG="" + SB2_QEMU="/unknown" + while test -n "$1" ; do + case "$1" in + --toolchain) + shift + SB2_TOOLCHAIN=$1 + shift + ;; + --installmode) + shift + SB2_INSTALLMODE=$1 + shift + ;; + --defaultmode) + shift + SB2_DEFAULTMODE=$1 + shift + ;; + --mappingmethod) + shift + SB2_MAPPING_METHOD=$1 + shift + ;; + --bootstrap) + shift + SB2_SYSROOT="" + ;; + --qemu) + shift + SB2_QEMU=$1 + shift + ;; + --infologs) + shift + SB2_DEBUG="-q -L info" + ;; + --debug) + shift + SB2_DEBUG="-q -d" + ;; + *) + break + ;; + esac + done + if [ "x$SB2_TOOLCHAIN" = "x/unknown" ]; then + echo "Please provide a proper SB2 toolchain in SB2flags. exiting.." + cleanup_and_exit 1 + fi +} + + +cleanup_sb2() { + if [ ! -z "$BUILD_SB2FLAGS" ]; then + if [ -e /home/abuild/sb2-session-needroot ]; then + su -c "cd $PWD; /usr/bin/sb2 -t oscbuild -D /home/abuild/sb2-session-needroot" - abuild + fi + if [ -e /home/abuild/sb2-session-needuser ]; then + su -c "cd $PWD; /usr/bin/sb2 -t oscbuild -D /home/abuild/sb2-session-needuser" - abuild + fi + fi +} + +# chroot-like wrapper, enter_target <mode: needroot|user> $TARGET commands +# needroot - operations that need to be done as root, like unpacking into file system, etc +# needuser - operations that will be done as non-root user + +enter_target() { + if [ -z "$BUILD_SB2FLAGS" ]; then + if [ x$1 == xneeduser ]; then + shift + chroot $BUILD_TARGET su -c "${*}" - $BUILD_USER + elif [ x$1 == xneedscript ]; then + shift + SCRIPT=$1 + shift + chroot $BUILD_TARGET su -s $SCRIPT $BUILD_USER -- ${*} + else + shift + chroot $BUILD_TARGET ${*} + fi + else + if [ -z "$VM_TYPE" ]; then + echo "SB2 currently does not work with chroots.." + cleanup_and_exit 1 + fi + if [ -z "$SB2_TOOLCHAIN" ]; then + internal_set_sb2_settings $BUILD_SB2FLAGS + fi + if [ ! -e $BUILD_TARGET/.sb2inited ]; then + ORIG=$PWD + cd $BUILD_TARGET + su -c "cd $PWD; /usr/bin/sb2-init $SB2_SYSROOT -c $SB2_QEMU -n -N -m $SB2_DEFAULTMODE -t / oscbuild $SB2_TOOLCHAIN" - abuild + su -c "cd $PWD; /usr/bin/sb2-config -t oscbuild setenv SBOX_MAPPING_METHOD $SB2_MAPPING_METHOD" - abuild + + cd $ORIG + touch $BUILD_TARGET/.sb2inited + fi + if [ x$1 = xneedscript ]; then + PARAM=needuser + else + PARAM=$1 + fi + case "$PARAM" in + needroot) + shift + ORIG=$PWD + cd /target + if [ ! -e /home/abuild/sb2-session-needroot ]; then + SESSION="-S /home/abuild/sb2-session-needroot -t oscbuild" + else + SESSION="-J /home/abuild/sb2-session-needroot" + fi + su -c "cd $PWD; /usr/bin/sb2-config -t oscbuild setenv HOME /root" - abuild + su -c "cd $PWD; /usr/bin/sb2-config -t oscbuild setenv USER root" - abuild + su -c "cd $PWD; /usr/bin/sb2 $SESSION $SB2_DEBUG -m $SB2_INSTALLMODE -R ${*}" - abuild + RET=$? + cd $ORIG + return $RET + ;; + needuser) + # Debugging + shift + ORIG=$PWD + cd /target + if [ ! -e /home/abuild/sb2-session-needuser ]; then + SESSION="-S /home/abuild/sb2-session-needuser -t oscbuild" + else + SESSION="-J /home/abuild/sb2-session-needuser" + fi + su -c "cd $PWD; /usr/bin/sb2-config -t oscbuild setenv HOME /home/abuild" - abuild + su -c "cd $PWD; /usr/bin/sb2-config -t oscbuild setenv USER abuild" - abuild + su -c "cd $PWD; /usr/bin/sb2 $SESSION $SB2_DEBUG -m $SB2_DEFAULTMODE ${*}" - abuild + RET=$? + cd $ORIG + return $RET + ;; + *) + echo "Unknown parameter $1" >&2 + ;; + esac + fi +} + check_use_emulator() { INITVM_NAME= # check if the extended host arch contains the build arch @@ -105,6 +256,8 @@ check_use_emulator() { if test -e "$BUILD_DIR/$INITVM_NAME" -a -e "$BUILD_DIR/qemu-reg" ; then chmod 0755 "$BUILD_DIR/$INITVM_NAME" return 0 # chroot build, we need to run + elif test -n "$BUILD_SB2FLAGS" ; then + return 0 # Use sb2 fi # XXX: error? echo "Warning: cross compile not possible due to missing static binaries. please install build-initvm package for that purpose." diff --git a/expanddeps b/expanddeps index fd6dfdb..e9cff24 100755 --- a/expanddeps +++ b/expanddeps @@ -290,6 +290,7 @@ sub print_rpmlist { } print "preinstall: @{$cf->{'preinstall'} || []}\n"; print "vminstall: @{$cf->{'vminstall'} || []}\n"; + print "sb2install: @{$cf->{'sb2install'} || []}\n"; # install if is_emulator_arch print "runscripts: @{$cf->{'runscripts'} || []}\n"; print "dist: $dist\n" if defined $dist; print "installonly: $installonly\n" if defined $installonly; diff --git a/getsb2flags b/getsb2flags new file mode 100644 index 0000000..6f038ef --- /dev/null +++ b/getsb2flags @@ -0,0 +1,41 @@ +#!/usr/bin/perl -w + +BEGIN { + unshift @INC, ($::ENV{'BUILD_DIR'} || '/usr/lib/build'); +} + +use strict; + +use Build; + +my ($dist, $archs, $configdir, $debug); + +while (@ARGV) { + if ($ARGV[0] eq '--dist') { + shift @ARGV; + $dist = shift @ARGV; + next; + } + if ($ARGV[0] eq '--archpath') { + shift @ARGV; + $archs = shift @ARGV; + next; + } + if ($ARGV[0] eq '--configdir') { + shift @ARGV; + $configdir = shift @ARGV; + next; + } + last; +} + +die("Usage: getsb2flags --dist <dist> --archpath <archpath> [--configdir <configdir>]\n") if @ARGV; + +my $cf = Build::read_config_dist($dist, $archs, $configdir); +exit 0 unless $cf->{'optflags'}; +my $all = $cf->{'optflags'}->{'*'}; +$all = defined($all) && $all ne '' ? " $all" : ''; +for (sort keys %{$cf->{'sb2flags'}}) { + next if $_ eq '*'; + print "$_ $cf->{'sb2flags'}->{$_}$all\n"; +} diff --git a/init_buildsystem b/init_buildsystem index 0d8a29e..2f10d9e 100755 --- a/init_buildsystem +++ b/init_buildsystem @@ -121,6 +121,9 @@ PKGS=("$@") cleanup_and_exit() { trap EXIT test "$BUILD_ROOT" = / -a -n "$browner" && chown "$browner" "$BUILD_ROOT" + if [ -z "$PREPARE_VM" ]; then + cleanup_sb2 + fi # umount so init_buildsystem can be used standalone # XXX: use stat -f /dev/pts/ -c %T to check whether it's mounted and not suppress errors then? umount -n "$BUILD_ROOT/proc/sys/fs/binfmt_misc" 2> /dev/null || true @@ -144,7 +147,7 @@ clean_build_root() { rm -rf -- "$BUILD_ROOT"/.build.kernel.* rm -rf -- "$BUILD_ROOT"/.build.initrd.* rm -rf -- "$BUILD_ROOT/.root" - rm -rf -- "$BUILD_ROOT/.init_b_cache" + rm -rf -- "$BUILD_TARGET/.init_b_cache" rm -rf -- "$BUILD_ROOT"/.preinstall_image/* rm -rf -- "$BUILD_ROOT"/.preinstallimage* mkdir -p "$BUILD_ROOT/proc" @@ -184,7 +187,7 @@ preinstall_image() { TAR="tar -x" fi # pipe output through perl to print a dot every 1000 lines - if ! $TAR -z --exclude .build --exclude .init_b_cache -f "$BUILD_ROOT/.init_b_cache/rpms/$1" -v > >(tee "$BUILD_ROOT/.preinstallimage.unpack" | perl -e '$|=1; my $done=0; $done++ % 1000 or print "." while <STDIN>; print "\n";') 2>&1 ; then + if ! $TAR -z --exclude .build --exclude .init_b_cache -f "$BUILD_TARGET/.init_b_cache/rpms/$1" -v > >(tee "$BUILD_ROOT/.preinstallimage.unpack" | perl -e '$|=1; my $done=0; $done++ % 1000 or print "." while <STDIN>; print "\n";') 2>&1 ; then echo "unpack failed." test -e "$BUILD_ROOT/.preinstallimage.unpack" && cat "$BUILD_ROOT/.preinstallimage.unpack" cleanup_and_exit 1 @@ -195,8 +198,12 @@ preinstall_image() { preinstall() { local PKG="$1" check_exit - echo "preinstalling $PKG..." - cd $BUILD_ROOT || cleanup_and_exit 1 + echo "preinstalling $PKG... $2" + if test -n "$BUILD_SB2FLAGS" -a "$2" = tools ; then + cd $BUILD_ROOT || cleanup_and_exit 1 + else + cd $BUILD_TARGET || cleanup_and_exit 1 + fi if test -x /usr/bin/bsdtar ; then CPIO="/usr/bin/bsdtar -P --chroot -o --numeric-owner -x -f-" TAR="/usr/bin/bsdtar -P --chroot -o --numeric-owner -x" @@ -218,12 +225,12 @@ run_pkg_scripts() { reorder() { test -z "$*" && return - rm -f $BUILD_ROOT/.init_b_cache/order.manifest + rm -f $BUILD_TARGET/.init_b_cache/order.manifest for PKG in "$@" ; do - echo "$PKG" >> $BUILD_ROOT/.init_b_cache/order.manifest + echo "$PKG" >> $BUILD_TARGET/.init_b_cache/order.manifest done - $BUILD_DIR/order --dist "$BUILD_DIST" --archpath "$BUILD_ARCH" --configdir $CONFIG_DIR --manifest $BUILD_ROOT/.init_b_cache/order.manifest $BUILD_ROOT/.init_b_cache/rpms || touch $BUILD_ROOT/exit - rm -f $BUILD_ROOT/.init_b_cache/order.manifest + $BUILD_DIR/order --dist "$BUILD_DIST" --archpath "$BUILD_ARCH" --configdir $CONFIG_DIR --manifest $BUILD_TARGET/.init_b_cache/order.manifest $BUILD_TARGET/.init_b_cache/rpms || touch $BUILD_ROOT/exit + rm -f $BUILD_TARGET/.init_b_cache/order.manifest } create_devs() { @@ -425,9 +432,9 @@ getcachedir() { can_reuse_cached_package() { local cachepkgid pkgid xpkgid test -s "$1" || return 1 - if test -s "$BUILD_ROOT/.init_b_cache/rpms/$PKG.id" ; then + if test -s "$BUILD_TARGET/.init_b_cache/rpms/$PKG.id" ; then pkgid=$(perl -I$BUILD_DIR -MBuild -e Build::showquery "$1" buildid) - read cachepkgid < $BUILD_ROOT/.init_b_cache/rpms/$PKG.id + read cachepkgid < $BUILD_TARGET/.init_b_cache/rpms/$PKG.id # check if the build time is zero case $cachepkgid in *" 0-"*) xpkgid="${pkgid##* }"; pkgid="${pkgid% *} 0-${xpkgid#*-}" ;; @@ -492,18 +499,18 @@ fi if test -e $BUILD_ROOT/.build/init_buildsystem.data ; then # vm continuation . $BUILD_ROOT/.build/init_buildsystem.data - if ! test -e $BUILD_ROOT/.init_b_cache/preinstall_finished ; then + if ! test -e $BUILD_TARGET/.init_b_cache/preinstall_finished ; then # finish preinstall run_pkg_scripts pkg_initdb - touch $BUILD_ROOT/.init_b_cache/preinstall_finished + touch $BUILD_TARGET/.init_b_cache/preinstall_finished fi else # # now make sure that all the packages are installed. # - rm -rf "$BUILD_ROOT/.init_b_cache" - mkdir -p "$BUILD_ROOT/.init_b_cache/scripts" + rm -rf "$BUILD_TARGET/.init_b_cache" + mkdir -p "$BUILD_TARGET/.init_b_cache/scripts" if test -z "$RPMLIST" ; then # @@ -515,7 +522,7 @@ else # # select and expand packages # - RPMLIST=$BUILD_ROOT/.init_b_cache/rpmlist + RPMLIST=$BUILD_TARGET/.init_b_cache/rpmlist test -z "$LIST_STATE" && echo "expanding package dependencies..." if ! $BUILD_DIR/expanddeps $USEUSEDFORBUILD "${definesnstuff[@]}" --dist "$BUILD_DIST" --depfile "$CACHE_FILE" --archpath "$BUILD_ARCH" --configdir $CONFIG_DIR "${PKGS[@]}" > $RPMLIST ; then rm -f $BUILD_IS_RUNNING @@ -529,12 +536,13 @@ else test "$PKG" = "preinstall:" && continue test "$PKG" = "runscripts:" && continue test "$PKG" = "cbpreinstall:" && continue + test "$PKG" = "sb2install:" && continue test "$PKG" = "vminstall:" && continue test "$PKG" = "dist:" && continue test "$PKG" = "rpmid:" && continue echo "${SRC##*/}" - done < $BUILD_ROOT/.init_b_cache/rpmlist - rm -rf "$BUILD_ROOT/.init_b_cache" + done < $BUILD_TARGET/.init_b_cache/rpmlist + rm -rf "$BUILD_TARGET/.init_b_cache" cleanup_and_exit 0 fi @@ -565,11 +573,12 @@ else PACKAGES_TO_NOINSTALL= PREINSTALL_IMAGE= PREINSTALL_IMAGE_SOURCE= + PACKAGES_TO_SB2INSTALL= RUNSCRIPTS_SEEN= PACKAGES_FROM_PREINSTALLIMAGE= GUESSED_DIST=unknown - mkdir -p $BUILD_ROOT/.init_b_cache/rpms - rm -f $BUILD_ROOT/.init_b_cache/rpmlist.download + mkdir -p $BUILD_TARGET/.init_b_cache/rpms + rm -f $BUILD_TARGET/.init_b_cache/rpmlist.download while read PKG SRC ; do if test "$PKG" = "preinstall:" ; then PACKAGES_TO_PREINSTALL=$SRC @@ -589,13 +598,17 @@ else fi if test "$PKG" = "preinstallimage:" ; then PREINSTALL_IMAGE=${SRC##*/} - ln -s "$SRC" "$BUILD_ROOT/.init_b_cache/rpms/${SRC##*/}" + ln -s "$SRC" "$BUILD_TARGET/.init_b_cache/rpms/${SRC##*/}" continue fi if test "$PKG" = "preinstallimagesource:" ; then PREINSTALL_IMAGE_SOURCE="$SRC" continue fi + if test "$PKG" = "sb2install:" ; then + PACKAGES_TO_SB2INSTALL=$SRC + continue + fi if test "$PKG" = "runscripts:" ; then RUNSCRIPTS_SEEN=true PACKAGES_TO_RUNSCRIPTS=$SRC @@ -606,7 +619,7 @@ else continue fi if test "$PKG" = "rpmid:" ; then - echo "${SRC#*:}" > $BUILD_ROOT/.init_b_cache/rpms/${SRC%%:*}.id + echo "${SRC#*:}" > $BUILD_TARGET/.init_b_cache/rpms/${SRC%%:*}.id continue fi if test "$PKG" != "${PKG%:}"; then @@ -622,7 +635,7 @@ else if test "${SRC#/}" = "$SRC" ; then case "$SRC" in zypp://* | http://* | https://* | ftp://* | ftps://*) - echo "$PKG $SRC" >>$BUILD_ROOT/.init_b_cache/rpmlist.download + echo "$PKG $SRC" >>$BUILD_TARGET/.init_b_cache/rpmlist.download continue ;; *) @@ -631,10 +644,23 @@ else ;; esac fi + # downloadpkg modified $SRC, so it has a right name for use SRCSUF=${SRC/%.pkg.tar.?z/.arch} - ln -s "$SRC" "$BUILD_ROOT/.init_b_cache/rpms/$PKG.${SRCSUF##*.}" + ln -s "$SRC" "$BUILD_TARGET/.init_b_cache/rpms/$PKG.${SRCSUF##*.}" done < $RPMLIST + # SB2 installs aren't part of the natural order, filter them out + if test -n "$PACKAGES_TO_SB2INSTALL" ; then + for SB2PKG in $PACKAGES_TO_SB2INSTALL ; do + for PKG in $PACKAGES_TO_INSTALL ; do + if [ "x$PKG" != "x$SB2PKG" ]; then + NEWPACKAGES_TO_INSTALL="$NEWPACKAGES_TO_INSTALL $PKG" + fi + done + PACKAGES_TO_INSTALL="$NEWPACKAGES_TO_INSTALL" + done + fi + PACKAGES_TO_ALL="$PACKAGES_TO_INSTALL" PACKAGES_TO_AVAILABLE="$PACKAGES_TO_INSTALL" @@ -656,9 +682,9 @@ else fi # check if we really can use cached versions for packages on the download list - if test -s $BUILD_ROOT/.init_b_cache/rpmlist.download ; then + if test -s $BUILD_TARGET/.init_b_cache/rpmlist.download ; then echo "calculating packages to download..." - rm -f $BUILD_ROOT/.init_b_cache/rpmlist.download2 + rm -f $BUILD_TARGET/.init_b_cache/rpmlist.download2 while read PKG SRC ; do cachepkg="${SRC##*/}" cachepkg="${cachepkg/%.pkg.tar.?z/.arch}" @@ -668,26 +694,26 @@ else cachedir="${cachedir%/*}" if can_reuse_cached_package "$cachedir/$cachepkg" ; then SRCSUF=${SRC/%.pkg.tar.?z/.arch} - ln -s "$cachedir/$cachepkg" "$BUILD_ROOT/.init_b_cache/rpms/$PKG.${SRCSUF##*.}" + ln -s "$cachedir/$cachepkg" "$BUILD_TARGET/.init_b_cache/rpms/$PKG.${SRCSUF##*.}" continue fi fi cachedir="$(getcachedir "$SRC")" if can_reuse_cached_package "$cachedir/$cachepkg" ; then SRCSUF=${SRC/%.pkg.tar.?z/.arch} - ln -s "$cachedir/$cachepkg" "$BUILD_ROOT/.init_b_cache/rpms/$PKG.${SRCSUF##*.}" + ln -s "$cachedir/$cachepkg" "$BUILD_TARGET/.init_b_cache/rpms/$PKG.${SRCSUF##*.}" continue fi # not found in cache or cache has different package rm -f "$cachedir/$cachepkg" - echo "$PKG $SRC" >>$BUILD_ROOT/.init_b_cache/rpmlist.download2 - done < $BUILD_ROOT/.init_b_cache/rpmlist.download - rm -f $BUILD_ROOT/.init_b_cache/rpmlist.download - test -s $BUILD_ROOT/.init_b_cache/rpmlist.download2 && mv $BUILD_ROOT/.init_b_cache/rpmlist.download2 $BUILD_ROOT/.init_b_cache/rpmlist.download + echo "$PKG $SRC" >>$BUILD_TARGET/.init_b_cache/rpmlist.download2 + done < $BUILD_TARGET/.init_b_cache/rpmlist.download + rm -f $BUILD_TARGET/.init_b_cache/rpmlist.download + test -s $BUILD_TARGET/.init_b_cache/rpmlist.download2 && mv $BUILD_TARGET/.init_b_cache/rpmlist.download2 $BUILD_TARGET/.init_b_cache/rpmlist.download fi # now do the download of missing packages - if test -s $BUILD_ROOT/.init_b_cache/rpmlist.download ; then + if test -s $BUILD_TARGET/.init_b_cache/rpmlist.download ; then PACKAGES_TO_DOWNLOAD=`cat ${RPMLIST}.download|awk '{print $2}'` progress_setup PACKAGES_TO_DOWNLOAD while read PKG SRC ; do @@ -695,12 +721,13 @@ else downloadpkg "$SRC" # downloadpkg modified $SRC, so it has a right name for use SRCSUF=${SRC/%.pkg.tar.?z/.arch} - ln -s "$SRC" "$BUILD_ROOT/.init_b_cache/rpms/$PKG.${SRCSUF##*.}" - done < $BUILD_ROOT/.init_b_cache/rpmlist.download - rm -f $BUILD_ROOT/.init_b_cache/rpmlist.download + ln -s "$SRC" "$BUILD_TARGET/.init_b_cache/rpms/$PKG.${SRCSUF##*.}" + done < $BUILD_TARGET/.init_b_cache/rpmlist.download + rm -f $BUILD_TARGET/.init_b_cache/rpmlist.download echo fi + test -n "$PACKAGES_TO_SB2INSTALL" && echo "sb2install : $PACKAGES_TO_SB2INSTALL" # compatibility... test -z "$RUNSCRIPTS_SEEN" && PACKAGES_TO_RUNSCRIPTS="$PACKAGES_TO_PREINSTALL" @@ -712,7 +739,7 @@ else if test -n "$PREINSTALL_IMAGE" ; then for PKG in $PACKAGES_FROM_PREINSTALLIMAGE ; do # touch the file so that the copying works - touch $BUILD_ROOT/.init_b_cache/rpms/"$PKG.$PSUF" + touch $BUILD_TARGET/.init_b_cache/rpms/"$PKG.$PSUF" done fi @@ -722,11 +749,11 @@ fi # test if we need to preinstall # if test ! -e $BUILD_ROOT/installed-pkg -a ! -e $BUILD_ROOT/.build/init_buildsystem.data ; then - mkdir -p $BUILD_ROOT/etc || cleanup_and_exit 1 - mkdir -p $BUILD_ROOT/proc || cleanup_and_exit 1 - test -f $BUILD_ROOT/etc/HOSTNAME || hostname -f > $BUILD_ROOT/etc/HOSTNAME + mkdir -p $BUILD_TARGET/etc || cleanup_and_exit 1 + mkdir -p $BUILD_TARGET/proc || cleanup_and_exit 1 + test -f $BUILD_TARGET/etc/HOSTNAME || hostname -f > $BUILD_TARGET/etc/HOSTNAME for PKG in $PACKAGES_TO_RUNSCRIPTS ; do - : > $BUILD_ROOT/.init_b_cache/scripts/$PKG.run + : > $BUILD_TARGET/.init_b_cache/scripts/$PKG.run done PACKAGES_TO_PREINSTALL_FILTERED="$PACKAGES_TO_PREINSTALL" PACKAGES_TO_VMINSTALL_FILTERED="$PACKAGES_TO_VMINSTALL" @@ -737,10 +764,19 @@ if test ! -e $BUILD_ROOT/installed-pkg -a ! -e $BUILD_ROOT/.build/init_buildsyst PACKAGES_TO_VMINSTALL_FILTERED=`preinstall_image_filter $PACKAGES_TO_VMINSTALL_FILTERED` fi PACKAGES_TO_PREINSTALL_FILTERED=`reorder $PACKAGES_TO_PREINSTALL_FILTERED` + if test -n "$PACKAGES_TO_SB2INSTALL" ; then + mkdir -p $BUILD_ROOT/target + progress_setup PACKAGES_TO_SB2INSTALL + for PKG in $PACKAGES_TO_SB2INSTALL ; do + progress_step PACKAGES_TO_SB2INSTALL + preinstall ${PKG##*/} tools + done + fi progress_setup PACKAGES_TO_PREINSTALL_FILTERED for PKG in $PACKAGES_TO_PREINSTALL_FILTERED ; do progress_step PACKAGES_TO_PREINSTALL_FILTERED preinstall ${PKG##*/} + cd $BUILD_ROOT done echo if test -n "$PREPARE_VM" ; then @@ -749,6 +785,7 @@ if test ! -e $BUILD_ROOT/installed-pkg -a ! -e $BUILD_ROOT/.build/init_buildsyst for PKG in $PACKAGES_TO_VMINSTALL_FILTERED ; do progress_step PACKAGES_TO_VMINSTALL_FILTERED preinstall ${PKG##*/} + cd $BUILD_ROOT done fi # for reorder @@ -756,12 +793,12 @@ if test ! -e $BUILD_ROOT/installed-pkg -a ! -e $BUILD_ROOT/.build/init_buildsyst if test -w /root ; then test -c $BUILD_ROOT/dev/null || create_devs fi - test -e $BUILD_ROOT/etc/fstab || touch $BUILD_ROOT/etc/fstab - test ! -e $BUILD_ROOT/etc/ld.so.conf -a -e $BUILD_ROOT/etc/ld.so.conf.in && cp $BUILD_ROOT/etc/ld.so.conf.in $BUILD_ROOT/etc/ld.so.conf + test -e $BUILD_TARGET/etc/fstab || touch $BUILD_TARGET/etc/fstab + test ! -e $BUILD_TARGET/etc/ld.so.conf -a -e $BUILD_TARGET/etc/ld.so.conf.in && cp $BUILD_TARGET/etc/ld.so.conf.in $BUILD_TARGET/etc/ld.so.conf if test -z "$PREPARE_VM" ; then run_pkg_scripts pkg_initdb - touch $BUILD_ROOT/.init_b_cache/preinstall_finished + touch $BUILD_TARGET/.init_b_cache/preinstall_finished fi # mark as preinstalled no longer needed rm -rf "$BUILD_ROOT/installed-pkg" @@ -771,9 +808,9 @@ fi if test -n "$PREPARE_VM" ; then echo "copying packages..." for PKG in $PACKAGES_TO_ALL ; 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 + rm -f $BUILD_TARGET/.init_b_cache/$PKG.$PSUF + cp $BUILD_TARGET/.init_b_cache/rpms/$PKG.$PSUF $BUILD_TARGET/.init_b_cache/$PKG.$PSUF || cleanup_and_exit 1 + ln -s -f ../$PKG.$PSUF $BUILD_TARGET/.init_b_cache/rpms/$PKG.$PSUF check_exit done # alreadyinstalled check will not work, but we have to live with that... @@ -806,8 +843,8 @@ if test -n "$CREATE_BUILD_BINARIES" ; then echo "creating .build.binaries directory..." mkdir -p "$BUILD_ROOT/.build.binaries" for PKG in $PACKAGES_TO_AVAILABLE ; do - test -L "$BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF" || continue - LPKG=`readlink -f "$BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF"` + test -L "$BUILD_TARGET/.init_b_cache/rpms/$PKG.$PSUF" || continue + LPKG=`readlink -f "$BUILD_TARGET/.init_b_cache/rpms/$PKG.$PSUF"` ln "$LPKG" "$BUILD_ROOT/.build.binaries/$PKG.$PSUF" 2>/dev/null test -f "$BUILD_ROOT/.build.binaries/$PKG.$PSUF" && continue cp "$LPKG" "$BUILD_ROOT/.build.binaries/$PKG.$PSUF" @@ -828,10 +865,10 @@ fi # # get list and ids of already installed packages # -mkdir -p $BUILD_ROOT/.init_b_cache/alreadyinstalled -listinstalled --root "$BUILD_ROOT" --type "$PSUF" --extraname | ( +mkdir -p $BUILD_TARGET/.init_b_cache/alreadyinstalled +listinstalled --root "$BUILD_TARGET" --type "$PSUF" --extraname | ( while read id name buildid; do - echo "$buildid" > "$BUILD_ROOT/.init_b_cache/alreadyinstalled/$name" + echo "$buildid" > "$BUILD_TARGET/.init_b_cache/alreadyinstalled/$name" done ) @@ -841,28 +878,28 @@ pkg_prepare # # delete all packages we don't want # -mkdir -p $BUILD_ROOT/.init_b_cache/todelete -for PKG in $BUILD_ROOT/.init_b_cache/alreadyinstalled/* ; do +mkdir -p $BUILD_TARGET/.init_b_cache/todelete +for PKG in $BUILD_TARGET/.init_b_cache/alreadyinstalled/* ; do PKG=${PKG##*/} test "$PKG" = "*" && continue - ln $BUILD_ROOT/.init_b_cache/alreadyinstalled/$PKG $BUILD_ROOT/.init_b_cache/todelete/$PKG + ln $BUILD_TARGET/.init_b_cache/alreadyinstalled/$PKG $BUILD_TARGET/.init_b_cache/todelete/$PKG done for PKG in $PACKAGES_TO_INSTALL; do - rm -f $BUILD_ROOT/.init_b_cache/todelete/$PKG + rm -f $BUILD_TARGET/.init_b_cache/todelete/$PKG done -for PKG in $BUILD_ROOT/.init_b_cache/todelete/* ; do +for PKG in $BUILD_TARGET/.init_b_cache/todelete/* ; do PKG=${PKG##*/} test "$PKG" = "*" && continue echo "deleting $PKG" pkg_erase check_exit done -rm -rf "$BUILD_ROOT/.init_b_cache/todelete" +rm -rf "$BUILD_TARGET/.init_b_cache/todelete" -rm -rf "$BUILD_ROOT/.init_b_cache/preinstalls" -mkdir -p "$BUILD_ROOT/.init_b_cache/preinstalls" +rm -rf "$BUILD_TARGET/.init_b_cache/preinstalls" +mkdir -p "$BUILD_TARGET/.init_b_cache/preinstalls" for PKG in $PACKAGES_TO_PREINSTALL; do - touch "$BUILD_ROOT/.init_b_cache/preinstalls/$PKG" + touch "$BUILD_TARGET/.init_b_cache/preinstalls/$PKG" done rm -rf "$BUILD_ROOT/installed-pkg" @@ -876,7 +913,9 @@ for PKG in $MAIN_LIST ; do test -f $BUILD_ROOT/installed-pkg/$PKG && continue progress_step MAIN_LIST - if test -e "$BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF" -a ! -s "$BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF" ; then + cd $BUILD_TARGET + + if test -e "$BUILD_TARGET/.init_b_cache/rpms/$PKG.$PSUF" -a ! -s "$BUILD_TARGET/.init_b_cache/rpms/$PKG.$PSUF" ; then # preinstallimage package, make sure it's in the image if ! test -e $BUILD_ROOT/.preinstall_image/$PKG ; then echo "Package $PKG is missing from the preinstall image" @@ -891,29 +930,29 @@ for PKG in $MAIN_LIST ; do # get the hdrmd5 if we want to create a preinstall image PKG_HDRMD5= if test -d $BUILD_ROOT/.preinstall_image -a ! -e $BUILD_ROOT/.preinstall_image/$PKG ; then - PKG_HDRMD5=`perl -I$BUILD_DIR -MBuild -e 'print Build::queryhdrmd5($ARGV[0])' $BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF` + PKG_HDRMD5=`perl -I$BUILD_DIR -MBuild -e 'print Build::queryhdrmd5($ARGV[0])' $BUILD_TARGET/.init_b_cache/rpms/$PKG.$PSUF` test -n "$PKG_HDRMD5" || cleanup_and_exit 1 fi - test -L $BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF || continue + test -L $BUILD_TARGET/.init_b_cache/rpms/$PKG.$PSUF || continue # check if we can keep an already installed package - if test "$VERIFY_BUILD_SYSTEM" != true -a -f $BUILD_ROOT/.init_b_cache/rpms/$PKG.id -a -f $BUILD_ROOT/.init_b_cache/alreadyinstalled/$PKG ; then - read PKGID < $BUILD_ROOT/.init_b_cache/rpms/$PKG.id - read OLDPKGID < $BUILD_ROOT/.init_b_cache/alreadyinstalled/$PKG + if test "$VERIFY_BUILD_SYSTEM" != true -a -f $BUILD_TARGET/.init_b_cache/rpms/$PKG.id -a -f $BUILD_TARGET/.init_b_cache/alreadyinstalled/$PKG ; then + read PKGID < $BUILD_TARGET/.init_b_cache/rpms/$PKG.id + read OLDPKGID < $BUILD_TARGET/.init_b_cache/alreadyinstalled/$PKG if test "$PKGID" = "$OLDPKGID" ; then #echo "keeping ${PKGID%% *}" - rm -f $BUILD_ROOT/.init_b_cache/$PKG.$PSUF + rm -f $BUILD_TARGET/.init_b_cache/$PKG.$PSUF echo "$PKGID" > $BUILD_ROOT/installed-pkg/$PKG test -n "$PKG_HDRMD5" && echo "$PKG_HDRMD5 $PKGID" > $BUILD_ROOT/.preinstall_image/$PKG continue fi fi - PKGID=$(perl -I$BUILD_DIR -MBuild -e Build::showquery "$BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF" buildid) + PKGID=$(perl -I$BUILD_DIR -MBuild -e Build::showquery "$BUILD_TARGET/.init_b_cache/rpms/$PKG.$PSUF" buildid) - if test -f $BUILD_ROOT/.init_b_cache/alreadyinstalled/$PKG ; then - read OLDPKGID < $BUILD_ROOT/.init_b_cache/alreadyinstalled/$PKG + if test -f $BUILD_TARGET/.init_b_cache/alreadyinstalled/$PKG ; then + read OLDPKGID < $BUILD_TARGET/.init_b_cache/alreadyinstalled/$PKG if test "$PKGID" != "$OLDPKGID" ; then echo "deleting unwanted ${OLDPKGID%% *}" pkg_erase @@ -927,7 +966,7 @@ for PKG in $MAIN_LIST ; do echo "deleting incomplete ${OLDPKGID%% *}" pkg_erase fi - if test -e "$BUILD_ROOT/.init_b_cache/preinstalls/$PKG" ; then + if test -e "$BUILD_TARGET/.init_b_cache/preinstalls/$PKG" ; then preinstall "$PKG" fi check_exit @@ -940,13 +979,13 @@ for PKG in $MAIN_LIST ; do # install the package echo "installing ${PKGID%% *}" - if ! test "$BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF" -ef "$BUILD_ROOT/.init_b_cache/$PKG.$PSUF" ; then - 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 + if ! test "$BUILD_TARGET/.init_b_cache/rpms/$PKG.$PSUF" -ef "$BUILD_TARGET/.init_b_cache/$PKG.$PSUF" ; then + rm -f $BUILD_TARGET/.init_b_cache/$PKG.$PSUF + cp $BUILD_TARGET/.init_b_cache/rpms/$PKG.$PSUF $BUILD_TARGET/.init_b_cache/$PKG.$PSUF || cleanup_and_exit 1 fi pkg_install check_exit - rm -f $BUILD_ROOT/.init_b_cache/$PKG.$PSUF + rm -f $BUILD_TARGET/.init_b_cache/$PKG.$PSUF echo "$PKGID" > $BUILD_ROOT/installed-pkg/$PKG test -n "$PKG_HDRMD5" && echo "$PKG_HDRMD5 $PKGID" > $BUILD_ROOT/.preinstall_image/$PKG @@ -963,17 +1002,17 @@ cd $BUILD_ROOT || cleanup_and_exit 1 # # setup /etc/mtab # -rm -f $BUILD_ROOT/etc/mtab -cp /proc/mounts $BUILD_ROOT/etc/mtab -chmod 644 $BUILD_ROOT/etc/mtab +rm -f $BUILD_TARGET/etc/mtab +cp /proc/mounts $BUILD_TARGET/etc/mtab +chmod 644 $BUILD_TARGET/etc/mtab # # make sure, that our nis is not present in the chroot system # -test -e $BUILD_ROOT/etc/nsswitch.conf && { - echo "removing nis flags from $BUILD_ROOT/etc/nsswitch.conf..." - cat $BUILD_ROOT/etc/nsswitch.conf | sed -e"s:nis::g" > $BUILD_ROOT/etc/nsswitch.conf.tmp - mv $BUILD_ROOT/etc/nsswitch.conf.tmp $BUILD_ROOT/etc/nsswitch.conf +test -e $BUILD_TARGET/etc/nsswitch.conf && { + echo "removing nis flags from $BUILD_TARGET/etc/nsswitch.conf..." + cat $BUILD_TARGET/etc/nsswitch.conf | sed -e"s:nis::g" > $BUILD_TARGET/etc/nsswitch.conf.tmp + mv $BUILD_TARGET/etc/nsswitch.conf.tmp $BUILD_TARGET/etc/nsswitch.conf } # @@ -982,21 +1021,21 @@ test -e $BUILD_ROOT/etc/nsswitch.conf && { for DIR in /usr/share/doc/packages \ /usr/X11R6/include/X11/pixmaps \ /usr/X11R6/include/X11/bitmaps ; do - mkdir -p $BUILD_ROOT/$DIR + mkdir -p $BUILD_TARGET/$DIR done for FILE in /var/run/utmp /var/log/wtmp /etc/fstab ; do - mkdir -p $BUILD_ROOT/${FILE%/*} - touch $BUILD_ROOT/$FILE + mkdir -p $BUILD_TARGET/${FILE%/*} + touch $BUILD_TARGET/$FILE done echo now finalizing build dir... -if test -x $BUILD_ROOT/sbin/ldconfig ; then - CHROOT_RETURN="`chroot $BUILD_ROOT /sbin/ldconfig 2>&1`" +if test -x $BUILD_TARGET/sbin/ldconfig ; then + CHROOT_RETURN="`enter_target needroot /sbin/ldconfig 2>&1`" case "$CHROOT_RETURN" in *warning:*) - chroot $BUILD_ROOT /sbin/ldconfig + enter_target needroot /sbin/ldconfig echo - echo chroot $BUILD_ROOT /sbin/ldconfig + echo chroot $BUILD_TARGET /sbin/ldconfig echo echo "$CHROOT_RETURN" echo @@ -1007,54 +1046,54 @@ if test -x $BUILD_ROOT/sbin/ldconfig ; then esac fi -if test -x $BUILD_ROOT/usr/sbin/Check && ! grep -q "/usr/sbin/Check is obsolete" $BUILD_ROOT/usr/sbin/Check ; then - chroot $BUILD_ROOT /usr/sbin/Check +if test -x $BUILD_TARGET/usr/sbin/Check && ! grep -q "/usr/sbin/Check is obsolete" $BUILD_TARGET/usr/sbin/Check ; then + enter_target needroot /usr/sbin/Check fi -mkdir -p $BUILD_ROOT/var/adm/packages -touch $BUILD_ROOT/var/adm/packages +mkdir -p $BUILD_TARGET/var/adm/packages +touch $BUILD_TARGET/var/adm/packages -if test -x $BUILD_ROOT/sbin/SuSEconfig ; then - if grep norestarts $BUILD_ROOT/sbin/SuSEconfig > /dev/null ; then - chroot $BUILD_ROOT /sbin/SuSEconfig --norestarts --force +if test -x $BUILD_TARGET/sbin/SuSEconfig ; then + if grep norestarts $BUILD_TARGET/sbin/SuSEconfig > /dev/null ; then + enter_target needroot /sbin/SuSEconfig --norestarts --force else - chroot $BUILD_ROOT /sbin/SuSEconfig --force + enter_target needroot /sbin/SuSEconfig --force fi fi -if test -x $BUILD_ROOT/usr/X11R6/bin/switch2mesasoft ; then - chroot $BUILD_ROOT /usr/X11R6/bin/switch2mesasoft +if test -x $BUILD_TARGET/usr/X11R6/bin/switch2mesasoft ; then + enter_target needroot /usr/X11R6/bin/switch2mesasoft fi for PROG in /usr/bin/TeX/texhash /usr/bin/texhash ; do - test -x $BUILD_ROOT/$PROG && \ - chroot $BUILD_ROOT bash -c ". /etc/profile ; $PROG" + test -x $BUILD_TARGET/$PROG && \ + enter_target needroot bash -c ". /etc/profile ; $PROG" done -if test -e $BUILD_ROOT/usr/share/zoneinfo/UTC ; then +if test -e $BUILD_TARGET/usr/share/zoneinfo/UTC ; then for PROG in /usr/sbin/zic /usr/bin/zic /bin/zic /sbin/zic ; do - test -x $BUILD_ROOT/$PROG && chroot $BUILD_ROOT bash -c "$PROG -l \$(readlink -f /usr/share/zoneinfo/UTC)" + test -x $BUILD_TARGET/$PROG && enter_target needroot bash -c "$PROG -l \$(readlink -f /usr/share/zoneinfo/UTC)" done fi test -e $BUILD_ROOT/.build/init_buildsystem.data || HOST=`hostname` -test -e $BUILD_ROOT/etc/hosts || echo "127.0.0.1 localhost" > $BUILD_ROOT/etc/hosts -if ! grep -F "127.0.0.1 $HOST" $BUILD_ROOT/etc/hosts > /dev/null ; then +test -e $BUILD_TARGET/etc/hosts || echo "127.0.0.1 localhost" > $BUILD_TARGET/etc/hosts +if ! grep -F "127.0.0.1 $HOST" $BUILD_TARGET/etc/hosts > /dev/null ; 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 + echo "127.0.0.1 $HOST" > $BUILD_TARGET/etc/hosts.new + test -f $BUILD_TARGET/etc/hosts && cat $BUILD_TARGET/etc/hosts >> $BUILD_TARGET/etc/hosts.new + mv $BUILD_TARGET/etc/hosts.new $BUILD_TARGET/etc/hosts fi # XXX: still needed? -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 +if test -x $BUILD_TARGET/bin/rpm -a ! -f $BUILD_TARGET/var/lib/rpm/packages.rpm -a ! -f $BUILD_TARGET/var/lib/rpm/Packages ; then pkg_initdb_rpm - chroot $BUILD_ROOT rpm -q --whatprovides rpm >/dev/null 2>&1 # create provides index + enter_target needroot rpm -q --whatprovides rpm >/dev/null 2>&1 # create provides index fi -rm -f $BUILD_ROOT/.rpmmacros $BUILD_ROOT/root/.rpmmacros -rm -rf "$BUILD_ROOT/.init_b_cache" +rm -f $BUILD_TARGET/.rpmmacros $BUILD_TARGET/root/.rpmmacros +rm -rf "$BUILD_TARGET/.init_b_cache" rm -f $BUILD_IS_RUNNING rm -f $TMPFILE diff --git a/initscript_sb2 b/initscript_sb2 new file mode 100644 index 0000000..e896f12 --- /dev/null +++ b/initscript_sb2 @@ -0,0 +1,23 @@ +#!/bin/bash +ABUILD_UID=399 +ABUILD_GID=399 + +echo "Setting up abuild user in $BUILD_ROOT for SB2" +echo "abuild::${ABUILD_UID}:${ABUILD_GID}:Autobuild:/home/abuild:/bin/bash" >> /etc/passwd +echo 'abuild:*:::::::' >>/etc/shadow # This is needed on Mandriva 2009 +echo 'abuild:*::' >>/etc/gshadow # This is needed on Ubuntu +echo "abuild::${ABUILD_GID}:" >>/etc/group +mkdir -p /target /home/abuild +chmod 775 /target +chown -R "$ABUILD_UID:$ABUILD_GID" /target /home/abuild +if [ -e /home/abuild/sb2-session-needroot ]; then + rm -rf /home/abuild/sb2-session-needroot +fi +if [ -e /home/abuild/sb2-session-needuser ]; then + rm -rf /home/abuild/sb2-session-needuser +fi +if [ -e /target/.sb2inited ]; then + rm -rf /target/.sb2inited +fi +unset BUILD_DIR BUILD_ROOT +exec /.build/build -- 2.1.0
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Contact
Support
@OBShq
The Open Build Service is an
openSUSE project
.
Log In
Places
Places
All Projects
Status Monitor