Fixed typo, or loss of current thought or something lol.
This commit is contained in:
+39
-16
@@ -31,7 +31,7 @@ verify_image() {
|
||||
e2fsck -fn "${loopdev}p2"
|
||||
}
|
||||
|
||||
# shellcheck disable=SC2329 # compress_image is invoked from cleanup, which is invoked via trap EXIT
|
||||
# shellcheck disable=SC2329 # compress_image is invoked from finish_build
|
||||
compress_image() {
|
||||
local compressedImage="${imageName}.xz"
|
||||
|
||||
@@ -42,21 +42,21 @@ compress_image() {
|
||||
|
||||
echo "Compressing ${imageName} to ${compressedImage}..."
|
||||
xz -T0 -9 "${imageName}"
|
||||
echo "Creating SHA-256 checksum for ${compressedImage}..."
|
||||
echo "Creating SHA-1 checksum for ${compressedImage}..."
|
||||
sha1sum "${compressedImage}" > "${compressedImage}.sha1sum"
|
||||
echo "Image build complete: ${compressedImage}"
|
||||
echo "Checksum: ${compressedImage}.sha1sum"
|
||||
}
|
||||
|
||||
# shellcheck disable=SC2329 # cleanup is invoked via trap EXIT
|
||||
cleanup() {
|
||||
status=$? # capture original exit status so failures propagate
|
||||
cleanupStatus=0
|
||||
# shellcheck disable=SC2329 # cleanup_image is invoked from cleanup and finish_build
|
||||
cleanup_image() {
|
||||
local verifyFilesystems="${1:-false}"
|
||||
local cleanupStatus=0
|
||||
|
||||
if [[ $mounted -eq 0 ]]; then
|
||||
if ! umount -R /mnt; then
|
||||
cleanupStatus=1
|
||||
elif [[ $status -eq 0 ]]; then
|
||||
elif [[ "$verifyFilesystems" == true ]]; then
|
||||
if ! verify_image; then
|
||||
cleanupStatus=1
|
||||
fi
|
||||
@@ -77,11 +77,19 @@ cleanup() {
|
||||
rm -rf "${tmpDir}"
|
||||
fi
|
||||
|
||||
if [[ $status -eq 0 && $cleanupStatus -eq 0 ]]; then
|
||||
if ! compress_image; then
|
||||
status=1
|
||||
fi
|
||||
elif [[ $status -eq 0 ]]; then
|
||||
return "$cleanupStatus"
|
||||
}
|
||||
|
||||
# shellcheck disable=SC2329 # cleanup is invoked via trap EXIT
|
||||
cleanup() {
|
||||
local status=$? # capture original exit status so failures propagate
|
||||
local cleanupStatus=0
|
||||
|
||||
if ! cleanup_image false; then
|
||||
cleanupStatus=1
|
||||
fi
|
||||
|
||||
if [[ $status -eq 0 && $cleanupStatus -ne 0 ]]; then
|
||||
echo "Image build commands completed, but cleanup or filesystem verification failed."
|
||||
status=1
|
||||
fi
|
||||
@@ -89,6 +97,21 @@ cleanup() {
|
||||
exit "$status"
|
||||
}
|
||||
|
||||
finish_build() {
|
||||
trap - EXIT
|
||||
|
||||
if ! cleanup_image true; then
|
||||
echo "Image build commands completed, but cleanup or filesystem verification failed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! compress_image; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
||||
}
|
||||
|
||||
help() {
|
||||
echo -e "Usage:\n"
|
||||
echo "With no arguments, build with default parameters."
|
||||
@@ -143,7 +166,7 @@ if [[ -e "$imageName" ]]; then
|
||||
echo "${imageName} exists, please remove or move it for this script to continue."
|
||||
exit 1
|
||||
fi
|
||||
for outputFile in "${imageName}.xz" "${imageName}.xz.sha256sum"; do
|
||||
for outputFile in "${imageName}.xz" "${imageName}.xz.sha1sum"; do
|
||||
if [[ -e "$outputFile" ]]; then
|
||||
echo "${outputFile} exists, please remove or move it for this script to continue."
|
||||
exit 1
|
||||
@@ -173,7 +196,7 @@ for i in arch-install-scripts dosfstools parted ; do
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
for i in e2fsck fsck.vfat sha256sum xz ; do
|
||||
for i in e2fsck fsck.vfat sha1sum xz ; do
|
||||
if ! command -v "$i" &> /dev/null ; then
|
||||
echo "Please install ${i} before continuing."
|
||||
exit 1
|
||||
@@ -447,5 +470,5 @@ find ../files/etc/skel/ -mindepth 1 -exec cp -rv "{}" /mnt/home/stormux/ \;
|
||||
# Copy boot files again to ensure custom config overrides any package changes
|
||||
cp -rv ../files/boot/* /mnt/boot
|
||||
|
||||
# Exiting calls the cleanup function to unmount.
|
||||
exit 0
|
||||
# Clean up, verify, compress, and create the checksum.
|
||||
finish_build
|
||||
|
||||
Reference in New Issue
Block a user