recipes: x-apps/emacs: Enable emacs again, trying the -no-pie option
[dragora.git] / stages / 2 / 04-iso
blob80e36ac5da77c1ebbd87ef1939d8d7b356a9409b
1 # Build script to compose the Live CD image.
3 # Copyright (c) 2017 MMPG.
4 # Copyright (c) 2017-2022 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.
18 # ISO file name
19 ISONAME="${ISONAME:-dragora-3.0_$(date +%Y%m%d)-${package_arch}}"
21 # Perform sanity checks (requirements)
23 if ! type xorriso > /dev/null
24 then
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
27     exit 2;
30 if ! test -e "${rootdir}/squashfs-tools_lzip/mksquashfs"
31 then
32     echo "Local \`${rootdir}/squashfs-tools_lzip/mksquashfs' does not exist." 1>&2
33     exit 4;
36 # This depends on the existence of the stage 1
38 if test ! -d "${output}/stage1/usr/pkg"
39 then
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
42     exit 1;
44 if test ! -f "${rootdir}/initrd/initrd.img"
45 then
46     echo "${rootdir}/initrd/initrd.img: No such initramfs file" 1>&2
47     exit 4;
50 STAGE1="${output}/stage1"
51 CDROM="${rootdir}/cdrom"
53 # Re-create CD tree
55 echo "Re-creating CD tree (${CDROM}) ..."
56 echo ""
57 rm -rf -- "$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%%-*}"
68 done
69 unset 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.
78 # Set auto-login:
79 sed \
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)
93 # values.
96 # Add personal bin directory to the end of path
97 # and make it known to child process
99 PATH=${PATH}:${HOME}/bin
100 export PATH
102 # Run Dragora setup if the "parameter" in the boot was set
105 # Execute setup only on tty1/serial console
107 case "$(fgconsole)" in
108 1* | serial* )
109     if grep -q -m 1 DRAGORA_SETUP /proc/cmdline
110     then
111         /sbin/dragora-keymap
112         /sbin/dragora-mouse
113         /sbin/dragora-installer
114     fi
115     ;;
116 esac
120 # Produce compressed images using mksquashfs(1)
122 cd -- "$STAGE1"
123 rm -f ./dragora.sfs
125 EXCLUDED_PATHS_COMMON="
126  ./tools \
127  ./root/.ash_history \
128  ./*-log* \
129  ./usr/src/qi \
130  ./usr/bin/build-for-release
132 EXCLUDED_PATHS_CD="
133  $EXCLUDED_PATHS_COMMON \
134  ./var/cache/qi/packages \
135  ./usr/pkg/kernel-buildtree-* \
136  ./usr/src/linux-*
139 # For a DVD live-image with binary packages and kernel sources
140 echo "Creating DVD ISO image ..."
141 echo ""
143 echo "Binding ${worktree}/packages with ${rootdir}/var/cache/qi/packages ..."
144 mount -o bind "${worktree}/packages" ./var/cache/qi/packages
145 echo ""
147 "${rootdir}"/squashfs-tools_lzip/mksquashfs ./* "${CDROM}/dragora.sfs" \
148  -comp lzip -b 1024K -Xcompression-level 1 -Xdict-size 100% \
149  -noappend -e $EXCLUDED_PATHS_COMMON
151 echo ""
152 echo "Unmounting bind-mount ${worktree}/packages ..."
153 umount ./var/cache/qi/packages
155 # Produce hybrid ISO-9660 image (DVD)
156 cd -- "$CDROM"
158 rm -f ./${ISONAME}-dvd*
159 xorriso -as mkisofs -verbose \
160          -o ${ISONAME}-dvd.iso                                    \
161          -J -rational-rock -hide-rr-moved -iso-level 3            \
162          -c "isolinux/boot.cat"                                   \
163          -b "isolinux/isolinux.bin"                               \
164             -partition_offset 16                                  \
165             -no-emul-boot -boot-load-size 4 -boot-info-table      \
166          -isohybrid-mbr "isolinux/isohdpfx.bin"                   \
167          -publisher "Dragora GNU/Linux-Libre, https://www.dragora.org" \
168          -volid "Dragora_${package_arch}"                         \
169          .
171 echo "Creating .sha256 sum ..."
172 echo "sha256sum ${ISONAME}-dvd.iso > ${ISONAME}-dvd.iso.sha256"
173 sha256sum ${ISONAME}-dvd.iso > ${ISONAME}-dvd.iso.sha256
175 # ^ End Of 'For a DVD live-image with binary packages and kernel sources'
177 echo "Finishing ..."
178 echo ""
179 echo "***"
180 echo "The DVD ISO image has been produced at"
181 echo "    ${CDROM}/${ISONAME}-dvd.iso"
182 echo "***"
183 echo ""
185 exit 0