[pacman-dev] [PATCH] Fix use of relative paths for packages in repo-add

Dan McGee dpmcgee at gmail.com
Thu Mar 24 17:53:04 EDT 2011


On Thu, Mar 24, 2011 at 4:46 PM, Ray Kohler <ataraxia937 at gmail.com> wrote:
> 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.

Hmm. This is caused by bitrot, actually: commit 7ce90bb removed
startdir on purpose. I'd prefer a fix that does not reintroduce this-
e.g. just moving the checksum calculation block before the first pushd
call, as well as doing the PGP business there too if necessary.

>
> Signed-off-by: Ray Kohler <ataraxia937 at gmail.com>
> ---
>  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
>
>
>


More information about the pacman-dev mailing list