increase the version number of Dragora
[dragora.git] / stages / 2 / 03-iso
blob10a5eb9cb0836bc9c26b8d25b412948c2384695d
1 # Build script to compose the liveCD image.
3 # Copyright (c) 2017 MMPG.
4 # Copyright (c) 2017 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 # Perform sanity checks (requirements)
19 type mksquashfs > /dev/null  || exit 2;
20 type mkisofs > /dev/null     || exit 2;
22 # This depends on the existence of the stage 1
23 if test ! -d "${output}/stage1/usr/pkg"
24 then
25     echo "The stage number 1 does not exist or is incomplete." 1>&2
26     echo "Build (completely) the stage 1 before processing '$stage'." 1>&2
27     exit 1;
29 if test ! -f "${rootdir}/initrd/initrd.img"
30 then
31     echo "${rootdir}/initrd/initrd.img: No such initramfs file" 1>&2
32     exit 1;
35 STAGE1="${output}/stage1"
36 CDROM="${rootdir}/cdrom"
38 # Re-create CD tree
39 rm -rf -- "$CDROM"
40 mkdir -p -- "${CDROM}/isolinux"
42 # Copy kernel installation to isolinux/
43 cd -- "${STAGE1}/boot"
45 for file in System.map config vmlinuz
47     if test -L $file -a ! -e $file
48     then
49         cp -p "${STAGE1}/$(readlink -- "$file")" "${CDROM}/isolinux/$file"
50     elif test -f $file
51     then
52         cp -p "${STAGE1}/boot/$file" "${CDROM}/isolinux/$file"
53     else
54         echo "No valid symlinks or regular files for copying the kernel" 1>&2
55         exit 1;
56     fi
57 done
58 unset file
60 # Copy local isolinux files and initramfs for ISOLINUX
62 cp -p "${worktree}"/archive/isolinux/* "${CDROM}/isolinux/"
63 rm -f "${CDROM}/isolinux/isohybrid.pl"
65 cp -p "${rootdir}/initrd/initrd.img" "${CDROM}/isolinux/"
67 # Produce compressed image using mksquashfs(1)
68 cd -- "$STAGE1"
69 rm -f ./dragora.sfs
71 mksquashfs ./* "${CDROM}/dragora.sfs" \
72  -comp gzip -b 256K -Xcompression-level 9 -keep-as-directory \
73  -e ./tools ./var/cache/qi/packages ./root/.ash_history \
74     ./usr/pkg/kernel-buildtree-* ./usr/src/linux-* ./usr/src/qi
76 # Produce hybrid ISO-9660 image
77 cd -- "$CDROM"
78 rm -f ./dragora-live*
80 mkisofs -v -o "${CDROM}/dragora-live.iso"                 \
81         -no-emul-boot -boot-load-size 4 -boot-info-table  \
82         -b "isolinux/isolinux.bin"                        \
83         -c "isolinux/boot.cat"                            \
84         -A 'Dragora' -V 'Dragora'                         \
85         .
87 echo "Applying \"hybrid booting\" to the ISO image ..."
88 "${worktree}"/archive/isolinux/isohybrid.pl "${CDROM}/dragora-live.iso"
90 sha256sum "${CDROM}/dragora-live.iso" > "${CDROM}/dragora-live.iso.sha256"
92 echo "Finish ..."
93 echo ""
94 echo "The ISO image has been produced:"
95 echo "${CDROM}/dragora-live.iso"
96 echo ""