Bug 249374 - ports-mgmt/pkg: 1.15.4 cannot unroll hard links to copies, and still runs pkg-install after error
Summary: ports-mgmt/pkg: 1.15.4 cannot unroll hard links to copies, and still runs pkg...
Status: Closed Not Accepted
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-pkg (Nobody)
URL:
Keywords:
Depends on:
Blocks: 249284
  Show dependency treegraph
 
Reported: 2020-09-16 14:05 UTC by Matthias Andree
Modified: 2020-11-01 20:23 UTC (History)
2 users (show)

See Also:
bugzilla: maintainer-feedback? (pkg)


Attachments
minimal port for /usr/ports/sysutils/ to demonstrate the issue (1.55 KB, text/plain)
2020-09-16 14:19 UTC, Matthias Andree
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matthias Andree freebsd_committer freebsd_triage 2020-09-16 14:05:30 UTC
Presume I have hardlinked files in my $STAGEDIR, say, sbin/example and usr/local/sbin/example.

I can package them into the tarball (examplepkg-1.2.3_4,5.txz), and tar xvf properly shows them as "link to".

Installing the package however can fail with "cross-device link" errors.

pkg should copy the file in that case. We can't make a global decision as to where and how a package user will split their file systems, so we need to prepare for unexpected device crossings.

also, in that situation, pkg then removes all files, but still tries to run POST-INSTALL, which it should not.

The port shown to error as given below is not committed to any trees yet:

===>  Installing for e2fsprogs-1.45.6_4
===>  Checking if e2fsprogs is already installed
===>  Switching to root credentials for 'install' target
===>   Registering installation for e2fsprogs-1.45.6_4
Installing e2fsprogs-1.45.6_4...
pkg-static: Fail to create hardlink: /usr/local/sbin/.pkgtemp.e2fsck.S4cGKN1JKu2i:Cross-device link
cp: /usr/local/etc/mke2fs.conf.dist: No such file or directory
pkg-static: POST-INSTALL script failed
*** Error code 70
Comment 1 Matthias Andree freebsd_committer freebsd_triage 2020-09-16 14:19:07 UTC
Created attachment 218008 [details]
minimal port for /usr/ports/sysutils/ to demonstrate the issue

attached a port to show the issue. In order to reproduce the problem, make sure that /etc and /usr/local/etc are on different file systems. (Untested: Just copy/rsync your /usr/local/etc somewhere else and mount by NFS, for instance, should do.)
Comment 2 Matthias Andree freebsd_committer freebsd_triage 2020-09-16 14:20:42 UTC
the demo port prints:

===>  Installing for failport-0.0
===>  Checking if failport is already installed
===>  Switching to root credentials for 'install' target
===>   Registering installation for failport-0.0
Installing failport-0.0...
/bin/sh failport-0.0 PRE-INSTALL
[...environment dump here, omitted from PR...]
pkg-static: Fail to create hardlink: /usr/local/etc/.pkgtemp.example.timestamp.sfTyw84qY7mt:Cross-device link
/bin/sh failport-0.0 POST-INSTALL
[...environment dump here, omitted from PR...]
/bin/sh pkg-install failport-0.0 POST-INSTALL should _NOT_ be run, but was
pkg-static: POST-INSTALL script failed
*** Error code 70

Stop.
make[1]: stopped in /usr/ports.svn/sysutils/failport
*** Error code 1

Stop.
make: stopped in /usr/ports.svn/sysutils/failport