aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/%HOME%
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--%HOME%/.bash_utils/distr.sh35
1 files changed, 31 insertions, 4 deletions
diff --git a/%HOME%/.bash_utils/distr.sh b/%HOME%/.bash_utils/distr.sh
index 06d342a..58e088a 100644
--- a/%HOME%/.bash_utils/distr.sh
+++ b/%HOME%/.bash_utils/distr.sh
@@ -7,9 +7,36 @@
checksums_path='sha1sums.txt'
-update_checksums() {
- sha1sum -- "$@" > "$checksums_path"
-}
+list_checksums_paths() (
+ set -o errexit -o nounset -o pipefail
+
+ if [ -f "$checksums_path" ]; then
+ local path
+ while IFS= read -r path; do
+ printf "$path"'\0'
+ done < <( sed --binary 's/^\\\?[[:alnum:]]\+ [ *]//' "$checksums_path" )
+ fi
+)
+
+update_checksums() (
+ set -o errexit -o nounset -o pipefail
+
+ local path
+
+ local -A existing
+ while IFS= read -d '' -r path; do
+ existing[$path]=1
+ done < <( list_checksums_paths )
+
+ local -a missing
+ for path in "$@"; do
+ if [ -z "${existing[$path]+x}" ]; then
+ missing+=("$path")
+ fi
+ done
+
+ sha1sum -- "${missing[@]+"${missing[@]}"}" >> "$checksums_path"
+)
update_checksums_distr() (
set -o errexit -o nounset -o pipefail
@@ -19,7 +46,7 @@ update_checksums_distr() (
while IFS= read -d '' -r path; do
paths+=("$path")
- done < <( find . -type f -\( -iname '*.exe' -o -iname '*.iso' -\) -print0 )
+ done < <( find . -type f -\( -iname '*.exe' -o -iname '*.iso' -\) -printf '%P\0' )
update_checksums "${paths[@]+"${paths[@]}"}"
)