2016-05-05 18:43:33 +00:00
|
|
|
#!/bin/bash -e
|
|
|
|
|
2019-01-21 18:42:54 +00:00
|
|
|
IMG_FILE="${STAGE_WORK_DIR}/${IMG_FILENAME}${IMG_SUFFIX}.img"
|
|
|
|
INFO_FILE="${STAGE_WORK_DIR}/${IMG_FILENAME}${IMG_SUFFIX}.info"
|
2016-05-05 18:43:33 +00:00
|
|
|
|
2016-11-14 23:55:45 +00:00
|
|
|
on_chroot << EOF
|
2019-08-27 17:16:24 +00:00
|
|
|
if [ -x /etc/init.d/fake-hwclock ]; then
|
|
|
|
/etc/init.d/fake-hwclock stop
|
|
|
|
fi
|
|
|
|
if hash hardlink 2>/dev/null; then
|
|
|
|
hardlink -t /usr/share/doc
|
|
|
|
fi
|
2016-05-05 18:43:33 +00:00
|
|
|
EOF
|
|
|
|
|
2019-01-14 23:39:48 +00:00
|
|
|
if [ -d "${ROOTFS_DIR}/home/${FIRST_USER_NAME}/.config" ]; then
|
|
|
|
chmod 700 "${ROOTFS_DIR}/home/${FIRST_USER_NAME}/.config"
|
2016-11-06 14:46:27 +00:00
|
|
|
fi
|
|
|
|
|
2018-03-02 20:08:24 +00:00
|
|
|
rm -f "${ROOTFS_DIR}/usr/bin/qemu-arm-static"
|
2016-05-05 18:43:33 +00:00
|
|
|
|
2019-06-07 16:30:05 +00:00
|
|
|
if [ "${USE_QEMU}" != "1" ]; then
|
|
|
|
if [ -e "${ROOTFS_DIR}/etc/ld.so.preload.disabled" ]; then
|
|
|
|
mv "${ROOTFS_DIR}/etc/ld.so.preload.disabled" "${ROOTFS_DIR}/etc/ld.so.preload"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2019-06-07 16:27:13 +00:00
|
|
|
rm -f "${ROOTFS_DIR}/etc/network/interfaces.dpkg-old"
|
|
|
|
|
2018-03-02 20:08:24 +00:00
|
|
|
rm -f "${ROOTFS_DIR}/etc/apt/sources.list~"
|
|
|
|
rm -f "${ROOTFS_DIR}/etc/apt/trusted.gpg~"
|
2017-03-30 16:51:23 +00:00
|
|
|
|
2018-03-02 20:08:24 +00:00
|
|
|
rm -f "${ROOTFS_DIR}/etc/passwd-"
|
|
|
|
rm -f "${ROOTFS_DIR}/etc/group-"
|
|
|
|
rm -f "${ROOTFS_DIR}/etc/shadow-"
|
|
|
|
rm -f "${ROOTFS_DIR}/etc/gshadow-"
|
2018-06-04 08:43:42 +00:00
|
|
|
rm -f "${ROOTFS_DIR}/etc/subuid-"
|
|
|
|
rm -f "${ROOTFS_DIR}/etc/subgid-"
|
2017-03-30 16:51:23 +00:00
|
|
|
|
2018-03-26 12:06:10 +00:00
|
|
|
rm -f "${ROOTFS_DIR}"/var/cache/debconf/*-old
|
|
|
|
rm -f "${ROOTFS_DIR}"/var/lib/dpkg/*-old
|
2017-03-30 16:51:23 +00:00
|
|
|
|
2018-03-26 12:06:10 +00:00
|
|
|
rm -f "${ROOTFS_DIR}"/usr/share/icons/*/icon-theme.cache
|
2017-03-30 16:51:23 +00:00
|
|
|
|
2018-03-02 20:08:24 +00:00
|
|
|
rm -f "${ROOTFS_DIR}/var/lib/dbus/machine-id"
|
2017-03-30 16:51:23 +00:00
|
|
|
|
2018-03-02 20:08:24 +00:00
|
|
|
true > "${ROOTFS_DIR}/etc/machine-id"
|
2017-03-30 16:51:23 +00:00
|
|
|
|
2018-03-02 20:08:24 +00:00
|
|
|
ln -nsf /proc/mounts "${ROOTFS_DIR}/etc/mtab"
|
2017-05-15 15:40:31 +00:00
|
|
|
|
2018-03-02 20:08:24 +00:00
|
|
|
find "${ROOTFS_DIR}/var/log/" -type f -exec cp /dev/null {} \;
|
2017-03-30 16:51:23 +00:00
|
|
|
|
|
|
|
rm -f "${ROOTFS_DIR}/root/.vnc/private.key"
|
2017-11-21 22:04:33 +00:00
|
|
|
rm -f "${ROOTFS_DIR}/etc/vnc/updateid"
|
2017-03-30 16:51:23 +00:00
|
|
|
|
2018-03-02 20:08:24 +00:00
|
|
|
update_issue "$(basename "${EXPORT_DIR}")"
|
|
|
|
install -m 644 "${ROOTFS_DIR}/etc/rpi-issue" "${ROOTFS_DIR}/boot/issue.txt"
|
2017-07-12 11:29:57 +00:00
|
|
|
|
|
|
|
cp "$ROOTFS_DIR/etc/rpi-issue" "$INFO_FILE"
|
|
|
|
|
|
|
|
|
2018-03-02 20:08:24 +00:00
|
|
|
{
|
2019-04-25 09:28:48 +00:00
|
|
|
if [ -f "$ROOTFS_DIR/usr/share/doc/raspberrypi-kernel/changelog.Debian.gz" ]; then
|
|
|
|
firmware=$(zgrep "firmware as of" \
|
|
|
|
"$ROOTFS_DIR/usr/share/doc/raspberrypi-kernel/changelog.Debian.gz" | \
|
|
|
|
head -n1 | sed -n 's|.* \([^ ]*\)$|\1|p')
|
|
|
|
printf "\nFirmware: https://github.com/raspberrypi/firmware/tree/%s\n" "$firmware"
|
2017-07-12 11:29:57 +00:00
|
|
|
|
2019-04-25 09:28:48 +00:00
|
|
|
kernel="$(curl -s -L "https://github.com/raspberrypi/firmware/raw/$firmware/extra/git_hash")"
|
|
|
|
printf "Kernel: https://github.com/raspberrypi/linux/tree/%s\n" "$kernel"
|
2017-07-12 11:29:57 +00:00
|
|
|
|
2019-04-25 09:28:48 +00:00
|
|
|
uname="$(curl -s -L "https://github.com/raspberrypi/firmware/raw/$firmware/extra/uname_string7")"
|
|
|
|
printf "Uname string: %s\n" "$uname"
|
|
|
|
fi
|
2017-07-12 11:29:57 +00:00
|
|
|
|
2018-03-02 20:08:24 +00:00
|
|
|
printf "\nPackages:\n"
|
|
|
|
dpkg -l --root "$ROOTFS_DIR"
|
|
|
|
} >> "$INFO_FILE"
|
2017-07-12 11:29:57 +00:00
|
|
|
|
2018-03-02 20:08:24 +00:00
|
|
|
mkdir -p "${DEPLOY_DIR}"
|
2016-05-05 18:43:33 +00:00
|
|
|
|
2022-03-01 16:23:42 +00:00
|
|
|
rm -f "${DEPLOY_DIR}/${ARCHIVE_FILENAME}${IMG_SUFFIX}.*"
|
2019-01-30 18:09:36 +00:00
|
|
|
rm -f "${DEPLOY_DIR}/${IMG_FILENAME}${IMG_SUFFIX}.img"
|
|
|
|
|
2021-02-10 10:37:15 +00:00
|
|
|
mv "$INFO_FILE" "$DEPLOY_DIR/"
|
|
|
|
|
|
|
|
if [ "${USE_QCOW2}" = "0" ] && [ "${NO_PRERUN_QCOW2}" = "0" ]; then
|
|
|
|
ROOT_DEV="$(mount | grep "${ROOTFS_DIR} " | cut -f1 -d' ')"
|
|
|
|
|
|
|
|
unmount "${ROOTFS_DIR}"
|
|
|
|
zerofree "${ROOT_DEV}"
|
|
|
|
|
|
|
|
unmount_image "${IMG_FILE}"
|
|
|
|
else
|
|
|
|
unload_qimage
|
|
|
|
make_bootable_image "${STAGE_WORK_DIR}/${IMG_FILENAME}${IMG_SUFFIX}.qcow2" "$IMG_FILE"
|
|
|
|
fi
|
|
|
|
|
2022-03-01 16:23:42 +00:00
|
|
|
case "${DEPLOY_COMPRESSION}" in
|
|
|
|
zip)
|
2019-01-30 18:09:36 +00:00
|
|
|
pushd "${STAGE_WORK_DIR}" > /dev/null
|
2022-03-01 16:23:42 +00:00
|
|
|
zip -"${COMPRESSION_LEVEL}" \
|
|
|
|
"${DEPLOY_DIR}/${ARCHIVE_FILENAME}${IMG_SUFFIX}.zip" "$(basename "${IMG_FILE}")"
|
2019-01-30 18:09:36 +00:00
|
|
|
popd > /dev/null
|
2022-03-01 16:23:42 +00:00
|
|
|
;;
|
|
|
|
gz)
|
|
|
|
pigz --force -"${COMPRESSION_LEVEL}" "$IMG_FILE" --stdout > \
|
|
|
|
"${DEPLOY_DIR}/${ARCHIVE_FILENAME}${IMG_SUFFIX}.img.gz"
|
|
|
|
;;
|
|
|
|
xz)
|
|
|
|
xz --compress --force --threads 0 --memlimit-compress=50% -"${COMPRESSION_LEVEL}" \
|
|
|
|
--stdout "$IMG_FILE" > "${DEPLOY_DIR}/${ARCHIVE_FILENAME}${IMG_SUFFIX}.img.xz"
|
|
|
|
;;
|
|
|
|
none | *)
|
|
|
|
cp "$IMG_FILE" "$DEPLOY_DIR/"
|
|
|
|
;;
|
|
|
|
esac
|