#! /bin/sh set -e export LC_ALL=C ( . "${LIVE_BUILD}/scripts/build.sh" > /dev/null 2>&1 || true ) || . /usr/lib/live/build.sh Arguments "${@}" Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source Set_defaults # Setup cleanup function Setup_cleanup rm -f binary.success ( lb bootstrap "$@" Chroot chroot "dpkg-divert --quiet --add \ --divert /usr/sbin/update-initramfs.REAL --rename \ /usr/sbin/update-initramfs" cat > chroot/usr/sbin/update-initramfs <<'EOF' #! /bin/sh if [ $# != 1 ] || [ "$1" != -u ]; then exec update-initramfs.REAL "$@" fi echo "update-initramfs: diverted by livecd-rootfs (will be called later)" >&2 exit 0 EOF chmod +x chroot/usr/sbin/update-initramfs cat > config/hooks/999-undivert-update-initramfs.chroot <<'EOF' #! /bin/sh rm -f /usr/sbin/update-initramfs dpkg-divert --quiet --remove --rename /usr/sbin/update-initramfs EOF cat > config/hooks/fixvmlinuz.binary <<'EOF' #! /bin/sh kernel=$(ls binary/casper/vmlinuz-*-generic | grep -v efi | sort_by_version | tac | head -1) kernel_efi=$(ls binary/casper/vmlinuz-* | grep efi | sort_by_version | tac | head -1) initrd=$(ls binary/casper/initrd.img-* | grep -v efi | sort_by_version | tac | head -1) if [ ! -z $kernel ]; then cp $kernel binary/casper/vmlinuz fi if [ ! -z $kernel_efi ]; then cp $kernel_efi binary/casper/vmlinuz.efi fi cp $initrd binary/casper/initrd.lz EOF if [ "${LB_ARCHITECTURES}" = 'amd64' ]; then cat > pooltemplatevariables < config/hooks/generatepoolefi.binary <<'EOF' #! /bin/sh sed -i -f pooltemplatevariables binary/conf/distributions sed -i -f pooltemplatevariables binary/conf/updates rm pooltemplatevariables cd binary reprepro update reprepro retrack reprepro export cd .. EOF fi 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 rm chroot/etc/apt/sources.list.d/* || true rm -rf chroot/var/lib/apt/lists/lliurex.net* || true cp -r config/final_apt/* chroot/etc/apt/ 2>/dev/null || true cp /usr/lib/live/build/lb_binary custom_binary cp /usr/lib/live/build/lb_binary_disk custom_binary_disk chmod +x custom_binary custom_binary_disk # Enabling custom_binary_disk sed -i -e 's%^lb binary_disk ${\*}%./custom_binary_disk ${*}%g' custom_binary # Fixing disk/info sed -i -e 's%Ubuntu%LliureX%g' custom_binary_disk if [ "${LB_ARCHITECTURES}" = 'amd64' ]; then echo "===== Detected AMD64 hooking to custom_binary build =====" sed -i -e 's%^lb binary_iso ${\*}%auto/lliurexbuildiso ${*}%g' custom_binary fi ./custom_binary "$@" touch binary.success ) 2>&1 | tee binary.log # bash has trouble with the build.sh sourcing arrangement at the top of this # file, so we use this cheap-and-cheerful approach rather than the more # correct 'set -o pipefail'. if [ -e binary.success ]; then rm -f binary.success else exit 1 fi # 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 ext4 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 ISO in binary.iso binary.hybrid.iso; do [ -e "$ISO" ] || continue ln "$ISO" "$PREFIX.iso" chmod 644 "$PREFIX.iso" break done if [ -e "binary/$INITFS/filesystem.dir" ]; then (cd "binary/$INITFS/filesystem.dir/" && tar -c *) | \ gzip -9 --rsyncable > "$PREFIX.rootfs.tar.gz" chmod 644 "$PREFIX.rootfs.tar.gz" elif [ -e binary-tar.tar.gz ]; then cp -a binary-tar.tar.gz "$PREFIX.rootfs.tar.gz" fi # '--initramfs none' produces different manifest names. if [ -e "binary/$INITFS/filesystem.packages" ]; then ln "binary/$INITFS/filesystem.packages" "$PREFIX.manifest" chmod 644 "$PREFIX.manifest" fi if [ -e "binary/$INITFS/filesystem.packages-remove" ]; then # Not a typo, empty manifest-remove has a single LF in it. :/ if [ $(cat binary/$INITFS/filesystem.packages-remove | wc -c) -gt 1 ]; then ln "binary/$INITFS/filesystem.packages-remove" "$PREFIX.manifest-remove" chmod 644 "$PREFIX.manifest-remove" fi fi for FLAVOUR in $LB_LINUX_FLAVOURS; do if [ -z "$LB_LINUX_FLAVOURS" ] || [ "$LB_LINUX_FLAVOURS" = "none" ]; then continue fi if [ "$FLAVOUR" = "virtual" ]; then # The virtual kernel is named generic in /boot FLAVOUR="generic" fi KVERS="$( (cd "binary/$INITFS"; ls vmlinu?-* 2>/dev/null || true) | (fgrep -v .efi || true) | sed -n "s/^vmlinu.-\\([^-]*-[^-]*-$FLAVOUR\\)$/\\1/p" )" if [ -z "$KVERS" ]; then if [ -e "binary/$INITFS/vmlinuz" ]; then # already renamed by ubuntu-defaults-image break fi 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" if [ -e "binary/$INITFS/"vmlinu?-"$KVERS.efi.signed" ]; then ln "binary/$INITFS/"vmlinu?-"$KVERS.efi.signed" "$PREFIX.kernel-$FLAVOUR.efi.signed" chmod 644 "$PREFIX.kernel-$FLAVOUR.efi.signed" fi 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 ] && [ "$LB_LINUX_FLAVOURS" != "none" ]; then # only one kernel flavour if [ -e "binary/$INITFS/vmlinuz" ]; then ln "binary/$INITFS/vmlinuz" "$PREFIX.kernel" chmod 644 "$PREFIX.kernel" else ln -sf "$PREFIX.kernel-$LB_LINUX_FLAVOURS" "$PREFIX.kernel" fi if [ -e "binary/$INITFS/initrd.lz" ]; then ln "binary/$INITFS/initrd.lz" "$PREFIX.initrd" chmod 644 "$PREFIX.initrd" else ln -sf "$PREFIX.initrd-$LB_LINUX_FLAVOURS" "$PREFIX.initrd" fi fi