Updated the script build_all_shredos.sh so that if the defconfig is lite or extra then lite and plus-partitionare inserted into the filename immediately prior to the extension. The placing of this extra information at the end of the version information is important. In this position it doesn't interfere with the search that is conducted in the script find_shredos_boot_script.sh in relation to the search for the shredos boot disc. The sha1 checksum is calculated and placed in a file with the same name as the image but with the addition of the extension.sha1. These .sha1 files are also copied to the folder dist/ along with the corresponding .iso or .img file. The addition of this extra information in the filenames makes the files unique amongst the group of build files. This is required when the .iso and .img files are uploaded when a ShredOS release is published

This commit is contained in:
PartialVolume
2026-01-31 23:35:15 +00:00
parent 6ede7ef074
commit e06ba53380

View File

@@ -409,9 +409,12 @@ build_config_success() {
run_cmd mv "$log_file" "dist/${config}-SUCCESS.log"
fi
rename_and_checksum_images "$config"
run_cmd mkdir -p "dist/$config"
run_cmd mv output/images/shredos*.iso "dist/$config/" 2>/dev/null || true
run_cmd mv output/images/shredos*.img "dist/$config/" 2>/dev/null || true
run_cmd mv output/images/shredos*.sha1 "dist/$config/" 2>/dev/null || true
printf "%b" "$GREEN"
echo
@@ -463,6 +466,79 @@ build_config_failed() {
fi
}
# Function to handle suffix insertion before the extension
insert_suffix() {
local fname="$1"
local suffix="$2"
local base="${fname%.*}"
local ext="${fname##*.}"
echo "${base}${suffix}.${ext}"
}
rename_and_checksum_images() {
local config="$1"
target_dir="output/images"
# If the defconfig contains the string `lite`, i.e a reduced size
# so it will boot on systems with only 512MB of RAM then insert
# into the .iso or .img filename the string _lite prior to the extension.
if [[ "$config" == *"lite"* ]]; then
shopt -s nullglob
for file in "$target_dir"/shredos*.{iso,img}; do
filename=$(basename "$file")
if [[ "$filename" != *"_lite"* ]]; then
new_name=$(insert_suffix "$filename" "_lite")
mv -v "$file" "$target_dir/$new_name"
fi
done
shopt -u nullglob
else
echo "Condition not met: 'lite' not in $config, rename not necessary."
fi
# If the defconfig contains the string `extra`, i.e an extra partition
# then insert into the .iso or .img filename the string _plus-partition
if [[ "$config" == *"extra"* ]]; then
shopt -s nullglob
for file in "$target_dir"/shredos*.{iso,img}; do
filename=$(basename "$file")
if [[ "$filename" != *"_plus-partition"* ]]; then
new_name=$(insert_suffix "$filename" "_plus-partition")
mv -v "$file" "$target_dir/$new_name"
fi
done
shopt -u nullglob
else
echo "Condition not met: 'extra' not in $config, rename not necessary."
fi
# Clean up orphaned .sha1 files (that don't match any existing image)
echo "Cleaning up orphaned .sha1 files..."
shopt -s nullglob
for sha_file in "$target_dir"/shredos*.sha1; do
# Strip .sha1 to find the base image name
corresponding_image="${sha_file%.sha1}"
if [[ ! -f "$corresponding_image" ]]; then
rm -v "$sha_file"
fi
done
shopt -u nullglob
# Calculate SHA1 for all final files
echo "Calculating SHA1 checksums..."
current_dir=$(pwd)
cd "$target_dir" || exit
shopt -s nullglob
for file in shredos*.{iso,img}; do
sha1sum "$file" > "$file.sha1"
done
shopt -u nullglob
cd $current_dir || exit
echo "[DONE]"
}
################################################################################
if [ -f "build_all_shredos.log" ]; then