diff --git a/BuildLiveCD b/BuildLiveCD index fbb9a275..d84e6ec1 100755 --- a/BuildLiveCD +++ b/BuildLiveCD @@ -13,7 +13,7 @@ finish() { fi if [ "$SEND_LOG" = "yes" ]; then exec >/dev/null 2>&1 - mailx -s "LiveCD: $STATUS $STE:$arg${SUBARCH:+-$SUBARCH} build on ${ARCH}" buildd+porters < "$BUILD_LOG" + mailx -s "LiveCD: $STATUS $STE:$FS${SUBARCH:+-$SUBARCH} build on ${ARCH}" buildd+porters < "$BUILD_LOG" fi rm -f ~/buildLiveCD.lock nohup ~/bin/pruneLiveCD >/dev/null 2>&1 & @@ -31,13 +31,15 @@ NEWSUITE="natty" SUITES="" PROPOSED="" IMAGEFORMAT="" +LIVE_BUILD=false -while getopts :s:d:f:pa: name; do case $name in +while getopts :s:d:f:pa:l name; do case $name in s) SUBARCH="$OPTARG";; d) NEWSUITE="$OPTARG";; f) IMAGEFORMAT="-f$OPTARG";; p) PROPOSED="-p";; a) APT_SOURCE="-A $OPTARG";; + l) LIVE_BUILD=:;; esac; done; shift $((OPTIND-1)) @@ -68,7 +70,7 @@ if [ "$new_suite" = "yes" ] && [ "$old_suite" = "yes" ]; then echo "greater than hardy at the same time, please use two invocations" >&2 exit 1 fi -if (( $# == 0 )) || [ "X$1" = "Xall" ]; then +if ([ $# = 0 ] || [ "X$1" = "Xall" ]) && ! $LIVE_BUILD; then set -- ubuntu kubuntu kubuntu-mobile kubuntu-netbook edubuntu xubuntu mythbuntu base if [ "$ARCH" = "i386" ]; then set -- ubuntu ubuntu-dvd ubuntu-lpia ubuntu-netbook kubuntu kubuntu-dvd kubuntu-mobile kubuntu-netbook edubuntu edubuntu-dvd xubuntu mythbuntu base @@ -95,6 +97,8 @@ if [ "`echo $@ | wc -w`" -gt "1" ]; then done exit 0 fi +FS="$1" +shift lockfile ~/buildLiveCD.lock || exit 1 trap "finish" 0 @@ -116,52 +120,64 @@ for STE in $SUITES; do DIR=~/build.live/chroot-${STE}/./build/ fi - for arg in "$@"; do - PUBDIR=~/public_html/LiveCD/${STE}/${arg}${SUBARCH:+-$SUBARCH}/ - mkdir -p ${PUBDIR} + PUBDIR=~/public_html/LiveCD/${STE}/${FS}${SUBARCH:+-$SUBARCH}/ + mkdir -p ${PUBDIR} - NOW=$(date +%Y%m%d) - if [ -d ${PUBDIR}${NOW} ]; then - typeset -i n=1; while [ -d ${PUBDIR}${NOW}.$n ]; do n=n+1; done - NOW=${NOW}.$n - fi - NOW=${NOW} - LOG=${PUBDIR}${NOW}/livecd-${NOW}-${ARCH}.out + NOW=$(date +%Y%m%d) + if [ -d ${PUBDIR}${NOW} ]; then + typeset -i n=1; while [ -d ${PUBDIR}${NOW}.$n ]; do n=n+1; done + NOW=${NOW}.$n + fi + NOW=${NOW} + LOG=${PUBDIR}${NOW}/livecd-${NOW}-${ARCH}.out + > ${LOG} - rm -f ${PUBDIR}latest - ln -sf ${PUBDIR}${NOW} ${PUBDIR}latest - mkdir -p ${PUBDIR}${NOW} - if $LINUX32 sudo chroot ${DIR%/./*} sh -c "cd /${DIR#*/./} && /usr/sbin/livecd.sh ${SUBARCHARG} ${APT_SOURCE} ${PROPOSED} -d${STE} ${IMAGEFORMAT} ${ARCHARG} ${IMAGEARG} $arg" > ${LOG} 2>&1; then - rm -f ${PUBDIR}current - ln -sf ${NOW} ${PUBDIR}current + rm -f ${PUBDIR}latest + ln -sf ${PUBDIR}${NOW} ${PUBDIR}latest + mkdir -p ${PUBDIR}${NOW} + if $LIVE_BUILD; then + mkdir -p "${DIR}/auto" + for f in config build clean; do + ln -s "/usr/share/livecd-rootfs/live-build/auto/$f" "${DIR}/auto/" + done + $LINUX32 sudo chroot ${DIR%/./*} sh -c "cd /${DIR#*/./} && lb clean --purge" >> ${LOG} 2>&1 || true + if ! $LINUX32 sudo chroot ${DIR%/./*} sh -c "cd /${DIR#*/./} && SUITE=${STE} PROJECT=${FS} ARCH=${ARCH} SUBARCH=${SUBARCH} IMAGEFORMAT=${IMAGEFORMAT} lb config" >> ${LOG} 2>&1; then + exit 1 + fi + COMMAND="PROJECT=${FS} ARCH=${ARCH} SUBARCH=${SUBARCH} lb build" + else + COMMAND="/usr/sbin/livecd.sh ${SUBARCHARG} ${APT_SOURCE} ${PROPOSED} -d${STE} ${IMAGEFORMAT} ${ARCHARG} ${IMAGEARG} ${FS}" + fi + if $LINUX32 sudo chroot ${DIR%/./*} sh -c "cd /${DIR#*/./} && $COMMAND" >> ${LOG} 2>&1; then + rm -f ${PUBDIR}current + ln -sf ${NOW} ${PUBDIR}current - for file in ${DIR}livecd.*; do - if [ -f ${file} ]; then - ext=${file##*.} - base=${file%.*}; base=${base##*/} - sudo chown buildd ${file} - sudo mv ${file} ${PUBDIR}${NOW}/${base}-${NOW}-${ARCH}.${ext} - ln -sf ${base}-${NOW}-${ARCH}.${ext} ${PUBDIR}${NOW}/${base}.${ext} - fi - done + for file in ${DIR}livecd.*; do + if [ -f ${file} ]; then + ext=${file##*.} + base=${file%.*}; base=${base##*/} + sudo chown buildd ${file} + sudo mv ${file} ${PUBDIR}${NOW}/${base}-${NOW}-${ARCH}.${ext} + ln -sf ${base}-${NOW}-${ARCH}.${ext} ${PUBDIR}${NOW}/${base}.${ext} + fi + done - for f in ${PUBDIR}${NOW}/livecd.*.cloop-*; do - target=${f%-*} - if [ ! -f ${target} ]; then - for fsbs in 4096:4096 1024:65536; do - if [ -f ${target}-${fsbs} ]; then - ln -sf ${target##*/}-${fsbs} ${target} - break - fi - done - if [ ! -f ${target} ]; then - best=$(ls -ld ${target}-* | sort -k5,5n| awk '{print $NF; quit}') - ln -sf ${best##*/} ${target} + for f in ${PUBDIR}${NOW}/livecd.*.cloop-*; do + target=${f%-*} + if [ ! -f ${target} ]; then + for fsbs in 4096:4096 1024:65536; do + if [ -f ${target}-${fsbs} ]; then + ln -sf ${target##*/}-${fsbs} ${target} + break fi + done + if [ ! -f ${target} ]; then + best=$(ls -ld ${target}-* | sort -k5,5n| awk '{print $NF; quit}') + ln -sf ${best##*/} ${target} fi - done - else - exit 1 - fi - done + fi + done + else + exit 1 + fi done diff --git a/debian/changelog b/debian/changelog index 1b10bdc1..2218607a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +livecd-rootfs (2.0) UNRELEASED; urgency=low + + * Add live-build support. The old livecd.sh is still here for + compatibility, but this package's primary purpose is now to provide + Ubuntu-specific configuration for live-build. + + -- Colin Watson Mon, 13 Jun 2011 12:32:28 +0100 + livecd-rootfs (1.167) oneiric; urgency=low * Drop language-support-en from LIVELIST for kubuntu-mobile and diff --git a/debian/control b/debian/control index d0d15536..25f29db7 100644 --- a/debian/control +++ b/debian/control @@ -8,7 +8,7 @@ Vcs-Bzr: http://bazaar.launchpad.net/~ubuntu-core-dev/livecd-rootfs/trunk Package: livecd-rootfs Architecture: all -Depends: ${misc:Depends}, debootstrap, rsync, python-minimal | python, procps, squashfs-tools (>= 1:3.3-1), grep-dctrl, fdupes, lsb-release, lzma, e2fsprogs +Depends: ${misc:Depends}, debootstrap, rsync, python-minimal | python, procps, squashfs-tools (>= 1:3.3-1), grep-dctrl, fdupes, lsb-release, lzma, e2fsprogs, live-build (>= 3.0~a20-1ubuntu1) Suggests: partimage Description: construction script for the livecd rootfs livecd-rootfs provides the script used to create the root filesystem diff --git a/debian/install b/debian/install index f960f4ef..c12d1e96 100644 --- a/debian/install +++ b/debian/install @@ -1 +1,2 @@ livecd.sh e2fs-zero.py usr/sbin +live-build usr/share/livecd-rootfs diff --git a/live-build/auto/build b/live-build/auto/build new file mode 100755 index 00000000..19ef2a58 --- /dev/null +++ b/live-build/auto/build @@ -0,0 +1,105 @@ +#! /bin/sh +set -e + +export LC_ALL=C + +. "${LB_BASE:-/usr/share/live/build}"/scripts/build.sh + +Arguments "${@}" + +Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source +Set_defaults + +( + lb bootstrap "$@" + lb chroot "$@" + + echo "===== Checking size of /usr/share/doc =====" + echo BEGIN docdirs + (cd chroot && find usr/share/doc -maxdepth 1 -type d | xargs du -s | sort -nr) + echo END docdirs + + if which fdupes >/dev/null 2>&1; then + echo "===== Checking for duplicate files =====" + echo "first line: " + echo "data lines: [ ...]" + echo BEGIN fdupes + (cd chroot \ + && fdupes --recurse --noempty --sameline --size --quiet usr \ + | awk '/bytes each/ {s=$1} /^usr/ { n+=1; n2+=NF-1; sum+=s*(NF-1); print s*(NF-1), NF-1, s, $0 } END {print sum, n, n2}' \ + | sort -nr + ) + echo END fdupes + fi + + lb binary "$@" +) 2>&1 | tee binary.log + +# Link output files somewhere BuildLiveCD will be able to find them. +PREFIX="livecd.$PROJECT${SUBARCH:+-$SUBARCH}" + +case $LB_INITRAMFS in + casper) + INITFS="casper" + ;; + + live-boot) + INITFS="live" + ;; + + *) + INITFS="boot" + ;; +esac + +for OUTPUT in ext2 ext3 manifest manifest-remove size squashfs; do + [ -e "binary/$INITFS/filesystem.$OUTPUT" ] || continue + ln "binary/$INITFS/filesystem.$OUTPUT" "$PREFIX.$OUTPUT" + chmod 644 "$PREFIX.$OUTPUT" +done + +for FLAVOUR in $LB_LINUX_FLAVOURS; do + KVERS="$( (cd "binary/$INITFS"; ls vmlinu?-*) | sed -n "s/^vmlinu.-\\([^-]*-[^-]*-$FLAVOUR\\)/\\1/p" )" + if [ -z "$KVERS" ]; then + echo "No kernel output for $FLAVOUR!" >&2 + exit 1 + fi + NUMKVERS="$(set -- $KVERS; echo $#)" + if [ "$NUMKVERS" -gt 1 ]; then + echo "Cannot handle more than one kernel for $FLAVOUR ($KVERS)!" >&2 + exit 1 + fi + ln "binary/$INITFS/"vmlinu?-"$KVERS" "$PREFIX.kernel-$FLAVOUR" + chmod 644 "$PREFIX.kernel-$FLAVOUR" + if [ -e "binary/$INITFS/initrd.img-$KVERS" ]; then + ln "binary/$INITFS/initrd.img-$KVERS" "$PREFIX.initrd-$FLAVOUR" + chmod 644 "$PREFIX.initrd-$FLAVOUR" + fi +done + +NUMFLAVOURS="$(set -- $LB_LINUX_FLAVOURS; echo $#)" +if [ "$NUMFLAVOURS" = 1 ]; then + # only one kernel flavour + ln -sf "$PREFIX.kernel-$LB_LINUX_FLAVOURS" "$PREFIX.kernel" + ln -sf "$PREFIX.initrd-$LB_LINUX_FLAVOURS" "$PREFIX.initrd" +fi + +# LTSP chroot building (only in 32bit and for Edubuntu (DVD)) +case $PROJECT in + edubuntu-dvd) + if [ "$ARCH" = i386 ]; then + echo "Building LTSP chroot" + ltsp-build-client --base $(pwd) --mirror $LB_PARENT_MIRROR_BOOTSTRAP --arch $ARCH --dist $LB_PARENT_DISTRIBUTION --chroot ltsp-live --late-packages ldm-edubuntu-theme,plymouth-theme-edubuntu --purge-chroot --skipimage + mkdir -p images + mksquashfs ltsp-live images/ltsp-live.img -noF -noD -noI -no-exports -e cdrom + rm -Rf ltsp-live + if [ -f images/ltsp-live.img ]; then + mv images/ltsp-live.img livecd.$PROJECT-ltsp.squashfs + chmod 0644 livecd.$PROJECT-ltsp.squashfs + rmdir --ignore-fail-on-non-empty images + else + echo "LTSP: Unable to build the chroot, see above for details." + fi + fi + ;; +esac diff --git a/live-build/auto/clean b/live-build/auto/clean new file mode 100755 index 00000000..4711f35d --- /dev/null +++ b/live-build/auto/clean @@ -0,0 +1,8 @@ +#! /bin/sh +set -e + +lb clean noauto "$@" + +rm -rf config +rm -f binary.manifest binary.manifest-desktop binary.log +rm -f livecd.* diff --git a/live-build/auto/config b/live-build/auto/config new file mode 100755 index 00000000..aea794ef --- /dev/null +++ b/live-build/auto/config @@ -0,0 +1,172 @@ +#! /bin/sh +set -e + +if [ -z "$MIRROR" ]; then + case $(hostname --fqdn) in + bld-*.mmjgroup.com) ;; + *.mmjgroup.com) + case $ARCH in + i386|amd64) MIRROR=http://archive.mmjgroup.com/ubuntu/ ;; + *) MIRROR=http://archive.mmjgroup.com/ubuntu-ports/ ;; + esac + ;; + *.0c3.net) MIRROR=http://ftp.iinet.net.au/linux/ubuntu/ ;; + *.ubuntu.com) MIRROR=http://ftpmaster.internal/ubuntu/ ;; + *.warthogs.hbd.com) MIRROR=http://ftpmaster.internal/ubuntu/ ;; + *.buildd) MIRROR=http://ftpmaster.internal/ubuntu/ ;; + esac +fi + +mkdir -p config/chroot_local-tasklists config/chroot_local-packagelists +rm -f config/chroot_local-tasklists/livecd-rootfs.list config/chroot_local-packagelists/livecd-rootfs.list + +add_task () +{ + local pass="$1" + shift + local task + + for task; do + echo "$task" >> "config/chroot_local-tasklists/livecd-rootfs.list.$pass" + done +} + +add_package () +{ + local pass="$1" + shift + local pkg + + for pkg; do + echo "$pkg" >> "config/chroot_local-packagelists/livecd-rootfs.list.$pass" + done +} + +OPTS= +COMPONENTS= +BINARY_REMOVE_LINUX=true + +case $IMAGEFORMAT in + ext2|ext3) + OPTS="${OPTS:+$OPTS }--initramfs none" + add_package live jasper + ;; + + *) + add_package live lupin-casper + ;; +esac + +case $PROJECT in + ubuntu|ubuntu-dvd) + add_task install minimal standard ubuntu-desktop + add_task live ubuntu-live + ;; + + kubuntu|kubuntu-dvd) + add_task install minimal standard kubuntu-desktop + add_task live kubuntu-live + ;; + + kubuntu-mobile) + add_task install minimal standard kubuntu-mobile + add_task live kubuntu-mobile-live + COMPONENTS='main restricted universe' + ;; + + edubuntu|edubuntu-dvd) + add_task install minimal standard edubuntu-desktop-gnome + add_task live edubuntu-live + COMPONENTS='main restricted universe' + ;; + + xubuntu) + add_task install minimal standard xubuntu-desktop + add_package install xterm + add_task live edubuntu-live + COMPONENTS='main restricted universe multiverse' + ;; + + ubuntu-netbook) + add_task install minimal standard ubuntu-netbook + add_task live netbook-live + ;; + + mythbuntu) + add_task install minimal standard mythbuntu-desktop + add_task live mythbuntu-live + COMPONENTS='main restricted universe multiverse' + ;; + + base) + add_task install minimal standard + ;; + + ubuntu-headless) + add_task install minimal standard + ;; + + *) + echo "unknown project $PROJECT" >&2 + exit 2 + ;; +esac +case $PROJECT in + *-dvd) + add_task live "$PROJECT-live" + ;; +esac + +case $ARCH in + armel) + KERNEL_FLAVOURS="$SUBARCH" + case $SUBARCH in + dove) + BINARY_REMOVE_LINUX=false + ;; + omap) + add_package install x-loader-omap3-beagle u-boot-linaro-omap3-beagle + BINARY_REMOVE_LINUX=false + ;; + omap4) + add_package install x-loader-omap4-panda u-boot-linaro-omap4-panda + BINARY_REMOVE_LINUX=false + ;; + esac + ;; +esac + +lb config noauto \ + --mode ubuntu \ + --distribution "$SUITE" \ + --bootstrap-keyring ubuntu-keyring \ + --binary-images none \ + --binary-remove-linux "$BINARY_REMOVE_LINUX" \ + --memtest none \ + --source false \ + --build-with-chroot false \ + ${MIRROR:+--parent-mirror-bootstrap $MIRROR} \ + ${COMPONENTS:+--parent-archive-areas "$COMPONENTS"} \ + --package-lists none \ + --initsystem none \ + --bootloader none \ + --initramfs-compression lzma \ + $OPTS + +case $PROJECT in + kubuntu|kubuntu-mobile) + ln -s /usr/share/live/build/examples/hooks/kubuntu_chroot_icon-theme.sh config/chroot_local-hooks/ + ;; +esac + +case $PROJECT in + *-dvd) + . config/bootstrap + + cat > config/chroot_sources/dvd.binary << EOF +deb $LB_PARENT_MIRROR_BINARY $SUITE universe multiverse +deb $LB_PARENT_MIRROR_BINARY_SECURITY $SUITE-security universe multiverse +deb $LB_PARENT_MIRROR_BINARY_VOLATILE $SUITE-updates universe multiverse +EOF + ;; +esac