mkchroot.sh 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #!/bin/sh
  2. # Perform chroot activities on the mounted primary filesystem
  3. # Copyright Brian Conway <bconway@rcesoftware.com>, see LICENSE for details
  4. # Set up a temporary /tmp
  5. mount -t mfs -o noatime,nodev,noexec,-s256M swap ${BUILDPATH}/fs/tmp
  6. # Run syspatch if directed
  7. if [ -n "${syspatch+1}" ]; then
  8. echo -n " Relinking kernel and running syspatch"
  9. st=$(date +%s)
  10. chroot ${BUILDPATH}/fs cksum -a sha256 -h /var/db/kernel.SHA256 /bsd
  11. if ! chroot ${BUILDPATH}/fs /usr/libexec/reorder_kernel; then
  12. ${ESCECHO} "\n*** WARNING: Relink failed, check" \
  13. "${BUILDPATH}/02.mkchroot.00.relink for details. ***"
  14. fi
  15. cp ${BUILDPATH}/fs/usr/share/relink/kernel/${KERNEL}/relink.log \
  16. ${BUILDPATH}/02.mkchroot.00.relink
  17. if [ $(chroot ${BUILDPATH}/fs syspatch -c|wc -l) -ne 0 ] && \
  18. ! chroot ${BUILDPATH}/fs syspatch >> ${BUILDPATH}/02.mkchroot.01.syspatch \
  19. 2>&1; then
  20. ${ESCECHO} "\n*** WARNING: Syspatch failed, check" \
  21. "${BUILDPATH}/02.mkchroot.01.syspatch for connectivity and version" \
  22. "compatibility. ***"
  23. fi
  24. rm ${BUILDPATH}/fs/var/db/kernel.SHA256
  25. echo " ($(($(date +%s) - st))s)"
  26. fi
  27. # Preload ld.so.hints for potential package installation
  28. if [ -n "${pkgdir+1}" ] || [ -n "${pkglist+1}" ]; then
  29. if [ -d ${BUILDPATH}/fs/usr/X11R6/lib ]; then
  30. chroot ${BUILDPATH}/fs ldconfig /usr/X11R6/lib /usr/local/lib
  31. else
  32. chroot ${BUILDPATH}/fs ldconfig /usr/local/lib
  33. fi
  34. fi
  35. # Install packages from pkgdir if directed, must run before pkglist to support
  36. # compiled dependencies
  37. if [ -n "${pkgdir+1}" ]; then
  38. echo -n " Installing packages: ${pkgdir}"
  39. st=$(date +%s)
  40. mkdir -p ${BUILDPATH}/fs/tmp/pkg
  41. cp ${pkgdir}/*.tgz ${BUILDPATH}/fs/tmp/pkg/
  42. if ! chroot ${BUILDPATH}/fs sh -c "env PKG_PATH=${pkgpath} pkg_add -I -v -D \
  43. unsigned /tmp/pkg/*.tgz" >> ${BUILDPATH}/02.mkchroot.02.pkg_add.pkg_dir \
  44. 2>&1; then
  45. ${ESCECHO} "\n*** WARNING: Package installation failed, check" \
  46. "${BUILDPATH}/02.mkchroot.02.pkg_add.pkg_dir for binary compatibility. ***"
  47. fi
  48. echo " ($(($(date +%s) - st))s)"
  49. fi
  50. # Install packages from pkgpath/pkglist if directed
  51. if [ -n "${pkglist+1}" ]; then
  52. echo -n " Installing packages: ${pkgpath}"
  53. st=$(date +%s)
  54. if ! chroot ${BUILDPATH}/fs sh -c "env PKG_PATH=${pkgpath} pkg_add -I -v \
  55. $(echo ${pkglist}|tr , ' ')" >> ${BUILDPATH}/02.mkchroot.03.pkg_add.pkg_list \
  56. 2>&1; then
  57. ${ESCECHO} "\n*** WARNING: Package installation failed, check" \
  58. "${BUILDPATH}/02.mkchroot.03.pkg_add.pkg_list for connectivity and" \
  59. "version compatibility. ***"
  60. fi
  61. echo " ($(($(date +%s) - st))s)"
  62. fi
  63. # Clean up
  64. umount ${BUILDPATH}/fs/tmp