stages: 2/04-iso: improve message when mkisofs/genisoimage is not found
[dragora.git] / stages / 2 / 04-iso
blobf8dfe9b6c9fc00c2cab8093a5d1a3b456dd0d73f
1 # Build script to compose the Live CD image.
3 # Copyright (c) 2017 MMPG.
4 # Copyright (c) 2017-2019 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 # Default mkisofs(8) invocation name
19 MKISOFS=mkisofs
21 # Perform sanity checks (requirements)
23 if ! test -e "${rootdir}/squashfs-tools_lzip/mksquashfs"
24 then
25     echo "Local \`${rootdir}/squashfs-tools_lzip/mksquashfs' does not exist." 1>&2
26     exit 2;
28 if ! type mkisofs > /dev/null
29 then
30     echo "" 1>&2
31     echo "\`mkisofs' is not found in your PATH." 1>&2
32     if type genisoimage > /dev/null
33     then
34         MKISOFS=genisoimage
35     else
36         echo "\`genisoimage' was not found in your PATH." 1>&2
37         echo "" 1>&2
38         echo "Please install one of these programs to make the ISO image." 1>&2
39         echo "" 1>&2
40         exit 2;
41     fi
44 # This depends on the existence of the stage 1
46 if test ! -d "${output}/stage1/usr/pkg"
47 then
48     echo "The stage number 1 does not exist or is incomplete." 1>&2
49     echo "Build (completely) the stage 1 before processing '$stage'." 1>&2
50     exit 1;
52 if test ! -f "${rootdir}/initrd/initrd.img"
53 then
54     echo "${rootdir}/initrd/initrd.img: No such initramfs file" 1>&2
55     exit 1;
58 STAGE1="${output}/stage1"
59 CDROM="${rootdir}/cdrom"
61 # Re-create CD tree
63 echo "Re-creating CD tree (${CDROM}) ..."
64 rm -rf -- "$CDROM"
65 mkdir -p -- "${CDROM}/isolinux"
67 # Copy kernel installation to isolinux/
69 cd -- "${STAGE1}/boot"
71 for file in System.map-* config-* vmlinuz-*
73     cp -p "${STAGE1}/boot/$file" "${CDROM}/isolinux/${file%%-*}"
74 done
75 unset file
77 # Copy local isolinux files and initramfs for ISOLINUX
79 cp -p "${worktree}"/archive/isolinux/* "${CDROM}/isolinux/"
80 rm -f "${CDROM}/isolinux/isohybrid.pl" \
81       "${CDROM}/isolinux/generate-keymap"
83 cp -p "${rootdir}/initrd/initrd.img" "${CDROM}/isolinux/"
85 # Produce compressed image using mksquashfs(1)
86 cd -- "$STAGE1"
87 rm -f ./dragora.sfs
89 "${rootdir}"/squashfs-tools_lzip/mksquashfs ./* "${CDROM}/dragora.sfs" \
90  -comp lzip -b 128K -Xcompression-level 0 -Xdict-size 100% \
91  -noappend -e ./tools ./var/cache/qi/packages ./root/.ash_history \
92   ./*-log* ./usr/pkg/kernel-buildtree-* ./usr/src/linux-* ./usr/src/qi
94 # Produce hybrid ISO-9660 image
96 cd -- "$CDROM"
98 rm -f ./dragora-live*
99 $MKISOFS -v -o dragora-live.iso                            \
100          -iso-level 2                                      \
101          -no-emul-boot -boot-load-size 4 -boot-info-table  \
102          -b "isolinux/isolinux.bin"                        \
103          -c "isolinux/boot.cat"                            \
104          -A 'Dragora' -V 'Dragora'                         \
105          .
106 unset MKISOFS
108 echo "Applying \"hybrid booting\" to the ISO image ..."
109 "${worktree}"/archive/isolinux/isohybrid.pl dragora-live.iso
111 sha256sum dragora-live.iso > dragora-live.iso.sha256
113 echo "Finish ..."
114 echo ""
115 echo "***"
116 echo "The ISO image has been produced at"
117 echo "    ${CDROM}/dragora-live.iso"
118 echo "***"
119 echo ""
120 exit 0