live-build/scripts/build/binary_iso

232 lines
5.2 KiB
Plaintext
Raw Normal View History

2007-09-23 08:04:46 +00:00
#!/bin/sh
## live-build(7) - System Build Scripts
2013-05-06 12:48:46 +00:00
## Copyright (C) 2006-2012 Daniel Baumann <daniel@debian.org>
##
## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
## 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
[ -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
DESCRIPTION="$(Echo 'build iso binary image')"
2007-09-23 08:04:48 +00:00
HELP=""
USAGE="${PROGRAM} [--force]"
Arguments "${@}"
2007-09-23 08:04:46 +00:00
# Reading configuration files
Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source
2007-09-23 08:04:46 +00:00
Set_defaults
case "${LIVE_IMAGE_TYPE}" in
iso)
IMAGE="binary.iso"
;;
iso-hybrid)
IMAGE="binary.hybrid.iso"
;;
*)
exit 0
;;
esac
2007-09-23 08:05:11 +00:00
Echo_message "Begin building binary iso image..."
# Requiring stage file
Require_stagefile .build/config .build/bootstrap
2007-09-23 08:05:11 +00:00
# Checking stage file
Check_stagefile .build/binary_iso
2007-09-23 08:05:11 +00:00
# Checking lock file
Check_lockfile .lock
# Creating lock file
Create_lockfile .lock
# Checking depends
2012-12-16 19:06:25 -01:00
Check_package chroot/usr/bin/xorriso xorriso
if [ "${LIVE_IMAGE_TYPE}" = "iso-hybrid" ]
2013-05-06 12:48:46 +00:00
then
2012-12-16 19:06:25 -01:00
Check_package chroot/usr/lib/syslinux/isohdpfx.bin syslinux-common
2013-05-06 12:48:46 +00:00
fi
2007-09-23 08:05:15 +00:00
# Restoring cache
Restore_cache cache/packages.binary
2007-09-23 08:05:15 +00:00
2007-09-23 08:05:11 +00:00
# Installing depends
Install_package
# Remove old iso image
if [ -f ${IMAGE} ]
2007-09-23 08:05:11 +00:00
then
rm -f ${IMAGE}
2007-09-23 08:05:11 +00:00
fi
2012-12-16 19:06:25 -01:00
# Handle xorriso generic options
XORRISO_OPTIONS="-as mkisofs -r -J -joliet-long -l -cache-inodes"
# Handle xorriso live-build specific options
if [ "${LIVE_IMAGE_TYPE}" = "iso-hybrid" ]
2012-12-16 19:06:25 -01:00
then
XORRISO_OPTIONS="${XORRISO_OPTIONS} -isohybrid-mbr /usr/lib/syslinux/isohdpfx.bin -partition_offset 16"
fi
if [ "${_QUIET}" = "true" ]
then
2012-12-16 19:06:25 -01:00
XORRISO_OPTIONS="${XORRISO_OPTIONS} -quiet"
fi
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
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
if [ -n "${LB_ISO_PREPARER}" ] && [ "${LB_ISO_PREPARER}" != "none" ]
2007-09-23 08:05:11 +00:00
then
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
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
if [ -n "${LB_ISO_VOLUME}" ] && [ "${LB_ISO_VOLUME}" != "none" ]
2007-09-23 08:05:11 +00:00
then
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
2012-12-16 19:06:25 -01:00
# Handle xorriso architecture specific options
case "${LB_BOOTLOADER}" in
2007-09-23 08:05:12 +00:00
grub)
2012-12-16 19:06:25 -01:00
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"
2007-09-23 08:05:12 +00:00
;;
grub2)
2012-12-16 19:06:25 -01:00
XORRISO_OPTIONS="${XORRISO_OPTIONS} -no-emul-boot -boot-load-size 4 -boot-info-table"
XORRISO_OPTIONS="${XORRISO_OPTIONS} -b boot/grub/grub_eltorito -J"
XORRISO_EXCLUDE="boot/grub/grub_eltorito"
;;
silo)
2012-12-16 19:06:25 -01:00
XORRISO_OPTIONS="${XORRISO_OPTIONS} -G boot/isofs.b -B ..."
XORRISO_EXCLUDE="boot/isofs.b"
;;
2007-09-23 08:05:12 +00:00
syslinux)
case "${LB_MODE}" in
progress-linux)
2012-12-16 19:06:25 -01:00
XORRISO_OPTIONS="${XORRISO_OPTIONS} -b boot/boot.bin -c boot/boot.cat"
XORRISO_EXCLUDE="boot/boot.bin"
;;
*)
2012-12-16 19:06:25 -01:00
XORRISO_OPTIONS="${XORRISO_OPTIONS} -b isolinux/isolinux.bin -c isolinux/boot.cat"
XORRISO_EXCLUDE="isolinux/isolinux.bin"
;;
esac
2012-12-16 19:06:25 -01:00
XORRISO_OPTIONS="${XORRISO_OPTIONS} -no-emul-boot -boot-load-size 4 -boot-info-table"
2007-09-23 08:05:12 +00:00
;;
yaboot)
2012-12-16 19:06:25 -01:00
XORRISO_OPTIONS="${XORRISO_OPTIONS} --iso-level 2 --netatalk -hfs -probe -map"
XORRISO_OPTIONS="${XORRISO_OPTIONS} binary/yaboot/hfs.map --chrp-boot -part -no-desktop"
XORRISO_OPTIONS="${XORRISO_OPTIONS} -hfs-bless binary/yaboot -hfs-volid Debian/Live_powerpc"
XORRISO_EXCLUDE="yaboot/hfs.map"
2007-09-23 08:05:12 +00:00
;;
*)
Echo_warning "Bootloader on your architecture not yet supported by live-build."
Echo_warning "This will produce a most likely not bootable image (Continuing in 5 seconds)."
2007-09-23 08:05:12 +00:00
sleep 5
;;
esac
#if [ "${LB_DEBIAN_INSTALLER}" != "live" ]
#then
2012-12-16 19:06:25 -01:00
# XORRISO_OPTIONS="${XORRISO_OPTIONS} -m ${XORRISO_EXCLUDE}"
#fi
if [ "${LB_BOOTLOADER}" = "grub2" ]
then
cat > binary.sh << EOF
#!/bin/sh
input_dir=/usr/lib/grub/i386-pc
# build core.img
core_img=\$(mktemp)
grub-mkimage -d \${input_dir} -o \${core_img} -O i386-pc biosdisk iso9660
# build grub_eltorito image
cat \${input_dir}/cdboot.img \${core_img} > binary/boot/grub/grub_eltorito
rm -f \${core_img}
for file in \${input_dir}/*.mod \${input_dir}/efiemu??.o \
\${input_dir}/command.lst \${input_dir}/moddep.lst \${input_dir}/fs.lst \
\${input_dir}/handler.lst \${input_dir}/parttool.lst
do
if test -f "\$file"
then
cp -f "\$file" binary/boot/grub
fi
done
EOF
else
echo "#!/bin/sh" > binary.sh
fi
cat >> binary.sh << EOF
2012-12-16 19:06:25 -01:00
xorriso ${XORRISO_OPTIONS} -o ${IMAGE} binary
EOF
case "${LB_BUILD_WITH_CHROOT}" in
true)
2007-09-23 08:05:15 +00:00
# Moving image
mv binary.sh chroot
2007-09-23 08:05:15 +00:00
mv binary chroot
Chroot chroot "sh binary.sh"
2007-09-23 08:05:15 +00:00
# Move image
mv chroot/binary chroot/${IMAGE} ./
2007-09-23 08:05:15 +00:00
rm -f chroot/binary.sh
;;
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
2007-09-23 08:05:15 +00:00
# Saving cache
Save_cache cache/packages.binary
2007-09-23 08:04:48 +00:00
2007-09-23 08:05:11 +00:00
# Removing depends
Remove_package
2007-09-23 08:04:46 +00:00
2007-09-23 08:05:11 +00:00
# Creating stage file
Create_stagefile .build/binary_iso