[pacman-dev] [PATCH] makepkg: canonicalize paths from environmental variables

Xavier chantry.xavier at gmail.com
Thu Sep 30 07:26:29 EDT 2010

> Well, one way to avoid all this is to add something like:
> [[ $PKGDIR == "." ]] && $PKGDIR="$startdir"
> before we preserve the environmental variables.   But that is bad as
> things like PKGDIR="../" would still cause issues.

I rather meant a way to remove any assumption of PKGDEST being absolute.

This is the only broken code, isn't it :

if (( ! ret )) && [[ "$PKGDEST" != "${startdir}" ]]; then
  ln -sf "${pkg_file}" "${pkg_file/$PKGDEST/$startdir}"

Why not do something like :
  local link_file="$startdir/${nameofpkg}-${pkgver}-${pkgrel}-${PKGARCH}${PKGEXT}"
  if [[ ! -f "$link_file" ]]; then
    ln -sf $pkg_file $link_file

I don't know if there are cases where a regular file exists but is not the
package we just built. If it can happen and we care, we could try to test
whether pkg_file and link_file are not actually the same regular file.

> So I think we should just add the bash implementation of realpath as
> a function inside makepkg.  The one at stackoverflow is very
> simplistic so I will take another look at the one posted to the
> mailing list.  We should really look at libifying some/all of this
> sort of stuff out of makepkg...
> Allan

Btw there are actually several bash impl in that link, the last one is more
complex :

More information about the pacman-dev mailing list