When pulling from a registry we get a compressed tar archive, so
we need to wrap the stream in the right kind of compress reader.
Unfortunately go doesn't have an Xz decompression method, but I
don't think any docker layers use that atm anyway.
The TestLookupImage test seems to use a layer that contains
/etc/postgres/postgres.conf, but not e.g. /etc/postgres.
To handle this we ensure that the parent directory always
exists, and if not we create it.
The default gnu tar format has no sub-second precision mtime support,
and the golang tar writer currently doesn't support that either.
This means if we export the changes from a container we will not
get zeron in the sub-second precision field when the change is applied.
This means we can't compare that to the original without getting a
spurious change. So, we detect this case by treating a case where the
seconds match and either of the two nanoseconds are zero as equal.
Rather than calling out to tar we use the golang tar parser
to directly extract the tar files. This has two major advantages:
1) We're able to replace an existing directory with a file in the
new layer. This currently breaks with the external tar, since
it refuses to recursively remove the destination directory in
this case, and there are no options to make it do that.
2) We avoid extracting the whiteout files just to later remove them.
This moves Driver.Size() to Differ.DiffSize(), removing the empty
implementations in devmapper and dummy, and renaming the one in aufs.
Then we fall back to a container.Changes() implementation in the non-aufs
case.
This adds 3 tests:
Verify that ChangesDirs() returns nothing when run on a copy of the
same directory.
Verify that various mutations of a directory get reported with the
right changes.
Verify that ExportChanges() + ApplyLayer() of the above mutation gets
an identical directory.
Unfortunately the last test is disabled because it fails in multiple
ways atm. But I want to get it in so that we can fix it.
This replaces the current version with the latest version from the
dm branch. Advantages in this version:
We only scan each directory tree once, which means less i/o and less chance
of container changes inbetween the two scans causing inconsistencies.
We avoid comparing some fields for change detection:
* Inode
* size-in-blocks
These can change during a copy operation (e.g. in the dummy backend)
without needing to actually reflect a change in content or metadata.
* Ctime
Any copy operation will create a new Ctime value, and there is no
API to change it to the "source" value.
* size for directories
The size of a directory doesn't have to be the same just because you
recreated the same content as another director. Internal details in
the filesystem may make these different with no "real" change.