From b2aa1f9d7a4f5474ce53cd4ce697a8d1abecc32b Mon Sep 17 00:00:00 2001 From: Viktor Kronvall Date: Wed, 31 Mar 2021 02:24:44 +0900 Subject: [PATCH] dockerTools: preserve order of images in manifest --- pkgs/build-support/docker/default.nix | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/pkgs/build-support/docker/default.nix b/pkgs/build-support/docker/default.nix index 36e8f3ad2265..0e1aa179cab8 100644 --- a/pkgs/build-support/docker/default.nix +++ b/pkgs/build-support/docker/default.nix @@ -692,15 +692,24 @@ rec { } '' mkdir image inputs # Extract images + repos=() + manifests=() for item in $images; do - mkdir inputs/$(basename $item) - tar -I pigz -xf $item -C inputs/$(basename $item) + name=$(basename $item) + mkdir inputs/$name + tar -I pigz -xf $item -C inputs/$name + if [ -f inputs/$name/repositories ]; then + repos+=(inputs/$name/repositories) + fi + if [ -f inputs/$name/manifest.json ]; then + manifests+=(inputs/$name/manifest.json) + fi done # Copy all layers from input images to output image directory cp -R --no-clobber inputs/*/* image/ # Merge repositories objects and manifests - jq -s add inputs/*/repositories > repositories - jq -s add inputs/*/manifest.json > manifest.json + jq -s add "''${repos[@]}" > repositories + jq -s add "''${manifests[@]}" > manifest.json # Replace output image repositories and manifest with merged versions mv repositories image/repositories mv manifest.json image/manifest.json