2016-05-05 14:43:33 -04:00
|
|
|
#!/bin/bash -e
|
|
|
|
|
2019-01-21 13:42:54 -05:00
|
|
|
IMG_FILE="${STAGE_WORK_DIR}/${IMG_FILENAME}${IMG_SUFFIX}.img"
|
|
|
|
INFO_FILE="${STAGE_WORK_DIR}/${IMG_FILENAME}${IMG_SUFFIX}.info"
|
2016-05-05 14:43:33 -04:00
|
|
|
|
2016-11-14 18:55:45 -05:00
|
|
|
on_chroot << EOF
|
2016-05-05 14:43:33 -04:00
|
|
|
/etc/init.d/fake-hwclock stop
|
2016-05-19 14:45:54 -04:00
|
|
|
hardlink -t /usr/share/doc
|
2016-05-05 14:43:33 -04:00
|
|
|
EOF
|
|
|
|
|
2019-01-14 18:39:48 -05:00
|
|
|
if [ -d "${ROOTFS_DIR}/home/${FIRST_USER_NAME}/.config" ]; then
|
|
|
|
chmod 700 "${ROOTFS_DIR}/home/${FIRST_USER_NAME}/.config"
|
2016-11-06 09:46:27 -05:00
|
|
|
fi
|
|
|
|
|
2018-03-02 15:08:24 -05:00
|
|
|
rm -f "${ROOTFS_DIR}/etc/apt/apt.conf.d/51cache"
|
|
|
|
rm -f "${ROOTFS_DIR}/usr/bin/qemu-arm-static"
|
2016-05-05 14:43:33 -04:00
|
|
|
|
2018-03-02 15:08:24 -05:00
|
|
|
rm -f "${ROOTFS_DIR}/etc/apt/sources.list~"
|
|
|
|
rm -f "${ROOTFS_DIR}/etc/apt/trusted.gpg~"
|
2017-03-30 12:51:23 -04:00
|
|
|
|
2018-03-02 15:08:24 -05: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 04:43:42 -04:00
|
|
|
rm -f "${ROOTFS_DIR}/etc/subuid-"
|
|
|
|
rm -f "${ROOTFS_DIR}/etc/subgid-"
|
2017-03-30 12:51:23 -04:00
|
|
|
|
2018-03-26 08:06:10 -04:00
|
|
|
rm -f "${ROOTFS_DIR}"/var/cache/debconf/*-old
|
|
|
|
rm -f "${ROOTFS_DIR}"/var/lib/dpkg/*-old
|
2017-03-30 12:51:23 -04:00
|
|
|
|
2018-03-26 08:06:10 -04:00
|
|
|
rm -f "${ROOTFS_DIR}"/usr/share/icons/*/icon-theme.cache
|
2017-03-30 12:51:23 -04:00
|
|
|
|
2018-03-02 15:08:24 -05:00
|
|
|
rm -f "${ROOTFS_DIR}/var/lib/dbus/machine-id"
|
2017-03-30 12:51:23 -04:00
|
|
|
|
2018-03-02 15:08:24 -05:00
|
|
|
true > "${ROOTFS_DIR}/etc/machine-id"
|
2017-03-30 12:51:23 -04:00
|
|
|
|
2018-03-02 15:08:24 -05:00
|
|
|
ln -nsf /proc/mounts "${ROOTFS_DIR}/etc/mtab"
|
2017-05-15 11:40:31 -04:00
|
|
|
|
2018-03-02 15:08:24 -05:00
|
|
|
find "${ROOTFS_DIR}/var/log/" -type f -exec cp /dev/null {} \;
|
2017-03-30 12:51:23 -04:00
|
|
|
|
|
|
|
rm -f "${ROOTFS_DIR}/root/.vnc/private.key"
|
2017-11-21 17:04:33 -05:00
|
|
|
rm -f "${ROOTFS_DIR}/etc/vnc/updateid"
|
2017-03-30 12:51:23 -04:00
|
|
|
|
2018-03-02 15:08:24 -05:00
|
|
|
update_issue "$(basename "${EXPORT_DIR}")"
|
|
|
|
install -m 644 "${ROOTFS_DIR}/etc/rpi-issue" "${ROOTFS_DIR}/boot/issue.txt"
|
|
|
|
install files/LICENSE.oracle "${ROOTFS_DIR}/boot/"
|
2016-05-05 14:43:33 -04:00
|
|
|
|
2017-07-12 07:29:57 -04:00
|
|
|
|
|
|
|
cp "$ROOTFS_DIR/etc/rpi-issue" "$INFO_FILE"
|
|
|
|
|
|
|
|
|
2018-03-02 15:08:24 -05:00
|
|
|
{
|
|
|
|
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 07:29:57 -04:00
|
|
|
|
2018-03-02 15:08:24 -05: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 07:29:57 -04:00
|
|
|
|
2018-03-02 15:08:24 -05:00
|
|
|
uname="$(curl -s -L "https://github.com/raspberrypi/firmware/raw/$firmware/extra/uname_string7")"
|
2017-07-12 07:29:57 -04:00
|
|
|
|
2018-03-02 15:08:24 -05:00
|
|
|
printf "Uname string: %s\n" "$uname"
|
|
|
|
printf "\nPackages:\n"
|
|
|
|
dpkg -l --root "$ROOTFS_DIR"
|
|
|
|
} >> "$INFO_FILE"
|
2017-07-12 07:29:57 -04:00
|
|
|
|
2018-03-02 15:08:24 -05:00
|
|
|
ROOT_DEV="$(mount | grep "${ROOTFS_DIR} " | cut -f1 -d' ')"
|
2016-05-05 14:43:33 -04:00
|
|
|
|
2018-03-02 15:08:24 -05:00
|
|
|
unmount "${ROOTFS_DIR}"
|
2019-01-30 15:48:22 -05:00
|
|
|
zerofree "${ROOT_DEV}"
|
2016-05-05 14:43:33 -04:00
|
|
|
|
2018-03-02 15:08:24 -05:00
|
|
|
unmount_image "${IMG_FILE}"
|
2016-05-05 14:43:33 -04:00
|
|
|
|
2018-03-02 15:08:24 -05:00
|
|
|
mkdir -p "${DEPLOY_DIR}"
|
2016-05-05 14:43:33 -04:00
|
|
|
|
2019-01-21 13:42:54 -05:00
|
|
|
rm -f "${DEPLOY_DIR}/${ZIP_FILENAME}${IMG_SUFFIX}.zip"
|
2019-01-30 13:09:36 -05:00
|
|
|
rm -f "${DEPLOY_DIR}/${IMG_FILENAME}${IMG_SUFFIX}.img"
|
|
|
|
|
|
|
|
if [ "${DEPLOY_ZIP}" == "1" ]; then
|
|
|
|
pushd "${STAGE_WORK_DIR}" > /dev/null
|
|
|
|
zip "${DEPLOY_DIR}/${ZIP_FILENAME}${IMG_SUFFIX}.zip" \
|
|
|
|
"$(basename "${IMG_FILE}")"
|
|
|
|
popd > /dev/null
|
|
|
|
else
|
|
|
|
cp "$IMG_FILE" "$DEPLOY_DIR"
|
|
|
|
fi
|
2017-07-12 07:29:57 -04:00
|
|
|
|
|
|
|
cp "$INFO_FILE" "$DEPLOY_DIR"
|