123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- # Build script to compose the Live CD image.
- #
- # Copyright (c) 2017 MMPG.
- # Copyright (c) 2017-2023 Matias Fonzo <selk@dragora.org>.
- #
- # Licensed under the Apache License, Version 2.0 (the "License");
- # you may not use this file except in compliance with the License.
- # You may obtain a copy of the License at
- #
- # http://www.apache.org/licenses/LICENSE-2.0
- #
- # Unless required by applicable law or agreed to in writing, software
- # distributed under the License is distributed on an "AS IS" BASIS,
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- # See the License for the specific language governing permissions and
- # limitations under the License.
- # ISO file name
- ISONAME="${ISONAME:-dragora-3.0_$(date +%Y%m%d)-${package_arch}}"
- # Perform sanity checks (requirements)
- if ! type xorriso > /dev/null
- then
- echo " xorriso(1) was not found in your PATH." 1>&2
- echo "GNU Xorriso is required to produce the ISO image(s)." 1>&2
- exit 2;
- fi
- if ! test -e "${rootdir}/squashfs-tools_lzip/mksquashfs"
- then
- echo "Local \`${rootdir}/squashfs-tools_lzip/mksquashfs' does not exist." 1>&2
- exit 4;
- fi
- # This depends on the existence of the stage 1
- if test ! -d "${output}/stage1/usr/pkg"
- then
- echo "The stage number 1 does not exist or is incomplete." 1>&2
- echo "Build (completely) the stage 1 before processing '$stage'." 1>&2
- exit 1;
- fi
- if test ! -f "${rootdir}/initrd/initrd.img"
- then
- echo "${rootdir}/initrd/initrd.img: No such initramfs file" 1>&2
- exit 4;
- fi
- STAGE1="${output}/stage1"
- CDROM="${rootdir}/cdrom"
- # Re-create CD tree
- echo "Re-creating CD tree (${CDROM}) ..."
- echo ""
- rm -rf -- "$CDROM"
- mkdir -p -- "${CDROM}/isolinux"
- #
- # Copy kernel installation to isolinux/
- cd -- "${STAGE1}/boot"
- for file in System.map-* config-* vmlinuz-*
- do
- cp -p "${STAGE1}/boot/$file" "${CDROM}/isolinux/${file%%-*}"
- done
- unset file
- # Copy local isolinux files and initramfs for ISOLINUX
- cp -p "${worktree}"/archive/isolinux/* "${CDROM}/isolinux/"
- cp -p "${rootdir}/initrd/initrd.img" "${CDROM}/isolinux/"
- # Adjust things on the live side.
- #
- # Set auto-login:
- sed \
- -e 's|c1:123:respawn:/sbin/agetty --noclear tty1 38400 linux|c1:123:respawn:/sbin/agetty --noclear --autologin root --noissue tty1 38400 linux|' \
- -e 's|c2:123:respawn:/sbin/agetty tty2 38400 linux|c2:123:respawn:/sbin/agetty --autologin root --login-pause --noissue tty2 38400 linux|' \
- -e 's|c3:12345:respawn:/sbin/agetty tty3 38400 linux|c3:12345:respawn:/sbin/agetty --autologin root --login-pause --noissue tty3 38400 linux|' \
- -i "${STAGE1}/etc/inittab"
- # Add instructions for running the installer from boot menu option
- cat << 'EOF' > "${STAGE1}/root/.profile"
- #
- # .profile - Personal shell-initialization file.
- #
- # The instructions here could serve to complement
- # /etc/profile or to override default (previous)
- # values.
- #
- # Add personal bin directory to the end of path
- # and make it known to child process
- PATH=${PATH}:${HOME}/bin
- export PATH
- # Run Dragora setup if the "parameter" in the boot was set
- #
- # Execute setup only on tty1/serial console
- case "$(fgconsole)" in
- 1* | serial* )
- if grep -q -m 1 DRAGORA_SETUP /proc/cmdline
- then
- /sbin/dragora-keymap
- sleep 1
- /sbin/dragora-mouse
- sleep 1
- /sbin/dragora-installer
- fi
- ;;
- esac
- EOF
- # Produce compressed images using mksquashfs(1)
- cd -- "$STAGE1"
- rm -f ./dragora.sfs
- EXCLUDED_PATHS_COMMON="
- ./tools \
- ./root/.ash_history \
- ./*-log* \
- ./usr/src/qi \
- ./usr/bin/build-for-release
- "
- EXCLUDED_PATHS_CD="
- $EXCLUDED_PATHS_COMMON \
- ./usr/pkg/kernel-buildtree-* \
- ./usr/src/linux-*
- "
- # For a DVD live-image with binary packages and kernel sources
- echo "Creating DVD ISO image ..."
- echo ""
- echo "Binding ${worktree}/packages with ${rootdir}/var/cache/qi/packages ..."
- mount -o bind "${worktree}/packages" ./var/cache/qi/packages
- echo ""
- "${rootdir}"/squashfs-tools_lzip/mksquashfs ./* "${CDROM}/dragora.sfs" \
- -comp gzip -b 1024K -Xcompression-level 9 -noappend \
- -e $EXCLUDED_PATHS_COMMON
- echo ""
- echo "Unmounting bind-mount ${worktree}/packages ..."
- umount ./var/cache/qi/packages
- # Produce hybrid ISO-9660 image (DVD)
- cd -- "$CDROM"
- rm -f ./${ISONAME}-dvd*
- xorriso -as mkisofs -verbose \
- -o ${ISONAME}-dvd.iso \
- -J -rational-rock -hide-rr-moved -iso-level 3 \
- -c "isolinux/boot.cat" \
- -b "isolinux/isolinux.bin" \
- -partition_offset 16 \
- -no-emul-boot -boot-load-size 4 -boot-info-table \
- -isohybrid-mbr "isolinux/isohdpfx.bin" \
- -publisher "Dragora GNU/Linux-Libre, https://www.dragora.org" \
- -volid "Dragora_${package_arch}" \
- .
- echo "Creating .sha256 sum ..."
- echo "sha256sum ${ISONAME}-dvd.iso > ${ISONAME}-dvd.iso.sha256"
- sha256sum ${ISONAME}-dvd.iso > ${ISONAME}-dvd.iso.sha256
- # ^ End Of 'For a DVD live-image with binary packages and kernel sources'
- echo "Finishing ..."
- echo ""
- echo "***"
- echo "The DVD ISO image has been produced at"
- echo " ${CDROM}/${ISONAME}-dvd.iso"
- echo "***"
- echo ""
- exit 0
|