Skip to content
This repository was archived by the owner on Oct 19, 2021. It is now read-only.

removed attempt to hard link files, avoiding potential cross device h… #57

Conversation

norvil-khee
Copy link

Whenever you try to hard link between two different filesystems an error like this will be produced:

error: unpacking of archive failed on file /etc/init.d/xxxxxx;56703af6: cpio: link failed - Invalid cross-device link

In this Pullrequest the code trying to create hardlinks is simply commented out to avoid this.

The final solution should probably check if filesystems are different before actually trying to create a hardlink.

@michaelrsweet michaelrsweet self-assigned this Oct 3, 2017
@michaelrsweet michaelrsweet added this to the Stable milestone Oct 3, 2017
@michaelrsweet
Copy link
Owner

Well, if the source and destination are not on the same filesystem then the hard link should fail (or at least that's how it is defined for POSIX...)

Investigating...

@michaelrsweet
Copy link
Owner

@norvil-khee What OS and type of package are you trying to create?

@norvil-khee
Copy link
Author

We encountered this problem at least on all SLES 9 through SLES 12 (but if I remember correctly AIX 5.1 to AIX 7.2 and HPUX 11.31 were affected, too).

Here is a minimal example to reproduce the problem:

This package file:

%product link_test
%copyright Public Domain
%vendor aperture labs 
%license ./COPYING
%readme ./README
%description test package
%version 0.42
%packager glados

d 755 root root /mnt/test -
f 755 root root /mnt/test/somescript ./mnt/test/somescript
f 755 root root /etc/init.d/somescript ./mnt/test/somescript

will be used.

/mnt/test will be a different file system from /etc:

root@wheatley:/var/tmp/cdai-449/link_test : df /etc/
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/sda2       20510716 5599492  13862652  29% /
root@wheatley:/var/tmp/cdai-449/link_test : df /mnt/test/
Filesystem              1K-blocks  Used Available Use% Mounted on
/dev/mapper/vg00-lvtest     27633   395     24945   2% /mnt/test

Here, e.g. the output of our SLES-12-x64 test host:

epm call:

root@wheatley:/var/tmp/cdai-449/link_test : /var/tmp/epm-4.3/epm -f rpm -v -u -m SLES_12_x64 link_test -g
epm: Product names should only contain letters and numbers!
ESP Package Manager v4.3
Copyright 1999-2007 by Easy Software Products.

EPM is free software and comes with ABSOLUTELY NO WARRANTY; for details
see the GNU General Public License in the file COPYING or at
"http://www.fsf.org/gpl.html".  Report all problems to "[email protected]".

Searching for product information...
Creating RPM distribution...
Creating spec file...
Copying temporary distribution files...
Building RPM binary distribution...
          2k  SLES_12_x64/link_test-0.42-SLES_12_x64.rpm
Removing temporary distribution files...
SLES_12_x64/RPMS/x86_64
Done!

rpm call:

root@wheatley:/var/tmp/cdai-449/link_test : rpm -Uv SLES_12_x64/link_test-0.42-SLES_12_x64.rpm 
Preparing packages...
link_test-0.42-0.x86_64
error: unpacking of archive failed on file /etc/init.d/somescript;59dc8ea0: cpio: link
error: link_test-0.42-0.x86_64: install failed

Attached file link_test.tar.gz including the test-package above.

Final note:
Error can be avoided if this row is removed from list file:

f 755 root root /mnt/test/somescript ./mnt/test/somescript

however this is not desired in our case.

michaelrsweet added a commit that referenced this pull request Oct 11, 2017
…n for

copies, as current versions of RPM do not support such things (Issue #57)
@michaelrsweet
Copy link
Owner

Hmm, well it looks like they made changes to cpio or rpm to preserve hard links rather than embed the linked file.

This optimization has been in EPM for a very long time (7 years), and this is the first time we've heard of problems with it... Anyways, I've reverted the change from 7 years ago:

[master a6c4ce4] Revert change from old STR #21 that used hard links as an optimization for copies, as current versions of RPM do not support such things (Issue #57)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants