I first noticed that checksums weren't calculated if a relative path was used,
since they're done after moving into the $tmpdir and relative paths become
useless. Then I saw that PGP sigs had basically the same problem, with the
addition of the introduction of $startdir, which was never set beforehand
(cut-n-paste from makepkg?). Seeing that having this value known would solve
both problems, I just defined it and used it for the checksums as well.

Signed-off-by: Ray Kohler <[email protected]>
---
 scripts/repo-add.sh.in |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/scripts/repo-add.sh.in b/scripts/repo-add.sh.in
index 59e98cf..0461c7a 100644
--- a/scripts/repo-add.sh.in
+++ b/scripts/repo-add.sh.in
@@ -235,7 +235,8 @@ db_write_entry()
        # blank out all variables
        local pkgfile="$1"
        local pkgname pkgver pkgdesc csize size md5sum url arch builddate 
packager \
-               _groups _licenses _replaces _depends _conflicts _provides 
_optdepends
+               startdir _groups _licenses _replaces _depends _conflicts 
_provides \
+               _optdepends
 
        local OLDIFS="$IFS"
        # IFS (field separator) is only the newline character
@@ -271,6 +272,8 @@ db_write_entry()
                return 1
        fi
 
+       startdir=$(pwd)
+
        pushd "$tmpdir" >/dev/null
        if [[ -d $pkgname-$pkgver ]]; then
                warning "$(gettext "An entry for '%s' already existed")" 
"$pkgname-$pkgver"
@@ -286,9 +289,9 @@ db_write_entry()
 
        # compute checksums
        msg2 "$(gettext "Computing checksums...")"
-       md5sum="$(openssl dgst -md5 "$pkgfile")"
+       md5sum="$(openssl dgst -md5 "$startdir/$pkgfile")"
        md5sum="${md5sum##* }"
-       sha256sum="$(openssl dgst -sha256 "$pkgfile")"
+       sha256sum="$(openssl dgst -sha256 "$startdir/$pkgfile")"
        sha256sum="${sha256sum##* }"
 
        # remove an existing entry if it exists, ignore failures
@@ -317,7 +320,7 @@ db_write_entry()
        echo -e "%SHA256SUM%\n$sha256sum\n" >>desc
 
        # add base64'd PGP signature
-       if [[ -f $startdir/$pkgfile.sig ]]; then
+       if [[ -f "$startdir/$pkgfile.sig" ]]; then
                pgpsig=$(openssl base64 -in "$startdir/$pkgfile.sig" | tr -d 
'\n')
                echo -e "%PGPSIG%\n$pgpsig\n" >>desc
        fi
-- 
1.7.4.1


Reply via email to