#!/bin/bash # # ec2ubuntu-build-ami # # This script builds, bundles, and uploads an Ubuntu or Debian AMI for # Amazon EC2. This can be run on any of the following Fedora Core # AMIs, depending on what type of new Ubuntu or Debian AMI you wish to # create: # # 32-bit, 2.6.21 kernel: ami-f51aff9c # 64-bit, 2.6.21 kernel: ami-f21aff9b # # Command line options: # # --bucket NAME - REQUIRED # --prefix PREFIX - Defaults to a reasonable manifest name. # --user ID - Defaults to $AWS_USER_ID # --access-key ID - Defaults to $AWS_ACCESS_KEY_ID # --secret-key ID - Defaults to $AWS_SECRET_ACCESS_KEY_ID # --private-key PATH - Defaults to $EC2_PRIVATE_KEY # --cert PATH - Defaults to $EC2_CERT # --distribution NAME - ubuntu debian # --codename NAME - dapper edgy feisty gusty hardy intrepid etch lenny # --release VERSION - 6.06 6.10 7.04 7.10 8.04 8.10 4.0 5.0 # --arch ARCHITECTURE - i386 amd64 - Defaults to the architecture of the running kernel # --timezone ZONE - Defaults to UTC # --locale LOCALE - Defaults to en_US # --charmap CHARMAP - Defaults to UTF-8 # --size MB - Root partition size in megabytes # --no-run-user-data - Do not run user-data script on first boot # --package NAME - Additional Ubuntu package to install # --script FILE - External script/command to run before bundle # --modules "URL1 URL2" - Kernel modules to download and install # --desktop nx - Takes longer and makes AMI much bigger # --builddir DIR - Build directory [default: /mnt/build] # --bundle-opts OPTIONS - Options to pass to ec2-bundle-vol # # It is ok to specify multiple --package and --script options. # It is ok to specify a quoted command for the --script option. # You can also use "--desktop yes" to install the desktop packages # without the NX software. # # Example: # # Build an Ubuntu 8.04 Hardy base install AMI and upload to MYBUCKET: # # bash ec2ubuntu-build-ami \ # --codename hardy \ # --bucket MYBUCKET \ # --user $AWS_USER_ID \ # --access-key $AWS_ACCESS_KEY_ID \ # --secret-key $AWS_SECRET_ACCESS_KEY \ # --private-key pk*.pem \ # --cert cert*.pem # # Amazon EC2 AMIs built using this script: # # http://alestic.com # # Updated versions of this script: # # http://code.google.com/p/ec2ubuntu/ # # General Ubuntu on EC2 support (including support for this script): # # http://groups.google.com/group/ec2ubuntu # # History: # # 2008-11-26 Eric Hammond # - Upgrade EC2 AMI tools to 1.3-26357 20071010 # - Remove old 2.6.16 kernel modules # - Upgrade desktop images to NX Free Edition 3.3.0 # # 2008-11-26 Don Spaulding II <> # - Add --arch option # # 2008-10-31 Eric Hammond # - Upgrade desktop to latest version of NX Free Edition software # # 2008-10-06 Eric Hammond # - Remove apparmor which will not work on older kernels. # # 2008-10-02 Eric Hammond # - Add 'hwcap 0 nosegneg' to /etc/ld.so.conf.d/libc6-xen.conf # Thanks to research by Eric Mason # # 2008-09-23 Eric Hammond # - Garrett Smith noted ec2-bundle-vol now requires --generate-fstab # # 2008-09-16 Eric Hammond # - Changes based on ideas from Hans Omli: # - Hardy and Intrepid now install libc6-xen (and remove libc6-i686) # # 2008-09-16 Eric Hammond # - Changes based on ideas from justnulling: # - Run depmod for all installed kernel module versions # - Add --bundle-opts option # - Cleanup the correct cache/log files in the image # # 2008-09-16 Eric Hammond # - Changes based on ideas from yourabi: # - Add --no-run-user-data option. # - Do not purge patch and alien as this would remove build-essential. # - Export $distribution to external scripts. # # 2008-09-04 Eric Hammond # - Fix ec2-ssh-host-key-gen to not run on reboot. # # 2008-08-04 Eric Hammond # - Upgrade to latest AMI tools 1.3-21885 20071010 (obviates 1 patch) # # 2008-07-21 Eric Hammond # - Upgrade to debootstrap 1.0.10 # - Output new ssh host keys to console log for security. # - Use newly built kernel modules where fuse supports NFS export. # # 2008-07-03 Eric Hammond # - Split startup scripts into their own files and reorganize a bit. # # 2008-06-30 Eric Hammond # - Support building Debian desktop AMIs. # # 2008-06-28 Eric Hammond # - Enhance to support building Debian AMIs as well as Ubuntu AMIs. # - Add "intrepid" for the Ubuntu 8.10 alpha release. # # 2008-06-10 Thomas Shealy # - Upgrade NX server to latest version. # # 2008-06-10 Thomas Shealy # - Add --builddir option to support multiple concurrent AMI builds. # - Make build parameters available in external scripts. # # 2008-06-09 Eric Hammond # - Prevent prompting for desktop packages w/ DEBIAN_FRONTEND=noninteractive # - Use fixed revision of ec2-run-user-data # - Use fixed release of the Amazon EC2 AMI command line tools. # # 2008-06-04 Eric Hammond # - Run --script file directly if it is executable, otherwise use /bin/bash # - Option to --script can be a quoted command line. # # 2008-06-02 Eric Hammond # - Change default timezone to UTC. # - Increase default root partition size to 10GB (still 3GB for Dapper). # - Upgrade to debootstrap 1.0.9 # # 2008-06-01 Eric Hammond # - Tweaks to allow running this script on Ubuntu 8.04 Hardy. # - Trim 15MB off of the post-boot disk footprint. # # 2008-05-21 Eric Hammond # - Add "kubuntu-desktop" to desktop builds so they have Gnome and KDE. # # 2008-05-20 Eric Hammond # - Add option to specify kernel modules. # # 2008-05-16 Eric Hammond # - Run the instance user-data if it looks like a script (starts with #!) # - Wait for the network (DHCP) to come up before grabbing instance data. # # 2008-05-14 Eric Hammond # - Create new ssh host keys on first boot. # - Disable apparmor as we don't have the kernel module installed yet. # - Don't claim every AMI was built by Eric Hammond in /etc/motd # - Create /tmp earlier in the boot process to avoid warnings. # - Implemented following suggestions from Hans Omli: # - Disable useless CMOS hwclock at boot to avoid error and save seconds. # - Avoid grep warning about missing authorized_keys file on first boot. # # 2008-05-13 Thomas Shealy # - Add --retry to ec2-upload-bundle. # # 2008-05-12 Thomas Shealy # - Support 64-bit desktop AMIs. # - Upgrade to NX 3.2. # # 2008-04-29 Eric Hammond # - Support command line options with reasonable defaults. # - Support building Ubuntu 8.04 Hardy Heron. # # 2008-04-22 Vincent Desjardins # - Add a variable to override the default size of the image created # - Add a optional call to an external script before bundling the AMI # # 2008-04-19 Eric Hammond # - Support 2.6.21 kernel with 64-bit builds. # # 2008-04-18 Eric Hammond # - Fix performance problem with 2.6.21 initrd (with killall nash-hotplug). # # 2008-04-11 Eric Hammond # - Install kernel modules for both 2.6.16-xenU and 2.6.21.7-2.fc8xen # # 2008-04-05 Eric Hammond # - Add support for desktop build with NoMachine NX Free. # # 2008-04-03 Eric Hammond # - Upgrade to latest AMI tools 1.3-20041 20071010 (obviates several patches) # - Add new Ubuntu patches for new version of AMI tools # - Switch from "uname -i" to "uname -m" to enable building on Ubuntu 64-bit # - Merge Dapper, Edgy, Feisty, Gutsy, Hardy scripts (Hardy doesn't work yet) # # 2008-03-13 Eric Hammond # - Prevent apt-get from running newly installed daemons # # 2008-03-09 Eric Hammond # - Upgrade to kernel modules 2.6.16.60 # - Upgrade fuse kernel module to 2.7.3 # - Upgrade to latest AMI tools 1.3-19365 (obviates one patch) # # 2008-02-05 Eric Hammond # - Patch AMI tools to work with new Ruby 1.8.6 # # 2008-02-03 Eric Hammond # - Install rsync without lutimes support (as it's not in the EC2 kernel) # # 2008-01-17 Eric Hammond # - Upgrade to debootstrap 1.0.8 # # 2007-12-25 Eric Hammond # - Install fuse kernel module (32-bit) # - Upgrade to debootstrap 1.0.7 # # 2007-12-02 Eric Hammond # - Use architecture "amd64" instead of "i386" for debootstrap on 64-bit # - Add ia32-libs compatability package for 64-bit # # 2007-12-01 Eric Hammond # - Add support for building on 64-bit kernel (large, extra large instances) # # 2007-11-23 Eric Hammond # - ssh credentials retrieved from instance parameters or ephemeral storage. # - Patch ec2-unbundle to work on Ubuntu # - Also add locale to /etc/default/locale # # 2007-11-22 Eric Hammond # - Upgrade Ubuntu AMI tools patch to match new AMI tools source. # - Install ca-certificates to better support ec2-upload-bundle per: # http://developer.amazonwebservices.com/connect/thread.jspa?threadID=16543&tstart=0 # - ec2-bundle-vol excludes /etc/udev/rules.d/70-persistent-net.rules # so that the network works on a rebundled instance, per: # http://developer.amazonwebservices.com/connect/message.jspa?messageID=70873 # # 2007-11-18 Eric Hammond # - Original put together based on code, tricks, and fixes from many # others. # VERSION=$(perl -e 'print q$Revision$=~/(\d+)/') svnpath=http://ec2ubuntu.googlecode.com/svn-history/r99 packages="openssh-server rsync ruby openssl curl ca-certificates libopenssl-ruby patch alien" while [ $# -gt 0 ]; do case $1 in --distribution) distribution=$2; shift 2 ;; --codename) codename=$2; shift 2 ;; --release) release=$2; shift 2 ;; --arch) bsarch=$2; shift 2 ;; --tag) tag=$2; shift 2 ;; --bucket) bucket=$2; shift 2 ;; --prefix) prefix=$2; shift 2 ;; --user) AWS_USER_ID=$2; shift 2 ;; --access-key) AWS_ACCESS_KEY_ID=$2; shift 2 ;; --secret-key) AWS_SECRET_ACCESS_KEY=$2; shift 2 ;; --private-key) EC2_PRIVATE_KEY=$2; shift 2 ;; --cert) EC2_CERT=$2; shift 2 ;; --timezone) timezone=$2; shift 2 ;; --locale) locale=$2; shift 2 ;; --charmap) charmap=$2; shift 2 ;; --size) size=$2; shift 2 ;; --no-run-user-data) no_run_user_data=1; shift ;; --script) scripts=("${scripts[@]}" "$2"); shift 2 ;; --package) packages="$packages $2"; shift 2 ;; --modules) modules=$2; shift 2 ;; --desktop) desktop=$2; shift 2 ;; --builddir) builddir=$2; shift 2 ;; --bundle-opts) bundle_vol_options=$2; shift 2 ;; *) echo "$0: Unrecognized option: $1" >&2; exit 1; esac done if [ "$codename" = "" -a "$release" = "" ]; then codename=hardy fi if [ "$release" = "" ]; then case $codename in dapper) release=6.06 ;; edgy) release=6.10 ;; feisty) release=7.04 ;; gutsy) release=7.10 ;; hardy) release=8.04 ;; intrepid) release=8.10 ;; etch) release=4.0 ;; lenny) release=5.0 ;; sid) release=unstable ;; *) echo "$0: Unrecognized codename: $codename" >&2; exit 1; esac elif [ "$codename" = "" ]; then case $release in 6.06) codename=dapper ;; 6.10) codename=edgy ;; 7.04) codename=feisty ;; 7.10) codename=gutsy ;; 8.04) codename=hardy ;; 8.10) codename=intrepid ;; *) echo "$0: Unrecognized release: $release" >&2; exit 1; esac fi if [ "$distribution" = "" ]; then case $codename in dapper|edgy|feisty|gutsy|hardy|intrepid) distribution=ubuntu ;; hamm|slink|potato|woody|sarge|etch|lenny|sid) distribution=debian ;; *) echo "$0: Unrecognized codename: $codename" >&2; exit 1; esac fi if [ "$codename" = "sid" ]; then echo >&2 "$0: You really don't want to build a Debian unstable sid AMI :)" echo >&2 "$0: http://wooledge.org/~greg/sidfaq.html" exit 1 fi # Required and default parameters true ${AWS_USER_ID:?} ${AWS_ACCESS_KEY_ID:?} ${AWS_SECRET_ACCESS_KEY:?} \ ${bucket:?} \ ${EC2_CERT:=$(echo /mnt/cert-*.pem)} \ ${EC2_PRIVATE_KEY:=$(echo /mnt/pk-*.pem)} \ ${locale:=en_US} ${charmap:=UTF-8} ${timezone:=UTC} \ ${tag:=custom} ${prefix:=$distribution-$release-$codename-$tag-$(date +%Y%m%d)} \ ${builddir:=/mnt/build} if [ "$codename" == "dapper" ]; then true ${size:=3072} else true ${size:=10240} fi if [ "$distribution" = "ubuntu" ]; then packages="ubuntu-standard $packages" if [ "$desktop" ]; then packages="$packages ubuntu-desktop kubuntu-desktop user-setup" fi elif [ "$distribution" = "debian" ]; then packages="$packages udev psmisc lsb-release" if [ "$desktop" ]; then packages="$packages user-setup" fi fi if [ "$bsarch" = "" ]; then if [ $(uname -m) = 'x86_64' ]; then bsarch="amd64" else bsarch="i386" fi fi echo Building AMI for $distribution $release $codename echo locale: $locale echo charmap: $charmap echo timezone: $timezone echo Image size: ${size} MB echo Uploading to: $bucket/$prefix echo Packages: $packages set -e set -x # The good stuff starts here. mkdir -p $builddir cd $builddir imagedir=$builddir/$distribution mkdir -p $imagedir if which apt-get >/dev/null 2>/dev/null; then # Ubuntu / Debian apt-get install -y binutils else # Fedora Core / Red Hat / CentOS yum install -y binutils fi # Amazon's kernel modules are mostly out of date, missing fixes, or # not built with the right version string. To build the modules # yourself, see: # http://groups.google.com/group/ec2ubuntu/web/compiling-kernel-modules-from-source-for-amazon-ec2 # http://groups.google.com/group/ec2ubuntu/web/compiling-2-6-21-kernel-modules-from-source-for-amazon-ec2 if [ $bsarch = 'amd64' ]; then true ${modules:=http://alestic-downloads.s3.amazonaws.com/ec2-kernel-modules-2.6.21.x86_64-20080722.tar.gz} # http://s3.amazonaws.com/ec2-downloads/ec2-modules-2.6.16.33-xenU-x86_64.tgz # http://ec2-downloads.s3.amazonaws.com/ec2-modules-2.6.18-xenU-ec2-v1.0-x86_64.tgz # http://s3.amazonaws.com/ec2-downloads/ec2-modules-2.6.21-2952.fc8xen-x86_64.tgz bundlearch="x86_64" export notlongext="64" elif [ $bsarch = 'i386' ]; then true ${modules:=http://alestic-downloads.s3.amazonaws.com/ec2-kernel-modules-2.6.21.i686-20080722.tar.gz} # http://alestic-downloads.s3.amazonaws.com/ec2-kernel-modules-2.6.16-xenU.tgz # http://s3.amazonaws.com/ec2-downloads/ec2-modules-2.6.18-xenU-ec2-v1.0-i686.tgz # http://s3.amazonaws.com/ec2-downloads/ec2-modules-2.6.21-2952.fc8xen-i686.tgz bundlearch="i386" export notlongext="" else echo >&2 "$0: Unrecognized --arch $bsarch" exit 1 fi echo "bundlearch: $bundlearch" echo "bsarch: $bsarch" echo "modules: $modules" if [ "$desktop" ]; then notlongext="$notlongext-desktop" fi # Don't launch daemons on apt-get install mkdir -p $imagedir/usr/sbin/ cat << EOF > $imagedir/usr/sbin/policy-rc.d #!/bin/sh exit 101 EOF chmod 755 $imagedir/usr/sbin/policy-rc.d # Bootstrap Ubuntu BSURL=http://us.archive.ubuntu.com/ubuntu/pool/main/d/debootstrap BSVER=debootstrap_1.0.10 BSDIR=$(pwd)/debootstrap curl -s $BSURL/$BSVER.tar.gz | tar xz curl -s $BSURL/${BSVER}_all.deb > /tmp/${BSVER}_all.deb ar p /tmp/${BSVER}_all.deb data.tar.gz | tar xvzOf - ./usr/share/debootstrap/devices.tar.gz > $BSDIR/devices.tar.gz case "$codename" in hardy|intrepid) ln -s gutsy $BSDIR/scripts/ubuntu/$codename ;; lenny|etch) ln -s sid $BSDIR/scripts/debian/$codename ;; esac (cd $BSDIR/scripts ; ln -s */$codename $codename) export DEBOOTSTRAP_DIR=$BSDIR #perl -pi.bak -e 'print "set -v -x\n" if $.==2' $BSDIR/debootstrap $BSDIR/debootstrap --arch $bsarch $codename $imagedir chroot $imagedir mount -t proc none /proc chroot $imagedir mkdir -p /dev/pts chroot $imagedir mount -t devpts none /dev/pts test -e /dev/ptmx || chroot $imagedir mknod --mode 666 /dev/ptmx c 5 2 chroot $imagedir apt-get -f install -y # Set locale chroot $imagedir apt-get install -y --force-yes locales # for Debian chroot $imagedir localedef -c --inputfile=$locale --charmap=$charmap $locale.$charmap echo "LANG=\"$LANG\"" >$imagedir/etc/default/locale # Set timezone echo $timezone >$imagedir/etc/timezone /bin/cp -f $imagedir/usr/share/zoneinfo/$timezone $imagedir/etc/localtime # Basic sources.list mv $imagedir/etc/apt/sources.list $imagedir/etc/apt/sources.list.orig || true if [ "$distribution" = "debian" ]; then cat <$imagedir/etc/apt/sources.list deb http://http.us.debian.org/debian $codename main contrib non-free #deb http://non-us.debian.org/debian-non-US stable/non-US main contrib non-free deb http://security.debian.org $codename/updates main contrib non-free EOF else cat <$imagedir/etc/apt/sources.list deb http://us.archive.ubuntu.com/ubuntu $codename main restricted universe multiverse deb-src http://us.archive.ubuntu.com/ubuntu $codename main restricted universe multiverse deb http://us.archive.ubuntu.com/ubuntu $codename-updates main restricted universe multiverse deb-src http://us.archive.ubuntu.com/ubuntu $codename-updates main restricted universe multiverse deb http://security.ubuntu.com/ubuntu $codename-security main restricted universe multiverse deb-src http://security.ubuntu.com/ubuntu $codename-security main restricted universe multiverse EOF fi # Update package list chroot $imagedir apt-get update # Architecture/release specific instructions if [ "$bundlearch" = "i386" ]; then if [ "$codename" != "dapper" ]; then chroot $imagedir apt-get install -y libc6-xen echo 'hwcap 0 nosegneg' > $imagedir/etc/ld.so.conf.d/libc6-xen.conf chroot $imagedir apt-get remove -y libc6-i686 || true chroot $imagedir ldconfig fi else chroot $imagedir apt-get install -y ia32-libs fi # MAKEDEV is expected in /dev by some packages. ln -s /sbin/MAKEDEV $imagedir/dev/MAKEDEV # Upgrade/install packages chroot $imagedir apt-get -y upgrade export DEBIAN_FRONTEND=noninteractive chroot $imagedir apt-get install -y $packages chroot $imagedir apt-get remove -y apparmor apparmor-utils || true if [ "$desktop" -a "$distribution" = "debian" ]; then chroot $imagedir aptitude install -y desktop gnome chroot $imagedir aptitude install -y desktop kde fi unset DEBIAN_FRONTEND # Install kernel modules for module in $modules; do curl -s $module | tar xzC $imagedir done for module_version in $(cd $imagedir/lib/modules; ls); do chroot $imagedir depmod -a $module_version done # Xen expects a single tty1 /bin/rm -f $imagedir/etc/event.d/tty[2-6] # Security chroot $imagedir shadowconfig on chroot $imagedir passwd -d root # Basic networking cat <<'EOF' >$imagedir/etc/network/interfaces auto lo iface lo inet loopback auto eth0 iface eth0 inet dhcp EOF cat <<'EOF' >$imagedir/etc/hosts 127.0.0.1 localhost.localdomain localhost # The following lines are desirable for IPv6 capable hosts ::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters ff02::3 ip6-allhosts EOF cat <<'EOF' >>$imagedir/etc/ssh/sshd_config UseDNS no EOF # Install Amazon EC2 AMI tools if [ "$codename" = "intrepid" ]; then chroot $imagedir apt-get install -y ec2-ami-tools else curl -s http://us.archive.ubuntu.com/ubuntu/pool/multiverse/e/ec2-ami-tools/ec2-ami-tools_1.3-26357-0ubuntu5_$bsarch.deb > $imagedir/tmp/ec2-ami-tools.deb chroot $imagedir dpkg -i /tmp/ec2-ami-tools.deb fi # Make sure the new image doesn't try to remember a hardcoded mac address. chroot $imagedir patch -d /usr/lib/ec2-ami-tools/lib/ec2/platform/linux <<'EOF' --- /usr/lib/ec2-ami-tools/lib/ec2/platform/linux/image.rb.orig 2008-11-27 04:58:36.964214178 -0800 +++ /usr/lib/ec2-ami-tools/lib/ec2/platform/linux/image.rb 2008-11-27 05:00:25.095464580 -0800 @@ -26,7 +26,9 @@ # Symbolic links are preserved. class Image IMG_MNT = '/mnt/img-mnt' - EXCLUDES= ['/dev', '/media', '/mnt', '/proc', '/sys'] + EXCLUDES= ['/dev', '/media', '/mnt', '/proc', '/sys', + '/etc/udev/rules.d/70-persistent-net.rules', + '/etc/udev/rules.d/z25_persistent-net.rules' ] DEFAULT_FSTAB = EC2::Platform::Linux::Fstab::DEFAULT LEGACY_FSTAB = EC2::Platform::Linux::Fstab::LEGACY EOF # Download and install startup scripts. install_init(){ script=$1 startpriority=$2 startlevels=$3 stoppriority=$4 stoplevels=$5 curl -s -o $imagedir/etc/init.d/$script $svnpath/trunk/etc/init.d/$script chmod 755 $imagedir/etc/init.d/$script for level in $startlevels; do ln -s ../init.d/$script $imagedir/etc/rc$level.d/S$startpriority$script done for level in $stoplevels; do ln -s ../init.d/$script $imagedir/etc/rc$level.d/K$stoppriority$script done } install_init ec2-killall-nash-hotplug 00 "S" install_init ec2-mkdir-tmp 36 "S" install_init ec2-ssh-host-key-gen 50 "S" install_init ec2-get-credentials 70 "2 3 4 5" if [ ! $no_run_user_data ]; then install_init ec2-run-user-data 71 "2 3 4 5" fi # Inside Xen, CMOS clock is irrelevant, so save seconds at boot /bin/rm -f $imagedir/etc/rc?.d/*hwclock* # We're missing the apparmor kernel module for now so avoid boot warnings /bin/rm -f $imagedir/etc/rc?.d/*apparmor # Release-specific if [ "$codename" = "gutsy" ]; then # Install a copy of rsync with no lutimes support, as the Amazon EC2 # kernel does not support this newer feature to change symlink timestamps. curl -s -o $imagedir/tmp/rsync_2.6.9-5ubuntu1_$bsarch.deb \ https://level22.s3.amazonaws.com/20080203-rsync-no-lutimes/rsync_2.6.9-5ubuntu1_$bsarch.deb chroot $imagedir dpkg --install /tmp/rsync_2.6.9-5ubuntu1_$bsarch.deb fi # Are we installing the desktop with NoMachine NX? if [ "$desktop" = "nx" ]; then if [ "$bundlearch" = "i386" ]; then nxclient_pkg="nxclient_3.3.0-3_i386.deb" nxnode_pkg="nxnode_3.3.0-3_i386.deb" nxserver_pkg="nxserver_3.3.0-8_i386.deb" else nxclient_pkg="nxclient_3.3.0-3_x86_64.deb" nxnode_pkg="nxnode_3.3.0-3_x86_64.deb" nxserver_pkg="nxserver_3.3.0-8_x86_64.deb" fi curl -o $imagedir/tmp/$nxclient_pkg \ http://64.34.161.181/download/3.3.0/Linux/$nxclient_pkg curl -o $imagedir/tmp/$nxnode_pkg \ http://64.34.161.181/download/3.3.0/Linux/$nxnode_pkg curl -o $imagedir/tmp/$nxserver_pkg \ http://64.34.161.181/download/3.3.0/Linux/FE/$nxserver_pkg chroot $imagedir dpkg -i /tmp/$nxclient_pkg chroot $imagedir dpkg -i /tmp/$nxnode_pkg chroot $imagedir dpkg -i /tmp/$nxserver_pkg fi # Export build parameters so they are available in external scripts export distribution release codename tag bucket prefix \ timezone locale charmap size scripts packages modules desktop \ builddir imagedir bundlearch \ AWS_USER_ID AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY EC2_PRIVATE_KEY EC2_CERT # Invoke external scripts/commands if requested for script in "${scripts[@]}"; do if [ -x "$script" ]; then "$script" elif [ -f "$script" ]; then /bin/bash "$script" else eval $script fi done # cleanup #if [ "$codename" != "dapper" -a "$codename" != "etch" ]; then # chroot $imagedir apt-get -y autoremove --purge patch alien #fi chroot $imagedir apt-get clean rm -rf $imagedir/usr/sbin/policy-rc.d \ $imagedir/var/log/{bootstrap,dpkg}.log \ $imagedir/var/cache/apt/*.bin \ $imagedir/var/lib/apt/lists \ $imagedir/tmp/* \ $imagedir/root/.bash_history mkdir -p $imagedir/var/lib/apt/lists/partial # Bundle & upload to S3 cp $EC2_PRIVATE_KEY $imagedir/tmp/pk.pem cp $EC2_CERT $imagedir/tmp/cert.pem chroot $imagedir ec2-bundle-vol \ -r $bundlearch \ -d /tmp \ -p $prefix \ -u $AWS_USER_ID \ -k /tmp/pk.pem \ -c /tmp/cert.pem \ -s $size \ -e /tmp \ --generate-fstab \ $bundle_vol_options ec2-upload-bundle \ --retry \ -b $bucket \ -m $imagedir/tmp/$prefix.manifest.xml \ -a $AWS_ACCESS_KEY_ID \ -s $AWS_SECRET_ACCESS_KEY umount $imagedir/dev/pts umount $imagedir/proc || true set +x cat <