1 # Build script to compose the Live CD image.
3 # Copyright (c) 2017 MMPG.
4 # Copyright (c) 2017-2024 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 # Perform sanity checks (requirements)
23 if ! type xorriso > /dev/null
25 echo " xorriso(1) was not found in your PATH." 1>&2
26 echo "GNU Xorriso is required to produce the ISO image(s)." 1>&2
30 if ! test -e "${rootdir}/squashfs-tools_lzip/mksquashfs"
32 echo "Local \`${rootdir}/squashfs-tools_lzip/mksquashfs' does not exist." 1>&2
36 # This depends on the existence of the stage 1
38 if test ! -d "${output}/stage1/usr/pkg"
40 echo "The stage number 1 does not exist or is incomplete." 1>&2
41 echo "Build (completely) the stage 1 before processing '$stage'." 1>&2
44 if test ! -f "${rootdir}/initrd/initrd.img"
46 echo "${rootdir}/initrd/initrd.img: No such initramfs file" 1>&2
50 STAGE1="${output}/stage1"
51 CDROM="${rootdir}/cdrom"
55 echo "Re-creating CD tree (${CDROM}) ..."
58 mkdir -p -- "${CDROM}/isolinux"
61 # Copy kernel installation to isolinux/
63 cd -- "${STAGE1}/boot"
65 for file in System.map-* config-* vmlinuz-*
67 cp -p "${STAGE1}/boot/$file" "${CDROM}/isolinux/${file%%-*}"
71 # Copy local isolinux files and initramfs for ISOLINUX
73 cp -p "${worktree}"/archive/isolinux/* "${CDROM}/isolinux/"
74 cp -p "${rootdir}/initrd/initrd.img" "${CDROM}/isolinux/"
76 # Adjust things on the live side.
80 -e 's|c1:123:respawn:/sbin/agetty --noclear tty1 38400 linux|c1:123:respawn:/sbin/agetty --noclear --autologin root --noissue tty1 38400 linux|' \
81 -e 's|c2:123:respawn:/sbin/agetty tty2 38400 linux|c2:123:respawn:/sbin/agetty --autologin root --login-pause --noissue tty2 38400 linux|' \
82 -e 's|c3:12345:respawn:/sbin/agetty tty3 38400 linux|c3:12345:respawn:/sbin/agetty --autologin root --login-pause --noissue tty3 38400 linux|' \
83 -i "${STAGE1}/etc/inittab"
85 # Add instructions for running the installer from boot menu option
87 cat << 'EOF' > "${STAGE1}/root/.profile"
89 # .profile - Personal shell-initialization file.
91 # The instructions here could serve to complement
92 # /etc/profile or to override default (previous)
96 # Add personal bin directory to the end of path
97 # and make it known to child process
99 PATH=${PATH}:${HOME}/bin
102 # Run Dragora setup if the "parameter" in the boot was set
105 # Execute setup only on tty1/serial console
107 case "$(fgconsole)" in
109 if grep -q -m 1 DRAGORA_SETUP /proc/cmdline
115 /sbin/dragora-installer
122 # Produce compressed images using mksquashfs(1)
127 EXCLUDED_PATHS_COMMON="
129 ./root/.ash_history \
132 ./usr/bin/build-for-release \
133 ./usr/pkg/kernel-buildtree-* \
137 # For a DVD live-image with binary packages and kernel sources
138 echo "Creating DVD ISO image ..."
141 echo "Binding ${worktree}/packages with ${rootdir}/var/cache/qi/packages ..."
142 mount -o bind "${worktree}/packages" ./var/cache/qi/packages
145 "${rootdir}"/squashfs-tools_lzip/mksquashfs ./* "${CDROM}/dragora.sfs" \
146 -comp gzip -b 1024K -Xcompression-level 9 -noappend \
147 -e $EXCLUDED_PATHS_COMMON
150 echo "Unmounting bind-mount ${worktree}/packages ..."
151 umount ./var/cache/qi/packages
153 # Produce hybrid ISO-9660 image (DVD)
156 rm -f ./${ISONAME}-dvd*
157 xorriso -as mkisofs -verbose \
158 -o ${ISONAME}-dvd.iso \
159 -J -rational-rock -hide-rr-moved -iso-level 3 \
160 -c "isolinux/boot.cat" \
161 -b "isolinux/isolinux.bin" \
162 -partition_offset 16 \
163 -no-emul-boot -boot-load-size 4 -boot-info-table \
164 -isohybrid-mbr "isolinux/isohdpfx.bin" \
165 -publisher "Dragora GNU/Linux-Libre, https://www.dragora.org" \
166 -volid "Dragora_${package_arch}" \
169 echo "Creating .sha256 sum ..."
170 echo "sha256sum ${ISONAME}-dvd.iso > ${ISONAME}-dvd.iso.sha256"
171 sha256sum ${ISONAME}-dvd.iso > ${ISONAME}-dvd.iso.sha256
173 # ^ End Of 'For a DVD live-image with binary packages and kernel sources'
178 echo "The DVD ISO image has been produced at"
179 echo " ${CDROM}/${ISONAME}-dvd.iso"