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