2016-05-27 10:56:23 +00:00
|
|
|
#!/bin/bash -e
|
|
|
|
|
|
|
|
NOOBS_DIR="${STAGE_WORK_DIR}/${IMG_DATE}-${IMG_NAME}${IMG_SUFFIX}"
|
2018-03-02 20:08:24 +00:00
|
|
|
mkdir -p "${STAGE_WORK_DIR}"
|
2019-11-18 20:50:48 +00:00
|
|
|
|
|
|
|
if [ "${USE_QCOW2}" = "1" ]; then
|
|
|
|
IMG_FILE="${WORK_DIR}/export-image/${IMG_FILENAME}${IMG_SUFFIX}.img"
|
|
|
|
else
|
|
|
|
cp "${WORK_DIR}/export-image/${IMG_FILENAME}${IMG_SUFFIX}.img" "${STAGE_WORK_DIR}/"
|
|
|
|
IMG_FILE="${STAGE_WORK_DIR}/${IMG_FILENAME}${IMG_SUFFIX}.img"
|
|
|
|
fi
|
|
|
|
unmount_image "${IMG_FILE}"
|
2016-05-27 10:56:23 +00:00
|
|
|
|
2018-12-17 00:02:18 +00:00
|
|
|
rm -rf "${NOOBS_DIR}"
|
2016-05-27 10:56:23 +00:00
|
|
|
|
2019-03-18 14:49:18 +00:00
|
|
|
PARTED_OUT=$(parted -sm "${IMG_FILE}" unit b print)
|
|
|
|
BOOT_OFFSET=$(echo "$PARTED_OUT" | grep -e '^1:' | cut -d':' -f 2 | tr -d B)
|
|
|
|
BOOT_LENGTH=$(echo "$PARTED_OUT" | grep -e '^1:' | cut -d':' -f 4 | tr -d B)
|
|
|
|
|
|
|
|
ROOT_OFFSET=$(echo "$PARTED_OUT" | grep -e '^2:' | cut -d':' -f 2 | tr -d B)
|
|
|
|
ROOT_LENGTH=$(echo "$PARTED_OUT" | grep -e '^2:' | cut -d':' -f 4 | tr -d B)
|
2017-01-23 12:44:03 +00:00
|
|
|
|
2018-03-02 20:08:24 +00:00
|
|
|
BOOT_DEV=$(losetup --show -f -o "${BOOT_OFFSET}" --sizelimit "${BOOT_LENGTH}" "${IMG_FILE}")
|
|
|
|
ROOT_DEV=$(losetup --show -f -o "${ROOT_OFFSET}" --sizelimit "${ROOT_LENGTH}" "${IMG_FILE}")
|
2017-01-23 12:44:03 +00:00
|
|
|
echo "/boot: offset $BOOT_OFFSET, length $BOOT_LENGTH"
|
|
|
|
echo "/: offset $ROOT_OFFSET, length $ROOT_LENGTH"
|
2016-05-27 10:56:23 +00:00
|
|
|
|
2018-03-02 20:08:24 +00:00
|
|
|
mkdir -p "${STAGE_WORK_DIR}/rootfs"
|
|
|
|
mkdir -p "${NOOBS_DIR}"
|
2016-05-27 10:56:23 +00:00
|
|
|
|
2018-03-02 20:08:24 +00:00
|
|
|
mount "$ROOT_DEV" "${STAGE_WORK_DIR}/rootfs"
|
|
|
|
mount "$BOOT_DEV" "${STAGE_WORK_DIR}/rootfs/boot"
|
2016-05-27 10:56:23 +00:00
|
|
|
|
2017-07-12 11:33:57 +00:00
|
|
|
ln -sv "/lib/systemd/system/apply_noobs_os_config.service" "$ROOTFS_DIR/etc/systemd/system/multi-user.target.wants/apply_noobs_os_config.service"
|
|
|
|
|
2019-03-11 11:49:04 +00:00
|
|
|
bsdtar --numeric-owner --format gnutar -C "${STAGE_WORK_DIR}/rootfs/boot" -cpf - . | xz -T0 > "${NOOBS_DIR}/boot.tar.xz"
|
2018-03-02 20:08:24 +00:00
|
|
|
umount "${STAGE_WORK_DIR}/rootfs/boot"
|
2019-03-11 11:49:04 +00:00
|
|
|
bsdtar --numeric-owner --format gnutar -C "${STAGE_WORK_DIR}/rootfs" --one-file-system -cpf - . | xz -T0 > "${NOOBS_DIR}/root.tar.xz"
|
2016-05-27 10:56:23 +00:00
|
|
|
|
2018-03-02 20:08:24 +00:00
|
|
|
unmount_image "${IMG_FILE}"
|