Ticket #1225 (closed defect: fixed)
pbin archives should restore hard links efficiently (instead of making multiple copies)
| Reported by: | chutz | Owned by: | |
|---|---|---|---|
| Priority: | Sometime | Milestone: | |
| Component: | clients/cave | Version: | 0.72.0 |
| Keywords: | Cc: | ||
| Blocked By: | Blocking: | ||
| Distribution: | Gentoo |
Description
Packages installed via a binary do not preserve hard links while installing the package directly from the source repository does preserve the hard links.
I see that gnu tar, and even bsdtar are capable of maintaining hard links, so it seems that Paludis should be able to do the same, too.
Demonstration
- Git installed from a source repo to the root system. /usr/bin/git-receive-pack has 109 links
> stat /usr/bin/git-receive-pack File: `/usr/bin/git-receive-pack' Size: 1314360 Blocks: 2568 IO Block: 4096 regular file Device: fd01h/64769d Inode: 3171604 Links: 109 Access: (0755/-rwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2012-02-25 21:27:48.539721714 +0900 Modify: 2012-02-25 21:27:50.959721299 +0900 Change: 2012-02-25 21:27:55.429720538 +0900 Birth: -
- A PBIN of git, which contains no hard link information
> tar tvf /tmp/desktop-bin--dev-vcs--git-1.7.8.4--C.18361.1330169606.850618.C.tar.bz2 | grep -e bin/git-receive -e bin/git-upload-archive -rwxr-xr-x root/root 1314360 2012-02-25 20:33 usr/bin/git-receive-pack -rwxr-xr-x root/root 1314360 2012-02-25 20:33 usr/bin/git-upload-archive -rw-r--r-- root/root 171923 2012-02-25 20:33 usr/lib64/debug/usr/bin/git-receive-pack.debug
- libarchive *can* archive hardlinks efficiently (version 3.0.3 here)
> bsdtar -cf - --format gnutar -C / usr/bin/git usr/bin/git-receive-pack usr/bin/git-upload-archive | tar tv -rwxr-xr-x root/root 1314360 2012-02-25 21:27 usr/bin/git hrwxr-xr-x root/root 0 2012-02-25 21:27 usr/bin/git-receive-pack link to usr/bin/git hrwxr-xr-x root/root 0 2012-02-25 21:27 usr/bin/git-upload-archive link to usr/bin/git
Change History
comment:2 Changed 15 months ago by chutz
Much to my surprise it was easier than expected.
I installed git from a binary package and now my /usr/bin/git has 109 links, as it should. And the binary package itself is considerably smaller:
$ ls -hgG desktop-bin--dev-vcs--git-1.7.8.4--* -rw-r--r--+ 1 69M Feb 25 15:14 desktop-bin--dev-vcs--git-1.7.8.4--C.4199.1330150437.946996.C.tar.bz2 -rw-r--r--+ 1 4.3M Feb 26 18:30 desktop-bin--dev-vcs--git-1.7.8.4--C.4320.1330248606.623596.C.tar.bz2
All I had to update was the archiver. On extraction, tar can handle the hardlinks itself.
I have not tried this with the other archive formats, though I would expect it to still work. I did try the following, though, and it seems okay:
$ touch f1; ln f1 f2; mkdir out $ bsdtar -cf - --format pax f? | /usr/libexec/paludis/utils/unpaxinate img /dev/stdin out f1 f2 $ stat -c %i:%n out/f1 out/f2 2107974:out/f1 2107974:out/f2
Here is the patch:
The following changes since commit 8f4f01deaf9fad78ec0a6c9cd5928855109a054c:
Don't try to dodoc directories. (2012-02-21 15:05:28 +0000)
are available in the git repository at:
git://github.com/chutzimir/paludis.git pbin-hardlinks
Georgi Georgiev (1):
Support hardlinks in pbins
paludis/tar_extras.cc | 35 +++++++++++++++++++++++++----------
1 files changed, 25 insertions(+), 10 deletions(-)

Can you figure out how to get libarchive to do that when using the library?