rocky-linux-generic-images/create-image.sh

56 lines
1.6 KiB
Bash
Raw Normal View History

2023-07-27 14:23:23 +00:00
#!/usr/bin/env bash
2023-07-29 07:32:14 +00:00
set -x
APPLIANCE_NAME="Rocky-9-aarch64-Orange-Pi-5-minimal"
2023-07-27 14:23:23 +00:00
KICKSTARTER_FILENAME="${APPLIANCE_NAME}.ks"
2023-07-29 07:47:09 +00:00
IMAGE_NAME="${APPLIANCE_NAME}-$(TZ='UTC' date +%Y.%m.%d-%H%M%S).raw"
2023-07-29 07:32:14 +00:00
COMPRESSED_IMAGE_NAME="${IMAGE_NAME}.zst"
2023-07-27 14:23:23 +00:00
if [[ ${EUID} -ne 0 ]]; then
2023-07-29 08:55:27 +00:00
>&2 echo "$0: error: Please run this script as root"
exit 1
fi
if ! command -v appliance-creator > /dev/null; then
>&2 echo "$0: error: unable to find command 'appliance-creator'"
exit 1
fi
if ! command -v shasum > /dev/null; then
>&2 echo "$0: error: unable to find command 'shasum'"
2023-07-27 14:23:23 +00:00
exit 1
fi
appliance-creator \
--config "${KICKSTARTER_FILENAME}" \
--name "${APPLIANCE_NAME}" \
--format raw \
--no-compress \
--outdir "${PWD}" \
--debug \
--verbose
# DO NOT USE THE '--checksum' OPTION BECAUSE, FOR SOME REASON
# UTF8 ERRORS ARE GENERATED DURING IMAGE CREATION
# AND THE IMAGE CREATION STEP FAILS
#--checksum \
# DO NOT USE THE '--cache' OPTION SINCE IT USES OLDER VERSIONS
# OF PACKAGES, WHICH IS THE WORST WHEN TESTING CHANGES:w
#--cache "/root/cache" \
if [[ -d "${APPLIANCE_NAME}" ]]; then
pushd "${APPLIANCE_NAME}" || exit 1
mv -v -f "${APPLIANCE_NAME}-sda.raw" "${IMAGE_NAME}"
zstd -9 -z "${IMAGE_NAME}"
sha256sum "${IMAGE_NAME}" > "${IMAGE_NAME}.sha256"
sha512sum "${IMAGE_NAME}" > "${IMAGE_NAME}.sha512"
sha256sum "${COMPRESSED_IMAGE_NAME}" > "${COMPRESSED_IMAGE_NAME}.sha256"
sha512sum "${COMPRESSED_IMAGE_NAME}" > "${COMPRESSED_IMAGE_NAME}.sha512"
popd || exit 1
echo 'DONE'
echo "Please chown '${APPLIANCE_NAME}/' if necessary"
fi