diff --git a/Makefile b/Makefile index 21f6c98..215dfbf 100644 --- a/Makefile +++ b/Makefile @@ -1,85 +1,25 @@ all: -clean: clean-lynx32 clean-lynxx32 clean-lynx64 clean-lynxx64 clean-meerkat32 clean-meerkat64 clean-narwhal32 clean-narwhal64 +clean: clean-precise32 clean-precise64 -lynx32: - NICKNAME=lynx VERSION=10.04 ARCH=i386 ./build-iso - NICKNAME=lynx VERSION=10.04 ARCH=i386 ./build-vbox - NICKNAME=lynx VERSION=10.04 ARCH=i386 ./build-vagrant +precise32: + NICKNAME=precise VERSION=12.04 ARCH=i386 ./build-iso + NICKNAME=precise VERSION=12.04 ARCH=i386 ./build-vbox + NICKNAME=precise VERSION=12.04 ARCH=i386 ./build-vagrant -clean-lynx32: - NICKNAME=lynx VERSION=10.04 ARCH=i386 ./clean-iso - NICKNAME=lynx VERSION=10.04 ARCH=i386 ./clean-vbox || true - NICKNAME=lynx VERSION=10.04 ARCH=i386 ./clean-vagrant +clean-precise32: + NICKNAME=precise VERSION=12.04 ARCH=i386 ./clean-iso + NICKNAME=precise VERSION=12.04 ARCH=i386 ./clean-vbox || true + NICKNAME=precise VERSION=12.04 ARCH=i386 ./clean-vagrant -lynxx32: - NICKNAME=lynxx VERSION=10.04.2 ARCH=i386 ./build-iso - NICKNAME=lynxx VERSION=10.04.2 ARCH=i386 ./build-vbox - NICKNAME=lynxx VERSION=10.04.2 ARCH=i386 ./build-vagrant +precise64: + NICKNAME=precise VERSION=12.04 ARCH=amd64 ./build-iso + NICKNAME=precise VERSION=12.04 ARCH=amd64 ./build-vbox + NICKNAME=precise VERSION=12.04 ARCH=amd64 ./build-vagrant -clean-lynxx32: - NICKNAME=lynxx VERSION=10.04.2 ARCH=i386 ./clean-iso - NICKNAME=lynxx VERSION=10.04.2 ARCH=i386 ./clean-vbox || true - NICKNAME=lynxx VERSION=10.04.2 ARCH=i386 ./clean-vagrant +clean-precise64: + NICKNAME=precise VERSION=12.04 ARCH=amd64 ./clean-iso + NICKNAME=precise VERSION=12.04 ARCH=amd64 ./clean-vbox || true + NICKNAME=precise VERSION=12.04 ARCH=amd64 ./clean-vagrant -lynx64: - NICKNAME=lynx VERSION=10.04 ARCH=amd64 ./build-iso - NICKNAME=lynx VERSION=10.04 ARCH=amd64 ./build-vbox - NICKNAME=lynx VERSION=10.04 ARCH=amd64 ./build-vagrant - -clean-lynx64: - NICKNAME=lynx VERSION=10.04 ARCH=amd64 ./clean-iso - NICKNAME=lynx VERSION=10.04 ARCH=amd64 ./clean-vbox || true - NICKNAME=lynx VERSION=10.04 ARCH=amd64 ./clean-vagrant - -lynxx64: - NICKNAME=lynxx VERSION=10.04.2 ARCH=amd64 ./build-iso - NICKNAME=lynxx VERSION=10.04.2 ARCH=amd64 ./build-vbox - NICKNAME=lynxx VERSION=10.04.2 ARCH=amd64 ./build-vagrant - -clean-lynxx64: - NICKNAME=lynxx VERSION=10.04.2 ARCH=amd64 ./clean-iso - NICKNAME=lynxx VERSION=10.04.2 ARCH=amd64 ./clean-vbox || true - NICKNAME=lynxx VERSION=10.04.2 ARCH=amd64 ./clean-vagrant - -meerkat32: - NICKNAME=meerkat VERSION=10.10 ARCH=i386 ./build-iso - NICKNAME=meerkat VERSION=10.10 ARCH=i386 ./build-vbox - NICKNAME=meerkat VERSION=10.10 ARCH=i386 ./build-vagrant - -clean-meerkat32: - NICKNAME=meerkat VERSION=10.10 ARCH=i386 ./clean-iso - NICKNAME=meerkat VERSION=10.10 ARCH=i386 ./clean-vbox || true - NICKNAME=meerkat VERSION=10.10 ARCH=i386 ./clean-vagrant - -meerkat64: - NICKNAME=meerkat VERSION=10.10 ARCH=amd64 ./build-iso - NICKNAME=meerkat VERSION=10.10 ARCH=amd64 ./build-vbox - NICKNAME=meerkat VERSION=10.10 ARCH=amd64 ./build-vagrant - -clean-meerkat64: - NICKNAME=meerkat VERSION=10.10 ARCH=amd64 ./clean-iso - NICKNAME=meerkat VERSION=10.10 ARCH=amd64 ./clean-vbox || true - NICKNAME=meerkat VERSION=10.10 ARCH=amd64 ./clean-vagrant - -narwhal32: - NICKNAME=narwhal VERSION=11.04 ARCH=i386 ./build-iso - NICKNAME=narwhal VERSION=11.04 ARCH=i386 ./build-vbox - NICKNAME=narwhal VERSION=11.04 ARCH=i386 ./build-vagrant - -clean-narwhal32: - NICKNAME=narwhal VERSION=11.04 ARCH=i386 ./clean-iso - NICKNAME=narwhal VERSION=11.04 ARCH=i386 ./clean-vbox || true - NICKNAME=narwhal VERSION=11.04 ARCH=i386 ./clean-vagrant - -narwhal64: - NICKNAME=narwhal VERSION=11.04 ARCH=amd64 ./build-iso - NICKNAME=narwhal VERSION=11.04 ARCH=amd64 ./build-vbox - NICKNAME=narwhal VERSION=11.04 ARCH=amd64 ./build-vagrant - -clean-narwhal64: - NICKNAME=narwhal VERSION=11.04 ARCH=amd64 ./clean-iso - NICKNAME=narwhal VERSION=11.04 ARCH=amd64 ./clean-vbox || true - NICKNAME=narwhal VERSION=11.04 ARCH=amd64 ./clean-vagrant - -.PHONY: all lynx32 clean-lynx32 lynx64 clean-lynx64 meerkat32 clean-meerkat32 meerkat64 clean-meerkat64 clean-narwhal32 clean-narwhal64 +.PHONY: all clean-precise32 clean-precise64 diff --git a/README.md b/README.md index 03347e0..f72d80d 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,13 @@ -Ubuntu for DevStructure -======================= +Ubuntu for Vagrant +================== -Build a custom Ubuntu ISO for Vagrant by downloading, extracting, +Build a custom Ubuntu base box for Vagrant by downloading, extracting, tweaking, and packaging the stock Ubuntu ISO. Build dependencies ------------------ * `curl`(1). -* `hdiutil`(1), and therefore Mac OS X. It may be possible to relax - this dependency but it has not been investigated. * `m4`(1). * `mkisofs`(1) from the `cdrtools` package available from MacPorts or Homebrew. @@ -36,10 +34,15 @@ Features in the ISO are all configurable. * OpenSSH server is installed. * VirtualBox Guest Additions are installed. +* Chef is installed. Building -------- +Edit configuration in + + config.sh + Building ISO images: ./build-iso @@ -52,7 +55,14 @@ Building Vagrant boxes: ./build-vagrant -There are matching `clean-{iso,vbox,vagrant}` programs that remove the +There are matching `clean-{iso,vbox,vagrant}` scripts that remove the products of their build counterparts. -The `Makefile` contains targets for common build tasks. +The `Makefile` contains targets for common build tasks. For Ubuntu 12.04 +(Precise Pangolin) 32-bit use + + make precise32 + +For Ubuntu 12.04 (Precise Pangolin) 64-bit use + + make precise64 diff --git a/build-vagrant b/build-vagrant index 223a0ae..7f39033 100755 --- a/build-vagrant +++ b/build-vagrant @@ -8,19 +8,18 @@ VBOX="$NICKNAME-ubuntu-$VERSION-$DISTRO-$ARCH" # Start the virtual machine. Spin slowly until SSH is usable. VBoxManage startvm "$VBOX" --type gui -#VBoxHeadless --startvm "$VBOX" --vrdp config until eval "$SSH exit" do sleep 1 done # Install Ruby, RubyGems, and Chef as Vagrant requires. -# eval "$SSH \" -# set -e -# sudo apt-get -y install build-essential ruby-dev rubygems -# sudo gem install --no-rdoc --no-ri chef -# echo 'PATH=\"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/var/lib/gems/1.8/bin\"' | sudo tee /etc/environment >/dev/null -# \"" +eval "$SSH \" + set -e + sudo apt-get -y install build-essential ruby-dev rubygems + sudo gem install --no-rdoc --no-ri chef + echo 'PATH=\"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/var/lib/gems/1.8/bin\"' | sudo tee /etc/environment >/dev/null + \"" # Shutdown the virtual machine. eval "$SSH \"sudo shutdown -h now\"" @@ -34,5 +33,7 @@ vagrant package --base "$VBOX" mv "package.box" \ "$NICKNAME$([ "$ARCH" = "i386" ] && echo 32 || echo 64).box" +echo "Successfully built vagrant box!" + # Creating Vagrant boxes ruins the normal VM setup so get rid of them. eval "$(dirname $0)/clean-vbox" diff --git a/build-vbox b/build-vbox index cc4c75c..1b7be89 100755 --- a/build-vbox +++ b/build-vbox @@ -54,21 +54,26 @@ VBoxManage storageattach "$VBOX" \ # Start the virtual machine and the OS installation. This will take -# a while so this time it gets a GUI. Spin slowly until SSH is usable. +# a while so this time it gets a GUI. Wait until installation finished +# and vm is powered off. VBoxManage startvm "$VBOX" --type gui echo "Waiting for installion to finish.." -until eval "$SSH exit" +until VBoxManage showvminfo "$VBOX" | grep "^State: *powered off" do - sleep 60 + sleep 10 done # Attach the VBoxGuestAdditions ISO, implicitly detaching the custom -# installation ISO in the process. Install the additions and empty -# the drive. +# installation ISO in the process. VBoxManage storageattach "$VBOX" \ --storagectl SATA \ --port 1 --device 0 \ --type dvddrive --medium "$VBOX_GUEST_ADDITIONS" + +# Power up vm again. +VBoxManage startvm "$VBOX" -- + +# Install guest additions. eval "$SSH \" set -e sudo apt-get -y install linux-headers-\\\$(uname -r) build-essential @@ -79,10 +84,6 @@ eval "$SSH \" sudo /media/cdrom/VBoxLinuxAdditions.run sudo umount /media/cdrom \"" -VBoxManage storageattach "$VBOX" \ - --storagectl SATA \ - --port 1 --device 0 \ - --type dvddrive --medium emptydrive # Shutdown the virtual machine. eval "$SSH \"sudo shutdown -h now\"" @@ -90,3 +91,9 @@ until VBoxManage showvminfo "$VBOX" | grep "^State: *powered off" do sleep 1 done + +# Remove guest additions cd. +VBoxManage storageattach "$VBOX" \ + --storagectl SATA \ + --port 1 --device 0 \ + --type dvddrive --medium emptydrive diff --git a/clean-iso b/clean-iso index 3491c59..eb0c118 100755 --- a/clean-iso +++ b/clean-iso @@ -5,3 +5,10 @@ set -e . "$(dirname $0)/config.sh" rm -f "$NICKNAME-ubuntu-$VERSION-$DISTRO-$ARCH.iso" +{ + sudo diskutil unmount "mount" + sudo /usr/libexec/vndevice detach /dev/vn0 +} || { + sudo umount "mount" + rm -rf "mount" +} diff --git a/clean-vbox b/clean-vbox index d85a665..52f3e9c 100755 --- a/clean-vbox +++ b/clean-vbox @@ -1,14 +1,11 @@ #!/bin/sh -# set -e # Try our best to finish here. - . "$(dirname $0)/config.sh" ISO="$NICKNAME-ubuntu-$VERSION-$DISTRO-$ARCH.iso" VBOX="$NICKNAME-ubuntu-$VERSION-$DISTRO-$ARCH" VBoxManage controlvm "$VBOX" poweroff -VBoxManage storagectl "$VBOX" --name IDE --remove VBoxManage storagectl "$VBOX" --name SATA --remove VBoxManage unregistervm "$VBOX" VBoxManage closemedium dvd "$PWD/$ISO" diff --git a/config.sh b/config.sh index 9e9dfa4..a9785e1 100644 --- a/config.sh +++ b/config.sh @@ -4,7 +4,7 @@ : ${NICKNAME:="vagrant"} # Arguments given to the download router. -: ${VERSION:="10.10"} +: ${VERSION:="12.04"} : ${DISTRO:="server"} : ${RELEASE:="latest"} diff --git a/unattended.seed.m4 b/unattended.seed.m4 index 0474b04..3a3f862 100644 --- a/unattended.seed.m4 +++ b/unattended.seed.m4 @@ -48,6 +48,7 @@ d-i grub-installer/with_other_os boolean true d-i finish-install/reboot_in_progress note d-i cdrom-detect/eject boolean true d-i debian-installer/splash boolean false +d-i debian-installer/exit/poweroff boolean true # Everything else. d-i preseed/late_command string sh /cdrom/late_command.sh