diff options
author | merakor <cem@ckyln.com> | 2020-08-31 13:43:15 +0000 |
---|---|---|
committer | merakor <cem@ckyln.com> | 2020-08-31 13:43:15 +0000 |
commit | 81bdb80195f2af27490ff64891a549582f07732f (patch) | |
tree | eca960650cbf127eacd64cf98f9ddb7543068018 | |
parent | 4eede95064c255b47b6687e62ece4939d427b675 (diff) | |
download | cpt-81bdb80195f2af27490ff64891a549582f07732f.tar.gz |
cpt-lib: switch to the same method for checksums with kiss
FossilOrigin-Name: c19cbb2754fdc62aab4691c28343402b06091c77a329f0cef6c85f5e965e91a1
-rw-r--r-- | src/cpt-lib | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/cpt-lib b/src/cpt-lib index f2e8caf..3f6df23 100644 --- a/src/cpt-lib +++ b/src/cpt-lib @@ -387,7 +387,7 @@ sh256() { openssl dgst -r -sha256 "$1" || die "No sha256 program could be run." ;} | - while read -r hash _; do printf '%s %s\n' "$hash" "$1"; done + while read -r hash _; do printf '%s\n' "$hash"; done } pkg_isbuilt() ( @@ -409,7 +409,7 @@ pkg_lint() { repo_dir=$(pkg_find "$1") cd "$repo_dir" || die "'$repo_dir' not accessible" - [ -f sources ] || die "$1" "Sources file not found" + [ -f sources ] || warn "$1" "Sources file not found" [ -x build ] || die "$1" "Build file not found or not executable" [ -s version ] || die "$1" "Version file not found or empty" @@ -1063,6 +1063,8 @@ pkg_checksums() { # Generate checksums for packages. repo_dir=$(pkg_find "$1") + [ -f "$repo_dir/sources" ] || return 0 + while read -r src _ || [ "$src" ]; do # Comment. if [ -z "${src##\#*}" ]; then @@ -1077,9 +1079,7 @@ pkg_checksums() { src_path=$src_dir/$1 # File is a git repository. - elif [ -z "${src##git+*}" ]; then - printf 'git %s\n' "$src" - continue + elif [ -z "${src##git+*}" ]; then continue # Die here if source for some reason, doesn't exist. else @@ -1094,10 +1094,15 @@ pkg_checksums() { } pkg_verify() { - # Verify all package checksums. This is achieved by generating - # a new set of checksums and then comparing those with the old - # set. - for pkg do pkg_checksums "$pkg" | diff - "$(pkg_find "$pkg")/checksums" || { + # Verify all package checksums. This is achieved by generating a new set of + # checksums and then comparing those with the old set. + verify_cmd="NR==FNR{a[\$1];next}/^git .*/{next}!((\$1)in a){exit 1}" + + for pkg; do + repo_dir=$(pkg_find "$pkg") + [ -f "$repo_dir/sources" ] || continue + + pkg_checksums "$pkg" | awk "$verify_cmd" - "$repo_dir/checksums" || { log "$pkg" "Checksum mismatch" # Instead of dying above, log it to the terminal. Also define a |