04-iso 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. # Build script to compose the Live CD image.
  2. #
  3. # Copyright (c) 2017 MMPG.
  4. # Copyright (c) 2017-2022 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. /sbin/dragora-mouse
  91. /sbin/dragora-installer
  92. fi
  93. ;;
  94. esac
  95. EOF
  96. # Produce compressed images using mksquashfs(1)
  97. cd -- "$STAGE1"
  98. rm -f ./dragora.sfs
  99. EXCLUDED_PATHS_COMMON="
  100. ./tools \
  101. ./root/.ash_history \
  102. ./*-log* \
  103. ./usr/src/qi \
  104. ./usr/bin/build-for-release
  105. "
  106. EXCLUDED_PATHS_CD="
  107. $EXCLUDED_PATHS_COMMON \
  108. ./var/cache/qi/packages \
  109. ./usr/pkg/kernel-buildtree-* \
  110. ./usr/src/linux-*
  111. "
  112. # For a DVD live-image with binary packages and kernel sources
  113. echo "Creating DVD ISO image ..."
  114. echo ""
  115. echo "Binding ${worktree}/packages with ${rootdir}/var/cache/qi/packages ..."
  116. mount -o bind "${worktree}/packages" ./var/cache/qi/packages
  117. echo ""
  118. "${rootdir}"/squashfs-tools_lzip/mksquashfs ./* "${CDROM}/dragora.sfs" \
  119. -comp lzip -b 1024K -Xcompression-level 1 -Xdict-size 100% \
  120. -noappend -e $EXCLUDED_PATHS_COMMON
  121. echo ""
  122. echo "Unmounting bind-mount ${worktree}/packages ..."
  123. umount ./var/cache/qi/packages
  124. # Produce hybrid ISO-9660 image (DVD)
  125. cd -- "$CDROM"
  126. rm -f ./${ISONAME}-dvd*
  127. xorriso -as mkisofs -verbose \
  128. -o ${ISONAME}-dvd.iso \
  129. -J -rational-rock -hide-rr-moved -iso-level 3 \
  130. -c "isolinux/boot.cat" \
  131. -b "isolinux/isolinux.bin" \
  132. -partition_offset 16 \
  133. -no-emul-boot -boot-load-size 4 -boot-info-table \
  134. -isohybrid-mbr "isolinux/isohdpfx.bin" \
  135. -publisher "Dragora GNU/Linux-Libre, https://www.dragora.org" \
  136. -volid "Dragora_${package_arch}" \
  137. .
  138. echo "Creating .sha256 sum ..."
  139. echo "sha256sum ${ISONAME}-dvd.iso > ${ISONAME}-dvd.iso.sha256"
  140. sha256sum ${ISONAME}-dvd.iso > ${ISONAME}-dvd.iso.sha256
  141. # ^ End Of 'For a DVD live-image with binary packages and kernel sources'
  142. echo "Finishing ..."
  143. echo ""
  144. echo "***"
  145. echo "The DVD ISO image has been produced at"
  146. echo " ${CDROM}/${ISONAME}-dvd.iso"
  147. echo "***"
  148. echo ""
  149. exit 0