#!/bin/bash
-# NOTE on lxcsu
-# this tool derives from the PL code, from the lxc-userspace module
-# can be obtained through rpm/yum
-# it is used here as a replacement for 'vserver <> exec'
-# that is used throughout this code
-
COMMANDPATH=$0
COMMAND=$(basename $0)
DEFAULT_PERSONALITY=linux64
DEFAULT_BASE="@DATE@--@PLDISTRO@-@FCDISTRO@-@PERSONALITY@"
DEFAULT_BUILD_SCM_URL="git://git.onelab.eu/build"
-DEFAULT_IFNAME=eth0
# default gpg path used in signing yum repo
DEFAULT_GPGPATH="/etc/planetlab"
# but the PL code still uses this name for now, so let's keep it simple
function rootdir () {
slice=$1; shift
- echo /vservers/$slice/rootfs
+ echo /vservers/$slice
}
function logfile () {
slice=$1; shift
if test -z "$WEBLOG" ; then
WEBHOST=$(hostname)
WEBPATH=/tmp
- WEBBASE=/tmp/vbuild-early-$(date +%Y-%m-%d)
- WEBLOG=/tmp/vbuild-early-$(date +%Y-%m-%d).log.txt
+ WEBBASE=/tmp/lbuild-early-$(date +%Y-%m-%d)
+ WEBLOG=/tmp/lbuild-early-$(date +%Y-%m-%d).log.txt
fi
webpublish mkdir -p $WEBBASE ||:
webpublish_cp_local_to_remote $LOG $WEBLOG ||:
if test -z "$WEBLOG" ; then
WEBHOST=$(hostname)
WEBPATH=/tmp
- WEBLOG=/tmp/vbuild-early-$(date +%Y-%m-%d).log.txt
+ WEBLOG=/tmp/lbuild-early-$(date +%Y-%m-%d).log.txt
fi
webpublish mkdir -p $WEBBASE
webpublish_cp_local_to_remote $LOG $WEBLOG
exit 0
}
+##############################
+# manage root / container contexts
+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
ssh -n ${testmaster_ssh} rm -rf ${testdir} ${testdir}.git
# check it out in the build
- lxcsu -ro $BASE make -C /build tests-module
+ virsh -c lxc:/// lxc-enter-namespace $BASE -- $(bin_in_container $BASE 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}
}
-function in_root_context () {
- rpm -q libvirt > /dev/null
-}
-
# this part won't work if WEBHOST does not match the local host
# would need to be made webpublish_* compliant
# but do we really need this feature anyway ?
echo " -c testconfig - defaults to $DEFAULT_TESTCONFIG"
echo " -y {pl,pg} - passed to run_log"
echo " -e step - passed to run_log"
+ echo " -i step - passed to run_log"
echo " -X : passes --lxc to run_log"
echo " -S : passes --vs to run_log"
echo " -x <run_log_args> - a hook to pass other arguments to run_log"
echo " -n - dry-run: -n passed to make - vm gets created though - no mail sent"
echo " -v - be verbose"
echo " -7 - uses weekday-@FCDISTRO@ as base"
- echo " -i ifname - defaults to $DEFAULT_IFNAME - used to determine local IP"
echo " --build-branch branch - build using the branch from build module"
exit 1
}
SIGNYUMREPO=""
OPTS_ORIG=$@
- OPTS=$(getopt -o "f:d:p:m:s:t:b:o:c:y:e:XSx:w:W:r:M:Yg:u:K:SBTnv7i:P:h" -l "build-branch:" -- $@)
+ OPTS=$(getopt -o "f:d:p:m:s:t:b:o:c:y:e:i:XSx:w:W:r:M:Yg:u:K:SBTnv7i:P:h" -l "build-branch:" -- $@)
if [ $? != 0 ]
then
usage
-y) RUN_LOG_EXTRAS="$RUN_LOG_EXTRAS --rspec-style $2"; shift 2 ;;
# -e foo -> run_log -e foo
-e) RUN_LOG_EXTRAS="$RUN_LOG_EXTRAS --exclude $2"; shift 2 ;;
+ -i) RUN_LOG_EXTRAS="$RUN_LOG_EXTRAS --ignore $2"; shift 2 ;;
# -X -> run_log --lxc
-X) RUN_LOG_EXTRAS="$RUN_LOG_EXTRAS --lxc"; shift;;
# -S -> run_log --vs
-n) DRY_RUN="-n" ; shift ;;
-v) set -x ; VERBOSE="-v" ; shift ;;
-7) BASE="$(date +%a|tr A-Z a-z)-@FCDISTRO@" ; shift ;;
- -i) IFNAME=$2; shift 2 ;;
-P) PREINSTALLED="-P $2"; shift 2;;
-h) usage ; shift ;;
--) shift; break ;;
[ -z "$WEBROOT" ] && WEBROOT="$DEFAULT_WEBROOT"
[ -z "$GPGPATH" ] && GPGPATH="$DEFAULT_GPGPATH"
[ -z "$GPGUID" ] && GPGUID="$DEFAULT_GPGUID"
- [ -z "$IFNAME" ] && IFNAME="$DEFAULT_IFNAME"
[ -z "$BUILD_SCM_URL" ] && BUILD_SCM_URL="$DEFAULT_BUILD_SCM_URL"
[ -z "$TESTCONFIG" ] && TESTCONFIG="$DEFAULT_TESTCONFIG"
[ -z "$TESTMASTER" ] && TESTMASTER="$DEFAULT_TESTMASTER"
set -x
echo "XXXXXXXXXX $COMMAND: using existing vm $BASE" $(date)
# start in case e.g. we just rebooted
- virsh --connect lxc:/// start ${BASE} || :
+ virsh -c lxc:/// start ${BASE} || :
# retrieve environment from the previous run
- FCDISTRO=$(lxcsu -ro ${BASE} /build/getdistroname.sh)
- BUILD_SCM_URL=$(lxcsu -ro ${BASE} make --no-print-directory -C /build stage1=skip +build-GITPATH)
+ 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)
# for efficiency, crop everything in one make run
tmp=/tmp/${BASE}-env.sh
- lxcsu -ro ${BASE} make --no-print-directory -C /build stage1=skip \
+ 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
. $tmp
rm -f $tmp
# update build
[ -n "$SSH_KEY" ] && setupssh ${BASE} ${SSH_KEY}
- lxcsu -ro $BASE bash -c "cd /build; git pull; make tests-clean"
+ virsh -c lxc:/// lxc-enter-namespace $BASE /bin/bash -c "cd /build; git pull; make tests-clean"
# make sure we refresh the tests place in case it has changed
rm -f /build/MODULES/tests
options=(${options[@]} -d $PLDISTRO -t $PLDISTROTAGS -s $BUILD_SCM_URL)
# Create lxc vm
cd $tmpdir
- ./vbuild-init-lxc.sh $VERBOSE -f ${FCDISTRO} -d ${PLDISTRO} -p ${PERSONALITY} -i ${IFNAME} ${PREINSTALLED} ${BASE}
+ ./lbuild-initvm.sh $VERBOSE -f ${FCDISTRO} -d ${PLDISTRO} -p ${PERSONALITY} ${PREINSTALLED} ${BASE}
# cleanup
cd -
rm -rf $tmpdir
# Extract build again - in the vm
[ -n "$SSH_KEY" ] && setupssh ${BASE} ${SSH_KEY}
- lxcsu -ro $BASE bash -c "git clone $GIT_REPO /build; cd /build; git checkout $GIT_TAG"
+ # xxx not working as of now - waiting for Sapan to look into this
+ virsh -c lxc:/// lxc-enter-namespace $BASE /bin/bash -c "git clone $GIT_REPO /build; cd /build; git checkout $GIT_TAG"
fi
echo "XXXXXXXXXX $COMMAND: preparation of vm $BASE done" $(date)
cp $COMMANDPATH $(rootdir ${BASE})/build/
# invoke this command in the vm for building (-T)
- lxcsu -ro ${BASE} chmod +x /build/$COMMAND
- lxcsu -ro ${BASE} /build/$COMMAND "${options[@]}" -b "${BASE}" "${MAKEVARS[@]}" "${MAKETARGETS[@]}"
+ virsh -c lxc:/// lxc-enter-namespace ${BASE} $(bin_in_container $BASE chmod) +x /build/$COMMAND
+ virsh -c lxc:/// lxc-enter-namespace ${BASE} /build/$COMMAND "${options[@]}" -b "${BASE}" "${MAKEVARS[@]}" "${MAKETARGETS[@]}"
fi
# publish to the web so run_log can find them
else
# run scanpackages so we can use apt-get on this
# (not needed on fedora b/c this is done by the regular build already)
- lxcsu -ro $BASE bash -c "(cd /build ; dpkg-scanpackages DEBIAN/ | gzip -9c > Packages.gz)"
+ virsh -c lxc:/// lxc-enter-namespace $BASE /bin/bash -c "(cd /build ; dpkg-scanpackages DEBIAN/ | gzip -9c > Packages.gz)"
webpublish mkdir -p $WEBPATH/$BASE/DEBIAN
webpublish_rsync_files $WEBPATH/$BASE/DEBIAN/ $(rootdir $BASE)/build/DEBIAN/*.deb
webpublish_rsync_files $WEBPATH/$BASE/ $(rootdir $BASE)/build/Packages.gz
echo "==================== MAIN END $(date)"
fi
-}
+}
##########
main "$@"