1 # Build script to compose the Live CD image.
3 # Copyright (c) 2017 MMPG.
4 # Copyright (c) 2017-2021 Matias Fonzo <selk@dragora.org>.
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
19 ISONAME="${ISONAME:-dragora-3.0_$(date +%Y%m%d)-${package_arch}}"
21 # Default mkisofs(8) invocation name
24 # Perform sanity checks (requirements)
26 if ! test -e "${rootdir}/squashfs-tools_lzip/mksquashfs"
28 echo "Local \`${rootdir}/squashfs-tools_lzip/mksquashfs' does not exist." 1>&2
31 if ! type mkisofs > /dev/null
35 " \`mkisofs' was not found in your PATH ..." \
37 if type genisoimage > /dev/null
42 " \`genisoimage' was not found in your PATH." \
44 "Please install one of these programs to make the ISO image." \
49 echo "The \`${MKISOFS}' command will be used to generate the ISO image."
52 # This depends on the existence of the stage 1
54 if test ! -d "${output}/stage1/usr/pkg"
56 echo "The stage number 1 does not exist or is incomplete." 1>&2
57 echo "Build (completely) the stage 1 before processing '$stage'." 1>&2
60 if test ! -f "${rootdir}/initrd/initrd.img"
62 echo "${rootdir}/initrd/initrd.img: No such initramfs file" 1>&2
66 STAGE1="${output}/stage1"
67 CDROM="${rootdir}/cdrom"
73 echo "Re-creating CD tree (${CDROM}) ..."
76 mkdir -p -- "${CDROM}/isolinux"
79 # Copy kernel installation to isolinux/
82 cd -- "${STAGE1}/boot"
84 for file in System.map-* config-* vmlinuz-*
86 cp -p "${STAGE1}/boot/$file" "${CDROM}/isolinux/${file%%-*}"
91 # Copy local isolinux files and initramfs for ISOLINUX
94 cp -p "${worktree}"/archive/isolinux/* "${CDROM}/isolinux/"
95 cp -p "${rootdir}/initrd/initrd.img" "${CDROM}/isolinux/"
97 # Clean up (we don't want this on the final ISO)
98 rm -f "${CDROM}/isolinux/isohybrid.pl" \
99 "${CDROM}/isolinux/generate-keymap"
102 # Adjust things on the live side
107 -e 's|c1:123:respawn:/sbin/agetty --noclear tty1 38400 linux|c1:123:respawn:/sbin/agetty --noclear --autologin root --noissue tty1 38400 linux|' \
108 -e 's|c2:123:respawn:/sbin/agetty tty2 38400 linux|c2:123:respawn:/sbin/agetty --autologin root --login-pause --noissue tty2 38400 linux|' \
109 -e 's|c3:12345:respawn:/sbin/agetty tty3 38400 linux|c3:12345:respawn:/sbin/agetty --autologin root --login-pause --noissue tty3 38400 linux|' \
110 -i "${STAGE1}/etc/inittab"
112 # Add instructions for running the installer from boot menu option
113 cat << 'EOF' > "${STAGE1}/root/.profile"
115 # .profile - Personal shell-initialization file.
117 # The instructions here could serve to complement
118 # /etc/profile or to override default (previous)
122 # Add personal bin directory to the end of path
123 # and make it known to child process
125 PATH=${PATH}:${HOME}/bin
128 # Run Dragora setup if the "parameter" in the boot was set
130 # Execute setup only on tty1/serial console
132 case "$(fgconsole)" in
134 if grep -q -m 1 DRAGORA_SETUP /proc/cmdline
138 /sbin/dragora-installer
146 # Produce compressed image using mksquashfs(1)
152 "${rootdir}"/squashfs-tools_lzip/mksquashfs ./* "${CDROM}/dragora.sfs" \
153 -comp lzip -b 128K -Xcompression-level 1 -Xdict-size 100% \
154 -noappend -e ./tools ./var/cache/qi/packages ./root/.ash_history \
155 ./*-log* ./usr/pkg/kernel-buildtree-* ./usr/src/linux-* ./usr/src/qi \
156 ./usr/bin/build-for-release
159 # Produce hybrid ISO-9660 image
165 $MKISOFS -v -o ${ISONAME}.iso \
167 -no-emul-boot -boot-load-size 4 -boot-info-table \
168 -b "isolinux/isolinux.bin" \
169 -c "isolinux/boot.cat" \
170 -V "Dragora-${package_arch}" \
174 echo "Applying \"hybrid booting\" to the ISO image ..."
175 "${worktree}"/archive/isolinux/isohybrid.pl ${ISONAME}.iso
177 echo "Creating .sha256 sum ..."
178 echo "sha256sum ${ISONAME}.iso > ${ISONAME}.iso.sha256"
179 sha256sum ${ISONAME}.iso > ${ISONAME}.iso.sha256
184 echo "The ISO image has been produced at"
185 echo " ${CDROM}/${ISONAME}.iso"