coreos/rocket — pull request #222 by jonboulle (2014-12-06 01:54:38+00:00)
Title: actool: properly deal with hardlinks when building images

Implementation of tar that is used by `acitool build`, as tested on FreeBSD 10.1-RELEASE (I'm looking into alternatives to porting or reimplementing Docker for FreeBSD jails), produces files that are much larger before and after compression than those produced by `/usr/bin/tar` from same directory. I don't know whether this effect occurs on Linux as well.

Source directory is an unpacked FreeBSD-10.1 base system. The original distribution base.txz file weighs 63MB and is available at ftp://ftp2.freebsd.org/pub/FreeBSD/releases/amd64/amd64/10.1-RELEASE/base.txz . The unpacked directory takes 186MB (as reported by `du -sh`); when counting hard links it takes 989MB (as reported by `du -shl`). The uncompressed and compressed archives generated in various ways are:

-rw-r--r-- 1 root wheel 642M 5 Dec 16:01 tst.aci # actool build
-rw-r--r-- 1 root wheel 635M 5 Dec 16:01 tst.aci.xz # actool build + xz
-rw-r--r-- 1 root wheel 300M 5 Dec 16:20 tst.tar # tar c
-rw-r--r-- 1 root wheel 64M 5 Dec 16:20 tst.tar.xz # tar c + xz
-rw-r--r-- 1 root wheel 64M 5 Dec 16:13 tst.txz # tar cJ

After unpacking the `tst.aci` file, the output directory takes 989MB as reported by both `du -sh` and `du -shl`, so it seems that problem is caused by `actool build` not preserving hardlinks.