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

Allan McRae allan at archlinux.org
Wed Sep 29 22:43:55 EDT 2010


On 29/09/10 23:58, Xavier Chantry wrote:
> On Wed, Sep 29, 2010 at 3:52 PM, Allan McRae<allan at archlinux.org>  wrote:
>>
>> Just to clarify (thanks to Xavier), it worked on BSD but not in OSX which
>> does not have either "readlink -f" or "realpath"...
>>
>
> just found a link that might help :
> http://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-gnus-readlink-f-on-a-mac
>
> To sum up the solutions :
> 1) use python os.path.realpath
> 2) use C realpath (3)
> 3) use fink /sw/sbin/readlink -f
> 4) implement in bash
>
> Someone already proposed 4) a while ago :
> http://mailman.archlinux.org/pipermail/pacman-dev/2009-February/008147.html
> I did not compare this bash implementation with the one found on stackoverflow.
>
> The best might still be to see if there is any way to avoid using
> realpath, like I did for repo-add back then. But maybe there is really
> no way out for makepkg, I don't know.
>

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.

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


More information about the pacman-dev mailing list