1source "${stdenv}/setup"
2header "exporting ${repository}/${imageName} (tag: ${tag}) into ${out}"
3mkdir -p "${out}"
4
5cat <<EOF > "${out}/compositeImage.sh"
6#! ${bash}/bin/bash
7#
8# Create a tar archive of a docker image's layers, docker image config
9# json, manifest.json, and repositories json; this streams directly to
10# stdout and is intended to be used in concert with docker load, i.e:
11#
12# ${out}/compositeImage.sh | docker load
13
14# The first character follow the 's' command for sed becomes the
15# delimiter sed will use; this makes the transformation regex easy to
16# read. We feed tar a file listing the files we want in the archive,
17# because the paths are absolute and docker load wants them flattened in
18# the archive, we need to transform all of the paths going in by
19# stripping everything *including* the last solidus so that we end up
20# with the basename of the path.
21${gnutar}/bin/tar \
22 --transform='s=.*/==' \
23 --transform="s=.*-manifest.json=manifest.json=" \
24 --transform="s=.*-repositories=repositories=" \
25 -c "${manifest}" "${repositories}" -T "${imageFileStorePaths}"
26EOF
27chmod +x "${out}/compositeImage.sh"
28stopNest