You are not logged in.

#1 2024-11-11 00:23:08

Fytch
Member
Registered: 2019-09-28
Posts: 9

Symlink created in package() keeps pointing to $pkgdir/...

In package(), I run make as follows:

make PREFIX="$pkgdir/usr" install

The install target of this make script (not mine) creates a symlink from /usr/share/foo/bin/foo to /usr/bin/:

ln -sf ${PREFIX}/share/foo/bin/foo ${PREFIX}/bin/

When I run makepkg -i, I get a symlink at /usr/bin/foo that points to something in $pkgdir which is somewhere in ~ in my test case.
This is obviously not what I wanted. It should point to /usr/share/foo/bin/foo.

I was a bit surprised to see that makepkg does not do anything special with symlinks. I thought it's obvious that $pkgdir needs to be replaced with / in all symlinks in the .tar.zst file. I'm not sure why it does not do this.

What is the idiomatic solution for this kind of situation?
The easiest solution that comes to mind would be to apply a patch to the makefile so that the ln line above reads:

ln -sf /usr/share/foo/bin/foo ${PREFIX}/bin/

This feels a bit hacky so I was wondering if there's a nicer solution.

Offline

#2 2024-11-11 00:27:54

Scimmia
Fellow
Registered: 2012-09-01
Posts: 12,125

Re: Symlink created in package() keeps pointing to $pkgdir/...

This is why there's often a DESTDIR variable, separate from PREFIX to use for packaging. having $pkgdir in PREFIX is rarily correct.

Online

Board footer

Powered by FluxBB