25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

107 lines
3.1 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. 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}/${ZIP_FILENAME}${IMG_SUFFIX}.zip"
  58. rm -f "${DEPLOY_DIR}/${IMG_FILENAME}${IMG_SUFFIX}.img"
  59. rm -f "${DEPLOY_DIR}/${ZIP_FILENAME}${IMG_SUFFIX}.img.xz"
  60. mv "$INFO_FILE" "$DEPLOY_DIR/"
  61. if [ "${USE_QCOW2}" = "0" ] && [ "${NO_PRERUN_QCOW2}" = "0" ]; then
  62. ROOT_DEV="$(mount | grep "${ROOTFS_DIR} " | cut -f1 -d' ')"
  63. unmount "${ROOTFS_DIR}"
  64. zerofree "${ROOT_DEV}"
  65. unmount_image "${IMG_FILE}"
  66. else
  67. unload_qimage
  68. make_bootable_image "${STAGE_WORK_DIR}/${IMG_FILENAME}${IMG_SUFFIX}.qcow2" "$IMG_FILE"
  69. fi
  70. if [ "${DEPLOY_ZIP}" == "1" ]; then
  71. pushd "${STAGE_WORK_DIR}" > /dev/null
  72. xz -c "$(basename "${IMG_FILE}")" > "${DEPLOY_DIR}/${ZIP_FILENAME}${IMG_SUFFIX}.img.xz"
  73. popd > /dev/null
  74. rm -f "${DEPLOY_DIR}/${IMG_FILENAME}${IMG_SUFFIX}.img"
  75. else
  76. mv "$IMG_FILE" "$DEPLOY_DIR/"
  77. fi