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