You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

01-run.sh 3.3 KiB

4 vuotta sitten
4 vuotta sitten
3 vuotta sitten
4 vuotta sitten
3 vuotta sitten
4 vuotta sitten
3 vuotta sitten
4 vuotta sitten
3 vuotta sitten
4 vuotta sitten
3 vuotta sitten
4 vuotta sitten
4 vuotta sitten
4 vuotta sitten
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. #!/bin/bash -e
  2. IMG_FILE="${STAGE_WORK_DIR}/${IMG_FILENAME}${IMG_SUFFIX}.img"
  3. INFO_FILE="${STAGE_WORK_DIR}/${IMG_FILENAME}${IMG_SUFFIX}.info"
  4. on_chroot << EOF
  5. if [ -x /etc/init.d/fake-hwclock ]; then
  6. /etc/init.d/fake-hwclock stop
  7. fi
  8. if hash hardlink 2>/dev/null; then
  9. hardlink -t /usr/share/doc
  10. fi
  11. EOF
  12. if [ -d "${ROOTFS_DIR}/home/${FIRST_USER_NAME}/.config" ]; then
  13. chmod 700 "${ROOTFS_DIR}/home/${FIRST_USER_NAME}/.config"
  14. fi
  15. rm -f "${ROOTFS_DIR}/usr/bin/qemu-arm-static"
  16. if [ "${USE_QEMU}" != "1" ]; then
  17. if [ -e "${ROOTFS_DIR}/etc/ld.so.preload.disabled" ]; then
  18. mv "${ROOTFS_DIR}/etc/ld.so.preload.disabled" "${ROOTFS_DIR}/etc/ld.so.preload"
  19. fi
  20. fi
  21. rm -f "${ROOTFS_DIR}/etc/network/interfaces.dpkg-old"
  22. rm -f "${ROOTFS_DIR}/etc/apt/sources.list~"
  23. rm -f "${ROOTFS_DIR}/etc/apt/trusted.gpg~"
  24. rm -f "${ROOTFS_DIR}/etc/passwd-"
  25. rm -f "${ROOTFS_DIR}/etc/group-"
  26. rm -f "${ROOTFS_DIR}/etc/shadow-"
  27. rm -f "${ROOTFS_DIR}/etc/gshadow-"
  28. rm -f "${ROOTFS_DIR}/etc/subuid-"
  29. rm -f "${ROOTFS_DIR}/etc/subgid-"
  30. rm -f "${ROOTFS_DIR}"/var/cache/debconf/*-old
  31. rm -f "${ROOTFS_DIR}"/var/lib/dpkg/*-old
  32. rm -f "${ROOTFS_DIR}"/usr/share/icons/*/icon-theme.cache
  33. rm -f "${ROOTFS_DIR}/var/lib/dbus/machine-id"
  34. true > "${ROOTFS_DIR}/etc/machine-id"
  35. ln -nsf /proc/mounts "${ROOTFS_DIR}/etc/mtab"
  36. find "${ROOTFS_DIR}/var/log/" -type f -exec cp /dev/null {} \;
  37. rm -f "${ROOTFS_DIR}/root/.vnc/private.key"
  38. rm -f "${ROOTFS_DIR}/etc/vnc/updateid"
  39. update_issue "$(basename "${EXPORT_DIR}")"
  40. install -m 644 "${ROOTFS_DIR}/etc/rpi-issue" "${ROOTFS_DIR}/boot/issue.txt"
  41. cp "$ROOTFS_DIR/etc/rpi-issue" "$INFO_FILE"
  42. {
  43. if [ -f "$ROOTFS_DIR/usr/share/doc/raspberrypi-kernel/changelog.Debian.gz" ]; then
  44. firmware=$(zgrep "firmware as of" \
  45. "$ROOTFS_DIR/usr/share/doc/raspberrypi-kernel/changelog.Debian.gz" | \
  46. head -n1 | sed -n 's|.* \([^ ]*\)$|\1|p')
  47. printf "\nFirmware: https://github.com/raspberrypi/firmware/tree/%s\n" "$firmware"
  48. kernel="$(curl -s -L "https://github.com/raspberrypi/firmware/raw/$firmware/extra/git_hash")"
  49. printf "Kernel: https://github.com/raspberrypi/linux/tree/%s\n" "$kernel"
  50. uname="$(curl -s -L "https://github.com/raspberrypi/firmware/raw/$firmware/extra/uname_string7")"
  51. printf "Uname string: %s\n" "$uname"
  52. fi
  53. printf "\nPackages:\n"
  54. dpkg -l --root "$ROOTFS_DIR"
  55. } >> "$INFO_FILE"
  56. mkdir -p "${DEPLOY_DIR}"
  57. rm -f "${DEPLOY_DIR}/${ARCHIVE_FILENAME}${IMG_SUFFIX}.*"
  58. rm -f "${DEPLOY_DIR}/${IMG_FILENAME}${IMG_SUFFIX}.img"
  59. mv "$INFO_FILE" "$DEPLOY_DIR/"
  60. if [ "${USE_QCOW2}" = "0" ] && [ "${NO_PRERUN_QCOW2}" = "0" ]; then
  61. ROOT_DEV="$(mount | grep "${ROOTFS_DIR} " | cut -f1 -d' ')"
  62. unmount "${ROOTFS_DIR}"
  63. zerofree "${ROOT_DEV}"
  64. unmount_image "${IMG_FILE}"
  65. else
  66. unload_qimage
  67. make_bootable_image "${STAGE_WORK_DIR}/${IMG_FILENAME}${IMG_SUFFIX}.qcow2" "$IMG_FILE"
  68. fi
  69. case "${DEPLOY_COMPRESSION}" in
  70. zip)
  71. pushd "${STAGE_WORK_DIR}" > /dev/null
  72. zip -"${COMPRESSION_LEVEL}" \
  73. "${DEPLOY_DIR}/${ARCHIVE_FILENAME}${IMG_SUFFIX}.zip" "$(basename "${IMG_FILE}")"
  74. popd > /dev/null
  75. ;;
  76. gz)
  77. pigz --force -"${COMPRESSION_LEVEL}" "$IMG_FILE" --stdout > \
  78. "${DEPLOY_DIR}/${ARCHIVE_FILENAME}${IMG_SUFFIX}.img.gz"
  79. ;;
  80. xz)
  81. xz --compress --force --threads 0 --memlimit-compress=50% -"${COMPRESSION_LEVEL}" \
  82. --stdout "$IMG_FILE" > "${DEPLOY_DIR}/${ARCHIVE_FILENAME}${IMG_SUFFIX}.img.xz"
  83. ;;
  84. none | *)
  85. cp "$IMG_FILE" "$DEPLOY_DIR/"
  86. ;;
  87. esac