-
Notifications
You must be signed in to change notification settings - Fork 17
/
example.spec
52 lines (51 loc) · 2 KB
/
example.spec
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
; This script builds OBuilder itself using a snapshot of the ocaml/opam:debian-12-ocaml-4.14 base image.
;
; Run it from the top-level of the OBuilder source tree, e.g.
;
; dune exec -- obuilder build --store=zfs:tank -f example.spec .
;
; The result can then be found in /tank/HASH/rootfs/ (where HASH is displayed at the end of the build).
((build dev
((from ocaml/opam@sha256:02f01da51f1ed2ae4191f143a46a508e2a34652c11ad2715e2bbe8e0d36fc30d)
(workdir /src)
(user (uid 1000) (gid 1000)) ; Build as the "opam" user
(run (shell "sudo chown opam /src"))
(env OPAM_HASH "8187cd8d3681d53f5042b5da316fa3f5e005a247")
(run
(network host)
(shell "sudo apt-get --allow-releaseinfo-change update"))
(run
(network host)
(shell
"cd ~/opam-repository \
&& (git cat-file -e $OPAM_HASH || git fetch origin master) \
&& git reset -q --hard $OPAM_HASH \
&& git --no-pager log --no-decorate -n1 --oneline \
&& opam update -u"))
; Copy just the opam file first (helps caching)
(copy (src obuilder-spec.opam obuilder.opam) (dst ./))
(run (shell "opam pin add -yn ."))
; Install OS package dependencies
(run
(network host)
(cache (opam-archives (target /home/opam/.opam/download-cache)))
(shell "opam depext -yu obuilder"))
; Install OCaml dependencies
(run
(network host)
(cache (opam-archives (target /home/opam/.opam/download-cache)))
(shell "opam install --deps-only -t obuilder"))
(copy ; Copy the rest of the source code
(src .)
(dst /src/)
(exclude .git _build _opam))
(run (shell "opam exec -- dune build @install @runtest")))) ; Build and test
; Now generate a small runtime image with just the resulting binary:
(from debian:12)
(run
(network host)
(shell "apt-get update && apt-get install -y libsqlite3-0 --no-install-recommends"))
(copy (from (build dev))
(src /src/_build/default/main.exe)
(dst /usr/local/bin/obuilder))
(run (shell "obuilder --help")))