From: Thierry Parmentelat Date: Fri, 24 Jan 2014 10:44:00 +0000 (+0100) Subject: get rid of bin_in_container, use bash to find out commands in guest instead X-Git-Tag: before_libvirt_121~28 X-Git-Url: http://git.onelab.eu/?p=build.git;a=commitdiff_plain;h=b30d20ef9023e9f2799dd84a0472c4ddf84b5a18 get rid of bin_in_container, use bash to find out commands in guest instead --- diff --git a/build.common b/build.common index 7acfbb3e..268eaa73 100644 --- a/build.common +++ b/build.common @@ -13,20 +13,6 @@ # for locating pkgs.py export PATH=.:$PATH -# old guests have e.g. mount in /bin but this is no longer part of -# the standard PATH in recent hosts after usrmove, so let's keep it simple -export PATH=$PATH:/bin:/sbin - -# would be much simpler if enter-lxc-namespace was looking along a PATH... -function bin_in_container () { - lxc=$1; shift - binary=$1; shift - for path in $(echo $PATH | sed -e 's,:, ,g' ); do - [ -f /vservers/$lxc/$path/$binary ] && { echo $path/$binary; return; } - done - echo bin_in_container_cannot_find_$binary -} - # returns 'Fedora' or 'CentOS' for now function pl_getDistro() { if [ -f "/etc/redhat-release" ] ; then diff --git a/lbuild-initvm.sh b/lbuild-initvm.sh index a3ea8b23..0b088f60 100755 --- a/lbuild-initvm.sh +++ b/lbuild-initvm.sh @@ -13,6 +13,10 @@ BUILD_DIR=$(pwd) # pkgs parsing utilities export PATH=$(dirname $0):$PATH +# old guests have e.g. mount in /bin but this is no longer part of +# the standard PATH in recent hosts after usrmove, so let's keep it simple +export PATH=$PATH:/bin:/sbin + . build.common DEFAULT_FCDISTRO=f20 @@ -732,7 +736,7 @@ function post_install () { post_install_build $lxc $personality lxc_start $lxc # manually run dhclient in guest - somehow this network won't start on its own - virsh -c lxc:/// lxc-enter-namespace $lxc $(bin_in_container $lxc dhclient) $VIF_GUEST + virsh -c lxc:/// lxc-enter-namespace $lxc /bin/bash -c "dhclient $VIF_GUEST" else post_install_myplc $lxc $personality lxc_start $lxc diff --git a/lbuild-nightly.sh b/lbuild-nightly.sh index 8fd1f7d7..958c6168 100755 --- a/lbuild-nightly.sh +++ b/lbuild-nightly.sh @@ -3,6 +3,10 @@ COMMANDPATH=$0 COMMAND=$(basename $0) +# old guests have e.g. mount in /bin but this is no longer part of +# the standard PATH in recent hosts after usrmove, so let's keep it simple +export PATH=$PATH:/bin:/sbin + # default values, tunable with command-line options DEFAULT_FCDISTRO=f20 DEFAULT_PLDISTRO=planetlab @@ -214,22 +218,6 @@ function in_root_context () { rpm -q libvirt > /dev/null } -# copied from build.common because this cannot have deps. -# (when pulled from infrastructure/scripts/lbuild-nightly.sh) -# old guests have e.g. mount in /bin but this is no longer part of -# the standard PATH in recent hosts after usrmove, so let's keep it simple -export PATH=$PATH:/bin:/sbin - -# would be much simpler if enter-lxc-namespace was looking along a PATH... -function bin_in_container () { - lxc=$1; shift - binary=$1; shift - for path in $(echo $PATH | sed -e 's,:, ,g' ); do - [ -f /vservers/$lxc/$path/$binary ] && { echo $path/$binary; return; } - done - echo bin_in_container_cannot_find_$binary -} - # run in the vm - do not manage success/failure, will be done from the root ctx function build () { set -x @@ -304,7 +292,7 @@ function run_log () { ssh -n ${testmaster_ssh} rm -rf ${testdir} ${testdir}.git # check it out in the build - virsh -c lxc:/// lxc-enter-namespace $BASE -- $(bin_in_container $BASE make) -C /build tests-module + virsh -c lxc:/// lxc-enter-namespace $BASE /bin/bash -c "make -C /build tests-module" # push it onto the testmaster - just the 'system' subdir is enough rsync --verbose --archive $(rootdir $BASE)/build/MODULES/tests/system/ ${testmaster_ssh}:${BASE} @@ -632,11 +620,11 @@ function main () { virsh -c lxc:/// start ${BASE} || : # retrieve environment from the previous run FCDISTRO=$(virsh -c lxc:/// lxc-enter-namespace ${BASE} /build/getdistroname.sh) - BUILD_SCM_URL=$(virsh -c lxc:/// lxc-enter-namespace ${BASE} -- $(bin_in_container $BASE make) --no-print-directory -C /build stage1=skip +build-GITPATH) + BUILD_SCM_URL=$(virsh -c lxc:/// lxc-enter-namespace ${BASE} /bin/bash -c "make --no-print-directory -C /build stage1=skip +build-GITPATH") # for efficiency, crop everything in one make run tmp=/tmp/${BASE}-env.sh - virsh -c lxc:/// lxc-enter-namespace ${BASE} -- $(bin_in_container $BASE make) --no-print-directory -C /build stage1=skip \ - ++PLDISTRO ++PLDISTROTAGS ++PERSONALITY ++MAILTO ++WEBPATH ++TESTBUILDURL ++WEBROOT > $tmp + virsh -c lxc:/// lxc-enter-namespace ${BASE} /bin/bash -c "make --no-print-directory -C /build stage1=skip \ + ++PLDISTRO ++PLDISTROTAGS ++PERSONALITY ++MAILTO ++WEBPATH ++TESTBUILDURL ++WEBROOT" > $tmp . $tmp rm -f $tmp # update build @@ -721,7 +709,7 @@ function main () { cp $COMMANDPATH $(rootdir ${BASE})/build/ # invoke this command in the vm for building (-T) - virsh -c lxc:/// lxc-enter-namespace ${BASE} $(bin_in_container $BASE chmod) +x /build/$COMMAND + virsh -c lxc:/// lxc-enter-namespace ${BASE} /bin/bash -c "chmod +x /build/$COMMAND" virsh -c lxc:/// lxc-enter-namespace ${BASE} /build/$COMMAND "${options[@]}" -b "${BASE}" "${MAKEVARS[@]}" "${MAKETARGETS[@]}" fi