burrow-pi-img/export-image/04-finalise/01-run.sh

82 lines
2.3 KiB
Bash
Raw Normal View History

2016-05-05 18:43:33 +00:00
#!/bin/bash -e
IMG_FILE="${STAGE_WORK_DIR}/${IMG_DATE}-${IMG_NAME}${IMG_SUFFIX}.img"
2017-07-12 11:29:57 +00:00
INFO_FILE="${STAGE_WORK_DIR}/${IMG_DATE}-${IMG_NAME}${IMG_SUFFIX}.info"
2016-05-05 18:43:33 +00:00
on_chroot << EOF
2016-05-05 18:43:33 +00:00
/etc/init.d/fake-hwclock stop
2016-05-19 18:45:54 +00:00
hardlink -t /usr/share/doc
2016-05-05 18:43:33 +00:00
EOF
2016-11-06 14:46:27 +00:00
if [ -d ${ROOTFS_DIR}/home/pi/.config ]; then
chmod 700 ${ROOTFS_DIR}/home/pi/.config
fi
2016-05-05 18:43:33 +00:00
rm -f ${ROOTFS_DIR}/etc/apt/apt.conf.d/51cache
rm -f ${ROOTFS_DIR}/usr/bin/qemu-arm-static
2017-03-30 16:51:23 +00:00
rm -f ${ROOTFS_DIR}/etc/apt/sources.list~
rm -f ${ROOTFS_DIR}/etc/apt/trusted.gpg~
rm -f ${ROOTFS_DIR}/etc/passwd-
rm -f ${ROOTFS_DIR}/etc/group-
rm -f ${ROOTFS_DIR}/etc/shadow-
rm -f ${ROOTFS_DIR}/etc/gshadow-
rm -f ${ROOTFS_DIR}/var/cache/debconf/*-old
rm -f ${ROOTFS_DIR}/var/lib/dpkg/*-old
rm -f ${ROOTFS_DIR}/usr/share/icons/*/icon-theme.cache
rm -f ${ROOTFS_DIR}/var/lib/dbus/machine-id
true > ${ROOTFS_DIR}/etc/machine-id
2017-05-15 15:40:31 +00:00
ln -nsf /proc/mounts ${ROOTFS_DIR}/etc/mtab
2017-03-30 16:51:23 +00:00
for _FILE in $(find ${ROOTFS_DIR}/var/log/ -type f); do
true > ${_FILE}
done
rm -f "${ROOTFS_DIR}/root/.vnc/private.key"
rm -f "${ROOTFS_DIR}/etc/vnc/updateid"
2017-03-30 16:51:23 +00:00
2016-05-05 18:43:33 +00: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/
2017-07-12 11:29:57 +00:00
cp "$ROOTFS_DIR/etc/rpi-issue" "$INFO_FILE"
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" >> "$INFO_FILE"
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" >> "$INFO_FILE"
uname=$(curl -s -L "https://github.com/raspberrypi/firmware/raw/$firmware/extra/uname_string7")
printf "Uname string: %s\n" "$uname" >> "$INFO_FILE"
printf "\nPackages:\n">> "$INFO_FILE"
dpkg -l --root "$ROOTFS_DIR" >> "$INFO_FILE"
2016-05-05 18:43:33 +00:00
ROOT_DEV=$(mount | grep "${ROOTFS_DIR} " | cut -f1 -d' ')
unmount ${ROOTFS_DIR}
zerofree -v ${ROOT_DEV}
unmount_image ${IMG_FILE}
mkdir -p ${DEPLOY_DIR}
rm -f ${DEPLOY_DIR}/image_${IMG_DATE}-${IMG_NAME}${IMG_SUFFIX}.zip
pushd ${STAGE_WORK_DIR} > /dev/null
zip ${DEPLOY_DIR}/image_${IMG_DATE}-${IMG_NAME}${IMG_SUFFIX}.zip $(basename ${IMG_FILE})
popd > /dev/null
2017-07-12 11:29:57 +00:00
cp "$INFO_FILE" "$DEPLOY_DIR"