From 9739af2600e8cd0cce16efa5bf1734fb25f47ac7 Mon Sep 17 00:00:00 2001 From: David Farning Date: Thu, 21 Jan 2010 21:19:19 +0000 Subject: inital commit --- diff --git a/USR-master/README.TXT b/USR-master/README.TXT new file mode 100644 index 0000000..13bb03c --- /dev/null +++ b/USR-master/README.TXT @@ -0,0 +1,2 @@ +Sugar Ubuntu Remix comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. + diff --git a/USR-master/isolinux/16x16.fnt b/USR-master/isolinux/16x16.fnt new file mode 100644 index 0000000..d392957 --- /dev/null +++ b/USR-master/isolinux/16x16.fnt Binary files differ diff --git a/USR-master/isolinux/back.jpg b/USR-master/isolinux/back.jpg new file mode 100644 index 0000000..a60504c --- /dev/null +++ b/USR-master/isolinux/back.jpg Binary files differ diff --git a/USR-master/isolinux/boot.cat b/USR-master/isolinux/boot.cat new file mode 100644 index 0000000..8e40132 --- /dev/null +++ b/USR-master/isolinux/boot.cat Binary files differ diff --git a/USR-master/isolinux/bootlogo b/USR-master/isolinux/bootlogo new file mode 100644 index 0000000..73fcd68 --- /dev/null +++ b/USR-master/isolinux/bootlogo Binary files differ diff --git a/USR-master/isolinux/gfxboot.cfg b/USR-master/isolinux/gfxboot.cfg new file mode 100644 index 0000000..2aebaf3 --- /dev/null +++ b/USR-master/isolinux/gfxboot.cfg @@ -0,0 +1,12 @@ +background=0xB6875A +label normal=Normal +append normal= +label xforcevesa=Safe graphics mode +append xforcevesa=xforcevesa nomodeset +applies xforcevesa=live live-install +label driverupdates=Use driver update disc +append driverupdates=debian-installer/driver-update=true +applies driverupdates=live live-install +label oem=OEM install (for manufacturers) +append oem=oem-config/enable=true +applies oem=live live-install install diff --git a/USR-master/isolinux/isolinux.bin b/USR-master/isolinux/isolinux.bin new file mode 100644 index 0000000..4ce064d --- /dev/null +++ b/USR-master/isolinux/isolinux.bin Binary files differ diff --git a/USR-master/isolinux/isolinux.cfg b/USR-master/isolinux/isolinux.cfg new file mode 100644 index 0000000..00cac5b --- /dev/null +++ b/USR-master/isolinux/isolinux.cfg @@ -0,0 +1,5 @@ +include menu.cfg +default vesamenu.c32 +prompt 0 +timeout 300 +gfxboot bootlogo diff --git a/USR-master/isolinux/menu.cfg b/USR-master/isolinux/menu.cfg new file mode 100644 index 0000000..cee8bbc --- /dev/null +++ b/USR-master/isolinux/menu.cfg @@ -0,0 +1,7 @@ +menu hshift 13 +menu width 49 +menu margin 8 + +menu title Installer boot menu +include stdmenu.cfg +include text.cfg diff --git a/USR-master/isolinux/splash.pcx b/USR-master/isolinux/splash.pcx new file mode 100644 index 0000000..257645c --- /dev/null +++ b/USR-master/isolinux/splash.pcx Binary files differ diff --git a/USR-master/isolinux/splash.png b/USR-master/isolinux/splash.png new file mode 100644 index 0000000..5f7effb --- /dev/null +++ b/USR-master/isolinux/splash.png Binary files differ diff --git a/USR-master/isolinux/stdmenu.cfg b/USR-master/isolinux/stdmenu.cfg new file mode 100644 index 0000000..e70017c --- /dev/null +++ b/USR-master/isolinux/stdmenu.cfg @@ -0,0 +1,11 @@ +menu background splash.png +menu color title * #FFFFFFFF * +menu color border * #00000000 #00000000 none +menu color sel * #ffffffff #76a1d0ff * +menu color hotsel 1;7;37;40 #ffffffff #76a1d0ff * +menu color tabmsg * #ffffffff #00000000 * +menu vshift 12 +menu rows 10 +menu tabmsgrow 16 +menu timeoutrow 17 +menu tabmsg Press ENTER to boot or TAB to edit a menu entry diff --git a/USR-master/isolinux/text.cfg b/USR-master/isolinux/text.cfg new file mode 100644 index 0000000..764e25b --- /dev/null +++ b/USR-master/isolinux/text.cfg @@ -0,0 +1,19 @@ +default live +label live + menu label ^Try Ubuntu Sugar remix without any change to your computer + kernel /casper/vmlinuz + append file=/cdrom/preseed/ubuntu-sugar-remix.seed boot=casper apparmor=0 initrd=/casper/initrd -- +label live-install + menu label ^Install Ubuntu Sugar Remix + kernel /casper/vmlinuz + append file=/cdrom/preseed/ubuntu-sugar-remix.seed boot=casper apparmor=0 only-ubiquity initrd=/casper/initrd -- +label check + menu label ^Check disc for defects + kernel /casper/vmlinuz + append boot=casper integrity-check initrd=/casper/initrd.lz -- +label memtest + menu label Test ^memory + kernel /install/mt86plus +label hd + menu label ^Boot from first hard disk + localboot 0x80 diff --git a/USR-master/isolinux/text.cfg.~1~ b/USR-master/isolinux/text.cfg.~1~ new file mode 100644 index 0000000..65b5a75 --- /dev/null +++ b/USR-master/isolinux/text.cfg.~1~ @@ -0,0 +1,19 @@ +default live +label live + menu label ^Try Ubuntu Netbook without any change to your computer + kernel /casper/vmlinuz + append file=/cdrom/preseed/ubuntu-netbook.seed boot=casper apparmor=0 initrd=/casper/initrd -- +label live-install + menu label ^Install Ubuntu Netbook + kernel /casper/vmlinuz + append file=/cdrom/preseed/ubuntu-netbook.seed boot=casper apparmor=0 only-ubiquity initrd=/casper/initrd -- +label check + menu label ^Check disc for defects + kernel /casper/vmlinuz + append boot=casper integrity-check initrd=/casper/initrd.lz -- +label memtest + menu label Test ^memory + kernel /install/mt86plus +label hd + menu label ^Boot from first hard disk + localboot 0x80 diff --git a/USR-master/isolinux/vesamenu.c32 b/USR-master/isolinux/vesamenu.c32 new file mode 100644 index 0000000..a932bd4 --- /dev/null +++ b/USR-master/isolinux/vesamenu.c32 Binary files differ diff --git a/USR-master/preseed/ubuntu-sugar-remix.seed b/USR-master/preseed/ubuntu-sugar-remix.seed new file mode 100644 index 0000000..4014af7 --- /dev/null +++ b/USR-master/preseed/ubuntu-sugar-remix.seed @@ -0,0 +1,2 @@ +tasksel tasksel/first multiselect ubuntu-netbook +d-i passwd/auto-login boolean true diff --git a/usr-activities.sh b/usr-activities.sh new file mode 100755 index 0000000..5446939 --- /dev/null +++ b/usr-activities.sh @@ -0,0 +1,64 @@ +# Honey subset +ASLO="$ASLO org.laptop.community.TypingTurtle" +ASLO="$ASLO org.sugarlabs.IRC" +ASLO="$ASLO com.garycmartin.Moon" +ASLO="$ASLO org.laptop.sugar.ReadEtextsActivity" +ASLO="$ASLO com.ywwg.CartoonBuilderActivity" +ASLO="$ASLO vu.lux.olpc.Speak" +ASLO="$ASLO org.laptop.ViewSlidesActivity" +ASLO="$ASLO org.sugarlabs.InfoSlicer" +ASLO="$ASLO org.worldwideworkshop.olpc.FlipSticks" +ASLO="$ASLO org.worldwideworkshop.olpc.JigsawPuzzle" +ASLO="$ASLO org.worldwideworkshop.olpc.SliderPuzzle" +ASLO="$ASLO org.laptop.community.Colors" +ASLO="$ASLO org.squeak.FreeCell" +ASLO="$ASLO org.laptop.Develop" +ASLO="$ASLO org.laptop.TamTamEdit" +ASLO="$ASLO org.laptop.TamTamJam" +ASLO="$ASLO org.laptop.TamTamMini" +ASLO="$ASLO org.laptop.TamTamSynthLab" +ASLO="$ASLO org.laptop.Memorize" +ASLO="$ASLO org.worldwideworkshop.JokeMachineActivity" +ASLO="$ASLO vu.lux.olpc.Maze" +ASLO="$ASLO org.worldwideworkshop.olpc.storybuilder" +ASLO="$ASLO org.worldwideworkshop.PollBuilder" +ASLO="$ASLO org.gnome.Labyrinth" +ASLO="$ASLO org.laptop.RecordActivity" +ASLO="$ASLO org.laptop.Oficina" +#ASLO="$ASLO org.tuxpaint.sugar-is-lame" +ASLO="$ASLO tv.alterna.Clock" +ASLO="$ASLO org.laptop.physics" +ASLO="$ASLO org.laptop.sugar.GetIABooksActivity" +ASLO="$ASLO org.laptop.Arithmetic" + +WD=$PWD +BUNDLES_DIR=/home/systems/sugar/honey +rm -rf $BUNDLES_DIR + +mkdir -p $BUNDLES_DIR +cd $BUNDLES_DIR + +CACHE_DIR=/tmp/aslo +mkdir -p $CACHE_DIR + +ASLO_SP='0.86' +ASLO_URL='http://activities.sugarlabs.org/services/update-aslo.php' +ASLO_LINK='.//{http://www.mozilla.org/2004/em-rdf#}updateLink' + +for bundle_id in $ASLO ; do + curl -4 -s -L "$ASLO_URL?id=$bundle_id&appVersion=$ASLO_SP" > $CACHE_DIR/metadata + url=$(python -c "from xml.etree.ElementTree import parse; url=parse('$CACHE_DIR/metadata').find('$ASLO_LINK'); print url is not None and url.text or ''") + if [ -z "$url" ]; then + echo "Can not find url for $bundle_id" >&2 + continue + fi + remote_file=$(basename $(curl -4 -s -L -w %{url_effective} -I $url | tail -1)) + bundle=$CACHE_DIR/$remote_file + if [ ! -f $bundle ] ; then + curl -4 -L $url > $bundle + fi + cp -p $bundle $BUNDLES_DIR +done + +cd $BUNDLES_DIR +unp *.xo diff --git a/usr-chroot.sh b/usr-chroot.sh new file mode 100755 index 0000000..c9fc375 --- /dev/null +++ b/usr-chroot.sh @@ -0,0 +1,54 @@ +#!/bin/sh +## +## usr-chroot.sh +## +## Made by David Farning +## Login +## +## Started on Fri Jan 1 03:35:38 2010 David Farning +## Last update Thu Jan 14 12:56:12 2010 David Farning +## + +cat << EOF > /etc/apt/sources.list +deb http://10.0.0.2:3142/archive.ubuntu.com/ubuntu/ lucid main restricted universe multiverse +deb http://10.0.0.2:3142/ppa.launchpad.net/sugarteam/ppa/ubuntu lucid main +EOF + +cat << EOF > /etc/apt/preferences +Explanation: prefer packages from sugarteam PPA +Package: * +Pin: release o=LP-PPA-sugarteam +Pin-Priority: 1001 +EOF + +cat << EOF > /etc/usplash.conf +xres=1024 +yres=768 +EOF + +sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 363C5DAC + +apt-get update + +apt-get install --force-yes --yes ubuntu-sugar-remix sugar-activities +apt-get install --yes casper lupin-casper +apt-get install --yes discover1 laptop-detect os-prober +apt-get install --force-yes -y linux-image-generic +#apt-get install -y ubiquity grub-gfxboot + +#apt-get -y install hulahop xulrunner python-xpcom + +#FIXME #BUG502437 +#apt-get -y install python-numpy python-pygame + +## Install Sugar ## +#apt-get install -y --install-recommends sugar-session-0.88 sucrose-0.88 sugar-terminal-activity + +#apt-get -y upgrade + +## Install vim -- I just prefer it for working in the chroot ## +#apt-get -y install vim +/bin/bash + +apt-get clean +#exit diff --git a/usr-remaster.sh b/usr-remaster.sh new file mode 100755 index 0000000..6d6a823 --- /dev/null +++ b/usr-remaster.sh @@ -0,0 +1,492 @@ +#!/bin/bash +## +## usr.sh +## +## Made by David Farning +## Login +## +## Started on Wed Dec 23 17:25:39 2009 David Farning +## Last update Sat Jan 16 05:04:46 2010 David Farning +## +set -eu + +function check_if_user_is_root() +{ + if [ $UID != 0 ]; then + echo "You need root privileges" + exit 2 + fi +} + +function unmount_directory() +{ + DIR_TO_UNMOUNT="$1" + if mountpoint -q ${DIR_TO_UNMOUNT}; then #FIXME should be able to detect in tmp is mounted + echo "Unmounting directory ${DIR_TO_UNMOUNT}..." + umount -l ${DIR_TO_UNMOUNT} || failure "Cannot unmount directory ${DIR_TO_UNMOUNT}, error=$?" + fi +} + +function unmount_pseudofilesystems() +{ + if [ -n ${REMASTER_DIR} ]; then + unmount_directory ${REMASTER_DIR}/tmp + unmount_directory ${REMASTER_DIR}/lib/modules/*/volatile + unmount_directory ${REMASTER_DIR}/proc + unmount_directory ${REMASTER_DIR}/sys + unmount_directory ${REMASTER_DIR}/dev/pts + unmount_directory ${REMASTER_DIR}/var/run + fi +} + +function unmount_loopfilesystems() +{ + if [ -n ${SQUASHFS_MOUNT_DIR} ]; then + unmount_directory ${SQUASHFS_MOUNT_DIR} + fi + if [ -n ${ISO_MOUNT_DIR} ]; then + unmount_directory ${ISO_MOUNT_DIR} + fi +} + +function unmount_all() +{ + unmount_pseudofilesystems + unmount_loopfilesystems +} + +function failure() +{ + unmount_all + echo "$@" + exit 2 +} + +function script_cancelled_by_user() +{ + failure "Script cancelled by user" +} + +function remove_directory() +{ + DIR_TO_REMOVE="$1" + if [ ${DIR_TO_REMOVE} = "/" ]; then + failure "Trying to remove root directory" + fi + rm -rf ${DIR_TO_REMOVE} +} +function unpack_initrd() +{ + remove_remaster_initrd + mkdir -p ${INITRD_REMASTER_DIR} || failure "Cannot create directory ${INITRD_REMASTER_DIR}" + + if [ -e ${ISO_REMASTER_DIR}/casper/initrd.lz ]; then + INITRD_FILE=${ISO_REMASTER_DIR}/casper/initrd.lz + else + failure "Can't find initrd.lz file" + fi + + echo "Unpacking initrd image..." + pushd ${INITRD_REMASTER_DIR} || failure "Failed to change directory to ${INITRD_REMASTER_DIR}, error=$?" + + lzma -dcq -S .lz ${INITRD_FILE} | cpio -imvd --no-absolute-filenames + #cat ${INITRD_FILE} | gzip -d | cpio -i FIXME + RESULT=$? + if [ $RESULT -ne 0 ]; then + failure "Failed to unpack ${INITRD_FILE} to ${INITRD_REMASTER_DIR}, error=$RESULT" + fi + + popd +} + +function pack_initrd() +{ + echo "Packing initrd image..." + pushd ${INITRD_REMASTER_DIR} || failure "Failed to change directory to ${INITRD_REMASTER_DIR}, error=$?" + + find | cpio -H newc -o | lzma -7 > ${REMASTER_HOME}/initrd.lz + #find | cpio -H newc -o | gzip >${REMASTER_HOME}/initrd.lz + + RESULT=$? + if [ $RESULT -ne 0 ]; then + rm ${REMASTER_HOME}/initrd.lz + failure "Failed to compress initird image $INITRD_REMASTER_DIR to ${REMASTER_HOME}/initrd.lz, error=$RESULT" + fi + popd + + if [ -e ${ISO_REMASTER_DIR}/casper ]; then + INITRD_FILE=${ISO_REMASTER_DIR}/casper/initrd.gz + else + failure "Can't find where to copy the initrd.gz file" + fi + + mv ${REMASTER_HOME}/initrd.lz ${INITRD_FILE} || failure "Failed to move ${NEW_FILES_DIR}/initrd.lz to ${INITRD_FILE}, error=$?" +} + +function mount_iso() +{ + echo "Mounting ISO image..." + mkdir -p ${ISO_MOUNT_DIR} || failure "Cannot create directory ${ISO_MOUNT_DIR}, error=$?" + mount ${ISO_IMAGE} ${ISO_MOUNT_DIR} -o loop || failure "Cannot mount ${ISO_IMAGE} in ${ISO_MOUNT_DIR}, error=$?" +} + +function unmount_iso() +{ + if [ -e ${ISO_MOUNT_DIR} ] ; then + echo "Unmounting ISO image..." + umount ${ISO_MOUNT_DIR} || echo "Failed to unmount ISO mount directory ${ISO_MOUNT_DIR}, error=$?" + rmdir ${ISO_MOUNT_DIR} || echo "Failed to remove ISO mount directory ${ISO_MOUNT_DIR} error=$?" + fi +} + +function unpack_iso() +{ + echo "Unpacking ISO image..." + cp -a ${ISO_MOUNT_DIR} ${ISO_REMASTER_DIR} || failure "Failed to unpack ISO from ${ISO_MOUNT_DIR} to ${ISO_REMASTER_DIR}" + + #can't trap errors with diff because of its return codes, + #we pass the diff's output to cut cause we strip the version number + if [ -e ${ISO_REMASTER_DIR}/casper/filesystem.manifest ]; then + diff --unchanged-group-format='' ${ISO_REMASTER_DIR}/casper/filesystem.manifest ${ISO_REMASTER_DIR}/casper/filesystem.manifest-desktop | cut -d ' ' -f 1 > ${ISO_REMASTER_DIR}/casper/manifest.diff + fi +} + +function mount_squashfs() +{ + echo "Mounting SquashFS image..." + mkdir -p ${SQUASHFS_MOUNT_DIR} || failure "Cannot create directory ${SQUASHFS_MOUNT_DIR}, error=$?" + mount -t squashfs ${SQUASHFS_IMAGE} ${SQUASHFS_MOUNT_DIR} -o loop || failure "Cannot mount ${SQUASHFS_IMAGE} in ${SQUASHFS_MOUNT_DIR}, error=$?" +} + +function unmount_squashfs() +{ + if [ -e ${SQUASHFS_MOUNT_DIR} ] ; then + echo "Unmounting SquashFS image..." + umount ${SQUASHFS_MOUNT_DIR} || echo "Failed to unmount SquashFS mount directory ${SQUASHFS_MOUNT_DIR}, error=$?" + rmdir ${SQUASHFS_MOUNT_DIR} || echo "Failed to remove SquashFS mount directory ${SQUASHFS_MOUNT_DIR}, error=$?" + fi +} + +function unpack_rootfs() +{ + echo "Unpacking SquashFS image..." + cp -a ${SQUASHFS_MOUNT_DIR} ${REMASTER_DIR} || failure "Cannot copy files from ${SQUASHFS_MOUNT_DIR} to ${REMASTER_DIR}, error=$?" +} + +function remove_remaster_dir() +{ + if [ -e "$REMASTER_DIR" ] ; then + unmount_pseudofilesystems + echo "Removing remastering root dir..." + remove_directory "$REMASTER_DIR" + fi +} + +function prepare_new_files_directories() +{ + echo "Preparing directory for new files" + if [ -e ${NEW_FILES_DIR} ]; then + remove_directory ${NEW_FILES_DIR} || failure "Failed to remove directory ${NEW_FILES_DIR}" + fi + mkdir -p ${NEW_FILES_DIR} +} + +function prepare_rootfs_for_chroot() +{ + mount -t proc proc "$REMASTER_DIR/proc" || echo "Failed to mount $REMASTER_DIR/proc, error=$?" + mount -t sysfs sysfs "$REMASTER_DIR/sys" || echo "Failed to mount $REMASTER_DIR/sys, error=$?" + mount -t devpts none "$REMASTER_DIR/dev/pts" || failure "Failed to mount $REMASTER_DIR/dev/pts, error=$?" + mount -o bind /var/run "$REMASTER_DIR/var/run" + #mount -o bind /tmp "$REMASTER_DIR/tmp" FIXME do we need temp + + #create backup of root directory + chroot "$REMASTER_DIR" cp -a /root /root.saved || failure "Failed to create backup of /root directory, error=$?" + +# if [ -e $REMASTER_HOME/customization-scripts ]; then +# echo "Copying customization scripts..." +# cp -a "$REMASTER_HOME/customization-scripts" "$REMASTER_DIR/tmp" || failure "Cannot copy files from $CUSTOMIZE_DIR to $REMASTER_CUSTOMIZE_DIR, error=$?" +# fi + + echo "Copying resolv.conf..." + cp -f /etc/resolv.conf "$REMASTER_DIR/etc/resolv.conf" || failure "Failed to copy resolv.conf to image directory, error=$?" + + echo "Copying local apt cache, if available" + if [ -e "$APT_CACHE_SAVE_DIR" ]; then + mv "$REMASTER_DIR/var/cache/apt/" "$REMASTER_DIR/var/cache/apt.original" || failure "Cannot move $REMASTER_DIR/var/cache/apt/ to $REMASTER_DIR/var/cache/apt.original, error=$?" + mv "$APT_CACHE_SAVE_DIR" "$REMASTER_DIR/var/cache/apt" || failure "Cannot copy apt cache dir $APT_CACHE_SAVE_DIR to $REMASTER_DIR/var/cache/apt/, error=$?" + else + cp -a "$REMASTER_DIR/var/cache/apt/" "$REMASTER_DIR/var/cache/apt.original" || failure "Cannot copy $REMASTER_DIR/var/cache/apt/ to $REMASTER_DIR/var/cache/apt.original, error=$?" + fi + + echo "Creating DBUS uuid" + chroot "$REMASTER_DIR" dbus-uuidgen --ensure 1>/dev/null 2>&1 + + if [ -e "$REMASTER_HOME/customization-scripts/Xcookie" ] ; then + UCK_USER_HOME_DIR=`xauth info|grep 'Authority file'| sed "s/[ \t]//g" | sed "s/\/\.Xauthority//" | cut -d ':' -f2` + if [ `echo $UCK_USER_HOME_DIR | cut -d '/' -f2` == 'home' ] ; then + echo "Creating user directory..." + chroot "$REMASTER_DIR" mkdir -p "$UCK_USER_HOME_DIR" >/dev/null 2>&1 + echo "Copying X authorization file to chroot filesystem..." + cat "$REMASTER_HOME/customization-scripts/Xcookie" | chroot "$REMASTER_DIR" xauth -f /root/.Xauthority merge - || failure "Failed to merge X authorization file, error=$?" + cat "$REMASTER_HOME/customization-scripts/Xcookie" | chroot "$REMASTER_DIR" xauth merge - || failure "Failed to merge X authorization file in user directory, error=$?" + fi + fi +} + +function chroot_rootfs() +{ + cp -f ${WHAT_TO_EXTECUTE} ${REMASTER_DIR}/chroot.sh + chroot ${REMASTER_DIR} /chroot.sh + chroot ${REMASTER_DIR} /bin/bash +} + +function clean_rootfs_after_chroot() +{ + unmount_pseudofilesystems + save_apt_cache + + echo "Cleaning up apt" + chroot "$REMASTER_DIR" apt-get clean || failure "Failed to run apt-get clean, error=$?" + +# echo "Removing customize dir..." +# #Run in chroot to be on safe side +# chroot "$REMASTER_DIR" rm -rf "$REMASTER_CUSTOMIZE_RELATIVE_DIR" || failure "Cannot remove customize dir $REMASTER_CUSTOMIZE_RELATIVE_DIR, error=$?" + + echo "Cleaning up temporary directories..." + #Run in chroot to be on safe side + chroot "$REMASTER_DIR" rm -rf '/tmp/*' '/tmp/.*' '/var/tmp/*' '/var/tmp/.*' #2>/dev/null + + echo "Restoring /root directory..." + chroot "$REMASTER_DIR" rm -rf /root || failure "Cannot remove /root directory, error=$?" + chroot "$REMASTER_DIR" mv /root.saved /root + + echo "Removing /home/username directory, if created..." + UCK_USER_HOME_DIR=`xauth info|grep 'Authority file'| sed "s/[ \t]//g" | sed "s/\/\.Xauthority//" | cut -d ':' -f2` + if [ `echo $UCK_USER_HOME_DIR | cut -d '/' -f2` == 'home' ] ; then + chroot "$REMASTER_DIR" rm -rf "$UCK_USER_HOME_DIR" || failure "Cannot create user directory, error=$?" + fi + chroot "$REMASTER_DIR" rm -rf /var/lib/dbus/machine-id # 2>/dev/null + + echo "Restoring resolv.conf..." + rm -f "$REMASTER_DIR/etc/resolv.conf" || failure "Failed to remove resolv.conf, error=$?" +} + +function save_apt_cache() +{ + echo "Saving apt cache" + if [ -e "$APT_CACHE_SAVE_DIR" ]; then + mv -f "$APT_CACHE_SAVE_DIR" "$APT_CACHE_SAVE_DIR.old" || failure "Cannot save old apt-cache $APT_CACHE_SAVE_DIR to $APT_CACHE_SAVE_DIR.old, error=$?" + fi + mv "$REMASTER_DIR/var/cache/apt/" "$APT_CACHE_SAVE_DIR" || failure "Cannot move current apt-cache $REMASTER_DIR/var/cache/apt/ to $APT_CACHE_SAVE_DIR, error=$?" + mv "$REMASTER_DIR/var/cache/apt.original" "$REMASTER_DIR/var/cache/apt" || failure "Cannot restore original apt-cache $REMASTER_DIR/var/cache/apt.original to $REMASTER_DIR/var/cache/apt, error=$?" +} + +function pack_rootfs() +{ + echo "Updating files lists..." + chroot "$REMASTER_DIR" dpkg-query -W --showformat='${Package} ${Version}\n' > "$ISO_REMASTER_DIR/casper/filesystem.manifest" || failure "Cannot update filesystem.manifest, error=$?" + + cp ${ISO_REMASTER_DIR}/casper/filesystem.manifest ${ISO_REMASTER_DIR}/casper/filesystem.manifest-desktop + + sed -i '/ubiquity/d' ${ISO_REMASTER_DIR}/casper/filesystem.manifest-desktop + sed -i '/casper/d' ${ISO_REMASTER_DIR}/casper/filesystem.manifest-desktop + + echo "Packing SquashFS image..." + if [ -e "$ISO_REMASTER_DIR/casper/filesystem.squashfs" ]; then + rm -f "$ISO_REMASTER_DIR/casper/filesystem.squashfs" || failure "Cannot remove $ISO_REMASTER_DIR/casper/filesystem.squashfs to make room for created squashfs image, error=$?" + fi + + EXTRA_OPTS="" +# if [ -e "$CUSTOMIZE_DIR/rootfs.sort" ] ; then +# #FIXME: space not allowed in $CUSTOMIZE_DIR +# EXTRA_OPTS="-sort $CUSTOMIZE_DIR/rootfs.sort" +# fi + + mksquashfs "$REMASTER_DIR" "$ISO_REMASTER_DIR/casper/filesystem.squashfs" $EXTRA_OPTS || failure "Failed to create squashfs image to $ISO_REMASTER_DIR/casper/filesystem.squashfs, error=$?" +} + +function pack_iso() +{ + if [ ! -e ${ISO_REMASTER_DIR} ]; then + failure "ISO remastering directory does not exists" + fi + + #skip boot.cat, isolinux.bin, md5sums.txt + #mismatches are for those files, because they are generated by mkisofs or by generating MD5 sums: + EXCLUDED_FROM_MD5="./isolinux/isolinux.bin ./isolinux/boot.cat ./md5sum.txt ./manifest.diff" + EXCLUDED_FROM_MD5_EXPRESSION=$(echo $EXCLUDED_FROM_MD5 | tr ' ' '|') + EXCLUDED_FROM_MD5_EXPRESSION="($EXCLUDED_FROM_MD5_EXPRESSION)" + + echo "Updating md5sums..." + pushd ${ISO_REMASTER_DIR} + find . -type f -print0 | grep --null-data -v -E "$EXCLUDED_FROM_MD5_EXPRESSION" | xargs -0 md5sum > md5sum.txt + popd + + echo "Packing ISO image..." + + LIVECD_ISO_DESCRIPTION="Remastered Ubuntu LiveCD" + + if [ -e ${CUSTOMIZE_DIR}/iso_description ] ; then + LIVECD_ISO_DESCRIPTION=`cat ${CUSTOMIZE_DIR}/iso_description` + fi + + echo "ISO description set to: ${LIVECD_ISO_DESCRIPTION}" + + MKISOFS_EXTRA_OPTIONS="" + if [ -e ${CUSTOMIZE_DIR}/mkisofs_extra_options ] ; then + MKISOFS_EXTRA_OPTIONS=`cat ${CUSTOMIZE_DIR}/mkisofs_extra_options` + fi + + if [ "$1" = "ppc" ]; then + mkisofs -o "$NEW_FILES_DIR/$NEW_ISO_FILE_NAME" \ + -p "Ubuntu Customization Kit - http://uck.sf.net" \ + -probe -map "$UCK_LIBRARIES_DIR/hfs.map" -chrp-boot -iso-level 2 \ + -part -no-desktop -r --netatalk -hfs \ + -hfs-bless "$ISO_REMASTER_DIR/install" \ + -x "$ISO_REMASTER_DIR"/casper/manifest.diff \ + -V "$LIVECD_ISO_DESCRIPTION" \ + $MKISOFS_EXTRA_OPTIONS \ + "$ISO_REMASTER_DIR" + elif [ "$1" = "x86_64" ]; then + mkisofs -o "$NEW_FILES_DIR/$NEW_ISO_FILE_NAME" \ + -b "isolinux/isolinux.bin" -c "isolinux/boot.cat" \ + -p "Ubuntu Customization Kit - http://uck.sf.net" \ + -no-emul-boot -V "$LIVECD_ISO_DESCRIPTION" -r -J -l \ + -x "$ISO_REMASTER_DIR"/casper/manifest.diff \ + $MKISOFS_EXTRA_OPTIONS \ + "$ISO_REMASTER_DIR" + elif [ "$1" = "ia64" ]; then + mkisofs -o "$NEW_FILES_DIR/$NEW_ISO_FILE_NAME" \ + -b "isolinux/isolinux.bin" -c "isolinux/boot.cat" \ + -no-emul-boot -V "$LIVECD_ISO_DESCRIPTION" -J -r \ + -x "$ISO_REMASTER_DIR"/casper/manifest.diff \ + $MKISOFS_EXTRA_OPTIONS \ + "$ISO_REMASTER_DIR" + else + mkisofs -o "$NEW_FILES_DIR/$NEW_ISO_FILE_NAME" \ + -b "isolinux/isolinux.bin" -c "isolinux/boot.cat" \ + -p "Ubuntu Customization Kit - http://uck.sf.net" \ + -no-emul-boot -boot-load-size 4 -boot-info-table \ + -V "$LIVECD_ISO_DESCRIPTION" -cache-inodes -r -J -l \ + -x "$ISO_REMASTER_DIR"/casper/manifest.diff \ + $MKISOFS_EXTRA_OPTIONS \ + "$ISO_REMASTER_DIR" + fi + + RESULT=$? + if [ $RESULT -ne 0 ]; then + failure "Failed to pack ISO image, error=${RESULT}" + fi +} + +function generate_md5_for_new_iso() +{ + echo "Generating md5sum for newly created ISO..." + cd ${NEW_FILES_DIR} + md5sum ${NEW_ISO_FILE_NAME} > ${NEW_ISO_FILE_NAME}.md5 +} + +function remove_iso_remaster_dir() +{ + if [ -e "$ISO_REMASTER_DIR" ] ; then + echo "Removing ISO remastering dir..." + remove_directory "$ISO_REMASTER_DIR" || failure "Failed to remove directory $ISO_REMASTER_DIR, error=$?" +fi +} + +function remove_remaster_dir() +{ + if [ -e "$REMASTER_DIR" ] ; then + unmount_pseudofilesystems + echo "Removing remastering root dir..." + remove_directory "$REMASTER_DIR" + fi +} + +function remove_remaster_initrd() +{ + if [ -e "$INITRD_REMASTER_DIR" ]; then + echo "Removing initrd remastering dir..." + remove_directory "$INITRD_REMASTER_DIR" + fi +} + +export LANG=C +check_if_user_is_root +trap unmount_all EXIT +trap script_cancelled_by_user SIGINT + +REMASTER_HOME=/home/dfarning/usr +ISO_IMAGE=lucid-netbook-i386.iso + +############# +# unpacking # +############# + +ISO_REMASTER_DIR=${REMASTER_HOME}/remaster_iso +ISO_MOUNT_DIR=${REMASTER_HOME}/iso_mount +mount_iso +unpack_iso +unmount_iso + +#FIXME initrd should come before rootfs +REMASTER_DIR=${REMASTER_HOME}/remaster_root +SQUASHFS_MOUNT_DIR=${REMASTER_HOME}/squashfs_mount +SQUASHFS_IMAGE=${REMASTER_HOME}/remaster_iso/casper/filesystem.squashfs +remove_remaster_dir +mount_squashfs +unpack_rootfs +unmount_squashfs + +INITRD_REMASTER_DIR=${REMASTER_HOME}/remaster_initrd +unpack_initrd + +############### +# customizing # +############### + +WHAT_TO_EXTECUTE=/home/dfarning/usr/bin/usr-chroot.sh +APT_CACHE_SAVE_DIR=${REMASTER_HOME}/remaster_apt_cache +prepare_rootfs_for_chroot +chroot_rootfs +CHROOT_EXIT_CODE=$? +clean_rootfs_after_chroot + +## create text.cfg ## +cat << EOF > ${ISO_REMASTER_DIR}/isolinux/text.cfg +default live +label live + menu label ^Try Ubuntu Sugar Remix without any change to your computer + kernel /casper/vmlinuz + append file=/cdrom/preseed/ubuntu-netbook.seed boot=casper apparmor=0 initrd=/casper/initrd.lz quiet splash -- +label live-install + menu label ^Install Ubuntu Sugar Remix + kernel /casper/vmlinuz + append file=/cdrom/preseed/ubuntu-netbook.seed boot=casper apparmor=0 only-ubiquity initrd=/casper/initrd.lz quiet splash -- +EOF + + + +########### +# packing # +########### + +pack_initrd + +pack_rootfs + +NEW_ISO_FILE_NAME=ubuntu-sugar-remix.iso +NEW_FILES_DIR=${REMASTER_HOME}/remaster_new_files +CUSTOMIZE_DIR=${REMASTER_HOME}/customization_scripts +ARCH=x86 +prepare_new_files_directories +pack_iso ${ARCH} +generate_md5_for_new_iso + +############# +# finishing # +############# + +remove_remaster_initrd +remove_remaster_dir +remove_iso_remaster_dir diff --git a/usr-scratch.sh b/usr-scratch.sh new file mode 100755 index 0000000..55caa2f --- /dev/null +++ b/usr-scratch.sh @@ -0,0 +1,270 @@ +#!/bin/bash +## +## makedistro.sh +## +## Made by David Farning +## Login +## +## Started on Sat Jan 9 03:45:30 2010 David Farning +## Last update Thu Jan 14 06:04:12 2010 David Farning +## + +set -eu + +function usage() +{ + echo "The script needs 2 parameters: + + * Action to do: debootstrap|iso|squash|all + * Architecture to build: i386|amd64 + + Usage: $0 debootstrap|iso|squash|source|all|torrent i386|amd64" +} + +function failure() +{ + unmount_directories + echo "$@" + exit 2 +} + +function unmount_directory() +{ + DIR_TO_UNMOUNT="$1" + if mountpoint -q ${DIR_TO_UNMOUNT}; then #FIXME should be able to detect in tmp is mounted + echo "Unmounting directory ${DIR_TO_UNMOUNT}..." + umount -l ${DIR_TO_UNMOUNT} || failure "Cannot unmount directory ${DIR_TO_UNMOUNT}, error=$?" + fi +} + +function unmount_directories() +{ + # check for runs of the script + if [ -d ${CHROOT} ] ; then + echo "Cleaning up old build tree" + for MOUNT in /tmp /lib/modules/*/volatile /proc /sys /dev/pts /var/run ; do + unmount_directory ${CHROOT}${MOUNT} + done + fi +} + +function replace_ssd() +{ + # replace the start-stop-daemon, to make /etc/init.d/ scripts do nothing for a while + mv ${CHROOT}/sbin/start-stop-daemon ${CHROOT}/sbin/start-stop-daemon.REAL + cat < "$CHROOT/sbin/start-stop-daemon" +#!/bin/sh +echo +echo "Warning: Fake start-stop-daemon called, doing nothing" +EOF + chmod 755 ${CHROOT}/sbin/start-stop-daemon +} + +function restore_ssd() +{ + # enable /etc/init.d/ scripts + mv ${CHROOT}/sbin/start-stop-daemon.REAL ${CHROOT}/sbin/start-stop-daemon +} + +function prepare_chroot() +{ + export LANG=C + export LANGUAGE=C + + mount -t proc proc ${CHROOT}/proc || failure "Failed to mount ${CHROOT}/proc, error=$?" + mount -t sysfs sysfs ${CHROOT}/sys || failure "Failed to mount ${CHROOT}/sys, error=$?" + mount -t devpts none ${CHROOT}/dev/pts || failure "Failed to mount ${CHROOT}/dev/pts, error=$?" + mount -o bind /var/run ${CHROOT}/var/run + #mount -o bind /tmp ${CHROOT}/tmp FIXME do we need temp + + echo "Copying resolv.conf..." + cp -f /etc/resolv.conf ${CHROOT}/etc/resolv.conf || failure "Failed to copy resolv.conf to image directory, error=$?" + + echo "Creating DBUS uuid" + #${CCMD} dbus-uuidgen --ensure + echo "done" +} + +function in_chroot() +{ + cp usr-chroot.sh ${CHROOT} + ${CCMD} /usr-chroot.sh +} + +function clean_chroot() +{ + unmount_directories + + echo "Cleaning up apt" + ${CCMD} apt-get clean || failure "Failed to run apt-get clean, error=$?" + ${CCMD} apt-get autoclean || failure "Failed to run apt-get autoclean, error=$?" + + echo "Cleaning up temporary directories..." + ${CCMD} rm -rf '/tmp/*' '/tmp/.*' '/var/tmp/*' '/var/tmp/.*' #2>/dev/null + + ${CCMD} rm -rf /var/lib/dbus/machine-id # 2>/dev/null + + echo "Restoring hosts..." + ${CCMD} rm -f ${CHROOT}/etc/hosts || failure "Failed to hosts, error=$?" + + echo "Restoring resolv.conf..." + ${CCMD} rm -f ${CHROOT}/etc/resolv.conf || failure "Failed to remove resolv.conf, error=$?" +} + +function do_debootstrap() { + date + echo "DIST=${DIST} + ARCH=${ARCH} + CHROOT=${CHROOT}" + + unmount_directories + rm -rf $CHROOT || exit 1 + + # debootstrab the base system + mkdir ${CHROOT} + debootstrap --arch=${ARCH} lucid ${CHROOT} ${MIRROR} + +# replace_ssd + prepare_chroot + in_chroot + + cp casper $CHROOT/etc/init.d/casper + +# ${CCMD} update-usbids.sh +# ${CCMD} update-pciids + + ${CCMD} update-initramfs -uv + + clean_chroot +# restore_ssd +} + +function prepare_image_directory() +{ + echo "Preparing directory for image" + if [ -e ${IMAGE} ]; then + rm -rf ${IMAGE} || failure "Failed to remove directory ${IMAGE}" + fi + mkdir -p ${IMAGE} +} + +pack_squashfs() +{ + prepare_image_directory + cp -a USR-master/* ${IMAGE}/ + + echo "Updating files lists..." + ${CCMD} dpkg-query -W --showformat='${Package} ${Version}\n' > ${IMAGE}/casper/filesystem.manifest || failure "Cannot update filesystem.manifest, error=$?" + + cp ${IMAGE}/casper/filesystem.manifest ${IMAGE}/casper/filesystem.manifest-desktop + + sed -i '/ubiquity/d' ${IMAGE}/casper/filesystem.manifest-desktop + sed -i '/casper/d' ${IMAGE}/casper/filesystem.manifest-desktop + + + echo "Packing SquashFS image..." + if [ -e ${IMAGE}/casper/filesystem.squashfs ]; then + rm -f ${IMAGE}/casper/filesystem.squashfs || failure "Cannot remove ${IMAGE}/casper/filesystem.squashfs to make room for created squashfs image, error=$?" + fi + + mksquashfs ${CHROOT} ${IMAGE}/casper/filesystem.squashfs || failure "Failed to create squashfs image to ${IMAGE}/casper/filesystem.squashfs, error=$?" + + chmod 644 ${IMAGE}/casper/filesystem.squashfs +} + +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 + + echo "Updating md5sums..." + pushd ${CHROOT} + #rm md5sum.txt +# find . -type f | grep -v boot.cat | grep -v md5sum.txt | grep -v isolinux.bin | grep -v pdf$ | grep -v md5sum | xargs md5sum >> md5sum.txt + popd + + LIVECD_ISO_DESCRIPTION="Ubuntu Sugar Remix LiveCD" + + echo "ISO description set to: ${LIVECD_ISO_DESCRIPTION}" + + if [ ${ARCH} = "x86_64" ]; then + echo "#FIXME this has not been tested" +# mkisofs -o "$NEW_FILES_DIR/$NEW_ISO_FILE_NAME" \ +# -b "isolinux/isolinux.bin" -c "isolinux/boot.cat" \ +# -p "Ubuntu Customization Kit - http://uck.sf.net" \ +# -no-emul-boot -V "$LIVECD_ISO_DESCRIPTION" -r -J -l \ +# -x "$ISO_REMASTER_DIR"/casper/manifest.diff \ +# $MKISOFS_EXTRA_OPTIONS \ +# "$ISO_REMASTER_DIR" + else + mkisofs -o ${ISO} \ + -b "isolinux/isolinux.bin" -c "isolinux/boot.cat" \ + -no-emul-boot -boot-load-size 4 -boot-info-table \ + -cache-inodes -r -J -l \ + ${IMAGE} + fi + + RESULT=$? + if [ $RESULT -ne 0 ]; then + failure "Failed to pack ISO image, error=${RESULT}" + fi + + +#NAME=${DIST}_${VERSION}_$ARCH +#[ $ARCH = "i386" ] && NAME=${DIST}_${VERSION}_i686 +#mkisofs -D -r -V "${NAME}" -cache-inodes -J -l -b isolinux/isolinux.bin \ +# -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table \ +# -o iso/${NAME}.iso $DIST-master +} + + +case $1 in +debootstrap|iso|squash|source|all|torrent) ACTION=$1 + ;; +*) usage + exit 1 + ;; +esac + +case $2 in +i386|amd64) ARCH=$2 + ;; +*) usage + exit 1 + ;; +esac + +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 +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 +# ;; +#iso) COLUMNS=500 pack_iso 2>&1 3>&1 0>&1 | COLUMNS=500 tee $LOG +# ;; +#torrent) COLUMNS=500 DO_TORRENT 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 +# ;; +#source) COLUMNS=500 DO_SOURCE 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 +# ;; +#esac \ No newline at end of file -- cgit v0.9.1