Last active
October 12, 2018 18:25
-
-
Save tai271828/62771c4ee8bb5484c5139c9d84724691 to your computer and use it in GitHub Desktop.
Create Curtin development environment in a quick way
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
serial.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# ./activate.sh | |
# ubuntu / passw0rd | |
# "sudo shutdown -h now" to exit | |
# | |
# | |
# Flow: | |
# - create boot.img in 2G qcow by converting cloud image | |
# - use cloud-localds to make seed.img | |
# - inject seed.img as cloud-init data for boot.img 1st boot | |
# - ready to "curtin" something to disk1.img, which is a 5G disk in raw | |
# format created by qemu-create. | |
# - "curtin" tar.gz, which was downloaded from internet, to the disk1.img | |
# | |
# | |
# Tips to use the curtin ephemeral env (boot.img): | |
# - The ephemeral env could access internet, because it needs to pull packages during installation (flash root.tar.gz or something to the target disk). | |
# - you should tell where to get the root.tar.gz exactly by curtin install <the PATH> | |
# | |
# | |
# Refer to: | |
# https://curtin.readthedocs.io/en/latest/topics/development.html | |
# Updated: this page is not available anymore. The test flow seems | |
# to be integrated in vmtest. | |
# https://curtin.readthedocs.io/en/latest/topics/integration-testing.html | |
# | |
DLDIR=`mktemp -d -t curtin-dev-XXXXXX` | |
echo "Your temp working folder is: " $DLDIR | |
DLDIR=$( cd $DLDIR && pwd ) | |
# pull curtin source | |
# checkout to the earlier version because I do not want to use the vmtest integreation test. | |
( cd ${DLDIR} && git clone https://git.launchpad.net/curtin && cd curtin && git checkout fb9900476fc0f6a6cda30e0828288ef2659b05cf ) | |
# create the virtual environment | |
rel="trusty" | |
arch=amd64 | |
burl="http://cloud-images.ubuntu.com/$rel/current/" | |
prefix="$rel-server-cloudimg-${arch}" | |
BOOTIMG_NAME="${prefix}-disk1.qcow2" | |
BOOTIMG_ORIG_NAME="${prefix}-disk1.img" | |
ROOTTGZ_NAME="${prefix}-root.tar.gz" | |
BOOTIMG="$DLDIR/${BOOTIMG_NAME}" | |
BOOTIMG_ORIG="$DLDIR/${BOOTIMG_ORIG_NAME}" | |
ROOTTGZ="$DLDIR/${ROOTTGZ_NAME}" | |
for f in ${ROOTTGZ_NAME} ${BOOTIMG_ORIG_NAME} | |
do | |
wget "$burl/$f" -O $DLDIR/$f | |
done | |
( cd $DLDIR && qemu-img convert -O qcow ${BOOTIMG_ORIG} ${BOOTIMG} ) | |
# activate the virtual environment | |
cd $DLDIR/curtin/ | |
LAUNCH_CMD="./tools/launch $BOOTIMG --publish $ROOTTGZ -- curtin install \"PUBURL/${ROOTTGZ##*/}\"" | |
echo ${LAUNCH_CMD} | |
${LAUNCH_CMD} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
LAB="${HOME}/work/curtin-study/lab/launch-files" | |
qemu-system-x86_64 -enable-kvm \ | |
-device virtio-scsi-pci,id=virtio-scsi-xkvm \ | |
-device virtio-net-pci,netdev=net00 \ | |
-netdev type=tap,id=net00,script=no,downscript=no,ifname=tapvm0 \ | |
-drive file=${LAB}/boot.img,id=boot,if=none,format=qcow2,index=1,cache=unsafe \ | |
-device virtio-blk,drive=boot,serial=boot.img \ | |
-drive file=${LAB}/disk1.img,id=drv2,if=none,format=raw,index=2,cache=unsafe \ | |
-device virtio-blk,drive=drv2,serial=disk1.img,logical_block_size=512,physical_block_size=512,min_io_size=512 \ | |
-smp 2 \ | |
-m 1024 \ | |
-serial file:serial.log \ | |
-curses \ | |
-vga std \ | |
-drive file=${LAB}/seed.img,if=virtio,media=cdrom |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment