clic-rpi-image/export-noobs/00-release/00-run.sh

49 lines
1.9 KiB
Bash
Raw Permalink Normal View History

2016-05-27 10:56:23 +00:00
#!/bin/bash -e
2021-09-20 14:16:15 +00:00
NOOBS_DIR="${STAGE_WORK_DIR}/${IMG_NAME}${IMG_SUFFIX}"
2016-05-27 10:56:23 +00:00
2018-03-02 20:08:24 +00:00
install -v -m 744 files/partition_setup.sh "${NOOBS_DIR}/"
install -v files/partitions.json "${NOOBS_DIR}/"
install -v files/os.json "${NOOBS_DIR}/"
install -v files/OS.png "${NOOBS_DIR}/"
install -v files/release_notes.txt "${NOOBS_DIR}/"
2016-05-27 10:56:23 +00:00
2018-03-02 20:08:24 +00:00
tar -v -c -C files/marketing -f "${NOOBS_DIR}/marketing.tar" .
2016-05-27 10:56:23 +00:00
2019-06-07 14:55:54 +00:00
BOOT_SHASUM="$(sha256sum "${NOOBS_DIR}/boot.tar.xz" | cut -f1 -d' ')"
ROOT_SHASUM="$(sha256sum "${NOOBS_DIR}/root.tar.xz" | cut -f1 -d' ')"
2018-03-02 20:08:24 +00:00
BOOT_SIZE="$(xz --robot -l "${NOOBS_DIR}/boot.tar.xz" | grep totals | cut -f 5)"
ROOT_SIZE="$(xz --robot -l "${NOOBS_DIR}/root.tar.xz" | grep totals | cut -f 5)"
2016-05-27 10:56:23 +00:00
2018-10-30 13:07:28 +00:00
BOOT_SIZE="$(( BOOT_SIZE / 1024 / 1024 + 1))"
ROOT_SIZE="$(( ROOT_SIZE / 1024 / 1024 + 1))"
2016-05-27 10:56:23 +00:00
2019-06-07 14:51:06 +00:00
BOOT_NOM="256"
ROOT_NOM="$(echo "$ROOT_SIZE" | awk '{printf "%.0f", (($1 + 400) * 1.2) + 0.5 }')"
2016-05-27 10:56:23 +00:00
2018-03-02 20:08:24 +00:00
mv "${NOOBS_DIR}/OS.png" "${NOOBS_DIR}/${NOOBS_NAME// /_}.png"
2019-06-07 14:55:54 +00:00
sed "${NOOBS_DIR}/partitions.json" -i -e "s|BOOT_SHASUM|${BOOT_SHASUM}|"
sed "${NOOBS_DIR}/partitions.json" -i -e "s|ROOT_SHASUM|${ROOT_SHASUM}|"
2018-03-02 20:08:24 +00:00
sed "${NOOBS_DIR}/partitions.json" -i -e "s|BOOT_SIZE|${BOOT_SIZE}|"
sed "${NOOBS_DIR}/partitions.json" -i -e "s|ROOT_SIZE|${ROOT_SIZE}|"
2016-05-27 10:56:23 +00:00
2018-03-02 20:08:24 +00:00
sed "${NOOBS_DIR}/partitions.json" -i -e "s|BOOT_NOM|${BOOT_NOM}|"
sed "${NOOBS_DIR}/partitions.json" -i -e "s|ROOT_NOM|${ROOT_NOM}|"
2016-05-27 10:56:23 +00:00
2018-03-02 20:08:24 +00:00
sed "${NOOBS_DIR}/os.json" -i -e "s|UNRELEASED|${IMG_DATE}|"
sed "${NOOBS_DIR}/os.json" -i -e "s|NOOBS_NAME|${NOOBS_NAME}|"
sed "${NOOBS_DIR}/os.json" -i -e "s|NOOBS_DESCRIPTION|${NOOBS_DESCRIPTION}|"
sed "${NOOBS_DIR}/os.json" -i -e "s|RELEASE|${RELEASE}|"
sed "${NOOBS_DIR}/os.json" -i -e "s|KERNEL|$(cat "${STAGE_WORK_DIR}/kernel_version")|"
2018-03-02 20:08:24 +00:00
sed "${NOOBS_DIR}/release_notes.txt" -i -e "s|UNRELEASED|${IMG_DATE}|"
2016-05-27 10:56:23 +00:00
2021-02-10 10:37:15 +00:00
if [ "${USE_QCOW2}" = "1" ]; then
mv "${NOOBS_DIR}" "${DEPLOY_DIR}/"
else
cp -a "${NOOBS_DIR}" "${DEPLOY_DIR}/"
fi