25c6adfa Andy McCall 1 month ago ↶
1
2
0a45ba84 Andy McCall 1 month ago ↶
3
25c6adfa Andy McCall 1 month ago ↶
4
5
6
7
8
9
10
0a45ba84 Andy McCall 1 month ago ↶
11
25c6adfa Andy McCall 1 month ago ↶
12
13
14
15
set -euo pipefail
16
17
PKG = oxy
18
BIN = oxy
19
DEB_NAME = oxy
20
SUMMARY = " Oxygen version control: a distributed, commutative VCS"
21
DESCRIPTION = " Oxygen is a version control system in which changes commute: a
22
state is a set of changes, merges need no merge commits, conflicts are
23
recorded and resolved like any other change, and every change is signed
24
by its author."
25
HOMEPAGE = " https://oxygenhub.io/andymccall/oxygen"
26
MAINTAINER = " Andy McCall <[email protected] >"
27
DOCS = ( README.md LICENSE)
28
29
cd " $ ( dirname " $ 0 " ) /.."
30
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 '))" ) } "
31
VERSION = " $ { VERSION# v } "
32
OUT = " target/dist/$ VERSION "
33
rm - rf " $ OUT " && mkdir - p " $ OUT "
34
export PATH = " $ HOME /.local/opt/zig:$ PATH "
35
36
export CARGO_PROFILE_RELEASE_DEBUG = 0 CARGO_PROFILE_RELEASE_STRIP = true CARGO_INCREMENTAL = 0
37
38
export OXY_BUILD = " v$ VERSION "
39
40
41
PLATFORMS = (
42
" x86_64-unknown-linux-gnu.2.28|linux-x86_64|zig|amd64"
43
" aarch64-unknown-linux-gnu.2.28|linux-arm64|zig|arm64"
0a45ba84 Andy McCall 1 month ago ↶
44
" riscv64gc-unknown-linux-gnu.2.28|linux-riscv64|zig|riscv64"
25c6adfa Andy McCall 1 month ago ↶
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.* } "
53
echo " == $ platform ($ target )"
54
if [ " $ tool " = zig ] ; then
55
cargo zigbuild - q -- release -- locked -- target " $ target " - p " $ PKG "
56
else
57
cargo build - q -- release -- locked -- target " $ target " - p " $ PKG "
58
fi
59
exe = " $ BIN "
60
[[ " $ triple " == * windows* ]] && exe = " $ BIN .exe"
61
built = " target/$ triple /release/$ exe "
62
name = " $ BIN -$ VERSION -$ platform "
63
stage = " $ OUT /stage/$ name "
64
mkdir - p " $ stage "
65
cp " $ built " " $ stage /"
66
cp " $ { DOCS[ @ ] } " " $ stage /"
67
if [[ " $ triple " == * windows* ]] ; then
68
( cd " $ OUT /stage" && zip - qr " ../$ name .zip" " $ name " )
69
else
70
tar - C " $ OUT /stage" - czf " $ OUT /$ name .tar.gz" " $ name "
71
fi
72
if [ - n " $ deb " ] ; then
73
root = " $ OUT /stage/deb-$ deb "
74
mkdir - p " $ root /DEBIAN" " $ root /usr/bin" " $ root /usr/share/doc/$ DEB_NAME "
75
install - m 0755 " $ built " " $ root /usr/bin/$ BIN "
76
cp README.md " $ root /usr/share/doc/$ DEB_NAME /"
77
cp LICENSE " $ root /usr/share/doc/$ DEB_NAME /copyright"
78
cat > " $ root /DEBIAN/control" << EOF
79
Package: $ DEB_NAME
80
Version: $ VERSION
81
Architecture: $ deb
82
Maintainer: $ MAINTAINER
83
Depends: libc6 (>= 2.28)
84
Section: vcs
85
Priority: optional
86
Homepage: $ HOMEPAGE
87
Installed-Size: $ ( du - sk " $ root /usr" | cut - f1)
88
Description: $ SUMMARY
89
$ DESCRIPTION
90
EOF
91
dpkg-deb -- build -- root-owner-group - Zxz " $ root " " $ OUT /$ { DEB_NAME } _$ { VERSION } _$ deb .deb" > /dev/null
92
fi
93
done
94
95
rm - rf " $ OUT /stage"
96
( cd " $ OUT " && sha256sum -- * .tar.gz * .zip * .deb > SHA256SUMS )
97
echo " == $ OUT "
98
ls - l " $ OUT "