您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 

101 行
2.9 KiB

  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. rm -f "${ROOTFS_DIR}/etc/network/interfaces.dpkg-old"
  17. rm -f "${ROOTFS_DIR}/etc/apt/sources.list~"
  18. rm -f "${ROOTFS_DIR}/etc/apt/trusted.gpg~"
  19. rm -f "${ROOTFS_DIR}/etc/passwd-"
  20. rm -f "${ROOTFS_DIR}/etc/group-"
  21. rm -f "${ROOTFS_DIR}/etc/shadow-"
  22. rm -f "${ROOTFS_DIR}/etc/gshadow-"
  23. rm -f "${ROOTFS_DIR}/etc/subuid-"
  24. rm -f "${ROOTFS_DIR}/etc/subgid-"
  25. rm -f "${ROOTFS_DIR}"/var/cache/debconf/*-old
  26. rm -f "${ROOTFS_DIR}"/var/lib/dpkg/*-old
  27. rm -f "${ROOTFS_DIR}"/usr/share/icons/*/icon-theme.cache
  28. rm -f "${ROOTFS_DIR}/var/lib/dbus/machine-id"
  29. true > "${ROOTFS_DIR}/etc/machine-id"
  30. ln -nsf /proc/mounts "${ROOTFS_DIR}/etc/mtab"
  31. find "${ROOTFS_DIR}/var/log/" -type f -exec cp /dev/null {} \;
  32. rm -f "${ROOTFS_DIR}/root/.vnc/private.key"
  33. rm -f "${ROOTFS_DIR}/etc/vnc/updateid"
  34. update_issue "$(basename "${EXPORT_DIR}")"
  35. install -m 644 "${ROOTFS_DIR}/etc/rpi-issue" "${ROOTFS_DIR}/boot/issue.txt"
  36. cp "$ROOTFS_DIR/etc/rpi-issue" "$INFO_FILE"
  37. {
  38. if [ -f "$ROOTFS_DIR/usr/share/doc/raspberrypi-kernel/changelog.Debian.gz" ]; then
  39. firmware=$(zgrep "firmware as of" \
  40. "$ROOTFS_DIR/usr/share/doc/raspberrypi-kernel/changelog.Debian.gz" | \
  41. head -n1 | sed -n 's|.* \([^ ]*\)$|\1|p')
  42. printf "\nFirmware: https://github.com/raspberrypi/firmware/tree/%s\n" "$firmware"
  43. kernel="$(curl -s -L "https://github.com/raspberrypi/firmware/raw/$firmware/extra/git_hash")"
  44. printf "Kernel: https://github.com/raspberrypi/linux/tree/%s\n" "$kernel"
  45. uname="$(curl -s -L "https://github.com/raspberrypi/firmware/raw/$firmware/extra/uname_string7")"
  46. printf "Uname string: %s\n" "$uname"
  47. fi
  48. printf "\nPackages:\n"
  49. dpkg -l --root "$ROOTFS_DIR"
  50. } >> "$INFO_FILE"
  51. mkdir -p "${DEPLOY_DIR}"
  52. rm -f "${DEPLOY_DIR}/${ZIP_FILENAME}${IMG_SUFFIX}.zip"
  53. rm -f "${DEPLOY_DIR}/${IMG_FILENAME}${IMG_SUFFIX}.img"
  54. rm -f "${DEPLOY_DIR}/${ZIP_FILENAME}${IMG_SUFFIX}.img.xz"
  55. mv "$INFO_FILE" "$DEPLOY_DIR/"
  56. if [ "${USE_QCOW2}" = "0" ] && [ "${NO_PRERUN_QCOW2}" = "0" ]; then
  57. ROOT_DEV="$(mount | grep "${ROOTFS_DIR} " | cut -f1 -d' ')"
  58. unmount "${ROOTFS_DIR}"
  59. zerofree "${ROOT_DEV}"
  60. unmount_image "${IMG_FILE}"
  61. else
  62. unload_qimage
  63. make_bootable_image "${STAGE_WORK_DIR}/${IMG_FILENAME}${IMG_SUFFIX}.qcow2" "$IMG_FILE"
  64. fi
  65. if [ "${DEPLOY_ZIP}" == "1" ]; then
  66. pushd "${STAGE_WORK_DIR}" > /dev/null
  67. xz -T16 -c "$(basename "${IMG_FILE}")" > "${DEPLOY_DIR}/${ZIP_FILENAME}${IMG_SUFFIX}.img.xz"
  68. popd > /dev/null
  69. rm -f "${DEPLOY_DIR}/${IMG_FILENAME}${IMG_SUFFIX}.img"
  70. else
  71. mv "$IMG_FILE" "$DEPLOY_DIR/"
  72. fi