summary refs log tree commit diff
path: root/pkgs/build-support/docker
diff options
context:
space:
mode:
authorRichard Wallace <richard.wallace@simspace.com>2020-01-29 14:56:05 -0700
committerAntoine Eiche <lewo@abesis.fr>2020-02-14 09:26:26 +0100
commit3b65b3f6d637c6576cd9a0fe954aced5aa70de12 (patch)
tree814e3fa983678914a97bb0ef58c10b5cd872c478 /pkgs/build-support/docker
parent8979d2dde534eb7d8f979c4b8283697a789f5b0a (diff)
downloadnixpkgs-3b65b3f6d637c6576cd9a0fe954aced5aa70de12.tar
nixpkgs-3b65b3f6d637c6576cd9a0fe954aced5aa70de12.tar.gz
nixpkgs-3b65b3f6d637c6576cd9a0fe954aced5aa70de12.tar.bz2
nixpkgs-3b65b3f6d637c6576cd9a0fe954aced5aa70de12.tar.lz
nixpkgs-3b65b3f6d637c6576cd9a0fe954aced5aa70de12.tar.xz
nixpkgs-3b65b3f6d637c6576cd9a0fe954aced5aa70de12.tar.zst
nixpkgs-3b65b3f6d637c6576cd9a0fe954aced5aa70de12.zip
dockerTools.buildLayeredImage: store all paths passed in final layer
Fixes #78744

My previous change broke when there are more packages than the maximum
number of layers. I had assumed that the `store-path-to-layer.sh` was
only ever passed a single store path, but that is not the case if
there are multiple packages going into the final layer. To fix this, we
loop through the paths going into the final layer, appending them to the
tar file and making sure they end up at the right path.
Diffstat (limited to 'pkgs/build-support/docker')
-rw-r--r--pkgs/build-support/docker/examples.nix1
-rwxr-xr-xpkgs/build-support/docker/store-path-to-layer.sh21
2 files changed, 11 insertions, 11 deletions
diff --git a/pkgs/build-support/docker/examples.nix b/pkgs/build-support/docker/examples.nix
index a1f71d35793..f6520201a64 100644
--- a/pkgs/build-support/docker/examples.nix
+++ b/pkgs/build-support/docker/examples.nix
@@ -246,4 +246,5 @@ rec {
     contents = [ pkgs.bash pkgs.hello ];
     maxLayers = 2;
   };
+
 }
diff --git a/pkgs/build-support/docker/store-path-to-layer.sh b/pkgs/build-support/docker/store-path-to-layer.sh
index c808abab7a8..7e8efeea1c1 100755
--- a/pkgs/build-support/docker/store-path-to-layer.sh
+++ b/pkgs/build-support/docker/store-path-to-layer.sh
@@ -5,11 +5,8 @@ set -eu
 layerNumber=$1
 shift
 
-storePath="$1"
-shift
-
 layerPath="./layers/$layerNumber"
-echo "Creating layer #$layerNumber for $storePath"
+echo "Creating layer #$layerNumber for $@"
 
 mkdir -p "$layerPath"
 
@@ -35,13 +32,15 @@ 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.
-n=$(basename "$storePath")
-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
+for storePath in "$@"; do
+  n=$(basename "$storePath")
+  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
 
 # Compute a checksum of the tarball.
 tarhash=$(tarsum < $layerPath/layer.tar)