Log In
Log In
Places
All Projects
Status Monitor
Collapse sidebar
obs:tools
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 04fa7f79dbffe87ca3fd642efa45b68847a8f33d 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 | 134 +++++++++++++++++++++++---------------- build-pkg | 6 +- build-pkg-arch | 14 ++-- build-pkg-deb | 56 ++++++++-------- build-pkg-rpm | 62 +++++++++--------- build-recipe | 8 +-- build-recipe-dsc | 6 +- build-recipe-spec | 64 +++++++++---------- build-vm | 14 ++-- build-vm-sb2 | 48 ++++++++++++++ common_functions | 158 ++++++++++++++++++++++++++++++++++++++++++++++ expanddeps | 1 + getsb2flags | 41 ++++++++++++ init_buildsystem | 128 +++++++++++++++++++++++-------------- initscript_sb2 | 23 +++++++ 17 files changed, 566 insertions(+), 214 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 54b4e6b..19f11fe 100644 --- a/Build.pm +++ b/Build.pm @@ -411,6 +411,7 @@ sub read_config { delete $config->{'parsing_config'}; $config->{'preinstall'} = []; $config->{'vminstall'} = []; + $config->{'sb2install'} = []; $config->{'runscripts'} = []; $config->{'required'} = []; $config->{'support'} = []; @@ -423,6 +424,7 @@ sub read_config { $config->{'substitute'} = {}; $config->{'substitute_vers'} = {}; $config->{'optflags'} = {}; + $config->{'sb2flags'} = {}; $config->{'order'} = {}; $config->{'exportfilter'} = {}; $config->{'publishfilter'} = []; @@ -460,7 +462,7 @@ sub read_config { push @macros, "%define $l[1]" if @l == 2; 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:' || $l0 eq 'repourl:' || $l0 eq 'registryurl:' || $l0 eq 'assetsurl:' || $l0 eq 'onlynative:' || $l0 eq 'alsonative:') { + 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:' || $l0 eq 'repourl:' || $l0 eq 'registryurl:' || $l0 eq 'assetsurl:' || $l0 eq 'onlynative:' || $l0 eq 'alsonative:') { my $t = substr($l0, 0, -1); for my $l (@l) { if ($l eq '!*') { @@ -501,6 +503,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 '!*') { @@ -548,7 +554,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); @@ -922,6 +928,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 83d566c..cfc6271 100644 --- a/Makefile +++ b/Makefile @@ -52,10 +52,12 @@ install: getbinaryid \ getbuildids \ killchroot \ + getsb2flags \ queryconfig \ queryrecipe \ common_functions \ init_buildsystem \ + initscript_sb2 \ substitutedeps \ debtransform \ debtransformbz2 \ diff --git a/build b/build index dde347d..66ffbe9 100755 --- a/build +++ b/build @@ -41,7 +41,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 export BUILD_DIST ABUILD_UID ABUILD_GID icecream=0 @@ -515,6 +515,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 buildroot_umount /proc/sys/fs/binfmt_misc @@ -681,7 +682,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 @@ -719,7 +720,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" @@ -769,7 +770,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) @@ -783,7 +784,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 @@ -795,27 +796,27 @@ 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" } @@ -826,11 +827,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" @@ -905,8 +906,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" @@ -916,13 +917,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 -hR "$ABUILD_UID:$ABUILD_GID" "$BUILD_ROOT/$RSYNCDEST" + rsync -av $RSYNCSRC/* $BUILD_TARGET/$RSYNCDEST/ + chown -hR "$ABUILD_UID:$ABUILD_GID" "$BUILD_TARGET/$RSYNCDEST" RSYNCDONE=true echo "... done" else @@ -1398,6 +1399,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 @@ -1432,7 +1442,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" -a -z "$VM_TYPE"; then mount_stuff @@ -1462,6 +1483,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 @@ -1529,6 +1554,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}" @@ -1686,8 +1712,8 @@ for RECIPEPATH 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 @@ -1709,49 +1735,49 @@ for RECIPEPATH in "${RECIPEFILES[@]}" ; do # fixup passwd/group if test $BUILD_USER = abuild ; then - if ! grep -E '^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 - mkdir -p $BUILD_ROOT/home/abuild - chown "$ABUILD_UID:$ABUILD_GID" $BUILD_ROOT/home/abuild + if ! grep -E '^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_TARGET/home/abuild + chown "$ABUILD_UID:$ABUILD_GID" $BUILD_TARGET/home/abuild else - if ! grep -E "^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 ! grep -E "^abuild:x?:${ABUILD_UID}:${ABUILD_GID}" >/dev/null <$BUILD_TARGET/etc/passwd ; then + echo "abuild user present in the buildroot ($BUILD_TARGET) but uid:gid does not match" echo "buildroot currently using:" - grep -E "^abuild:" <$BUILD_ROOT/etc/passwd + grep -E "^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 grep -E '^abuild:' >/dev/null <$BUILD_ROOT/etc/passwd ; then + if grep -E '^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 @@ -1902,7 +1928,7 @@ BUILD_SUCCEEDED=false TIME_POSTCHECKS=$SECONDS # RPM specific post checks are in /usr/lib/build/checks -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 # workaround for broken 13.1 check scripts which umount /proc if test -n "$RUNNING_IN_VM" -a "$BUILD_ROOT" = / ; then umount -n $BUILD_ROOT/proc/sys/fs/binfmt_misc 2>/dev/null @@ -1918,19 +1944,19 @@ if test -n "$RPMS" -a -d "$BUILD_ROOT/usr/lib/build/checks" ; then done PNAME="${PNAME%-*-*.*.rpm}" fi - for CHECKSCRIPT in $BUILD_ROOT/usr/lib/build/checks/* ; do + for CHECKSCRIPT in $BUILD_TARGET/usr/lib/build/checks/* ; do echo "... running ${CHECKSCRIPT##*/}" - BUILD_ROOT=/ HOME=/root chroot "$BUILD_ROOT" "/usr/lib/build/checks/${CHECKSCRIPT##*/}" || cleanup_and_exit 1 + BUILD_ROOT=/ HOME=/root enter_target needroot "/usr/lib/build/checks/${CHECKSCRIPT##*/}" || cleanup_and_exit 1 done # workaround for broken 13.1 check scripts which umount /proc test -e "$BUILD_ROOT/proc/self" || mount -n -tproc none $BUILD_ROOT/proc fi # Generic post-build-checks are in /usr/lib/build/post-build-checks -for CHECKSCRIPT in $BUILD_ROOT/usr/lib/build/post-build-checks/* ; do +for CHECKSCRIPT in $BUILD_TARGET/usr/lib/build/post-build-checks/* ; do if test -x "$CHECKSCRIPT"; then echo "... running ${CHECKSCRIPT##*/}" - BUILD_ROOT=/ HOME=/root chroot "$BUILD_ROOT" "/usr/lib/build/post-build-checks/${CHECKSCRIPT##*/}" || cleanup_and_exit 1 + BUILD_ROOT=/ HOME=/root enter_target needroot "/usr/lib/build/post-build-checks/${CHECKSCRIPT##*/}" || cleanup_and_exit 1 fi done @@ -1975,7 +2001,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=$SECONDS recipe_compare_oldpackages TIME_BUILDCMP=$(( $SECONDS - $TIME_BUILDCMP )) diff --git a/build-pkg b/build-pkg index c7aa972..3081d30 100644 --- a/build-pkg +++ b/build-pkg @@ -70,9 +70,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 6202593..13926ba 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() { @@ -33,7 +33,7 @@ pkg_prepare_arch() { } pkg_erase_arch() { - ( cd $BUILD_ROOT && chroot $BUILD_ROOT pacman -R -n -d -d --noconfirm $PKG 2>&1 || touch $BUILD_ROOT/exit ) | \ + ( cd $BUILD_TARGET && enter_target needroot pacman -R -n -d -d --noconfirm $PKG 2>&1 || touch $BUILD_ROOT/exit ) | \ perl -ne '$|=1;/^(Total Removed Size: |Packages \(\d+\):|:: Do you want to remove these packages|deleting |removing | )/||/^$/||print' } @@ -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' } @@ -72,7 +72,7 @@ pkg_preinstall_arch() { pkg_runscripts_arch() { if test -e "$BUILD_INIT_CACHE/scripts/$PKG.post" ; then echo "running $PKG postinstall script" - ( cd $BUILD_ROOT && chroot $BUILD_ROOT ".init_b_cache/scripts/$PKG.post" < /dev/null ) + ( cd $BUILD_TARGET && enter_target needroot ".init_b_cache/scripts/$PKG.post" < /dev/null ) rm -f "$BUILD_INIT_CACHE/scripts/$PKG.post" fi } diff --git a/build-pkg-deb b/build-pkg-deb index ca73c9e..3db3811 100644 --- a/build-pkg-deb +++ b/build-pkg-deb @@ -35,36 +35,38 @@ 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 # Manpages database trigger takes a lot of time and is not useful in a build chroot - mkdir -p $BUILD_ROOT/var/cache/debconf/ - cat >> $BUILD_ROOT/var/cache/debconf/config.dat <<EOF + mkdir -p $BUILD_TARGET/var/cache/debconf/ + cat >> $BUILD_TARGET/var/cache/debconf/config.dat <<EOF Name: man-db/auto-update Template: man-db/auto-update Value: false @@ -77,8 +79,8 @@ EOF 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 - cp --remove-destination $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 + cp --remove-destination $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" @@ -99,15 +101,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() { @@ -116,7 +118,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" ;; @@ -177,20 +179,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 950113c..48216a1 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 } } @@ -92,7 +92,7 @@ rpm_init_cumulate() { } 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 @@ -103,7 +103,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 @@ -121,11 +121,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$" @@ -178,15 +178,15 @@ 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 - cp --remove-destination $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 \ + test "$BUILD_TARGET/.init_b_cache/rpms/$PKG" -ef "$BUILD_TARGET/${CUMULATED_LIST[$num]}" && continue + cp --remove-destination $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]##*/} @@ -259,25 +259,25 @@ pkg_preinstall_rpm() { # hack for rpm erasures if test -d "$BUILD_ROOT/installed-pkg" -a -z "$PREPARE_VM" ; then # call for rpm-4.x and not rpm-devel - test -z "${PKG##rpm-[0-9]*}" && chroot . rpm --rebuilddb + test -z "${PKG##rpm-[0-9]*}" && BUILD_TARGET=. enter_target needroot rpm --rebuilddb # also exec for exchanged rpm ! naming is rpm-x86-<target>-<ver> - test -z "${PKG##rpm-x86-*[0-9]*}" && chroot . rpm --rebuilddb + test -z "${PKG##rpm-x86-*[0-9]*}" && BUILD_TARGET=. 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 b/build-recipe index 0b44d68..3337a08 100644 --- a/build-recipe +++ b/build-recipe @@ -238,7 +238,7 @@ expand_recipe_directories() { recipe_setup_macros() { local 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 @@ -248,16 +248,16 @@ recipe_setup_macros() { %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 %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_TARGET/home/abuild/$rawcfgmacros } # generate a .build-changelog file from a .changes file diff --git a/build-recipe-dsc b/build-recipe-dsc index af3a502..170b538 100644 --- a/build-recipe-dsc +++ b/build-recipe-dsc @@ -119,12 +119,12 @@ recipe_prepare_dsc() { fi # run/copy sources - 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 @@ -208,7 +208,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 7d71d16..2d02aee 100644 --- a/build-recipe-spec +++ b/build-recipe-spec @@ -24,7 +24,7 @@ recipe_setup_spec() { spec_setup_stages "$BUILD_RPM_BUILD_STAGE" - 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 @@ -71,33 +71,33 @@ 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 # 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 # 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 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_TARGET/home/abuild/.rpmrc if test -z "$ABUILD_TARGET"; then ABUILD_TARGET=$(spec_get_buildtarget) @@ -183,7 +183,7 @@ recipe_build_spec() { rpmbopts[${#rpmbopts[@]}]="$BUILD_TOOL_OPT" fi if test "$DO_CHECKS" != true ; then - if chroot "$BUILD_ROOT" "$rpmbuild" --nocheck --help >/dev/null 2>&1; then + if enter_target needroot "$rpmbuild" --nocheck --help >/dev/null 2>&1; then rpmbopts[${#rpmbopts[@]}]="--nocheck" else echo "warning: --nocheck is not supported by this $rpmbuild version" @@ -244,9 +244,9 @@ recipe_build_spec() { -br \ "${rpmbopts[@]}" \ "$TOPDIR/SOURCES/$RECIPEFILE" \ - > $BUILD_ROOT/.build.command - chmod 755 $BUILD_ROOT/.build.command - chroot $BUILD_ROOT su -c /.build.command - $BUILD_USER < /dev/null + > $BUILD_TARGET/.build.command + chmod 755 $BUILD_TARGET/.build.command + enter_target needuser /.build.command < /dev/null st=$? if test "$st" != 0 -a "$st" != 11 ; then return @@ -258,8 +258,8 @@ recipe_build_spec() { test -f "$i" && reqsfile=${i##*/} done test -n "$reqsfile" || cleanup_and_exit 1 "no buildreqs.nosrc.rpm file?" - chroot $BUILD_ROOT rpm -qp --requires "$TOPDIR/SRPMS/$reqsfile" | grep -v '^rpmlib(' | sort -u > $BUILD_ROOT$TOPDIR/OTHER/_generated_buildreqs_tmp - chroot $BUILD_ROOT rpmspec -q --srpm --requires "$TOPDIR/SOURCES/$RECIPEFILE" >> $BUILD_ROOT$TOPDIR/OTHER/_generated_buildreqs_tmp || cleanup_and_exit 1 "rpm -q --spec failed" + enter_target needroot rpm -qp --requires "$TOPDIR/SRPMS/$reqsfile" | grep -v '^rpmlib(' | sort -u > $BUILD_ROOT$TOPDIR/OTHER/_generated_buildreqs_tmp + enter_target needroot rpmspec -q --srpm --requires "$TOPDIR/SOURCES/$RECIPEFILE" >> $BUILD_ROOT$TOPDIR/OTHER/_generated_buildreqs_tmp || cleanup_and_exit 1 "rpm -q --spec failed" sort < $BUILD_ROOT$TOPDIR/OTHER/_generated_buildreqs_tmp | uniq -u > $BUILD_ROOT$TOPDIR/OTHER/_generated_buildreqs rm -f $BUILD_ROOT$TOPDIR/OTHER/_generated_buildreqs_tmp while read db ; do @@ -277,12 +277,12 @@ recipe_build_spec() { $rpmstage \ "${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 local build_command="/.build.command" test -n "$RPM_BUILD_IN_PLACE" && build_command="cd /.build.packages/SOURCES && $build_command" - chroot $BUILD_ROOT su -c "$build_command" - $BUILD_USER < /dev/null + enter_target needuser $build_command < /dev/null st=$? test "$st" = 0 || break done @@ -330,11 +330,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 \ @@ -349,7 +349,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 @@ -359,9 +359,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 @@ -373,10 +373,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 13b0708..2cf6a89 100644 --- a/build-vm +++ b/build-vm @@ -73,7 +73,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 @@ -338,7 +338,7 @@ vm_shutdown_halt_helper() { vm_shutdown_halt() { # get rid of the exit handler trap EXIT - 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 # shutdown from fresh shell to close out deleted inodes exec -a "build: halt" -- $BASH -c "$(declare -f vm_shutdown_halt_helper); vm_shutdown_halt_helper $1" echo "Warning: clean shut down of the VM didn't work" @@ -627,7 +627,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 @@ -1013,7 +1013,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 @@ -1057,7 +1057,11 @@ vm_first_stage() { vm_init_script="/.build/build" if set_initvm_name_for_emulator_in "$BUILD_ROOT/.build" ; 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_ROOT" ; then 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 4c8e1eb..130dad6 100755 --- a/common_functions +++ b/common_functions @@ -93,6 +93,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_native_arch() { local arch="$1" local old_build_arch="$BUILD_ARCH" @@ -122,6 +273,8 @@ set_initvm_name_for_emulator_in() { if test -e "$initvmdir/$INITVM_NAME" -a -e "$initvmdir/qemu-reg" ; then # it exists, assume we need to run it return 0 + elif test -n "$BUILD_SB2FLAGS" ; then + return 0 # Use sb2 fi INITVM_NAME= @@ -172,6 +325,11 @@ buildroot_rm() { test -e "$BUILD_ROOT/$1" && cleanup_and_exit 1 "could not remove $BUILD_ROOT/$1" } +buildtarget_rm() { + rm -rf "$BUILD_TARGET/$1" + test -e "$BUILD_TARGET/$1" && cleanup_and_exit 1 "could not remove $BUILD_TARGET/$1" +} + assert_dirs() { local d rl if test -z "$1" ; then diff --git a/expanddeps b/expanddeps index 9014096..647136a 100755 --- a/expanddeps +++ b/expanddeps @@ -301,6 +301,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 0b000aa..41765cc 100755 --- a/init_buildsystem +++ b/init_buildsystem @@ -142,7 +142,7 @@ test -z "$CACHE_DIR" && detect_cache_dir BUILD_IS_RUNNING=$BUILD_ROOT/not-ready TMPFILE=$BUILD_ROOT/tmpfile -BUILD_INIT_CACHE="$BUILD_ROOT/.init_b_cache" +BUILD_INIT_CACHE="$BUILD_TARGET/.init_b_cache" # # needed functions @@ -178,6 +178,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 umount_stuff # never report a fatal error when the job got killed from outside @@ -237,7 +240,11 @@ run_cmd_with_xargs() { } preinstall_setup() { - cd "$BUILD_ROOT" || cleanup_and_exit 1 + 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 rm -rf build-preinstall mkdir build-preinstall || cleanup_and_exit 1 local mv_args=() @@ -311,7 +318,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 @@ -672,6 +679,7 @@ else while read PKG SRC ; do test "$PKG" = "preinstall:" && continue test "$PKG" = "runscripts:" && continue + test "$PKG" = "sb2install:" && continue test "$PKG" = "vminstall:" && continue test "$PKG" = "dist:" && continue test "$PKG" = "rpmid:" && continue @@ -709,6 +717,7 @@ else PACKAGES_TO_SYSROOTINSTALL= PREINSTALL_IMAGE= PREINSTALL_IMAGE_SOURCE= + PACKAGES_TO_SB2INSTALL= RUNSCRIPTS_SEEN= PACKAGES_FROM_PREINSTALLIMAGE= GUESSED_DIST=unknown @@ -740,6 +749,10 @@ else 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 @@ -787,6 +800,18 @@ else ln -s "$SRC" "$BUILD_INIT_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" @@ -855,6 +880,7 @@ else echo fi + test -n "$PACKAGES_TO_SB2INSTALL" && echo "sb2install : $PACKAGES_TO_SB2INSTALL" # compatibility... test -z "$RUNSCRIPTS_SEEN" && PACKAGES_TO_RUNSCRIPTS="$PACKAGES_TO_PREINSTALL" @@ -889,9 +915,9 @@ 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_INIT_CACHE/rpms $BUILD_ROOT/etc $BUILD_ROOT/proc || cleanup_and_exit 1 - test -L $BUILD_ROOT/etc/HOSTNAME && buildroot_rm etc/HOSTNAME - test -f $BUILD_ROOT/etc/HOSTNAME || hostname -f > $BUILD_ROOT/etc/HOSTNAME + mkdir -p -- $BUILD_INIT_CACHE/rpms $BUILD_TARGET/etc $BUILD_TARGET/proc || cleanup_and_exit 1 + test -L $BUILD_TARGET/etc/HOSTNAME && buildtarget_rm etc/HOSTNAME + test -f $BUILD_TARGET/etc/HOSTNAME || hostname -f > $BUILD_TARGET/etc/HOSTNAME for PKG in $PACKAGES_TO_RUNSCRIPTS ; do : > $BUILD_INIT_CACHE/scripts/$PKG.run done @@ -907,10 +933,19 @@ if test ! -e $BUILD_ROOT/installed-pkg -a ! -e $BUILD_ROOT/.build/init_buildsyst if test -n "$PREPARE_VM" ; then PACKAGES_TO_VMINSTALL_FILTERED=`reorder $PACKAGES_TO_VMINSTALL_FILTERED` fi + 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 if test -n "$PREPARE_VM" ; then echo @@ -918,6 +953,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 @@ -925,12 +961,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 - if ! test -e $BUILD_ROOT/etc/fstab ; then - rm -rf $BUILD_ROOT/etc/fstab - touch $BUILD_ROOT/etc/fstab + if ! test -e $BUILD_TARGET/etc/fstab ; then + rm -rf $BUILD_TARGET/etc/fstab + touch $BUILD_TARGET/etc/fstab fi - if test ! -e $BUILD_ROOT/etc/ld.so.conf -a -f $BUILD_ROOT/etc/ld.so.conf.in -a ! -L $BUILD_ROOT/etc/ld.so.conf.in ; then - cp --remove-destination $BUILD_ROOT/etc/ld.so.conf.in $BUILD_ROOT/etc/ld.so.conf + if test ! -e $BUILD_TARGET/etc/ld.so.conf -a -f $BUILD_TARGET/etc/ld.so.conf.in -a ! -L $BUILD_TARGET/etc/ld.so.conf.in ; then + cp --remove-destination $BUILD_TARGET/etc/ld.so.conf.in $BUILD_TARGET/etc/ld.so.conf fi if test -z "$PREPARE_VM" ; then mount_stuff @@ -1036,7 +1072,7 @@ done | "$BUILD_DIR/getbuildids" # get list and ids of already installed packages # mkdir -p $BUILD_INIT_CACHE/alreadyinstalled -listinstalled --root "$BUILD_ROOT" --type "$PSUF" --extraname | ( +listinstalled --root "$BUILD_TARGET" --type "$PSUF" --extraname | ( while read id name buildid; do echo "$buildid" > "$BUILD_INIT_CACHE/alreadyinstalled/$name" done @@ -1075,7 +1111,7 @@ fi 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 if test -n "$PACKAGES_TO_SYSROOTINSTALL" ; then # query sysroot config @@ -1194,36 +1230,36 @@ cd $BUILD_ROOT || cleanup_and_exit 1 # # setup /etc/mtab # -ln -sf ../proc/self/mounts $BUILD_ROOT/etc/mtab +ln -sf ../proc/self/mounts $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 # # create some default directories and files # mkdir -p -- \ - $BUILD_ROOT/usr/share/doc/packages \ - $BUILD_ROOT/usr/X11R6/include/X11/pixmaps \ - $BUILD_ROOT/usr/X11R6/include/X11/bitmaps \ - $BUILD_ROOT/var/run \ - $BUILD_ROOT/var/log \ - $BUILD_ROOT/etc -touch -- $BUILD_ROOT/var/run/utmp $BUILD_ROOT/var/log/wtmp $BUILD_ROOT/etc/fstab + $BUILD_TARGET/usr/share/doc/packages \ + $BUILD_TARGET/usr/X11R6/include/X11/pixmaps \ + $BUILD_TARGET/usr/X11R6/include/X11/bitmaps \ + $BUILD_TARGET/var/run \ + $BUILD_TARGET/var/log \ + $BUILD_TARGET/etc +touch -- $BUILD_TARGET/var/run/utmp $BUILD_TARGET/var/log/wtmp $BUILD_TARGET/etc/fstab 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 @@ -1234,29 +1270,29 @@ 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 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 @@ -1272,16 +1308,16 @@ if test -d $BUILD_ROOT/usr/lib/build/finalize-system ; then 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 -f $BUILD_TARGET/.rpmmacros $BUILD_TARGET/root/.rpmmacros rm -rf "$BUILD_INIT_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.40.1
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