Log In
Log In
Places
All Projects
Status Monitor
Collapse sidebar
obs:server:fedora:2.9
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 10d77f5670afb707e0c6f239b3efebd76d2426f2 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 | 82 +++++++------- build-recipe-dsc | 6 +- build-recipe-spec | 62 +++++------ build-vm | 14 ++- build-vm-sb2 | 48 +++++++++ common_functions | 153 +++++++++++++++++++++++++++ expanddeps | 1 + getsb2flags | 41 +++++++ init_buildsystem | 264 ++++++++++++++++++++++++++-------------------- initscript_sb2 | 23 ++++ 16 files changed, 632 insertions(+), 283 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 f863ca7..d169db9 100644 --- a/Build.pm +++ b/Build.pm @@ -300,6 +300,7 @@ sub read_config { $config->{'vminstall'} = []; $config->{'cbpreinstall'} = []; $config->{'cbinstall'} = []; + $config->{'sb2install'} = []; $config->{'runscripts'} = []; $config->{'required'} = []; $config->{'support'} = []; @@ -310,6 +311,7 @@ sub read_config { $config->{'substitute'} = {}; $config->{'substitute_vers'} = {}; $config->{'optflags'} = {}; + $config->{'sb2flags'} = {}; $config->{'order'} = {}; $config->{'exportfilter'} = {}; $config->{'publishfilter'} = []; @@ -339,7 +341,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:' || $l0 eq 'publishflags:') { + 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:' || $l0 eq 'publishflags:') { my $t = substr($l0, 0, -1); for my $l (@l) { if ($l eq '!*') { @@ -380,6 +382,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 '!*') { @@ -427,7 +433,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}}) ]; } init_helper_hashes($config); @@ -758,6 +764,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 07e1f68..2c5db7b 100644 --- a/Makefile +++ b/Makefile @@ -45,9 +45,11 @@ install: getbinaryid \ getbuildids \ killchroot \ + getsb2flags \ queryconfig \ common_functions \ init_buildsystem \ + initscript_sb2 \ substitutedeps \ debtransform \ debtransformbz2 \ diff --git a/build b/build index e8390d8..30e4bc5 100755 --- a/build +++ b/build @@ -40,7 +40,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 @@ -442,6 +442,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 @@ -524,7 +525,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 @@ -562,7 +563,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" @@ -612,7 +613,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) @@ -626,7 +627,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 @@ -638,28 +639,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" } @@ -670,11 +671,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" @@ -715,8 +716,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" @@ -726,13 +727,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 @@ -1134,6 +1135,15 @@ if test -n "$DO_WIPE" ; then cleanup_and_exit fi +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 kill_running_build cleanup_and_exit @@ -1157,7 +1167,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 if test "$DO_INIT" = false -a -n "$RUN_SHELL"; then mount_stuff @@ -1191,6 +1212,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 @@ -1240,6 +1265,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_ROOT:+ in $VM_ROOT}" @@ -1361,8 +1387,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 @@ -1384,49 +1410,49 @@ 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 - if test -n "$RUNNING_IN_VM" ; then + if test -n "$RUNNING_IN_VM" -a "$VM_TYPE" != "sb2" ; then vm_setup_network fi @@ -1569,7 +1595,7 @@ TIME_RPMLINT=0 TIME_BUILDCMP=0 TIME_DELTARPMS=0 -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 # workaround for broken 13.1 check scripts which umount /proc if test -n "$RUNNING_IN_VM" -a "$BUILD_ROOT" = / ; then @@ -1581,7 +1607,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 TIME_POSTCHECKS=`date +%s` - 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 @@ -1615,7 +1641,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 TIME_BUILDCMP=`date +%s` recipe_compare_oldpackages TIME_BUILDCMP=$(( `date +%s` - $TIME_BUILDCMP )) diff --git a/build-pkg b/build-pkg index fce1de2..a83b2e0 100644 --- a/build-pkg +++ b/build-pkg @@ -66,9 +66,9 @@ pkg_autodetect_type() { cleanup_and_exit 1 "cannot autodetect build type when using a preinstall image" 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 cleanup_and_exit 1 "could not autodetect package type" fi diff --git a/build-pkg-arch b/build-pkg-arch index 5fcd9ac..8224c2d 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() { @@ -50,7 +50,7 @@ pkg_install_arch() { # https://bbs.archlinux.org/viewtopic.php?id=129661 (cd $BUILD_ROOT/etc && sed -i "s/^CheckSpace/#CheckSpace/g" pacman.conf) # -d -d disables deps checking - ( cd $BUILD_ROOT && chroot $BUILD_ROOT pacman -U --overwrite '*' -d -d --noconfirm .init_b_cache/$PKG.$PSUF 2>&1 || touch $BUILD_ROOT/exit ) | \ + ( cd $BUILD_TARGET && enter_target needroot pacman -U --overwrite '*' -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|looking for conflicting packages|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|:: Processing package changes|checking available disk space|installing |upgrading |warning:.*is up to date -- reinstalling|Optional dependencies for| )/||/^$/||print' } @@ -59,7 +59,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" @@ -68,9 +68,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 26facaf..fcb81d7 100644 --- a/build-pkg-deb +++ b/build-pkg-deb @@ -34,40 +34,42 @@ deb_chroot () # when doing a 'chroot /' call lets subshell and change dir manually # ( - cd $1 && + # Ignore first argument (it's always $BUILD_ROOT) + shift + cd "$BUILD_TARGET" && DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical \ DEBCONF_NONINTERACTIVE_SEEN=true \ LC_ALL=C LANGUAGE=C LANG=C \ - chroot $* + enter_target needroot $* ) } 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 + 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 # Install a policy so that services are not started. See # https://manpages.debian.org/unstable/init-system-helpers/invoke-rc.d.8.en.html # for details. - mkdir -p $BUILD_ROOT/usr/sbin - cat > $BUILD_ROOT/usr/sbin/policy-rc.d <<EOF + mkdir -p $BUILD_TARGET/usr/sbin + cat > $BUILD_TARGET/usr/sbin/policy-rc.d <<EOF #!/bin/sh exit 101 EOF - chmod 755 $BUILD_ROOT/usr/sbin/policy-rc.d + chmod 755 $BUILD_TARGET/usr/sbin/policy-rc.d } 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 DEB_UNSAFE_IO= chroot $BUILD_ROOT dpkg --force-unsafe-io --version >/dev/null 2>&1 && DEB_UNSAFE_IO="--force-unsafe-io" @@ -86,15 +88,15 @@ pkg_install_deb() { # 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() { @@ -103,7 +105,7 @@ pkg_erase_deb() { while read line; do case "$line" in subprocess\ installed\ *script\ returned\ error\ exit\ status*) - chroot $BUILD_ROOT rm -f /var/lib/dpkg/info/$PKG.{pre,post}rm + deb_chroot $BUILD_ROOT rm -f /var/lib/dpkg/info/$PKG.{pre,post}rm retry=1 ;; *) echo "$line" ;; @@ -136,7 +138,7 @@ pkg_finalize_deb() { } 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 if test -f "control.tar.gz" ; then $TAR -C .init_b_cache/scripts/control -z -f control.tar.gz @@ -156,20 +158,20 @@ pkg_preinstall_deb() { } pkg_runscripts_deb() { - if ! test -e $BUILD_ROOT/var/lib/dpkg/status ; then + if ! test -e $BUILD_TARGET/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" deb_chroot $BUILD_ROOT ".init_b_cache/scripts/$PKG.pre" install \ < /dev/null - rm -f "$BUILD_ROOT/.init_b_cache/scripts/$PKG.pre" + 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" deb_chroot $BUILD_ROOT ".init_b_cache/scripts/$PKG.post" configure '' \ < /dev/null - rm -f "$BUILD_ROOT/.init_b_cache/scripts/$PKG.post" + rm -f "$BUILD_TARGET/.init_b_cache/scripts/$PKG.post" fi } diff --git a/build-pkg-rpm b/build-pkg-rpm index c2642b6..37fa8a1 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" ;; zstd) rpm --showrc | egrep 'PayloadIsZstd' > /dev/null || PAYLOADDECOMPRESS="zstd -d" ;; @@ -174,15 +174,15 @@ pkg_preinstall_rpm() { fi fi if test "$PAYLOADDECOMPRESS" = cat ; then - rpm2cpio "$BUILD_ROOT/.init_b_cache/rpms/$PKG.rpm" | $CPIO || cleanup_and_exit 1 + rpm2cpio "$BUILD_TARGET/.init_b_cache/rpms/$PKG.rpm" | $CPIO || cleanup_and_exit 1 else - rpm2cpio "$BUILD_ROOT/.init_b_cache/rpms/$PKG.rpm" | $PAYLOADDECOMPRESS | $CPIO || cleanup_and_exit 1 + rpm2cpio "$BUILD_TARGET/.init_b_cache/rpms/$PKG.rpm" | $PAYLOADDECOMPRESS | $CPIO || cleanup_and_exit 1 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 "%{PREINPROG}" "$BUILD_ROOT/.init_b_cache/rpms/$PKG.rpm" > ".init_b_cache/scripts/$PKG.preprog" - 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 "%{POSTINPROG}" "$BUILD_ROOT/.init_b_cache/rpms/$PKG.rpm" > ".init_b_cache/scripts/$PKG.postprog" + 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 "%{PREINPROG}" "$BUILD_TARGET/.init_b_cache/rpms/$PKG.rpm" > ".init_b_cache/scripts/$PKG.preprog" + rpm -qp --nodigest --nosignature --qf "%{POSTIN}" "$BUILD_TARGET/.init_b_cache/rpms/$PKG.rpm" > ".init_b_cache/scripts/$PKG.post" + rpm -qp --nodigest --nosignature --qf "%{POSTINPROG}" "$BUILD_TARGET/.init_b_cache/rpms/$PKG.rpm" > ".init_b_cache/scripts/$PKG.postprog" 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" @@ -191,25 +191,25 @@ 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" local prog - read prog < "$BUILD_ROOT/.init_b_cache/scripts/$PKG.preprog" - (cd $BUILD_ROOT && chroot $BUILD_ROOT "${prog:-sh}" ".init_b_cache/scripts/$PKG.pre" 0) - rm -f "$BUILD_ROOT/.init_b_cache/scripts/$PKG.pre" "$BUILD_ROOT/.init_b_cache/scripts/$PKG.preprog" + read prog < "$BUILD_TARGET/.init_b_cache/scripts/$PKG.preprog" + cd $BUILD_TARGET && enter_target needroot "${prog:-sh}" ".init_b_cache/scripts/$PKG.pre" 0 + rm -f "$BUILD_TARGET/.init_b_cache/scripts/$PKG.pre" "$BUILD_TARGET/.init_b_cache/scripts/$PKG.preprog" 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" local prog - read prog < "$BUILD_ROOT/.init_b_cache/scripts/$PKG.postprog" - (cd $BUILD_ROOT && chroot $BUILD_ROOT "${prog:-sh}" ".init_b_cache/scripts/$PKG.post" 1) - rm -f "$BUILD_ROOT/.init_b_cache/scripts/$PKG.post" "$BUILD_ROOT/.init_b_cache/scripts/$PKG.postprog" + read prog < "$BUILD_TARGET/.init_b_cache/scripts/$PKG.postprog" + cd $BUILD_TARGET && enter_target needroot "${prog:-sh}" ".init_b_cache/scripts/$PKG.post" 1 + rm -f "$BUILD_TARGET/.init_b_cache/scripts/$PKG.post" "$BUILD_TARGET/.init_b_cache/scripts/$PKG.postprog" fi } diff --git a/build-recipe-dsc b/build-recipe-dsc index d748c4e..58b82d6 100644 --- a/build-recipe-dsc +++ b/build-recipe-dsc @@ -67,12 +67,12 @@ 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 OBS_DCH_RELEASE="+$DEB_RELEASE" - 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 @@ -128,7 +128,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 d7bd2f7..5b663e3 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 cleanup_and_exit 1 "Error: TOPDIR empty" fi @@ -55,19 +55,19 @@ recipe_prepare_spec() { args[${#args[@]}]="$BUILD_ROOT/.build-changelog" fi - substitutedeps "${args[@]}" --root "$BUILD_ROOT" --dist "$BUILD_DIST" --archpath "$BUILD_ARCH" --configdir "$CONFIG_DIR" "$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" "$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 rawcfgmacros=.rpmmacros test "$BUILDTYPE" = debbuild && rawcfgmacros=.debmacros - queryconfig rawmacros --dist "$BUILD_DIST" --archpath "$BUILD_ARCH" --configdir "$CONFIG_DIR" > $BUILD_ROOT/root/$rawcfgmacros + queryconfig rawmacros --dist "$BUILD_DIST" --archpath "$BUILD_ARCH" --configdir "$CONFIG_DIR" > $BUILD_TARGET/root/$rawcfgmacros if test -n "$BUILD_DEBUG" && test "$BUILDTYPE" != debbuild ; then echo ' %prep %{?!__debug_package:%{?_build_create_debug:%?_build_insert_debug_package}}%%prep @@ -77,21 +77,21 @@ recipe_prepare_spec() { %undefine _enable_debug_packages \ %debug_package -' >> $BUILD_ROOT/root/$rawcfgmacros +' >> $BUILD_TARGET/root/$rawcfgmacros fi if test -n "$BUILD_JOBS" ; then - cat >> $BUILD_ROOT/root/$rawcfgmacros <<-EOF + cat >> $BUILD_TARGET/root/$rawcfgmacros <<-EOF ### from obs-build %jobs $BUILD_JOBS %_smp_mflags -j$BUILD_JOBS EOF fi - test $BUILD_USER = abuild && cp -p $BUILD_ROOT/root/$rawcfgmacros $BUILD_ROOT/home/abuild/$rawcfgmacros + test $BUILD_USER = abuild && cp -p $BUILD_TARGET/root/$rawcfgmacros $BUILD_ROOT/home/abuild/$rawcfgmacros # 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" ) @@ -99,17 +99,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 } @@ -177,7 +177,7 @@ recipe_build_spec() { "$TOPDIR/SOURCES/$RECIPEFILE" \ > $BUILD_ROOT/.build.command chmod 755 $BUILD_ROOT/.build.command - chroot $BUILD_ROOT su -c /.build.command - $BUILD_USER < /dev/null + enter_target needuser /.build.command < /dev/null st=$? if test "$st" != 0 -a "$st" != 11 ; then return @@ -206,10 +206,10 @@ 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 - chroot $BUILD_ROOT su -c /.build.command - $BUILD_USER < /dev/null + enter_target needuser /.build.command < /dev/null st=$? test "$st" = 0 && BUILD_SUCCEEDED=true test "$st" = 11 -a -n "$HAVE_DYNAMIC_BUILDREQUIRES" && BUILD_SUCCEEDED=genbuildreqs @@ -255,11 +255,11 @@ recipe_run_rpmlint() { # SUSE builds are using a special rpmlint binary which is not # pulling in additional dependencies local rpmlint="/opt/testing/bin/rpmlint" - if ! test -x "$BUILD_ROOT$rpmlint" ; then + if ! test -x "$BUILD_TARGET$rpmlint" ; then # default rpmlint place as fallback rpmlint="/usr/bin/rpmlint" fi - if ! test -x "$BUILD_ROOT$rpmlint" ; then + if ! test -x "$BUILD_TARGET$rpmlint" ; then return fi LINT_RPM_FILE_LIST=($(find $BUILD_ROOT/$TOPDIR/RPMS \ @@ -274,7 +274,7 @@ recipe_run_rpmlint() { rpmlint_logfile=$TOPDIR/OTHER/rpmlint.log rm -f "$BUILD_ROOT$rpmlint_logfile" ret=0 - chroot $BUILD_ROOT su -s $rpmlint "$BUILD_USER" -- \ + enter_target needscript $rpmlint \ --info ${LINT_RPM_FILE_LIST[*]#$BUILD_ROOT} \ ${SRPM_FILE_LIST[*]#$BUILD_ROOT} > >(tee "$BUILD_ROOT$rpmlint_logfile") 2>&1 || ret=1 echo @@ -284,9 +284,9 @@ 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" - if chroot $BUILD_ROOT /usr/lib/build/same-build-result.sh /.build.oldpackages "$TOPDIR/RPMS" "$TOPDIR/SRPMS"; then + if enter_target needroot /usr/lib/build/same-build-result.sh /.build.oldpackages "$TOPDIR/RPMS" "$TOPDIR/SRPMS"; then chroot $BUILD_ROOT touch /.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 @@ -298,10 +298,10 @@ 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 2125749..aa3fa24 100644 --- a/build-vm +++ b/build-vm @@ -80,7 +80,7 @@ EMULATOR_SCRIPT= # openstack specific VM_OPENSTACK_FLAVOR= -for i in ec2 emulator kvm lxc openstack qemu uml xen zvm docker pvm nspawn; do +for i in ec2 emulator kvm lxc openstack qemu uml xen zvm docker pvm nspawn sb2; do . "$BUILD_DIR/build-vm-$i" done @@ -305,7 +305,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 -o "$VM_TYPE" = nspawn && exit $1 + test "$VM_TYPE" = lxc -o "$VM_TYPE" = docker -o "$VM_TYPE" = nspawn -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 @@ -536,7 +536,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 -a "$VM_TYPE" != nspawn ; then + if test "$VM_TYPE" != lxc -a "$VM_TYPE" != docker -a "$VM_TYPE" != nspawn -a "$VM_TYPE" != sb2 ; then mount -n ${VMDISK_MOUNT_OPTIONS},remount,rw / fi umount /run >/dev/null 2>&1 @@ -879,7 +879,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[567]}" && PERSONALITY=8 ;; # workaround, to be removed esac - test "$VM_TYPE" = lxc -o "$VM_TYPE" = docker -o "$VM_TYPE" = nspawn && PERSONALITY=0 + test "$VM_TYPE" = lxc -o "$VM_TYPE" = docker -o "$VM_TYPE" = nspawn -o "$VM_TYPE" = sb2 && PERSONALITY=0 echo "PERSONALITY='$PERSONALITY'" >> $BUILD_ROOT/.build/build.data echo "VM_HOSTNAME='$HOST'" >> $BUILD_ROOT/.build/build.data echo -n "definesnstuff=(" >> $BUILD_ROOT/.build/build.data @@ -910,7 +910,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 # rsync as source and dest could be same 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 ff3afff..ef01085 100755 --- a/common_functions +++ b/common_functions @@ -90,6 +90,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 @@ -111,6 +262,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 d06f733..9e2cf26 100755 --- a/expanddeps +++ b/expanddeps @@ -298,6 +298,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 041f547..8a21b9f 100755 --- a/init_buildsystem +++ b/init_buildsystem @@ -151,6 +151,9 @@ cleanup_and_exit() { fi fi 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 if test -n "$BUILD_ROOT" -a "$BUILD_ROOT" != / ; then # XXX: use stat -f /dev/pts/ -c %T to check whether it's mounted and not suppress errors then? @@ -176,7 +179,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* fi @@ -210,7 +213,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 @@ -221,8 +224,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" @@ -235,7 +242,7 @@ preinstall() { } run_pkg_scripts() { - chroot $BUILD_ROOT /sbin/ldconfig 2>/dev/null + enter_target needroot /sbin/ldconfig 2>/dev/null for PKG in $PACKAGES_TO_RUNSCRIPTS ; do pkg_runscripts check_exit @@ -244,12 +251,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() { @@ -531,18 +538,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 # @@ -554,7 +561,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..." VMOPT= test -z "$PREPARE_VM" || VMOPT=--vm @@ -570,12 +577,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 @@ -606,11 +614,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 @@ -630,13 +639,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 @@ -647,7 +660,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 @@ -663,7 +676,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 ;; *) @@ -673,9 +686,21 @@ else fi SRCSUF=${SRC/%.pkg.tar.zst/.arch} SRCSUF=${SRCSUF/%.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" @@ -697,18 +722,18 @@ else fi # use cached packages where possible - 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..." while read PKG SRC ; do SRCSUF=${SRC/%.pkg.tar.zst/.arch} SRCSUF=${SRCSUF/%.pkg.tar.?z/.arch} - if test -s "$BUILD_ROOT/.init_b_cache/rpms/$PKG.id" ; then - read cachepkgid < $BUILD_ROOT/.init_b_cache/rpms/$PKG.id + if test -s "$BUILD_TARGET/.init_b_cache/rpms/$PKG.id" ; then + read cachepkgid < $BUILD_TARGET/.init_b_cache/rpms/$PKG.id echo "PKG $PKG $cachepkgid" else echo "PKG $PKG" fi - echo "DST $BUILD_ROOT/.init_b_cache/rpms/$PKG.${SRCSUF##*.}" + echo "DST $BUILD_TARGET/.init_b_cache/rpms/$PKG.${SRCSUF##*.}" if test "$SRC" != "${SRC#zypp://}" ; then # for zypp packages also look in the zypp cache cachedir="/var/cache/zypp/packages/${SRC#zypp://}" @@ -716,20 +741,20 @@ else fi cachedir="$(getcachedir "$SRC")" echo "CACHE $cachedir/${SRCSUF##*/}" - done < $BUILD_ROOT/.init_b_cache/rpmlist.download | "$BUILD_DIR/getbuildids" cachecheck + done < $BUILD_TARGET/.init_b_cache/rpmlist.download | "$BUILD_DIR/getbuildids" cachecheck # remove found packages from download list - rm -f $BUILD_ROOT/.init_b_cache/rpmlist.download2 + rm -f $BUILD_TARGET/.init_b_cache/rpmlist.download2 while read PKG SRC ; do SRCSUF=${SRC/%.pkg.tar.zst/.arch} SRCSUF=${SRCSUF/%.pkg.tar.?z/.arch} - test -L "$BUILD_ROOT/.init_b_cache/rpms/$PKG.${SRCSUF##*.}" || 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 + test -L "$BUILD_TARGET/.init_b_cache/rpms/$PKG.${SRCSUF##*.}" || 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 @@ -738,12 +763,13 @@ else # downloadpkg modified $SRC, so it has a right name for use SRCSUF=${SRC/%.pkg.tar.zst/.arch} SRCSUF=${SRCSUF/%.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" @@ -755,7 +781,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 @@ -775,11 +801,11 @@ esac # 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" @@ -790,10 +816,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 @@ -802,6 +837,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 @@ -809,12 +845,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" @@ -824,9 +860,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... @@ -854,8 +890,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" @@ -875,18 +911,18 @@ fi echo "querying package ids..." for PKG in $PACKAGES_TO_INSTALL ; do - test -s "$BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF" || continue - test -L "$BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF" || continue - echo "$BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF" + test -s "$BUILD_TARGET/.init_b_cache/rpms/$PKG.$PSUF" || continue + test -L "$BUILD_TARGET/.init_b_cache/rpms/$PKG.$PSUF" || continue + echo "$BUILD_TARGET/.init_b_cache/rpms/$PKG.$PSUF" done | "$BUILD_DIR/getbuildids" # # 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 ) @@ -896,34 +932,34 @@ 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" mkdir -p "$BUILD_ROOT/installed-pkg" -test -x $BUILD_ROOT/sbin/ldconfig && chroot $BUILD_ROOT /sbin/ldconfig 2>&1 +test -x $BUILD_TARGET/sbin/ldconfig && enter_target needroot /sbin/ldconfig 2>&1 MAIN_LIST="$PACKAGES_TO_INSTALL" progress_setup MAIN_LIST @@ -931,7 +967,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 cleanup_and_exit 1 "Package $PKG is missing from the preinstall image" @@ -945,21 +983,21 @@ for PKG in $MAIN_LIST ; do # get the hdrmd5 if we want to create a preinstall image PKG_HDRMD5= if test -n "$CREATE_PREINSTALL_DATA" -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 - if test -s "$BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF.buildid" ; then - read PKGID < "$BUILD_ROOT/.init_b_cache/rpms/$PKG.$PSUF.buildid" + if test -s "$BUILD_TARGET/.init_b_cache/rpms/$PKG.$PSUF.buildid" ; then + read PKGID < "$BUILD_TARGET/.init_b_cache/rpms/$PKG.$PSUF.buildid" else - 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) fi - if test -f "$BUILD_ROOT/.init_b_cache/alreadyinstalled/$PKG" ; then - read OLDPKGID < "$BUILD_ROOT/.init_b_cache/alreadyinstalled/$PKG" - if test "$PKGID" != "$OLDPKGID" && ! test -e "$BUILD_ROOT/.init_b_cache/preinstalls/$PKG" ; then + if test -f "$BUILD_TARGET/.init_b_cache/alreadyinstalled/$PKG" ; then + read OLDPKGID < "$BUILD_TARGET/.init_b_cache/alreadyinstalled/$PKG" + if test "$PKGID" != "$OLDPKGID" && ! test -e "$BUILD_TARGET/.init_b_cache/preinstalls/$PKG" ; then echo "deleting unwanted ${OLDPKGID%% *}" pkg_erase else @@ -972,7 +1010,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 @@ -985,13 +1023,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 @@ -1008,16 +1046,16 @@ 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 # -if test -e $BUILD_ROOT/etc/nsswitch.conf ; then - sed -e "s:nis::g" < $BUILD_ROOT/etc/nsswitch.conf > $BUILD_ROOT/etc/nsswitch.conf.tmp - mv $BUILD_ROOT/etc/nsswitch.conf.tmp $BUILD_ROOT/etc/nsswitch.conf +if test -e $BUILD_TARGET/etc/nsswitch.conf ; then + sed -e "s:nis::g" < $BUILD_TARGET/etc/nsswitch.conf > $BUILD_TARGET/etc/nsswitch.conf.tmp + mv $BUILD_TARGET/etc/nsswitch.conf.tmp $BUILD_TARGET/etc/nsswitch.conf fi # @@ -1026,21 +1064,21 @@ fi 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 @@ -1051,48 +1089,48 @@ 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 -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.26.2
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