Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)

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.

authored by

Richard Wallace and committed by
Robert Hensing
3781ac87 27eca645

+10 -11
+10 -11
pkgs/build-support/docker/store-path-to-layer.sh
··· 5 layerNumber=$1 6 shift 7 8 - storePath="$1" 9 - shift 10 - 11 layerPath="./layers/$layerNumber" 12 - echo "Creating layer #$layerNumber for $storePath" 13 14 mkdir -p "$layerPath" 15 ··· 35 # to /nix/store. In order to create the correct structure 36 # in the tar file, we transform the relative nix store 37 # path to the absolute store path. 38 - n=$(basename "$storePath") 39 - tar -C /nix/store -rpf "$layerPath/layer.tar" \ 40 - --hard-dereference --sort=name \ 41 - --mtime="@$SOURCE_DATE_EPOCH" \ 42 - --owner=0 --group=0 \ 43 - --transform="s,$n,/nix/store/$n," \ 44 - $n 45 46 # Compute a checksum of the tarball. 47 tarhash=$(tarsum < $layerPath/layer.tar)
··· 5 layerNumber=$1 6 shift 7 8 layerPath="./layers/$layerNumber" 9 + echo "Creating layer #$layerNumber for $@" 10 11 mkdir -p "$layerPath" 12 ··· 32 # to /nix/store. In order to create the correct structure 33 # in the tar file, we transform the relative nix store 34 # path to the absolute store path. 35 + for storePath in "$@"; do 36 + n=$(basename "$storePath") 37 + tar -C /nix/store -rpf "$layerPath/layer.tar" \ 38 + --hard-dereference --sort=name \ 39 + --mtime="@$SOURCE_DATE_EPOCH" \ 40 + --owner=0 --group=0 \ 41 + --transform="s,$n,/nix/store/$n," \ 42 + $n 43 + done 44 45 # Compute a checksum of the tarball. 46 tarhash=$(tarsum < $layerPath/layer.tar)