04-iso 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. # Build script to compose the Live CD image.
  2. #
  3. # Copyright (c) 2017 MMPG.
  4. # Copyright (c) 2017-2023 Matias Fonzo <selk@dragora.org>.
  5. #
  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
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  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.
  17. # ISO file name
  18. ISONAME="${ISONAME:-dragora-3.0_$(date +%Y%m%d)-${package_arch}}"
  19. # Perform sanity checks (requirements)
  20. if ! type xorriso > /dev/null
  21. then
  22. echo " xorriso(1) was not found in your PATH." 1>&2
  23. echo "GNU Xorriso is required to produce the ISO image(s)." 1>&2
  24. exit 2;
  25. fi
  26. if ! test -e "${rootdir}/squashfs-tools_lzip/mksquashfs"
  27. then
  28. echo "Local \`${rootdir}/squashfs-tools_lzip/mksquashfs' does not exist." 1>&2
  29. exit 4;
  30. fi
  31. # This depends on the existence of the stage 1
  32. if test ! -d "${output}/stage1/usr/pkg"
  33. then
  34. echo "The stage number 1 does not exist or is incomplete." 1>&2
  35. echo "Build (completely) the stage 1 before processing '$stage'." 1>&2
  36. exit 1;
  37. fi
  38. if test ! -f "${rootdir}/initrd/initrd.img"
  39. then
  40. echo "${rootdir}/initrd/initrd.img: No such initramfs file" 1>&2
  41. exit 4;
  42. fi
  43. STAGE1="${output}/stage1"
  44. CDROM="${rootdir}/cdrom"
  45. # Re-create CD tree
  46. echo "Re-creating CD tree (${CDROM}) ..."
  47. echo ""
  48. rm -rf -- "$CDROM"
  49. mkdir -p -- "${CDROM}/isolinux"
  50. #
  51. # Copy kernel installation to isolinux/
  52. cd -- "${STAGE1}/boot"
  53. for file in System.map-* config-* vmlinuz-*
  54. do
  55. cp -p "${STAGE1}/boot/$file" "${CDROM}/isolinux/${file%%-*}"
  56. done
  57. unset file
  58. # Copy local isolinux files and initramfs for ISOLINUX
  59. cp -p "${worktree}"/archive/isolinux/* "${CDROM}/isolinux/"
  60. cp -p "${rootdir}/initrd/initrd.img" "${CDROM}/isolinux/"
  61. # Adjust things on the live side.
  62. #
  63. # Set auto-login:
  64. sed \
  65. -e 's|c1:123:respawn:/sbin/agetty --noclear tty1 38400 linux|c1:123:respawn:/sbin/agetty --noclear --autologin root --noissue tty1 38400 linux|' \
  66. -e 's|c2:123:respawn:/sbin/agetty tty2 38400 linux|c2:123:respawn:/sbin/agetty --autologin root --login-pause --noissue tty2 38400 linux|' \
  67. -e 's|c3:12345:respawn:/sbin/agetty tty3 38400 linux|c3:12345:respawn:/sbin/agetty --autologin root --login-pause --noissue tty3 38400 linux|' \
  68. -i "${STAGE1}/etc/inittab"
  69. # Add instructions for running the installer from boot menu option
  70. cat << 'EOF' > "${STAGE1}/root/.profile"
  71. #
  72. # .profile - Personal shell-initialization file.
  73. #
  74. # The instructions here could serve to complement
  75. # /etc/profile or to override default (previous)
  76. # values.
  77. #
  78. # Add personal bin directory to the end of path
  79. # and make it known to child process
  80. PATH=${PATH}:${HOME}/bin
  81. export PATH
  82. # Run Dragora setup if the "parameter" in the boot was set
  83. #
  84. # Execute setup only on tty1/serial console
  85. case "$(fgconsole)" in
  86. 1* | serial* )
  87. if grep -q -m 1 DRAGORA_SETUP /proc/cmdline
  88. then
  89. /sbin/dragora-keymap
  90. sleep 1
  91. /sbin/dragora-mouse
  92. sleep 1
  93. /sbin/dragora-installer
  94. fi
  95. ;;
  96. esac
  97. EOF
  98. # Produce compressed images using mksquashfs(1)
  99. cd -- "$STAGE1"
  100. rm -f ./dragora.sfs
  101. EXCLUDED_PATHS_COMMON="
  102. ./tools \
  103. ./root/.ash_history \
  104. ./*-log* \
  105. ./usr/src/qi \
  106. ./usr/bin/build-for-release
  107. "
  108. EXCLUDED_PATHS_CD="
  109. $EXCLUDED_PATHS_COMMON \
  110. ./usr/pkg/kernel-buildtree-* \
  111. ./usr/src/linux-*
  112. "
  113. # For a DVD live-image with binary packages and kernel sources
  114. echo "Creating DVD ISO image ..."
  115. echo ""
  116. echo "Binding ${worktree}/packages with ${rootdir}/var/cache/qi/packages ..."
  117. mount -o bind "${worktree}/packages" ./var/cache/qi/packages
  118. echo ""
  119. "${rootdir}"/squashfs-tools_lzip/mksquashfs ./* "${CDROM}/dragora.sfs" \
  120. -comp gzip -b 1024K -Xcompression-level 9 -noappend \
  121. -e $EXCLUDED_PATHS_COMMON
  122. echo ""
  123. echo "Unmounting bind-mount ${worktree}/packages ..."
  124. umount ./var/cache/qi/packages
  125. # Produce hybrid ISO-9660 image (DVD)
  126. cd -- "$CDROM"
  127. rm -f ./${ISONAME}-dvd*
  128. xorriso -as mkisofs -verbose \
  129. -o ${ISONAME}-dvd.iso \
  130. -J -rational-rock -hide-rr-moved -iso-level 3 \
  131. -c "isolinux/boot.cat" \
  132. -b "isolinux/isolinux.bin" \
  133. -partition_offset 16 \
  134. -no-emul-boot -boot-load-size 4 -boot-info-table \
  135. -isohybrid-mbr "isolinux/isohdpfx.bin" \
  136. -publisher "Dragora GNU/Linux-Libre, https://www.dragora.org" \
  137. -volid "Dragora_${package_arch}" \
  138. .
  139. echo "Creating .sha256 sum ..."
  140. echo "sha256sum ${ISONAME}-dvd.iso > ${ISONAME}-dvd.iso.sha256"
  141. sha256sum ${ISONAME}-dvd.iso > ${ISONAME}-dvd.iso.sha256
  142. # ^ End Of 'For a DVD live-image with binary packages and kernel sources'
  143. echo "Finishing ..."
  144. echo ""
  145. echo "***"
  146. echo "The DVD ISO image has been produced at"
  147. echo " ${CDROM}/${ISONAME}-dvd.iso"
  148. echo "***"
  149. echo ""
  150. exit 0