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.
This commit is contained in:
parent
8979d2dde5
commit
3b65b3f6d6
@ -246,4 +246,5 @@ rec {
|
||||
contents = [ pkgs.bash pkgs.hello ];
|
||||
maxLayers = 2;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user