Created attachment 252298 [details] [PATCH] lang/perl5*: fix 'pkg -r' installation The @postexec commands in lang/perl5* pkg-plist files do not account for 'pkg -r' installations as they don't add DESTDIR (exposed as PKG_ROOTDIR to post-install scripts) to the PREFIX. The attached patch fixes that for all perl ports.
I don't think the patch is the correct fix, I don't really understand, the problem, but your patch should either be against all ports using @(post|pre)exec, or against pkg itself.
The problem: when you 'pkg -r /some/root install' a port, its POST-INSTALL or @postexec commands will execute from / instead of inside the /some/root chroot. This means that any commands that reference PREFIX or %D will be rooted in / and operate in the wrong root. This fix does work to correctly root those POST-INSTALL or @postexec commands in PKG_ROOTDIR which is provided here https://github.com/freebsd/pkg/blob/main/libpkg/scripts.c#L116. This problem is widespread in the ports collection. See the related discussion here https://github.com/freebsd/pkg/issues/2132#issuecomment-1517770514 for a fix recommendation, and the whole thread for why my patch isn't against 'pkg' itself. @bapt any newer recommendations on this? I am a heavy user of 'pkg -r install' and find it to be useful. I'd like to help fix this issue in the ports collection entirely.
but, mmm, `pkg -r /some/root` seems to be a bit strange, if you want this, you should probably use `pkg -c /some/root` it will chroot into it, and things will work just fine.
(In reply to Mathieu Arnold from comment #3) I have a use case where I don't want 'pkg' to be installed in my chroot/jail guest directory, but I want to use 'pkg' from the host to install/upgrade/maintain packages. If I use 'pkg -c install', then similar to 'pkg -j install', my package repositories need to be correctly configured inside the chroot. I neither want to install 'pkg' itself to the chroot, nor any repositories (since I build custom local repositories from a separate host using Poudriere). Ideally, I just want a simple way to redirect DESTDIR to /some/root and make everything work cleanly from the host. 'pkg -r' is documented as: pkg will install all packages within the specified <root directory>. This seems correct since it will use 'pkg' configuration from the host.
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/ports/commit/?id=06745788d4b143777aa2cb91e31a4c07af90ded3 commit 06745788d4b143777aa2cb91e31a4c07af90ded3 Author: Mathieu Arnold <mat@FreeBSD.org> AuthorDate: 2024-08-19 10:28:04 +0000 Commit: Mathieu Arnold <mat@FreeBSD.org> CommitDate: 2024-08-19 10:28:04 +0000 lang/perl5*: remove calls to makewhatis The @*exec macros have issues when being used when used with `pkg -r`, as %D does not account for the root directory. As we have a periodic task updating the makewhatis databases, and perl ports are the only ones actually doing that, probably for some long lost historic reason, it is easier to let that periodic task do its job. PR: 280458 Discussed with: bapt Reported by: Siva Mahadevan lang/perl5-devel/Makefile | 2 +- lang/perl5-devel/pkg-plist | 2 -- lang/perl5.36/Makefile | 2 +- lang/perl5.36/pkg-plist | 2 -- lang/perl5.38/Makefile | 2 +- lang/perl5.38/pkg-plist | 2 -- lang/perl5.40/Makefile | 2 +- lang/perl5.40/pkg-plist | 2 -- 8 files changed, 4 insertions(+), 12 deletions(-)
A commit in branch 2024Q3 references this bug: URL: https://cgit.FreeBSD.org/ports/commit/?id=0669690165a321f09540907ae75e541da1b85ec0 commit 0669690165a321f09540907ae75e541da1b85ec0 Author: Mathieu Arnold <mat@FreeBSD.org> AuthorDate: 2024-08-19 10:28:04 +0000 Commit: Mathieu Arnold <mat@FreeBSD.org> CommitDate: 2024-08-19 10:33:30 +0000 lang/perl5*: remove calls to makewhatis The @*exec macros have issues when being used when used with `pkg -r`, as %D does not account for the root directory. As we have a periodic task updating the makewhatis databases, and perl ports are the only ones actually doing that, probably for some long lost historic reason, it is easier to let that periodic task do its job. PR: 280458 Discussed with: bapt Reported by: Siva Mahadevan (cherry picked from commit 06745788d4b143777aa2cb91e31a4c07af90ded3) lang/perl5-devel/Makefile | 2 +- lang/perl5-devel/pkg-plist | 2 -- lang/perl5.36/Makefile | 2 +- lang/perl5.36/pkg-plist | 2 -- lang/perl5.38/Makefile | 2 +- lang/perl5.38/pkg-plist | 2 -- lang/perl5.40/Makefile | 2 +- lang/perl5.40/pkg-plist | 2 -- 8 files changed, 4 insertions(+), 12 deletions(-)