From 66644285fc9d404b54659255a79bdd18ddc3141f Mon Sep 17 00:00:00 2001 From: David Farning Date: Tue, 02 Feb 2010 01:51:18 +0000 Subject: refactor build structure --- diff --git a/usr-chroot.sh b/usr-chroot.sh index 13b1870..5e62020 100755 --- a/usr-chroot.sh +++ b/usr-chroot.sh @@ -6,7 +6,7 @@ ## Login ## ## Started on Fri Jan 1 03:35:38 2010 David Farning -## Last update Sun Jan 31 14:43:53 2010 David Farning +## Last update Mon Feb 1 17:03:17 2010 David Farning ## cat << EOF > /etc/apt/sources.list @@ -36,10 +36,7 @@ apt-get install --yes discover1 os-prober apt-get install --force-yes -y linux-image-generic apt-get install -y ubiquity ubiquity-casper ubiquity-frontend-gtk ubiquity-slideshow-ubuntu -#grub-gfxboot - -echo "here" -/bin/bash +#/bin/bash apt-get clean diff --git a/usr-scratch.sh b/usr-scratch.sh index 9068ef3..e7d709f 100755 --- a/usr-scratch.sh +++ b/usr-scratch.sh @@ -6,19 +6,20 @@ ## Login ## ## Started on Sat Jan 9 03:45:30 2010 David Farning -## Last update Sun Jan 31 19:04:58 2010 David Farning +## Last update Mon Feb 1 19:46:59 2010 David Farning ## set -eu function usage() { - echo "The script needs 2 parameters: + echo "The script needs 3 parameters: * Action to do: debootstrap|iso|squash|all * Architecture to build: i386|amd64 + * build date - Usage: $0 debootstrap|iso|squash|source|all|torrent i386|amd64" + Usage: $0 debootstrap|iso|squash|source|all|torrent i386|amd64 XXXX" } function failure() @@ -112,6 +113,17 @@ function clean_chroot() ${CCMD} rm -f ${CHROOT}/etc/resolv.conf || failure "Failed to remove resolv.conf, error=$?" } + +function prepare_filesystem_directory() +{ + echo "Preparing directory for filesystem" + if [ -e ${CHROOT} ]; then + rm -rf ${CHROOT} || failure "Failed to remove directory ${CHROOT}" + fi + mkdir -p ${CHROOT} +} + + function do_debootstrap() { date echo "DIST=${DIST} @@ -122,7 +134,7 @@ function do_debootstrap() { rm -rf $CHROOT || exit 1 # debootstrab the base system - mkdir ${CHROOT} + prepare_filesystem_directory debootstrap --arch=${ARCH} lucid ${CHROOT} ${MIRROR} # replace_ssd @@ -144,7 +156,7 @@ function prepare_image_directory() mkdir -p ${IMAGE} } -pack_squashfs() +function pack_squashfs() { prepare_image_directory cp -a USR-master/* ${IMAGE}/ @@ -169,7 +181,7 @@ pack_squashfs() chmod 644 ${IMAGE}/casper/filesystem.squashfs } -pack_iso(){ +function pack_iso(){ #update the kernel image in the master dir cp -v ${CHROOT}/boot/initrd.img* ${IMAGE}/casper/initrd cp -v ${CHROOT}/boot/vmlinuz* ${IMAGE}/casper/vmlinuz @@ -191,9 +203,45 @@ pack_iso(){ fi } +function build_vm(){ + VM=${DIST}-${ARCH}-${DATE} + +#if ! VBoxManage list runningvms | grep -qs "^\"${VM}\""; then +# break +# fi + + + VBoxManage createvm --name ${VM} --ostype Ubuntu --register + VBoxManage modifyvm ${VM} --memory 2048 + VBoxManage modifyvm ${VM} --cpus 3 + VBoxManage modifyvm ${VM} --vram 14 + VBoxManage modifyvm ${VM} --nic1 nat --acpi on + VBoxManage storagectl ${VM} --name ${VM}.ide --add ide --controller PIIX4 + VBoxManage createhd --filename ${VM}.vdi --size 5000 --remember + VBoxManage storageattach ${VM} --type hdd --storagectl ${VM}.ide --port 0 --device 0 --medium ${VM}.vdi + VBoxManage storageattach ${VM} --type dvddrive --storagectl ${VM}.ide --port 1 --device 0 --medium ~/usr/output/${VM}.iso + VBoxManage modifyvm ${VM} --boot1 dvd --nic1 nat --acpi on + + VBoxManage startvm ${VM} + while true; do + sleep 2 + if ! VBoxManage list runningvms | grep -qs "^\"${VM}\""; then + break + fi + done + + VBoxManage modifyvm ${VM} --memory 512 + VBoxManage modifyvm ${VM} --cpus 1 + VBoxManage storageattach ${VM} --type dvddrive --storagectl ${VM}.ide --port 1 --device 0 --medium none + VBoxManage export ${VM} -o ~/usr/output/${VM}.ovf +} + +function upload_files(){ + rsync --compress ${ISO} sunjammer.sugarlabs.org:public_html/${DIST}-${ARCH}-${DATE}.iso +} case $1 in -debootstrap|iso|squash|source|all|torrent) ACTION=$1 +debootstrap|squash|iso|vm|upload|all|debug) ACTION=$1 ;; *) usage exit 1 @@ -208,17 +256,39 @@ i386|amd64) ARCH=$2 ;; esac +DATE=$3 + export DEBIAN_FRONTEND=noninteractive MIRROR="http://10.0.02:3142/archive.ubuntu.com/ubuntu" DIST="USR" -CHROOT=${DIST}-${ARCH}-FS -IMAGE=${DIST}-${ARCH}-IMAGE -ISO=${DIST}-${ARCH}.iso -LOG=${CHROOT}.log +CHROOT=build/${ARCH}-FS +IMAGE=build/${ARCH}-IMAGE +ISO=output/${DIST}-${ARCH}-${DATE}.iso +LOG=logs/${DIST}-${ARCH}-${DATE}.log CCMD="chroot ${CHROOT}" -echo ${CCMD} -#do_debootstrap -pack_squashfs -pack_iso +case $ACTION in +debootstrap) COLUMNS=500 do_debootstrap 2>&1 3>&1 0>&1 | COLUMNS=500 tee $LOG + ;; +squash) COLUMNS=500 pack_squashfs 2>&1 3>&1 0>&1 | COLUMNS=500 tee $LOG + ;; +iso) COLUMNS=500 pack_iso 2>&1 3>&1 0>&1 | COLUMNS=500 tee $LOG + ;; +vm) COLUMNS=500 build_vm 2>&1 3>&1 0>&1 | COLUMNS=500 tee $LOG + ;; +upload) COLUMNS=500 upload_files 2>&1 3>&1 0>&1 | COLUMNS=500 tee $LOG + ;; +all) COLUMNS=500 do_debootstrap 2>&1 3>&1 0>&1 | COLUMNS=500 tee $LOG + COLUMNS=500 pack_squashfs 2>&1 3>&1 0>&1 | COLUMNS=500 tee -a $LOG + COLUMNS=500 pack_iso 2>&1 3>&1 0>&1 | COLUMNS=500 tee -a $LOG + COLUMNS=500 build_vm 2>&1 3>&1 0>&1 | COLUMNS=500 tee -a $LOG + COLUMNS=500 upload_files 2>&1 3>&1 0>&1 | COLUMNS=500 tee -a $LOG + ;; +debug) do_debootstrapG + pack_squashfs + pack_iso + build_vm + upload_files + ;; +esac diff --git a/usr-virtualbox.sh b/usr-virtualbox.sh deleted file mode 100755 index af67b2d..0000000 --- a/usr-virtualbox.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh -## - -RELEASE=USR-i386-0201 - -VBoxManage createvm --name ${RELEASE} --ostype Ubuntu --register - -VBoxManage modifyvm ${RELEASE} --memory 512 - -VBoxManage modifyvm ${RELEASE} --nic1 nat --acpi on - -VBoxManage storagectl ${RELEASE} --name ${RELEASE}.ide --add ide --controller PIIX4 - -VBoxManage createhd --filename ${RELEASE}.vdi --size 5000 --remember - -VBoxManage storageattach ${RELEASE} --type hdd --storagectl ${RELEASE}.ide --port 0 --device 0 --medium ${RELEASE}.vdi - -VBoxManage storageattach ${RELEASE} --type dvddrive --storagectl ${RELEASE}.ide --port 1 --device 0 --medium ~/USR/${RELEASE}.iso - -VBoxManage modifyvm ${RELEASE} --boot1 dvd --nic1 nat --acpi on - -VBoxManage startvm ${RELEASE} -- cgit v0.9.1