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