From 3781ac873fc352db8280dac5259f88f61d37bce3 Mon Sep 17 00:00:00 2001 From: Richard Wallace Date: Wed, 29 Jan 2020 14:56:05 -0700 Subject: [PATCH] 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. --- .../docker/store-path-to-layer.sh | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/pkgs/build-support/docker/store-path-to-layer.sh b/pkgs/build-support/docker/store-path-to-layer.sh index c808abab7a8a..7e8efeea1c10 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)