export GIT_PROJECT=kameleon export ROOT_PROJECT=$(dirname $(readlink -f ${BASH_SOURCE[0]})) export KAMELEON_LOG=${KAMELEON_LOG:-"info"} function kameleon { BUNDLE_GEMFILE=$ROOT_PROJECT/Gemfile sudo -E bundle exec kameleon $@ } function runtest { sudo -E BUNDLE_GEMFILE=$ROOT_PROJECT/Gemfile bundle exec rake $@ } function devrun_chroot_clean() { mount \ | grep rootfs | grep kameleon \ | py "s='rootfs'" "l=x.split(' ')[2].split(s)[0]" "print(l)" \ | uniq \ | xargs -I {} sudo bash "$ROOT_PROJECT"/contrib/scripts/umount-chroot.sh -p -f -a -k -y -c "{}" } function devrun_clear() { KAMELEON_WORKSPACE=${KAMELEON_WORKSPACE:-"/tmp/kameleon/"} RECIPE_DEV_NAME=${RECIPE_DEV_NAME:-"mymachine"} devrun_chroot_clean kameleon clear $RECIPE_DEV_NAME -w $KAMELEON_WORKSPACE if [ -d "$KAMELEON_WORKSPACE/builds" ]; then sudo rm "$KAMELEON_WORKSPACE/builds" -fr 2> /dev/null fi } function devrun_qemu() { KAMELEON_WORKSPACE=${KAMELEON_WORKSPACE:-"/tmp/kameleon/"} RECIPE_DEV_NAME=${RECIPE_DEV_NAME:-"mymachine"} path="$KAMELEON_WORKSPACE/builds/$RECIPE_DEV_NAME/${RECIPE_DEV_NAME}.qcow2" sudo qemu-system-x86_64 -enable-kvm $path } function devrun_build() { KAMELEON_WORKSPACE=${KAMELEON_WORKSPACE:-"/tmp/kameleon/"} RECIPE_DEV_NAME=${RECIPE_DEV_NAME:-"mymachine"} TEMPLATE=${1:-"debian-wheezy-chroot"} devrun_chroot_clean cmd="kameleon new $RECIPE_DEV_NAME -t $TEMPLATE -w $KAMELEON_WORKSPACE \ && kameleon build $RECIPE_DEV_NAME -w $KAMELEON_WORKSPACE" eval "$cmd" if [ -d "$KAMELEON_WORKSPACE/builds/$RECIPE_DEV_NAME" ]; then cd "$KAMELEON_WORKSPACE/builds/$RECIPE_DEV_NAME" fi }