2007-09-23 08:04:46 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2010-09-02 11:12:37 +00:00
|
|
|
## live-build(7) - System Build Scripts
|
2020-03-11 09:07:21 -01:00
|
|
|
## Copyright (C) 2016-2020 The Debian Live team
|
2015-01-04 18:05:39 -01:00
|
|
|
## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
|
2010-09-02 11:12:37 +00:00
|
|
|
##
|
2012-07-29 23:59:00 +00:00
|
|
|
## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
|
2010-09-02 11:12:37 +00:00
|
|
|
## This is free software, and you are welcome to redistribute it
|
|
|
|
## under certain conditions; see COPYING for details.
|
|
|
|
|
2007-09-23 08:04:46 +00:00
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2007-09-23 08:05:11 +00:00
|
|
|
# Including common functions
|
2012-08-27 13:52:29 +00:00
|
|
|
[ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh
|
2007-09-23 08:04:46 +00:00
|
|
|
|
2007-09-23 08:05:11 +00:00
|
|
|
# Setting static variables
|
2015-02-05 02:30:47 -01:00
|
|
|
DESCRIPTION="Build iso binary image"
|
2007-09-23 08:04:48 +00:00
|
|
|
USAGE="${PROGRAM} [--force]"
|
|
|
|
|
2015-02-05 02:30:47 -01:00
|
|
|
# Processing arguments and configuration files
|
|
|
|
Init_config_data "${@}"
|
2007-09-23 08:04:46 +00:00
|
|
|
|
2020-04-06 17:46:47 +00:00
|
|
|
case "${LB_IMAGE_TYPE}" in
|
2010-02-18 15:34:29 -01:00
|
|
|
iso)
|
2020-04-06 17:43:41 +00:00
|
|
|
IMAGE="${LB_IMAGE_NAME}-${LB_ARCHITECTURE}.iso"
|
2010-02-18 15:34:29 -01:00
|
|
|
;;
|
|
|
|
|
|
|
|
iso-hybrid)
|
2020-04-06 17:43:41 +00:00
|
|
|
IMAGE="${LB_IMAGE_NAME}-${LB_ARCHITECTURE}.hybrid.iso"
|
2010-02-18 15:34:29 -01:00
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
exit 0
|
|
|
|
;;
|
|
|
|
esac
|
2007-09-23 08:05:11 +00:00
|
|
|
|
|
|
|
Echo_message "Begin building binary iso image..."
|
|
|
|
|
|
|
|
# Requiring stage file
|
2020-03-15 12:05:44 -01:00
|
|
|
Require_stagefiles config bootstrap
|
2007-09-23 08:05:11 +00:00
|
|
|
|
|
|
|
# Checking stage file
|
2020-03-13 16:11:53 -01:00
|
|
|
Check_stagefile
|
2007-09-23 08:05:11 +00:00
|
|
|
|
2020-03-13 15:19:59 -01:00
|
|
|
# Acquire lock file
|
2015-02-05 02:30:47 -01:00
|
|
|
Acquire_lockfile
|
2007-09-23 08:05:11 +00:00
|
|
|
|
|
|
|
# Checking depends
|
2015-01-04 16:08:09 -01:00
|
|
|
Check_package chroot /usr/bin/xorriso xorriso
|
2015-01-07 08:57:00 -01:00
|
|
|
Check_package chroot /usr/lib/ISOLINUX/isohdpfx.bin isolinux
|
2023-06-06 15:31:51 +00:00
|
|
|
if [ "${LB_BOOTLOADER_BIOS}" = "grub-pc" ]
|
|
|
|
then
|
|
|
|
Check_package chroot /usr/lib/grub/i386-pc/boot_hybrid.img grub-pc-bin
|
|
|
|
fi
|
2013-01-19 16:04:52 -01:00
|
|
|
|
2007-09-23 08:05:15 +00:00
|
|
|
# Restoring cache
|
2015-01-06 02:46:37 -01:00
|
|
|
Restore_package_cache binary
|
2007-09-23 08:05:15 +00:00
|
|
|
|
2007-09-23 08:05:11 +00:00
|
|
|
# Installing depends
|
2020-05-05 15:42:44 +00:00
|
|
|
Install_packages
|
2007-09-23 08:05:11 +00:00
|
|
|
|
|
|
|
# Remove old iso image
|
2010-02-18 15:34:29 -01:00
|
|
|
if [ -f ${IMAGE} ]
|
2007-09-23 08:05:11 +00:00
|
|
|
then
|
2010-02-18 15:34:29 -01:00
|
|
|
rm -f ${IMAGE}
|
2007-09-23 08:05:11 +00:00
|
|
|
fi
|
|
|
|
|
2012-12-16 19:06:25 -01:00
|
|
|
# Handle xorriso generic options
|
2015-01-25 10:17:50 -01:00
|
|
|
XORRISO_OPTIONS="-R -r -J -joliet-long -l -cache-inodes -iso-level 3"
|
2012-12-16 19:06:25 -01:00
|
|
|
|
|
|
|
# Handle xorriso live-build specific options
|
2023-07-17 01:59:02 +00:00
|
|
|
if [ "${LB_IMAGE_TYPE}" = "iso-hybrid" ] && [ -n "${LB_BOOTLOADER_BIOS}" ];
|
2012-12-16 19:06:25 -01:00
|
|
|
then
|
2023-06-06 15:31:51 +00:00
|
|
|
if [ "${LB_BOOTLOADER_BIOS}" = "syslinux" ]
|
|
|
|
then
|
2014-12-10 06:38:42 -01:00
|
|
|
XORRISO_OPTIONS="${XORRISO_OPTIONS} -isohybrid-mbr /usr/lib/ISOLINUX/isohdpfx.bin -partition_offset 16"
|
2023-06-06 15:31:51 +00:00
|
|
|
elif [ "${LB_BOOTLOADER_BIOS}" = "grub-pc" ]
|
|
|
|
then
|
|
|
|
XORRISO_OPTIONS="${XORRISO_OPTIONS} --grub2-boot-info --grub2-mbr /usr/lib/grub/i386-pc/boot_hybrid.img"
|
|
|
|
XORRISO_OPTIONS="${XORRISO_OPTIONS} -efi-boot-part --efi-boot-image"
|
|
|
|
else
|
|
|
|
Echo_error "iso-hybrid images not supported with ${LB_BOOTLOADER_BIOS} as BIOS bootloader"
|
|
|
|
exit 1
|
|
|
|
fi
|
2012-12-16 19:06:25 -01:00
|
|
|
fi
|
2008-10-30 07:27:21 -01:00
|
|
|
|
2009-12-13 19:17:45 -01:00
|
|
|
if [ "${_QUIET}" = "true" ]
|
2007-09-23 12:05:14 +00:00
|
|
|
then
|
2012-12-16 19:06:25 -01:00
|
|
|
XORRISO_OPTIONS="${XORRISO_OPTIONS} -quiet"
|
2007-09-23 12:05:14 +00:00
|
|
|
fi
|
|
|
|
|
2009-12-13 19:17:45 -01:00
|
|
|
if [ "${_VERBOSE}" = "true" ]
|
2007-09-23 08:05:11 +00:00
|
|
|
then
|
2012-12-16 19:06:25 -01:00
|
|
|
XORRISO_OPTIONS="${XORRISO_OPTIONS} -v"
|
2007-09-23 08:05:11 +00:00
|
|
|
fi
|
|
|
|
|
2010-09-07 13:11:20 +00:00
|
|
|
if [ -n "${LB_ISO_APPLICATION}" ] && [ "${LB_ISO_APPLICATION}" != "none" ]
|
2007-09-23 08:05:11 +00:00
|
|
|
then
|
2012-12-16 19:06:25 -01:00
|
|
|
XORRISO_OPTIONS="${XORRISO_OPTIONS} -A \"${LB_ISO_APPLICATION}\""
|
2007-09-23 08:05:11 +00:00
|
|
|
fi
|
|
|
|
|
2010-09-07 13:11:20 +00:00
|
|
|
if [ -n "${LB_ISO_PREPARER}" ] && [ "${LB_ISO_PREPARER}" != "none" ]
|
2007-09-23 08:05:11 +00:00
|
|
|
then
|
2020-05-03 17:02:04 +00:00
|
|
|
LB_ISO_PREPARER="$(echo "${LB_ISO_PREPARER}" | sed "s|@LB_VERSION@|${VERSION}|")"
|
2012-12-16 19:06:25 -01:00
|
|
|
XORRISO_OPTIONS="${XORRISO_OPTIONS} -p \"${LB_ISO_PREPARER}\""
|
2007-09-23 08:05:11 +00:00
|
|
|
fi
|
|
|
|
|
2010-09-07 13:11:20 +00:00
|
|
|
if [ -n "${LB_ISO_PUBLISHER}" ] && [ "${LB_ISO_PUBLISHER}" != "none" ]
|
2007-09-23 08:05:11 +00:00
|
|
|
then
|
2012-12-16 19:06:25 -01:00
|
|
|
XORRISO_OPTIONS="${XORRISO_OPTIONS} -publisher \"${LB_ISO_PUBLISHER}\""
|
2007-09-23 08:05:11 +00:00
|
|
|
fi
|
|
|
|
|
2010-09-07 13:11:20 +00:00
|
|
|
if [ -n "${LB_ISO_VOLUME}" ] && [ "${LB_ISO_VOLUME}" != "none" ]
|
2007-09-23 08:05:11 +00:00
|
|
|
then
|
2020-10-04 11:49:06 +00:00
|
|
|
LB_ISO_VOLUME="$(echo "${LB_ISO_VOLUME}" | sed "s|@ISOVOLUME_TS@|$(date $DATE_UTC_OPTION -d@${SOURCE_DATE_EPOCH} +%Y%m%d-%H:%M)|")"
|
2012-12-16 19:06:25 -01:00
|
|
|
XORRISO_OPTIONS="${XORRISO_OPTIONS} -V \"${LB_ISO_VOLUME}\""
|
2007-09-23 08:05:11 +00:00
|
|
|
fi
|
|
|
|
|
2016-11-28 14:29:06 -01:00
|
|
|
# Set an explicit modification date
|
2020-10-04 11:49:06 +00:00
|
|
|
XORRISO_OPTIONS="${XORRISO_OPTIONS} --modification-date=$(date --utc -d@${SOURCE_DATE_EPOCH} +%Y%m%d%H%M%S00)"
|
2016-11-28 14:29:06 -01:00
|
|
|
|
2020-05-04 16:28:48 +00:00
|
|
|
# Enable BIOS bootloader selection
|
|
|
|
case "${LB_BOOTLOADER_BIOS}" in
|
|
|
|
grub-legacy)
|
|
|
|
XORRISO_OPTIONS="${XORRISO_OPTIONS} -no-emul-boot -boot-load-size 4 -boot-info-table"
|
|
|
|
XORRISO_OPTIONS="${XORRISO_OPTIONS} -b boot/grub/stage2_eltorito"
|
|
|
|
XORRISO_EXCLUDE="boot/grub/stage2_eltorito"
|
|
|
|
;;
|
|
|
|
|
|
|
|
grub-pc)
|
|
|
|
XORRISO_OPTIONS="${XORRISO_OPTIONS} -no-emul-boot -boot-load-size 4 -boot-info-table"
|
|
|
|
XORRISO_OPTIONS="${XORRISO_OPTIONS} -b boot/grub/grub_eltorito"
|
|
|
|
XORRISO_EXCLUDE="boot/grub/grub_eltorito"
|
|
|
|
;;
|
|
|
|
|
|
|
|
syslinux)
|
|
|
|
XORRISO_OPTIONS="${XORRISO_OPTIONS} -b isolinux/isolinux.bin -c isolinux/boot.cat"
|
|
|
|
XORRISO_OPTIONS="${XORRISO_OPTIONS} -no-emul-boot -boot-load-size 4 -boot-info-table"
|
|
|
|
XORRISO_EXCLUDE="isolinux/isolinux.bin"
|
|
|
|
;;
|
|
|
|
|
|
|
|
"")
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
Echo_error "Unhandled BIOS bootloader selection"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# If both BIOS and EFI bootloaders are in play, we need to tell mkisosfs to add
|
|
|
|
# an additional eltorito entry.
|
|
|
|
if [ -n "${LB_BOOTLOADER_BIOS}" ] && [ -n "${LB_BOOTLOADER_EFI}" ]; then
|
|
|
|
XORRISO_OPTIONS="${XORRISO_OPTIONS} -eltorito-alt-boot"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Enable EFI bootloader selection
|
|
|
|
case "${LB_BOOTLOADER_EFI}" in
|
|
|
|
grub-efi)
|
|
|
|
if [ -e binary/boot/grub/efi.img ]; then
|
|
|
|
XORRISO_OPTIONS="${XORRISO_OPTIONS} -e boot/grub/efi.img -no-emul-boot"
|
|
|
|
XORRISO_OPTIONS="${XORRISO_OPTIONS} -isohybrid-gpt-basdat -isohybrid-apm-hfsplus"
|
|
|
|
else
|
|
|
|
Echo_message "No EFI boot code to include in the ISO"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
|
|
|
|
"")
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
Echo_error "Unhandled EFI bootloader selection"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
2007-09-23 08:05:12 +00:00
|
|
|
|
2012-07-28 22:24:11 +00:00
|
|
|
#if [ "${LB_DEBIAN_INSTALLER}" != "live" ]
|
|
|
|
#then
|
2012-12-16 19:06:25 -01:00
|
|
|
# XORRISO_OPTIONS="${XORRISO_OPTIONS} -m ${XORRISO_EXCLUDE}"
|
2012-07-28 22:24:11 +00:00
|
|
|
#fi
|
2009-02-03 08:30:10 -01:00
|
|
|
|
2007-10-04 23:35:28 +00:00
|
|
|
cat > binary.sh << EOF
|
2009-10-28 11:15:30 -01:00
|
|
|
#!/bin/sh
|
2017-11-20 20:20:47 -01:00
|
|
|
xorriso -as mkisofs ${XORRISO_OPTIONS} -o ${IMAGE} binary
|
|
|
|
EOF
|
|
|
|
|
|
|
|
# retain the xorriso command used to create the image in the image itself
|
binary_iso: Execute mkdir binary/.disk before writing to it
Before commit 9f3e5fe8d (Fix the way the .disk/mkisofs file is created)
all these commands (`mkdir`, write to `binary/.disk/mkisofs` and
`xorriso`) were in the same `binary.sh` script. Since that commit, the
write was extracted, to prevent issues with quoting, but the related
mkdir was left in `binary.sh`. This means that the write is now executed
first, and the `mkdir` only afterwards, making the `mkdir` quite pointless.
In practice, this did not break becaue binary_disk also does the same
`mkdir` and runs before `binary_iso`, but if one runs commands manually
and skips `binary_iso`, then this does break.
Even though this is not really a supported usecase, just move the mkdir
outside of `binary.sh`, so it runs *before* the write again as intended.
2020-11-24 10:16:16 -01:00
|
|
|
mkdir -p binary/.disk
|
2017-11-20 20:20:47 -01:00
|
|
|
cat <<-EOF >binary/.disk/mkisofs
|
2013-01-19 16:03:19 -01:00
|
|
|
xorriso -as mkisofs ${XORRISO_OPTIONS} -o ${IMAGE} binary
|
2013-01-19 16:04:52 -01:00
|
|
|
EOF
|
2021-01-02 15:41:50 -01:00
|
|
|
# Set the timestamp
|
|
|
|
find binary/.disk -newermt "$(date -d@${SOURCE_DATE_EPOCH} '+%Y-%m-%d %H:%M:%S')" -printf "%y %p\n" -exec touch '{}' -d@${SOURCE_DATE_EPOCH} ';' >> binary.modified_timestamps
|
2013-01-19 16:04:52 -01:00
|
|
|
|
2010-09-07 13:11:20 +00:00
|
|
|
case "${LB_BUILD_WITH_CHROOT}" in
|
2009-12-13 19:17:45 -01:00
|
|
|
true)
|
2007-09-23 08:05:15 +00:00
|
|
|
# Moving image
|
2007-10-04 23:35:28 +00:00
|
|
|
mv binary.sh chroot
|
2007-09-23 08:05:15 +00:00
|
|
|
mv binary chroot
|
|
|
|
|
2008-10-28 14:44:06 -01:00
|
|
|
Chroot chroot "sh binary.sh"
|
2007-09-23 08:05:15 +00:00
|
|
|
|
|
|
|
# Move image
|
2010-02-18 15:34:29 -01:00
|
|
|
mv chroot/binary chroot/${IMAGE} ./
|
2007-09-23 08:05:15 +00:00
|
|
|
rm -f chroot/binary.sh
|
|
|
|
;;
|
|
|
|
|
2009-12-13 19:17:45 -01:00
|
|
|
false)
|
2007-09-23 08:05:15 +00:00
|
|
|
sh binary.sh
|
|
|
|
rm -f binary.sh
|
|
|
|
;;
|
|
|
|
esac
|
2007-09-23 08:05:09 +00:00
|
|
|
|
2022-01-22 16:14:05 -01:00
|
|
|
# Set the timestamp of the image
|
|
|
|
touch -d@${SOURCE_DATE_EPOCH} ${IMAGE}
|
|
|
|
echo "f ${IMAGE}" >> binary.modified_timestamps
|
|
|
|
|
2007-09-23 08:05:15 +00:00
|
|
|
# Saving cache
|
2015-01-06 02:46:37 -01:00
|
|
|
Save_package_cache binary
|
2007-09-23 08:04:48 +00:00
|
|
|
|
2007-09-23 08:05:11 +00:00
|
|
|
# Removing depends
|
2020-05-05 15:45:57 +00:00
|
|
|
Remove_packages
|
2007-09-23 08:04:46 +00:00
|
|
|
|
2007-09-23 08:05:11 +00:00
|
|
|
# Creating stage file
|
2020-03-13 16:11:53 -01:00
|
|
|
Create_stagefile
|