1
0
mirror of https://codeberg.org/kiss-community/kiss synced 2024-12-23 07:30:16 -07:00

sh256: add back checks

This commit is contained in:
Dylan Araps 2021-07-06 13:16:34 +03:00
parent 2f48bff2e7
commit 2cd3422ff6
No known key found for this signature in database
GPG Key ID: 13295DAC2CF13B5C

26
kiss
View File

@ -141,16 +141,20 @@ sh256() {
# All utilities must match 'sha256sum' output.
#
# Example: '<checksum> <file>'
hash=$(
sha256sum "$1" ||
sha256 -r "$1" ||
openssl dgst -sha256 -r "$1" ||
shasum -a 256 "$1" ||
digest -a sha256 "$1"
) 2>/dev/null || die "Failed to generate checksums for '$1'"
hash=
hash=${hash%% *}
printf '%s\n' "$hash"
if [ ! -d "$1" ] && [ -e "$1" ]; then
hash=$(
sha256sum "$1" ||
sha256 -r "$1" ||
openssl dgst -sha256 -r "$1" ||
shasum -a 256 "$1" ||
digest -a sha256 "$1"
) 2>/dev/null || die "Failed to generate checksums for '$1'"
hash=${hash%% *}
printf '%s\n' "$hash"
fi
}
pkg_lint() {
@ -627,7 +631,7 @@ pkg_etcsums() {
# This can't be a simple 'find -exec' as 'sh256' is a shell function
# and not a real command of any kind. This is the shell equivalent.
find "$pkg_dir/$1/etc" ! -type d | sort | while read -r line; do
[ ! -e "$line" ] || sh256 "$line"
sh256 "$line"
done > "$pkg_dir/$1/$pkg_db/$1/etcsums"
}
@ -1086,7 +1090,7 @@ pkg_remove_files() {
while read -r file; do
case $file in /etc/?*[!/])
sh256 "$KISS_ROOT/$file" >/dev/null
sum_old=$(grep -F "$hash" "$mak_dir/c")
sum_old=$(grep -F "${hash:=null}" "$mak_dir/c")
[ "$hash" = "$sum_old" ] || {
printf 'Skipping %s (modified)\n' "$file"