Browse files

Merge pull request #1 from mostlygeek/master

Updates for official 12.04 release
  • Loading branch information...
2 parents 586c4fd + bd8d872 commit e1d133bd7fa5aa683b372c225a594ea32cea66b6 @cal cal committed Apr 27, 2012
Showing with 88 additions and 8 deletions.
  1. +2 −1 .gitignore
  2. +18 −0 LICENSE
  3. +36 −0 README
  4. +32 −7 build.sh
View
3 .gitignore
@@ -3,4 +3,5 @@ test/
.DS_Store
-package.box
+*.box
+*.iso
View
18 LICENSE
@@ -0,0 +1,18 @@
+Copyright (C) 2012 Carl Johan Crafoord, Benson Wong
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
36 README
@@ -1,3 +1,39 @@
+About
+-----
+
+This script will:
+
+ 1. download the Ubuntu 12.04 alternate server, 64bit iso
+ 2. ... do some magic to turn it into a vagrant box file
+ 3. output package.box
+
+Usage
+-----
+
+ > ./build.sh
+
+ This should do everything you need. If you don't have
+ mkisofs, install macports, then: sudo port install cdrtools
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Ben's notes
+-----------
+
+Forked Carl's repo, and it sort of worked out of the box. Tweaked
+office 12.04 release:
+
+ - Downloading 12.04 final release. (Today as of this writing)
+ - Checking MD5 to make sure it is the right version
+ - Added a few more checks for external dependencies, mkisofs
+ - Removed wget, and used curl to reduce dependencies
+ - Added more output to see what is going on
+ - Still designed to work on Mac OS X :)
+ ... though it should work for Linux systems too (maybe w/ a bit of porting)
+
+Carl's original README
+----------------------
+
Decided I wanted to learn how to make a vagrant base box.
Let's target Precise Pangolin since it should be releasing soon, I said.
View
39 build.sh
@@ -1,5 +1,8 @@
#!/bin/bash
+# make sure we have dependencies
+hash mkisofs 2>/dev/null || { echo >&2 "ERROR: mkisofs not found. Aborting."; exit 1; }
+
BOX="ubuntu-precise-64"
# location, location, location
@@ -16,34 +19,49 @@ mkdir -p "${FOLDER_VBOX}"
mkdir -p "${FOLDER_ISO}"
# let's make sure they're empty
+echo "Cleaning Custom build directories..."
chmod -R u+w "${FOLDER_ISO_CUSTOM}"
rm -rf "${FOLDER_ISO_CUSTOM}"
mkdir -p "${FOLDER_ISO_CUSTOM}"
chmod -R u+w "${FOLDER_ISO_INITRD}"
rm -rf "${FOLDER_ISO_INITRD}"
mkdir -p "${FOLDER_ISO_INITRD}"
-ISO_URL="http://cdimage.ubuntu.com/daily/current/precise-alternate-amd64.iso"
+ISO_URL="http://releases.ubuntu.com/precise/ubuntu-12.04-alternate-amd64.iso"
ISO_FILENAME="${FOLDER_ISO}/`basename ${ISO_URL}`"
-
+ISO_MD5="9fcc322536575dda5879c279f0b142d7"
INITRD_FILENAME="${FOLDER_ISO}/initrd.gz"
ISO_GUESTADDITIONS="/Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso"
-# download the installation disk if you haven't already
-if [ ! -e "${ISO_FILENAME}" ]; then
- wget -O "${ISO_FILENAME}" "${ISO_URL}"
+# download the installation disk if you haven't already or it is corrupted somehow
+echo "Downloading ubuntu-12.04-alternate-amd64.iso ..."
+if [ ! -e "${ISO_FILENAME}" ]
+then
+ curl --output "${ISO_FILENAME}" -L "${ISO_URL}"
+else
+ # make sure download is right...
+ ISO_HASH=`md5 -q "${ISO_FILENAME}"`
+ if [ "${ISO_MD5}" != "${ISO_HASH}" ]; then
+ echo "ERROR: MD5 does not match. Got ${ISO_HASH} instead of ${ISO_MD5}. Aborting."
+ exit 1
+ fi
fi
# customize it
+echo "Creating Custom ISO"
if [ ! -e "${FOLDER_ISO}/custom.iso" ]; then
+
+ echo "Untarring downloaded ISO ..."
tar -C "${FOLDER_ISO_CUSTOM}" -xf "${ISO_FILENAME}"
# backup initrd.gz
+ echo "Backing up current init.rd ..."
chmod u+w "${FOLDER_ISO_CUSTOM}/install" "${FOLDER_ISO_CUSTOM}/install/initrd.gz"
mv "${FOLDER_ISO_CUSTOM}/install/initrd.gz" "${FOLDER_ISO_CUSTOM}/install/initrd.gz.org"
# stick in our new initrd.gz
+ echo "Installing new initrd.gz ..."
cd "${FOLDER_ISO_INITRD}"
gunzip -c "${FOLDER_ISO_CUSTOM}/install/initrd.gz.org" | cpio -id
cd "${FOLDER_BASE}"
@@ -52,19 +70,23 @@ if [ ! -e "${FOLDER_ISO}/custom.iso" ]; then
find . | cpio --create --format='newc' | gzip > "${FOLDER_ISO_CUSTOM}/install/initrd.gz"
# clean up permissions
+ echo "Cleaning up Permissions ..."
chmod u-w "${FOLDER_ISO_CUSTOM}/install" "${FOLDER_ISO_CUSTOM}/install/initrd.gz" "${FOLDER_ISO_CUSTOM}/install/initrd.gz.org"
# replace isolinux configuration
+ echo "Replacing isolinux config ..."
cd "${FOLDER_BASE}"
chmod u+w "${FOLDER_ISO_CUSTOM}/isolinux" "${FOLDER_ISO_CUSTOM}/isolinux/isolinux.cfg"
rm "${FOLDER_ISO_CUSTOM}/isolinux/isolinux.cfg"
cp isolinux.cfg "${FOLDER_ISO_CUSTOM}/isolinux/isolinux.cfg"
chmod u+w "${FOLDER_ISO_CUSTOM}/isolinux/isolinux.bin"
# add late_command script
+ echo "Add late_command script ..."
chmod u+w "${FOLDER_ISO_CUSTOM}"
cp "${FOLDER_BASE}/late_command.sh" "${FOLDER_ISO_CUSTOM}"
-
+
+ echo "Running mkisofs ..."
mkisofs -r -V "Custom Ubuntu Install CD" \
-cache-inodes -quiet \
-J -l -b isolinux/isolinux.bin \
@@ -74,6 +96,7 @@ if [ ! -e "${FOLDER_ISO}/custom.iso" ]; then
fi
+echo "Creating VM Box..."
# create virtual machine
if ! VBoxManage showvminfo "${BOX}" >/dev/null 2>/dev/null; then
VBoxManage createvm \
@@ -147,7 +170,7 @@ if ! VBoxManage showvminfo "${BOX}" >/dev/null 2>/dev/null; then
VBoxManage startvm "${BOX}"
# get private key
- wget -O "${FOLDER_BUILD}/id_rsa" --no-check-certificate "https://raw.github.com/mitchellh/vagrant/master/keys/vagrant"
+ curl --output "${FOLDER_BUILD}/id_rsa" "https://raw.github.com/mitchellh/vagrant/master/keys/vagrant"
chmod 600 "${FOLDER_BUILD}/id_rsa"
# install virtualbox guest additions
@@ -162,6 +185,7 @@ if ! VBoxManage showvminfo "${BOX}" >/dev/null 2>/dev/null; then
VBoxManage modifyvm "${BOX}" --natpf1 delete "guestssh"
# Detach guest additions iso
+ echo "Detach guest additions ..."
VBoxManage storageattach "${BOX}" \
--storagectl "IDE Controller" \
--port 1 \
@@ -170,6 +194,7 @@ if ! VBoxManage showvminfo "${BOX}" >/dev/null 2>/dev/null; then
--medium emptydrive
fi
+echo "Building Vagrant Box ..."
vagrant package --base "${BOX}"
# references:

0 comments on commit e1d133b

Please sign in to comment.