diff options
author | Utku Demir <me@utdemir.com> | 2020-05-06 15:43:39 +1200 |
---|---|---|
committer | Utku Demir <me@utdemir.com> | 2020-05-07 11:50:00 +1200 |
commit | 69f62947243423cd4975d1fac0035b38ae7c85c1 (patch) | |
tree | 917f7fe1190cd2c07b94ab6955dad29a4976c368 | |
parent | defdda6f93daf4c1bf9f1b104c0d503f90099506 (diff) | |
download | nixpkgs-69f62947243423cd4975d1fac0035b38ae7c85c1.tar nixpkgs-69f62947243423cd4975d1fac0035b38ae7c85c1.tar.gz nixpkgs-69f62947243423cd4975d1fac0035b38ae7c85c1.tar.bz2 nixpkgs-69f62947243423cd4975d1fac0035b38ae7c85c1.tar.lz nixpkgs-69f62947243423cd4975d1fac0035b38ae7c85c1.tar.xz nixpkgs-69f62947243423cd4975d1fac0035b38ae7c85c1.tar.zst nixpkgs-69f62947243423cd4975d1fac0035b38ae7c85c1.zip |
dockerTools.buildLayeredImage: Avoid appending to tarballs when building layers
Appending to an existing tar archive repeatedly seems to be a quadratic operation, since tar seems to traverse the existing archive even using the `-r, --append` flag. This commit avoids that by passing the list of files to a single tar invocation.
-rwxr-xr-x | pkgs/build-support/docker/store-path-to-layer.sh | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/pkgs/build-support/docker/store-path-to-layer.sh b/pkgs/build-support/docker/store-path-to-layer.sh index 7e8efeea1c1..e9fa22e4b99 100755 --- a/pkgs/build-support/docker/store-path-to-layer.sh +++ b/pkgs/build-support/docker/store-path-to-layer.sh @@ -32,15 +32,13 @@ tar -cf "$layerPath/layer.tar" \ # to /nix/store. In order to create the correct structure # in the tar file, we transform the relative nix store # path to the absolute store path. -for storePath in "$@"; do - n=$(basename "$storePath") +basename -a "$@" | tar -C /nix/store -rpf "$layerPath/layer.tar" \ - --hard-dereference --sort=name \ - --mtime="@$SOURCE_DATE_EPOCH" \ - --owner=0 --group=0 \ - --transform="s,$n,/nix/store/$n," \ - $n -done + --verbatim-files-from --files-from - \ + --hard-dereference --sort=name \ + --mtime="@$SOURCE_DATE_EPOCH" \ + --owner=0 --group=0 \ + --transform="flags=rS;s,^,/nix/store/," # Compute a checksum of the tarball. tarhash=$(tarsum < $layerPath/layer.tar) |