-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharchive.sh
executable file
·42 lines (32 loc) · 1.22 KB
/
archive.sh
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/sh
set -eu
set -o pipefail
# SPDX-FileCopyrightText: The vmnet-helper authors
# SPDX-License-Identifier: Apache-2.0
# Create reproducible archive.
# Derived from https://github.com/lima-vm/socket_vmnet/blob/master/Makefile
build_dir="${1:?Usage: $0 BUILD_DIR}"
# Install to root directory.
rm -rf "$build_dir/root"
DESTDIR=root meson install -C "$build_dir"
# v0.2.0 when building from tag (release)
# v0.1.0-7-gb928332 when building without tag (development)
version=$(git describe --tags)
machine=$(uname -m)
archive="$PWD/$build_dir/vmnet-helper-$version-$machine.tar"
# Make content reproducible by using commit time instead of build time.
commit_time=$(git log -1 --pretty=%ct)
commit_time_iso8601=$(date -u -Iseconds -r "$commit_time" | sed -e 's/+00:00/Z/')
find "$build_dir/root" -exec touch -d "$commit_time_iso8601" {} \;
# Create reproducible archive by sorting the files and overriding uid/gid.
(cd "$build_dir/root" && find -s .) | \
tar --create \
--file $archive \
--uid 0 \
--gid 0 \
--verbose \
--no-recursion \
--directory "$build_dir/root" \
--files-from /dev/stdin
# Create reproducible file by disabling filename and timestamp.
gzip -9 --no-name $archive