diff options
Diffstat (limited to 'usr-scratch.sh')
-rwxr-xr-x | usr-scratch.sh | 100 |
1 files changed, 85 insertions, 15 deletions
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 <dfarning@acer> ## ## 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 |