aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiam McLoughlin <hexxeh@hexxeh.net>2011-06-16 01:44:25 +0100
committerLiam McLoughlin <hexxeh@hexxeh.net>2011-06-16 01:50:34 +0100
commita5238a1738df4ccb5885257264017cd17192a689 (patch)
tree650c0d3fb58b5c6773d153d289af4a31b8cec9f5 /create_image.sh
parentMinimal configuration has to be larger, fixed a network setup error too (diff)
downloadgentoaster-a5238a1738df4ccb5885257264017cd17192a689.tar.gz
gentoaster-a5238a1738df4ccb5885257264017cd17192a689.tar.bz2
gentoaster-a5238a1738df4ccb5885257264017cd17192a689.zip
Bugfixes and tidy up
Diffstat (limited to 'create_image.sh')
-rwxr-xr-xcreate_image.sh45
1 files changed, 29 insertions, 16 deletions
diff --git a/create_image.sh b/create_image.sh
index 27d439b..5b7340a 100755
--- a/create_image.sh
+++ b/create_image.sh
@@ -14,14 +14,15 @@ IMAGE_NAME="${BUILD_ID}.image"
ROOT_MEGABYTES=$(( ${IMAGE_MEGABYTES} - ( ${BOOT_MEGABYTES} + ${SWAP_MEGABYTES} + 1 ) ))
IMAGE_BYTES=$(( ${IMAGE_MEGABYTES} * 1024 * 1024 ))
IMAGES_OUTPUT_PATH=`pwd`
-IMAGE_WORK_PATH="/root/gentoo/${BUILD_ID}"
+IMAGE_WORK_PATH="${IMAGES_OUTPUT_PATH}/${BUILD_ID}"
LOG_FILE="${IMAGE_WORK_PATH}/log.txt"
TOOL_RES_PATH=`pwd`/res
-CPU_CORES=`grep -c processor /proc/cpuinfo`
+NUM_JOBS=$(( `grep -c processor /proc/cpuinfo`+1 ))
STAGE3_URL="http://distfiles.gentoo.org/releases/x86/current-stage3/stage3-i486-20110607.tar.bz2"
PORTAGE_URL="http://distfiles.gentoo.org/snapshots/portage-latest.tar.bz2"
BINHOST_URL="http://tinderbox.dev.gentoo.org/default-linux/x86"
+EMERGE_PROXY="http://127.0.0.1:3128"
echo "Creating build working directory"
mkdir -p ${IMAGE_WORK_PATH}
@@ -121,16 +122,21 @@ cp -L /etc/resolv.conf etc/resolv.conf
echo "Setting up make.conf"
mkdir -p usr/portage/packages
-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
-if [[ ${OUTPUT_FORMAT} = "vbox" ]]
-then
+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
+
+if [[ ${OUTPUT_FORMAT} = "vbox" ]]; then
echo 'INPUT_DEVICES="virtualbox evdev"' >> etc/make.conf
echo 'VIDEO_CARDS="virtualbox"' >> etc/make.conf
fi
+if [ -n $EMERGE_PROXY ]; then
+ echo "Enabling HTTP proxy"
+ echo "http_proxy=\"${EMERGE_PROXY}\"" >> etc/make.conf
+fi
+
echo "Setting up package.use"
mkdir -p etc/portage
echo ${PACKAGE_USE} >> etc/portage/package.use
@@ -156,7 +162,7 @@ cp ${TOOL_RES_PATH}/fstab etc/fstab &>> ${LOG_FILE}
echo "Setting up networking"
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
+linux32 chroot . rc-update add net.eth0 default &>> ${LOG_FILE}
echo "Downloading/installing kernel sources"
linux32 chroot . emerge gentoo-sources &>> ${LOG_FILE}
@@ -165,7 +171,7 @@ echo "Copying kernel configuration"
cp ${TOOL_RES_PATH}/kernelconfig usr/src/linux/.config
echo "Building kernel"
-linux32 chroot . make -C /usr/src/linux -j$(( ${CPU_CORES}+1 )) &>> ${LOG_FILE}
+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}
@@ -174,8 +180,11 @@ linux32 chroot . cp /usr/src/linux/arch/i386/boot/bzImage /boot/kernel &>> ${LOG
echo "Setting root password"
linux32 chroot . /bin/bash -c "echo 'root:${ROOT_PASSWORD}' | chpasswd" &>> ${LOG_FILE}
-echo "Installing packages list"
-linux32 chroot . emerge ${PACKAGES_LIST} &>> ${LOG_FILE}
+echo "Processing packages list"
+for PACKAGE in ${PACKAGES_LIST}; do
+ echo "Installing ${PACKAGE}"
+ linux32 chroot . emerge --jobs=${NUM_JOBS} ${PACKAGE} &>> ${LOG_FILE}
+done
echo "Adding default user"
linux32 chroot . useradd -g users -G lp,wheel,audio,cdrom,portage -m ${DEFAULT_USERNAME}
@@ -186,10 +195,14 @@ then
echo "Installing VirtualBox additions/drivers"
linux32 chroot . emerge xf86-video-virtualbox xf86-input-virtualbox virtualbox-guest-additions &>> ${LOG_FILE}
linux32 chroot . rc-update add virtualbox-guest-additions default &>> ${LOG_FILE}
- linux32 chroot . mv /etc/X11/xorg.conf /etc/X11/xorg.conf.bak &>> ${LOG_FILE}
+ mv etc/X11/xorg.conf etc/X11/xorg.conf.bak &>> ${LOG_FILE}
linux32 chroot . usermod -a vboxguest ${DEFAULT_USERNAME}
fi
+if [ -n ${EMERGE_PROXY} ]; then
+ sed -i '/http_proxy/ d' etc/make.conf
+fi
+
echo "Installing extlinux"
extlinux --heads 255 --sectors 63 --install boot
dd if=/usr/lib/extlinux/mbr.bin of=../${IMAGE_NAME} conv=notrunc
@@ -200,19 +213,19 @@ cleanup_mounts
case "${OUTPUT_FORMAT}" in
"raw" )
echo "Already in raw format, not converting"
- IMAGE_OUT="${IMAGE_NAME}.image"
+ IMAGE_OUT="${BUILD_ID}.image"
;;
"vbox" )
echo "Converting image from RAW to VDI"
qemu-img convert -O vdi ${IMAGE_NAME} ${BUILD_ID}.vdi
rm -rf ${IMAGE_NAME}
- IMAGE_OUT="${IMAGE_NAME}.vdi"
+ IMAGE_OUT="${BUILD_ID}.vdi"
;;
"vmware" )
echo "Converting image from RAW to VMDK"
qemu-img convert -O vmdk ${IMAGE_NAME} ${BUILD_ID}.vmdk
rm -rf ${IMAGE_NAME}
- IMAGE_OUT="${IMAGE_NAME}.vmdk"
+ IMAGE_OUT="${BUILD_ID}.vmdk"
;;
esac
mv ${IMAGE_OUT} ${IMAGES_OUTPUT_PATH}/${IMAGE_OUT}