diff options
author | 2011-06-16 05:55:16 +0100 | |
---|---|---|
committer | 2011-06-16 05:55:16 +0100 | |
commit | 5178ae6f9bc4ecab8f6ad4cfac49466f24b62cb1 (patch) | |
tree | d8f1f9f76eb1654562acb41b6a9e93565b245051 /create_image.sh | |
parent | Adding Python 2.6 to fluxbox config to fix a build failure (diff) | |
download | gentoaster-5178ae6f9bc4ecab8f6ad4cfac49466f24b62cb1.tar.gz gentoaster-5178ae6f9bc4ecab8f6ad4cfac49466f24b62cb1.tar.bz2 gentoaster-5178ae6f9bc4ecab8f6ad4cfac49466f24b62cb1.zip |
Added flags and cachedkernel option
Diffstat (limited to 'create_image.sh')
-rwxr-xr-x | create_image.sh | 68 |
1 files changed, 51 insertions, 17 deletions
diff --git a/create_image.sh b/create_image.sh index 8ce4f98..d56d36f 100755 --- a/create_image.sh +++ b/create_image.sh @@ -5,8 +5,32 @@ # Usage: ./create_image.sh <configuration file path> # Prerequisites: extlinux, qemu-img, sfdisk +# Do some sanity checks first +if [ "$(id -u)" != "0" ]; then + echo "Gentoaster must run with root permissions!" 1>&2 + exit 1 +fi +hash qemu-img 2>&- || { echo >&2 "Gentoaster requires qemu-img, but it's not installed."; exit 1; } +hash extlinux 2>&- || { echo >&2 "Gentoaster requires extlinux, but it's not installed."; exit 1; } +hash sfdisk 2>&- || { echo >&2 "Gentoaster requires sfdisk, but it's not installed."; exit 1; } + +# Load shflags to parse flags +. ./lib/shflags + +DEFINE_string 'config' '' 'configuration to build from' +DEFINE_string 'proxy' '' 'HTTP proxy to use for emerges' +DEFINE_boolean 'cachedkernel' false 'use a cached kernel (shortens build time)' + +FLAGS "$@" || exit 1 +eval set -- "${FLAGS_ARGV}" + +if [ -z ${FLAGS_config} ]; then + echo >&2 "Gentoaster requires a valid configuration to be passed using the --config flag" + exit 1 +fi + # Parse the configuration we took as an arg -source parse_config.sh $1 +source parse_config.sh ${FLAGS_config} # Generate a few helper variables using the configuration file @@ -22,7 +46,7 @@ NUM_JOBS=$(( `grep -c processor /proc/cpuinfo`+1 )) STAGE3_URL="http://distribution.hexxeh.net/gentoo/stage3-i686-latest.tar.bz2" PORTAGE_URL="http://distribution.hexxeh.net/gentoo/portage-latest.tar.bz2" BINHOST_URL="http://tinderbox.dev.gentoo.org/default-linux/x86" -EMERGE_PROXY="http://127.0.0.1:3128" +EMERGE_PROXY="${FLAGS_proxy}" echo "Creating build working directory" mkdir -p ${IMAGE_WORK_PATH} @@ -41,12 +65,12 @@ qemu-img create -f raw ${IMAGE_NAME} ${REAL_IMAGE_BYTES} &>> ${LOG_FILE} # Clean up old mounts cleanup_mounts() { echo "Cleaning up old mounts" - umount -d rootfs/dev/pts &>> ${LOG_FILE} - umount -d rootfs/dev/shm &>> ${LOG_FILE} - umount -d rootfs/dev &>> ${LOG_FILE} - umount -d rootfs/proc &>> ${LOG_FILE} - umount -d rootfs/boot &>> ${LOG_FILE} - umount -d rootfs &>> ${LOG_FILE} + umount -d ${IMAGE_WORK_PATH}/rootfs/dev/pts &>> ${LOG_FILE} + umount -d ${IMAGE_WORK_PATH}/rootfs/dev/shm &>> ${LOG_FILE} + umount -d ${IMAGE_WORK_PATH}/rootfs/dev &>> ${LOG_FILE} + umount -d ${IMAGE_WORK_PATH}/rootfs/proc &>> ${LOG_FILE} + umount -d ${IMAGE_WORK_PATH}/rootfs/boot &>> ${LOG_FILE} + umount -d ${IMAGE_WORK_PATH}/rootfs &>> ${LOG_FILE} } cleanup_mounts @@ -126,6 +150,7 @@ echo "PORTAGE_BINHOST=\"${BINHOST_URL}\"" >> etc/make.conf echo "PKGDIR=\"/usr/portage/packages\"" >> etc/make.conf echo "FEATURES=\"${FEATURES}\"" >> etc/make.conf echo "USE=\"${USE_FLAGS}\"" >> etc/make.conf +echo "MAKEOPTS=\"-j${NUM_JOBS}\"" >> etc/make.conf if [[ ${OUTPUT_FORMAT} = "vbox" ]]; then echo 'INPUT_DEVICES="virtualbox evdev"' >> etc/make.conf @@ -164,18 +189,25 @@ echo 'config_eth0=( "dhcp" )' > etc/conf.d/net cp etc/init.d/net.lo etc/init.d/net.eth0 linux32 chroot . rc-update add net.eth0 default &>> ${LOG_FILE} -echo "Downloading/installing kernel sources" -linux32 chroot . emerge gentoo-sources &>> ${LOG_FILE} +# If we got the flag, used a cached kernel to reduce build times for testing +if [ ${FLAGS_cachedkernel} ]; then + echo "Using cached kernel" + cp ${TOOL_RES_PATH}/bzImage boot/kernel + cp -R ${TOOL_RES_PATH}/kernelmodules/* lib/modules/ +else + echo "Downloading/installing kernel sources" + linux32 chroot . emerge gentoo-sources &>> ${LOG_FILE} -echo "Copying kernel configuration" -cp ${TOOL_RES_PATH}/kernelconfig usr/src/linux/.config + echo "Copying kernel configuration" + cp ${TOOL_RES_PATH}/kernelconfig usr/src/linux/.config -echo "Building kernel" -linux32 chroot . make -C /usr/src/linux -j${NUM_JOBS} &>> ${LOG_FILE} + echo "Building kernel" + linux32 chroot . make -C /usr/src/linux -j${NUM_JOBS} &>> ${LOG_FILE} -echo "Installing kernel" -linux32 chroot . make -C /usr/src/linux modules_install &>> ${LOG_FILE} -linux32 chroot . cp /usr/src/linux/arch/i386/boot/bzImage /boot/kernel &>> ${LOG_FILE} + echo "Installing kernel" + linux32 chroot . make -C /usr/src/linux modules_install &>> ${LOG_FILE} + usr/src/linux/arch/i386/boot/bzImage boot/kernel &>> ${LOG_FILE} +fi echo "Setting root password" linux32 chroot . /bin/bash -c "echo 'root:${ROOT_PASSWORD}' | chpasswd" &>> ${LOG_FILE} @@ -199,9 +231,11 @@ then linux32 chroot . usermod -a vboxguest ${DEFAULT_USERNAME} fi +echo "Cleaning up make.conf" if [ -n ${EMERGE_PROXY} ]; then sed -i '/http_proxy/ d' etc/make.conf fi +sed -i '/MAKEOPTS/ d' etc/make.conf echo "Installing extlinux" extlinux --heads 255 --sectors 63 --install boot |