Commit
Author: Kevin Schoon [kevinschoon@gmail.com]
Hash: 288f9926d24026502843ec344a74beffda63c8c4
Timestamp: Mon, 14 Sep 2020 18:03:29 +0000 (4 years ago)

+117 -117 +/-7 browse
update build scripts
1diff --git a/scripts/generate_arch_artifact.sh b/scripts/generate_arch_artifact.sh
2deleted file mode 100755
3index ac9ead2..0000000
4--- a/scripts/generate_arch_artifact.sh
5+++ /dev/null
6 @@ -1,26 +0,0 @@
7- #!/bin/bash
8- set -e
9-
10- VERSION="$1"
11-
12- TARBALL="note-glibc-$VERSION.tar.gz"
13- REMOTE_URL="https://github.com/kevinschoon/note/releases/download/$VERSION/$TARBALL"
14- MD5SUM="$(cat "pkg/$TARBALL.md5" |cut -d ' ' -f 1)"
15-
16- cat >pkg/PKGBUILD-$VERSION<<EOF
17- pkgname=note
18- pkgver=$VERSION
19- pkgrel=1
20- pkgdesc="Simple Note Taking CLI"
21- url="https://github.com/kevinschoon/note"
22- arch=(x86_64)
23- license=('AGPL3')
24- source=("$TARBALL::$REMOTE_URL")
25- md5sums=($MD5SUM)
26-
27- package() {
28- install -Dm755 usr/bin/note -t "\${pkgdir}/usr/bin/"
29- install -Dm644 usr/share/bash-completion/completion/note -t \${pkgdir}/usr/share/bash-completion/completion/note
30- install -Dm644 usr/share/man/man1/note.1.gz -t \${pkgdir}/usr/share/man/man1/
31- }
32- EOF
33 diff --git a/scripts/generate_build.sh b/scripts/generate_build.sh
34new file mode 100755
35index 0000000..1feed75
36--- /dev/null
37+++ b/scripts/generate_build.sh
38 @@ -0,0 +1,48 @@
39+ #!/bin/bash
40+ # Generate a compiled build artifact. This is a hack because
41+ # to the best of my knowledge the distribution story for OCaml
42+ # binaries is terrible. Dynamic linking means we need to
43+ # compile against the oldest version of GLIBC we wish to support.
44+ # We also link against Alpine muslc for convenience. It is not
45+ # possible to compile Mach-O Darwin executables from Linux, again,
46+ # AFAICT. ARM binaries would be nice too. TODO: Use a Docker buildx
47+ # workflow or perferably something without Docker at all.
48+ set -e
49+
50+ DOCKER_FILE="$1"
51+ PREFIX="$2"
52+
53+ _usage() {
54+ echo "USAGE: "
55+ echo "generate_build_artifact.sh DOCKERFILE PREFIX"
56+ }
57+
58+ [[ -z "$DOCKER_FILE" ]] || [[ -z "$PREFIX" ]] && {
59+ _usage
60+ exit 1
61+ }
62+
63+ # TODO: Capture more build specifics
64+ VERSION="$(git describe --always)"
65+
66+ PKG="note-$PREFIX-$VERSION"
67+ PKG_PATH="pkg/$PKG"
68+ PKG_TARGET="pkg/$PKG.tar.gz"
69+ SOURCE="$(realpath "_build/install/default")"
70+
71+ mkdir -p "$PKG_PATH"
72+ pushd "$PKG_PATH"
73+ mkdir -p usr/bin
74+ mkdir -p usr/share/man/man1
75+ cp "$SOURCE/man/man1/note.1" usr/share/man/man1/
76+ mkdir -p usr/share/bash-completion/completions
77+ cp "$SOURCE/share/note/note" usr/share/bash-completion/completions/
78+ gzip usr/share/man/man1/note.1
79+ popd
80+
81+ docker build -t "$PKG" -f "$DOCKER_FILE" .
82+ container_id="$(docker create $PKG)"
83+ docker cp "$container_id:/usr/bin/note" "$PKG_PATH/usr/bin/note"
84+ docker rm "$container_id" 1>/dev/null
85+ tar --owner root --group root -C "$PKG_PATH" -czvf "$PKG_TARGET" .
86+ md5sum "$PKG_TARGET" > "$PKG_TARGET.md5"
87 diff --git a/scripts/generate_build_artifact.sh b/scripts/generate_build_artifact.sh
88deleted file mode 100755
89index 5942030..0000000
90--- a/scripts/generate_build_artifact.sh
91+++ /dev/null
92 @@ -1,51 +0,0 @@
93- #!/bin/bash
94- # Generate a compiled build artifact. This is a hack because
95- # to the best of my knowledge the distribution story for OCaml
96- # binaries is terrible. Dynamic linking means we need to
97- # compile against the oldest version of GLIBC we wish to support.
98- # We also link against Alpine muslc for convenience. It is not
99- # possible to compile Mach-O Darwin executables from Linux, again,
100- # AFAICT. ARM binaries would be nice too. TODO: Use a Docker buildx
101- # workflow or perferably something without Docker at all.
102- set -e
103-
104- DOCKER_FILE="$1"
105- PREFIX="$2"
106-
107- _usage() {
108- echo "USAGE: "
109- echo "generate_build_artifact.sh DOCKERFILE PREFIX"
110- }
111-
112- [[ -z "$DOCKER_FILE" ]] || [[ -z "$PREFIX" ]] && {
113- _usage
114- exit 1
115- }
116-
117- # TODO: Capture more build specifics
118- VERSION="$(git describe --always)"
119-
120- dune clean
121- dune build
122-
123- PKG="note-$PREFIX-$VERSION"
124- PKG_PATH="pkg/$PKG"
125- PKG_TARGET="pkg/$PKG.tar.gz"
126- SOURCE="$(realpath "_build/install/default")"
127-
128- mkdir -p "$PKG_PATH"
129- pushd "$PKG_PATH"
130- mkdir -p usr/bin
131- mkdir -p usr/share/man/man1
132- cp "$SOURCE/man/man1/note.1" usr/share/man/man1/
133- mkdir -p usr/share/bash-completion/completion
134- cp "$SOURCE/share/note/note" usr/share/bash-completion/completion/
135- gzip usr/share/man/man1/note.1
136- popd
137-
138- docker build -t "$PKG" -f "$DOCKER_FILE" .
139- container_id="$(docker create $PKG)"
140- docker cp "$container_id:/usr/bin/note" "$PKG_PATH/usr/bin/note"
141- docker rm "$container_id" 1>/dev/null
142- tar --owner root --group root -C "$PKG_PATH" -czvf "$PKG_TARGET" .
143- md5sum "$PKG_TARGET" > "$PKG_TARGET.md5"
144 diff --git a/scripts/generate_deb.sh b/scripts/generate_deb.sh
145new file mode 100755
146index 0000000..f602af9
147--- /dev/null
148+++ b/scripts/generate_deb.sh
149 @@ -0,0 +1,36 @@
150+ #!/bin/bash
151+ # generate a deb package for debian based systems
152+ set -e
153+
154+
155+ _usage () {
156+ echo "USAGE: "
157+ echo "generate_debian_artifact.sh VERSION"
158+ }
159+
160+ VERSION="$1"
161+
162+ [[ -z "$VERSION" ]] && {
163+ _usage
164+ exit 1
165+ }
166+
167+ BUILD_ARTIFACT="pkg/note-glibc-$VERSION"
168+ PKG="note-$VERSION-debian"
169+ PKG_PATH="pkg/$PKG"
170+ PKG_TARGET="$PKG_PATH.deb"
171+ mkdir -p "$PKG_PATH/DEBIAN"
172+
173+ cat >"$PKG_PATH/DEBIAN/control"<<EOF
174+ Package: note-ocaml
175+ Version: $VERSION
176+ Maintainer: Kevin Schoon <kevinschoon@gmail.com>
177+ Architecture: amd64
178+ Description: simple note taking cli
179+ EOF
180+
181+ cp -r "$BUILD_ARTIFACT"/* "$PKG_PATH/"
182+
183+ # TODO: dune doesn't allow this path somehow
184+ dpkg-deb --root-owner-group -b "$PKG_PATH"
185+ md5sum "$PKG_TARGET" > "$PKG_TARGET.md5"
186 diff --git a/scripts/generate_deb_artifact.sh b/scripts/generate_deb_artifact.sh
187deleted file mode 100755
188index f602af9..0000000
189--- a/scripts/generate_deb_artifact.sh
190+++ /dev/null
191 @@ -1,36 +0,0 @@
192- #!/bin/bash
193- # generate a deb package for debian based systems
194- set -e
195-
196-
197- _usage () {
198- echo "USAGE: "
199- echo "generate_debian_artifact.sh VERSION"
200- }
201-
202- VERSION="$1"
203-
204- [[ -z "$VERSION" ]] && {
205- _usage
206- exit 1
207- }
208-
209- BUILD_ARTIFACT="pkg/note-glibc-$VERSION"
210- PKG="note-$VERSION-debian"
211- PKG_PATH="pkg/$PKG"
212- PKG_TARGET="$PKG_PATH.deb"
213- mkdir -p "$PKG_PATH/DEBIAN"
214-
215- cat >"$PKG_PATH/DEBIAN/control"<<EOF
216- Package: note-ocaml
217- Version: $VERSION
218- Maintainer: Kevin Schoon <kevinschoon@gmail.com>
219- Architecture: amd64
220- Description: simple note taking cli
221- EOF
222-
223- cp -r "$BUILD_ARTIFACT"/* "$PKG_PATH/"
224-
225- # TODO: dune doesn't allow this path somehow
226- dpkg-deb --root-owner-group -b "$PKG_PATH"
227- md5sum "$PKG_TARGET" > "$PKG_TARGET.md5"
228 diff --git a/scripts/generate_pkgbuild.sh b/scripts/generate_pkgbuild.sh
229new file mode 100755
230index 0000000..9e25950
231--- /dev/null
232+++ b/scripts/generate_pkgbuild.sh
233 @@ -0,0 +1,26 @@
234+ #!/bin/bash
235+ set -e
236+
237+ VERSION="$1"
238+
239+ TARBALL="note-glibc-$VERSION.tar.gz"
240+ REMOTE_URL="https://github.com/kevinschoon/note/releases/download/$VERSION/$TARBALL"
241+ MD5SUM="$(cat "pkg/$TARBALL.md5" |cut -d ' ' -f 1)"
242+
243+ cat >pkg/PKGBUILD-$VERSION<<EOF
244+ pkgname=note
245+ pkgver=$VERSION
246+ pkgrel=1
247+ pkgdesc="Simple Note Taking CLI"
248+ url="https://github.com/kevinschoon/note"
249+ arch=(x86_64)
250+ license=('AGPL3')
251+ source=("$TARBALL::$REMOTE_URL")
252+ md5sums=($MD5SUM)
253+
254+ package() {
255+ install -Dm755 usr/bin/note -t "\${pkgdir}/usr/bin/"
256+ install -Dm644 usr/share/bash-completion/completions/note -t \${pkgdir}/usr/share/bash-completion/completions/
257+ install -Dm644 usr/share/man/man1/note.1.gz -t \${pkgdir}/usr/share/man/man1/
258+ }
259+ EOF
260 diff --git a/scripts/release.sh b/scripts/release.sh
261index 2e931a0..e8499ec 100755
262--- a/scripts/release.sh
263+++ b/scripts/release.sh
264 @@ -3,9 +3,12 @@ set -e
265
266 VERSION="$(git describe --always)"
267
268- scripts/generate_build_artifact.sh docker/Dockerfile.debian glibc
269- scripts/generate_deb_artifact.sh "$VERSION"
270+ dune clean
271+ dune build
272
273- scripts/generate_build_artifact.sh docker/Dockerfile.alpine muslc
274+ scripts/generate_build.sh docker/Dockerfile.debian glibc
275+ scripts/generate_deb.sh "$VERSION"
276
277- scripts/generate_arch_artifact.sh "$VERSION"
278+ scripts/generate_build.sh docker/Dockerfile.alpine muslc
279+
280+ scripts/generate_pkgbuild.sh "$VERSION"