25c6adfa Andy McCall 1 month ago ↶
1
2
3
4
5
6
7
8
1931724b Andy McCall 1 month ago ↶
9
25c6adfa Andy McCall 1 month ago ↶
10
11
12
13
14
15
set -euo pipefail
16
17
PKG = oxy
18
BIN = oxy
19
DEB_NAME = oxy
1931724b Andy McCall 1 month ago ↶
20
OTHER_DEB = oh
25c6adfa Andy McCall 1 month ago ↶
21
SUMMARY = " Oxygen version control: a distributed, commutative VCS"
22
DESCRIPTION = " Oxygen is a version control system in which changes commute: a
23
state is a set of changes, merges need no merge commits, conflicts are
24
recorded and resolved like any other change, and every change is signed
25
by its author."
26
HOMEPAGE = " https://oxygenhub.io/andymccall/oxygen"
27
MAINTAINER = " Andy McCall <[email protected] >"
28
DOCS = ( README.md LICENSE)
29
30
cd " $ ( dirname " $ 0 " ) /.."
31
VERSION = " $ { 1 :- $ ( cargo metadata -- no-deps -- format-version 1 | python3 - c " import json,sys; print(next(p['version'] for p in json.load(sys.stdin)['packages'] if p['name']=='$ PKG '))" ) } "
32
VERSION = " $ { VERSION# v } "
33
OUT = " target/dist/$ VERSION "
34
rm - rf " $ OUT " && mkdir - p " $ OUT "
35
export PATH = " $ HOME /.local/opt/zig:$ PATH "
36
37
export CARGO_PROFILE_RELEASE_DEBUG = 0 CARGO_PROFILE_RELEASE_STRIP = true CARGO_INCREMENTAL = 0
38
39
export OXY_BUILD = " v$ VERSION "
40
41
42
PLATFORMS = (
43
" x86_64-unknown-linux-gnu.2.28|linux-x86_64|zig|amd64"
44
" aarch64-unknown-linux-gnu.2.28|linux-arm64|zig|arm64"
45
" x86_64-apple-darwin|macos-x86_64|zig|"
46
" aarch64-apple-darwin|macos-arm64|zig|"
47
" x86_64-pc-windows-gnu|windows-x86_64|cargo|"
48
)
49
50
for p in " $ { PLATFORMS[ @ ] } " ; do
51
IFS = ' |' read - r target platform tool deb < < < " $ p "
52
triple = " $ { target%% .2.* } "
1931724b Andy McCall 1 month ago ↶
53
54
if [ - n " $ { ONLY :- } " ] && [[ " $ platform " != $ ONLY ]] ; then continue ; fi
25c6adfa Andy McCall 1 month ago ↶
55
echo " == $ platform ($ target )"
56
if [ " $ tool " = zig ] ; then
57
cargo zigbuild - q -- release -- locked -- target " $ target " - p " $ PKG "
58
else
59
cargo build - q -- release -- locked -- target " $ target " - p " $ PKG "
60
fi
61
exe = " $ BIN "
62
[[ " $ triple " == * windows* ]] && exe = " $ BIN .exe"
63
built = " target/$ triple /release/$ exe "
64
name = " $ BIN -$ VERSION -$ platform "
65
stage = " $ OUT /stage/$ name "
66
mkdir - p " $ stage "
67
cp " $ built " " $ stage /"
68
cp " $ { DOCS[ @ ] } " " $ stage /"
69
if [[ " $ triple " == * windows* ]] ; then
70
( cd " $ OUT /stage" && zip - qr " ../$ name .zip" " $ name " )
71
else
72
tar - C " $ OUT /stage" - czf " $ OUT /$ name .tar.gz" " $ name "
73
fi
74
if [ - n " $ deb " ] ; then
75
root = " $ OUT /stage/deb-$ deb "
76
mkdir - p " $ root /DEBIAN" " $ root /usr/bin" " $ root /usr/share/doc/$ DEB_NAME "
77
install - m 0755 " $ built " " $ root /usr/bin/$ BIN "
78
cp README.md " $ root /usr/share/doc/$ DEB_NAME /"
79
cp LICENSE " $ root /usr/share/doc/$ DEB_NAME /copyright"
1931724b Andy McCall 1 month ago ↶
80
81
82
83
mkdir - p " $ root /usr/share/$ DEB_NAME "
84
install - m 0644 packaging/oxygenhub-archive-keyring.gpg " $ root /usr/share/$ DEB_NAME /"
85
sed " s/@PKG@/$ DEB_NAME /" > " $ root /DEBIAN/postinst" << ' EOF '
86
#!/bin/sh
87
set -e
88
if [ "$1" = configure ]; then
89
# The key is refreshed on every install, so a new one reaches everyone.
90
install -m 0644 /usr/share/@PKG@/oxygenhub-archive-keyring.gpg /usr/share/keyrings/oxygenhub-archive-keyring.gpg
91
# The repository is added on the first install only: removing it
92
# keeps it removed.
93
L=/etc/apt/sources.list.d/oxygenhub.sources
94
if [ -z "$2" ] && [ ! -e "$L" ] && ! grep -rqs "oxygenhub.io/apt" /etc/apt/sources.list /etc/apt/sources.list.d; then
95
cat >"$L" <<SRC
96
Types: deb
97
URIs: https://oxygenhub.io/apt
98
Suites: stable
99
Components: main
100
Signed-By: /usr/share/keyrings/oxygenhub-archive-keyring.gpg
101
SRC
102
fi
103
fi
104
EOF
105
sed " s/@OTHER@/$ OTHER_DEB /" > " $ root /DEBIAN/postrm" << ' EOF '
106
#!/bin/sh
107
set -e
108
if [ "$1" = purge ] && ! dpkg-query -W -f='${Status}' @OTHER@ 2>/dev/null | grep -q "ok installed"; then
109
rm -f /etc/apt/sources.list.d/oxygenhub.sources /usr/share/keyrings/oxygenhub-archive-keyring.gpg
110
fi
111
EOF
112
chmod 0755 " $ root /DEBIAN/postinst" " $ root /DEBIAN/postrm"
25c6adfa Andy McCall 1 month ago ↶
113
cat > " $ root /DEBIAN/control" << EOF
114
Package: $ DEB_NAME
115
Version: $ VERSION
116
Architecture: $ deb
117
Maintainer: $ MAINTAINER
118
Depends: libc6 (>= 2.28)
119
Section: vcs
120
Priority: optional
121
Homepage: $ HOMEPAGE
122
Installed-Size: $ ( du - sk " $ root /usr" | cut - f1)
123
Description: $ SUMMARY
124
$ DESCRIPTION
125
EOF
126
dpkg-deb -- build -- root-owner-group - Zxz " $ root " " $ OUT /$ { DEB_NAME } _$ { VERSION } _$ deb .deb" > /dev/null
127
fi
128
done
129
130
rm - rf " $ OUT /stage"
1931724b Andy McCall 1 month ago ↶
131
( cd " $ OUT " && shopt -s nullglob && sha256sum -- * .tar.gz * .zip * .deb > SHA256SUMS )
25c6adfa Andy McCall 1 month ago ↶
132
echo " == $ OUT "
133
ls - l " $ OUT "