live-build/scripts/build/lb_binary_iso

239 lines
5.4 KiB
Plaintext
Raw Normal View History

2007-09-23 08:04:46 +00:00
#!/bin/sh
## live-build(7) - System Build Scripts
## Copyright (C) 2006-2012 Daniel Baumann <daniel@debian.org>
##
## live-build 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
. "${LB_BASE:-/usr/share/live/build}"/scripts/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 "${LB_BINARY_IMAGES}" 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
2007-10-19 10:54:26 +00:00
Check_package chroot/usr/bin/genisoimage genisoimage
2007-09-23 08:05:11 +00:00
if [ "${LB_BINARY_IMAGES}" = "iso-hybrid" ]
then
Check_package chroot/usr/bin/isohybrid syslinux
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
# Handle genisoimage generic options
GENISOIMAGE_OPTIONS="-J -l -cache-inodes -allow-multidot"
# Handle genisoimage live-build specific options
if [ "${_QUIET}" = "true" ]
then
GENISOIMAGE_OPTIONS="${GENISOIMAGE_OPTIONS} -quiet"
fi
if [ "${_VERBOSE}" = "true" ]
2007-09-23 08:05:11 +00:00
then
GENISOIMAGE_OPTIONS="${GENISOIMAGE_OPTIONS} -v"
fi
if [ -n "${LB_ISO_APPLICATION}" ] && [ "${LB_ISO_APPLICATION}" != "none" ]
2007-09-23 08:05:11 +00:00
then
GENISOIMAGE_OPTIONS="${GENISOIMAGE_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
GENISOIMAGE_OPTIONS="${GENISOIMAGE_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
GENISOIMAGE_OPTIONS="${GENISOIMAGE_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
GENISOIMAGE_OPTIONS="${GENISOIMAGE_OPTIONS} -V \"${LB_ISO_VOLUME}\""
2007-09-23 08:05:11 +00:00
fi
# Handle genisoimage architecture specific options
case "${LB_BOOTLOADER}" in
2007-09-23 08:05:12 +00:00
grub)
GENISOIMAGE_OPTIONS="${GENISOIMAGE_OPTIONS} -no-emul-boot -boot-load-size 4 -boot-info-table"
GENISOIMAGE_OPTIONS="${GENISOIMAGE_OPTIONS} -r -b boot/grub/stage2_eltorito"
GENISOIMAGE_EXCLUDE="boot/grub/stage2_eltorito"
2007-09-23 08:05:12 +00:00
;;
grub2)
GENISOIMAGE_OPTIONS="${GENISOIMAGE_OPTIONS} -no-emul-boot -boot-load-size 4 -boot-info-table"
GENISOIMAGE_OPTIONS="${GENISOIMAGE_OPTIONS} -r -b boot/grub/grub_eltorito -J"
GENISOIMAGE_EXCLUDE="boot/grub/grub_eltorito"
;;
silo)
GENISOIMAGE_OPTIONS="${GENISOIMAGE_OPTIONS} -r -G boot/isofs.b -B ..."
GENISOIMAGE_EXCLUDE="boot/isofs.b"
;;
2007-09-23 08:05:12 +00:00
syslinux)
GENISOIMAGE_OPTIONS="${GENISOIMAGE_OPTIONS} -no-emul-boot -boot-load-size 4 -boot-info-table"
case "${LB_MODE}" in
progress)
GENISOIMAGE_OPTIONS="${GENISOIMAGE_OPTIONS} -r -b boot/boot.bin -c boot/boot.cat"
GENISOIMAGE_EXCLUDE="boot/boot.bin"
;;
*)
GENISOIMAGE_OPTIONS="${GENISOIMAGE_OPTIONS} -r -b isolinux/isolinux.bin -c isolinux/boot.cat"
GENISOIMAGE_EXCLUDE="isolinux/isolinux.bin"
;;
esac
2007-09-23 08:05:12 +00:00
;;
yaboot)
GENISOIMAGE_OPTIONS="${GENISOIMAGE_OPTIONS} -r --iso-level 2 --netatalk -hfs -probe -map"
GENISOIMAGE_OPTIONS="${GENISOIMAGE_OPTIONS} binary/yaboot/hfs.map --chrp-boot -part -no-desktop"
GENISOIMAGE_OPTIONS="${GENISOIMAGE_OPTIONS} -hfs-bless binary/yaboot -hfs-volid Debian/Live_powerpc"
GENISOIMAGE_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 In_list "stripped minimal" "${LB_PACKAGE_LISTS}"
then
if [ "${LB_DEBIAN_INSTALLER}" != "live" ]
then
GENISOIMAGE_OPTIONS="${GENISOIMAGE_OPTIONS} -m ${GENISOIMAGE_EXCLUDE}"
fi
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
genisoimage ${GENISOIMAGE_OPTIONS} -o ${IMAGE} binary
EOF
if [ "${LB_BINARY_IMAGES}" = "iso-hybrid" ]
then
cat >> binary.sh << EOF
isohybrid ${ISOHYBRID_OPTIONS} ${IMAGE}
EOF
fi
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