summary refs log tree commit diff
path: root/pkgs/build-support/docker/store-path-to-layer.sh
blob: bcad9e83e06fbb7377d7144b4770687a6c2da74c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!@shell@

set -eu

layerNumber=$1
shift

layerPath="./layers/$layerNumber"
echo "Creating layer #$layerNumber for $@"

mkdir -p "$layerPath"
tar --no-recursion -rf "$layerPath/layer.tar" \
    --mtime="@$SOURCE_DATE_EPOCH" \
    --owner=0 --group=0 /nix /nix/store
tar -rpf "$layerPath/layer.tar" --hard-dereference --sort=name \
    --mtime="@$SOURCE_DATE_EPOCH" \
    --owner=0 --group=0 "$@"

# Compute a checksum of the tarball.
tarhash=$(tarsum < $layerPath/layer.tar)

# Add a 'checksum' field to the JSON, with the value set to the
# checksum of the tarball.
cat ./generic.json | jshon -s "$tarhash" -i checksum > $layerPath/json

# Indicate to docker that we're using schema version 1.0.
echo -n "1.0" > $layerPath/VERSION