1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-12-22 15:58:50 -05:00

Fix use of relative paths for packages in repo-add

Move checksum and pgpsig calcluation before changing into the
tmpdir, otherwise we can't find the files if a relative path
was used.

Signed-off-by: Ray Kohler <ataraxia937@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Ray Kohler 2011-03-24 18:05:30 -04:00 committed by Dan McGee
parent a8b22e16ef
commit cfa2eebdaf

View File

@ -234,8 +234,9 @@ 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
local pkgname pkgver pkgdesc csize size url arch builddate packager \
_groups _licenses _replaces _depends _conflicts _provides _optdepends \
md5sum sha256sum pgpsig
local OLDIFS="$IFS"
# IFS (field separator) is only the newline character
@ -265,6 +266,18 @@ db_write_entry()
csize=$(@SIZECMD@ "$pkgfile")
# compute checksums
msg2 "$(gettext "Computing checksums...")"
md5sum="$(openssl dgst -md5 "$pkgfile")"
md5sum="${md5sum##* }"
sha256sum="$(openssl dgst -sha256 "$pkgfile")"
sha256sum="${sha256sum##* }"
# compute base64'd PGP signature
if [[ -f "$pkgfile.sig" ]]; then
pgpsig=$(openssl base64 -in "$pkgfile.sig" | tr -d '\n')
fi
# ensure $pkgname and $pkgver variables were found
if [[ -z $pkgname || -z $pkgver ]]; then
error "$(gettext "Invalid package file '%s'.")" "$pkgfile"
@ -284,13 +297,6 @@ db_write_entry()
fi
fi
# compute checksums
msg2 "$(gettext "Computing checksums...")"
md5sum="$(openssl dgst -md5 "$pkgfile")"
md5sum="${md5sum##* }"
sha256sum="$(openssl dgst -sha256 "$pkgfile")"
sha256sum="${sha256sum##* }"
# remove an existing entry if it exists, ignore failures
db_remove_entry "$pkgname"
@ -316,11 +322,8 @@ db_write_entry()
echo -e "%MD5SUM%\n$md5sum\n" >>desc
echo -e "%SHA256SUM%\n$sha256sum\n" >>desc
# add base64'd PGP signature
if [[ -f $startdir/$pkgfile.sig ]]; then
pgpsig=$(openssl base64 -in "$startdir/$pkgfile.sig" | tr -d '\n')
echo -e "%PGPSIG%\n$pgpsig\n" >>desc
fi
# add PGP sig
[[ -n $pgpsig ]] && echo -e "%PGPSIG%\n$pgpsig\n" >>desc
[[ -n $url ]] && echo -e "%URL%\n$url\n" >>desc
write_list_entry "LICENSE" "$_licenses" "desc"