Applying patch from jnqnfe <jnqnfe@gmail.com> to correct grub2 bootloader directory...
[debian-live-build.git] / scripts / build / binary_iso
blob44a9418c86819d1eb262f828d77e86b80949de64
1 #!/bin/sh
3 ## live-build(7) - System Build Scripts
4 ## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
5 ##
6 ## This program comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
7 ## This is free software, and you are welcome to redistribute it
8 ## under certain conditions; see COPYING for details.
11 set -e
13 # Including common functions
14 [ -e "${LIVE_BUILD}/scripts/build.sh" ] && . "${LIVE_BUILD}/scripts/build.sh" || . /usr/lib/live/build.sh
16 # Setting static variables
17 DESCRIPTION="$(Echo 'build iso binary image')"
18 HELP=""
19 USAGE="${PROGRAM} [--force]"
21 Arguments "${@}"
23 # Reading configuration files
24 Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source
25 Set_defaults
27 case "${LIVE_IMAGE_TYPE}" in
28 iso)
29 IMAGE="${LIVE_IMAGE_NAME}-${LB_ARCHITECTURES}.iso"
32 iso-hybrid)
33 IMAGE="${LIVE_IMAGE_NAME}-${LB_ARCHITECTURES}.hybrid.iso"
37 exit 0
39 esac
41 Echo_message "Begin building binary iso image..."
43 # Requiring stage file
44 Require_stagefile .build/config .build/bootstrap
46 # Checking stage file
47 Check_stagefile .build/binary_iso
49 # Checking lock file
50 Check_lockfile .lock
52 # Creating lock file
53 Create_lockfile .lock
55 # Checking depends
56 Check_package chroot /usr/bin/xorriso xorriso
57 Check_package chroot /usr/lib/ISOLINUX/isohdpfx.bin isolinux
59 # Restoring cache
60 Restore_cache cache/packages.binary
62 # Installing depends
63 Install_package
65 # Remove old iso image
66 if [ -f ${IMAGE} ]
67 then
68 rm -f ${IMAGE}
71 # Handle xorriso generic options
72 XORRISO_OPTIONS="-R -r -J -joliet-long -l -cache-inodes -iso-level 3"
74 # Handle xorriso live-build specific options
75 if [ "${LIVE_IMAGE_TYPE}" = "iso-hybrid" ]
76 then
77 XORRISO_OPTIONS="${XORRISO_OPTIONS} -isohybrid-mbr /usr/lib/ISOLINUX/isohdpfx.bin -partition_offset 16"
80 if [ "${_QUIET}" = "true" ]
81 then
82 XORRISO_OPTIONS="${XORRISO_OPTIONS} -quiet"
85 if [ "${_VERBOSE}" = "true" ]
86 then
87 XORRISO_OPTIONS="${XORRISO_OPTIONS} -v"
90 if [ -n "${LB_ISO_APPLICATION}" ] && [ "${LB_ISO_APPLICATION}" != "none" ]
91 then
92 XORRISO_OPTIONS="${XORRISO_OPTIONS} -A \"${LB_ISO_APPLICATION}\""
95 if [ -n "${LB_ISO_PREPARER}" ] && [ "${LB_ISO_PREPARER}" != "none" ]
96 then
97 XORRISO_OPTIONS="${XORRISO_OPTIONS} -p \"${LB_ISO_PREPARER}\""
100 if [ -n "${LB_ISO_PUBLISHER}" ] && [ "${LB_ISO_PUBLISHER}" != "none" ]
101 then
102 XORRISO_OPTIONS="${XORRISO_OPTIONS} -publisher \"${LB_ISO_PUBLISHER}\""
105 if [ -n "${LB_ISO_VOLUME}" ] && [ "${LB_ISO_VOLUME}" != "none" ]
106 then
107 XORRISO_OPTIONS="${XORRISO_OPTIONS} -V \"${LB_ISO_VOLUME}\""
110 # Handle xorriso architecture specific options
111 case "${LB_BOOTLOADER}" in
112 grub)
113 XORRISO_OPTIONS="${XORRISO_OPTIONS} -no-emul-boot -boot-load-size 4 -boot-info-table"
114 XORRISO_OPTIONS="${XORRISO_OPTIONS} -b boot/grub/stage2_eltorito"
115 XORRISO_EXCLUDE="boot/grub/stage2_eltorito"
118 grub2)
119 XORRISO_OPTIONS="${XORRISO_OPTIONS} -no-emul-boot -boot-load-size 4 -boot-info-table"
120 XORRISO_OPTIONS="${XORRISO_OPTIONS} -b boot/grub/grub_eltorito -J"
121 XORRISO_EXCLUDE="boot/grub/grub_eltorito"
124 syslinux)
125 case "${LB_MODE}" in
126 progress-linux)
127 XORRISO_OPTIONS="${XORRISO_OPTIONS} -b boot/boot.bin -c boot/boot.cat"
128 XORRISO_EXCLUDE="boot/boot.bin"
132 XORRISO_OPTIONS="${XORRISO_OPTIONS} -b isolinux/isolinux.bin -c isolinux/boot.cat"
133 XORRISO_EXCLUDE="isolinux/isolinux.bin"
135 esac
137 XORRISO_OPTIONS="${XORRISO_OPTIONS} -no-emul-boot -boot-load-size 4 -boot-info-table"
141 Echo_warning "Bootloader on your architecture not yet supported by live-build."
142 Echo_warning "This will produce a most likely not bootable image (Continuing in 5 seconds)."
143 sleep 5
145 esac
147 #if [ "${LB_DEBIAN_INSTALLER}" != "live" ]
148 #then
149 # XORRISO_OPTIONS="${XORRISO_OPTIONS} -m ${XORRISO_EXCLUDE}"
152 if [ "${LB_BOOTLOADER}" = "grub2" ]
153 then
155 cat > binary.sh << EOF
156 #!/bin/sh
158 input_dir=/usr/lib/grub/i386-pc
160 # build core.img
161 core_img=\$(mktemp)
162 grub-mkimage -d \${input_dir} -o \${core_img} -O i386-pc biosdisk iso9660
164 # build grub_eltorito image
165 cat \${input_dir}/cdboot.img \${core_img} > binary/boot/grub/grub_eltorito
167 rm -f \${core_img}
169 for file in \${input_dir}/*.mod \${input_dir}/efiemu??.o \
170 \${input_dir}/command.lst \${input_dir}/moddep.lst \${input_dir}/fs.lst \
171 \${input_dir}/handler.lst \${input_dir}/parttool.lst
173 if test -f "\$file"
174 then
175 cp -f "\$file" binary/boot/grub/i386-pc
177 done
180 else
181 echo "#!/bin/sh" > binary.sh
184 cat >> binary.sh << EOF
186 xorriso -as mkisofs ${XORRISO_OPTIONS} -o ${IMAGE} binary
189 case "${LB_BUILD_WITH_CHROOT}" in
190 true)
191 # Moving image
192 mv binary.sh chroot
193 mv binary chroot
195 Chroot chroot "sh binary.sh"
197 # Move image
198 mv chroot/binary chroot/${IMAGE} ./
199 rm -f chroot/binary.sh
202 false)
203 sh binary.sh
204 rm -f binary.sh
206 esac
208 # Saving cache
209 Save_cache cache/packages.binary
211 # Removing depends
212 Remove_package
214 # Creating stage file
215 Create_stagefile .build/binary_iso