-
Notifications
You must be signed in to change notification settings - Fork 254
/
package-release-tarballs.bash
executable file
·97 lines (75 loc) · 2.35 KB
/
package-release-tarballs.bash
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/bash
set -eu
cd "$(dirname "$0")"
SIGNME=""
# git_archive_extra PREFIX EXTRA1 [EXTRA2 ...]
#
# Call git-archive and add additional files to the tarball.
# Output tarball is called "$PREFIX.tar.gz" and contains one folder
# called "$PREFIX".
git_archive_extra() {
local PREFIX=$1
shift
# Add files tracked in git
git archive --prefix "$PREFIX/" -o "$PREFIX.tar" HEAD
# Add "extra" files
tar --owner=root --group=root --transform "s!^!$PREFIX/!" --append -f "$PREFIX.tar" "$@"
# Compress
gzip -f "$PREFIX.tar"
}
package_source() {
local GITVERSION
GITVERSION=$(git describe --tags --dirty)
echo "$GITVERSION" > VERSION
# Render the manpages and include them in the tarball. This
# avoids a build-dependency to pandoc.
./Documentation/MANPAGE-render.bash
# gocryptfs source tarball
local PREFIX_SRC_ONLY=gocryptfs_${GITVERSION}_src
git_archive_extra "$PREFIX_SRC_ONLY" VERSION Documentation/*.1
# gocryptfs source + dependencies tarball
go mod vendor
local PREFIX_SRC_DEPS=gocryptfs_${GITVERSION}_src-deps
git_archive_extra "$PREFIX_SRC_DEPS" VERSION Documentation/*.1 vendor
rm VERSION
rm -R vendor
echo "Tars created."
SIGNME+=" $PREFIX_SRC_ONLY.tar.gz $PREFIX_SRC_DEPS.tar.gz"
}
package_static_binary() {
# Compiles the gocryptfs binary and sets $GITVERSION
source build-without-openssl.bash
if ldd gocryptfs > /dev/null ; then
echo "error: compiled gocryptfs binary is not static"
exit 1
fi
# Build man pages gocryptfs.1 & gocryptfs-xray.1
./Documentation/MANPAGE-render.bash > /dev/null
local ARCH
ARCH=$(go env GOARCH)
local OS
OS=$(go env GOOS)
local TARBALL
TARBALL=gocryptfs_${GITVERSION}_${OS}-static_${ARCH}.tar
local TARGZ
TARGZ=$TARBALL.gz
tar --owner=root --group=root --create -vf "$TARBALL" gocryptfs
tar --owner=root --group=root --append -vf "$TARBALL" -C gocryptfs-xray gocryptfs-xray
tar --owner=root --group=root --append -vf "$TARBALL" -C Documentation gocryptfs.1 gocryptfs-xray.1
gzip -f "$TARBALL"
echo "Tar created."
SIGNME+=" $TARGZ"
}
signing_hint() {
local GITVERSION
GITVERSION=$(git describe --tags --dirty)
echo "Hint for signing:"
echo " for i in gocryptfs_${GITVERSION}_*.tar.gz ; do gpg -u 23A02740 --armor --detach-sig \$i ; done"
}
if git describe --dirty | grep dirty ; then
echo "Tree is dirty - I will not package this!"
exit 1
fi
package_source
package_static_binary
signing_hint