.env in kameleon-builder-2.0.0 vs .env in kameleon-builder-2.1.0
- old
+ new
@@ -1,12 +1,21 @@
+#!/usr/bin/env bash
+
+export QEMU_AUDIO_DRV=alsa
export GIT_PROJECT=kameleon
export ROOT_PROJECT=$(dirname $(readlink -f ${BASH_SOURCE[0]}))
export KAMELEON_LOG=${KAMELEON_LOG:-"info"}
+# enable kameleon autocompletion
+source $ROOT_PROJECT/completion/kameleon.bash
+
+QEMU_MONITOR_PORT=11023
+
+
function kameleon {
- BUNDLE_GEMFILE=$ROOT_PROJECT/Gemfile sudo -E bundle exec kameleon $@
+ sudo -E BUNDLE_GEMFILE=$ROOT_PROJECT/Gemfile bundle exec kameleon $@
}
function runtest {
sudo -E BUNDLE_GEMFILE=$ROOT_PROJECT/Gemfile bundle exec rake $@
}
@@ -19,33 +28,72 @@
| 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/"}
+ KAMELEON_WORKDIR=${KAMELEON_WORKDIR:-"/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
+ cd $KAMELEON_WORKDIR
+ kameleon clear $RECIPE_DEV_NAME.yaml
+ if [ -d "$KAMELEON_WORKDIR/build" ]; then
+ sudo rm "$KAMELEON_WORKDIR/build" -fr 2> /dev/null
fi
}
+function devrun_qemu_stop() {
+ if nc -w 0 -z localhost $QEMU_MONITOR_PORT 2>/dev/null
+ then
+ echo "Shutting down qemu virtual machine"
+ echo "system_reset" | nc localhost $QEMU_MONITOR_PORT
+ echo ""
+ fi
+ while nc -w 0 -z localhost $QEMU_MONITOR_PORT
+ do
+ sleep 0.5
+ echo -n "."
+ done
+ echo " ~> OK"
+}
+
function devrun_qemu() {
- KAMELEON_WORKSPACE=${KAMELEON_WORKSPACE:-"/tmp/kameleon/"}
+ KAMELEON_WORKDIR=${KAMELEON_WORKDIR:-"/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
+ DRIVE="$KAMELEON_WORKDIR/build/$RECIPE_DEV_NAME/${RECIPE_DEV_NAME}.qcow2"
+ RAM_COUNT=2048
+ SPICE_PORT=5900
+ CPU_COUNT=2
+ sudo qemu-system-x86_64 \
+ -name "$VM_NAME" \
+ -machine pc-1.2,accel=kvm,usb=off -m 2048 -realtime mlock=off \
+ -smp $CPU_COUNT \
+ -drive file="$DRIVE",cache=none,media=disk,if=virtio,id=drive0 \
+ -m $RAM_COUNT \
+ -no-reboot \
+ -rtc base=utc \
+ -soundhw ac97 \
+ -net nic,model=virtio -net user \
+ -usb \
+ -usbdevice tablet \
+ -vga qxl \
+ -spice port=$SPICE_PORT,addr=127.0.0.1,disable-ticketing,image-compression=auto_lz \
+ -device virtio-serial-pci \
+ -device virtserialport,chardev=spicechannel0,name=com.redhat.spice.0 \
+ -chardev spicevmc,id=spicechannel0,name=vdagent \
+ -monitor tcp::$QEMU_MONITOR_PORT,server,nowait \
+ -daemonize
+ spicec -h 127.0.0.1 -p $SPICE_PORT --title "$VM_NAME" || :
+ devrun_qemu_stop
}
function devrun_build() {
- KAMELEON_WORKSPACE=${KAMELEON_WORKSPACE:-"/tmp/kameleon/"}
+ KAMELEON_WORKDIR=${KAMELEON_WORKDIR:-"/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"
+ TEMPLATE=${1:-"debian7"}
+ mkdir -p $KAMELEON_WORKDIR && cd $KAMELEON_WORKDIR
+ cmd="kameleon new $RECIPE_DEV_NAME $TEMPLATE \
+ && kameleon build $RECIPE_DEV_NAME.yaml"
eval "$cmd"
- if [ -d "$KAMELEON_WORKSPACE/builds/$RECIPE_DEV_NAME" ]; then
- cd "$KAMELEON_WORKSPACE/builds/$RECIPE_DEV_NAME"
+ if [ -d "$KAMELEON_WORKDIR/build/$RECIPE_DEV_NAME" ]; then
+ cd "$KAMELEON_WORKDIR/build/$RECIPE_DEV_NAME"
fi
}