owned this note
owned this note
Published
Linked with GitHub
# Fix MirageOS Libraries on CI
Reference: https://ocaml.ci.dev/github/mirage
| Status | Package | Issue | Comments |
|--------|---------|-------|----------|
| DONE | Either | WARNING: updating https://dl-cdn.alpinelinux.org/alpine/v3.19/main: temporary error (try again later) | Use alpine-3.19-ocaml-5.1 Docker image for successful build |
| DONE | Coin | (lower-bound) and alpine-3.19-5.1_opam-2.1 build failure with WARNING: updating https://dl-cdn.alpinelinux.org/alpine/v3.19/main: temporary error (try again later) | Ensure re package is installed. |
| DONE | bechamel | Result is not found | Install linux-headers apk and re-build with dependencies installed |
| DONE | irmin-watcher | Error: Unbound value Mtime.Span.to_ms |
| TODO | alcotest | Failing on debian-12-5.2~alpha1_opam-2.1 and FreeBSD | |
| TODO | cactus | Error: Unbound value Mtime.Span.to_ms | |
| TODO | mirage-www | Failed in 0s | |
| TODO | conan | Failing on dependency error on debian-12-4.14+flambda_opam-2.1 | |
| TODO | cowabloga | Error: Unbound module Cohttp_lwt_unix_net (multiple distros) | |
| TODO | irmin | lint error | |
|
On Ubuntu 22.04 LTS:
## Docker
```
$ sudo apt install docker.io
$ sudo docker pull alpine:3.19.1
```
## Attempt III: Using images from ocaml/opam
Test with alpine-3.19-ocaml-5.1:
Pre-requisites:
```
$ sudo docker pull ocaml/opam:alpine-3.19-ocaml-5.1
$ sudo docker run -it ocaml/opam:alpine-3.19-ocaml-5.1 bash
```
### Either
```
$ git clone https://github.com/mirage/either.git
$ opam install dune
$ cd either
$ dune build
$ cd _build/default/src/.either.jobs/byte/
$ ocaml
# #load "either.cmo" ;;
# Either.left ;;
```
### coin
```
$ git clone https://github.com/mirage/coin.git
$ opam install . --deps-only -y
$ dune build
$ dune runtest
$ dune exec -- ./_build/default/gen/generate.exe
```
### bechamel
```
$ git clone https://github.com/mirage/bechamel.git
$ cd bechamel
$ sudo apk add linux-headers
# Add "result" to depends in bechamel.opam
$ opam install . --deps-only --with-test
$ dune build
$ dune runtest
$ dune exec -- ./_build/default/examples/list.exe
$ dune exec -- ./_build/default/examples/fact.exe
````
### cactus
gmp-dev is not installed on alpine.
$ sudo apk add gmp-dev
$ opam install . --deps-only --with-test -y
$ dune build
```
~/cactus$ dune build
File "src/stats.ml", line 78, characters 36-52:
78 | let point = add_span |> Mtime.Span.to_us |> Float.log in
^^^^^^^^^^^^^^^^
Error: Unbound value Mtime.Span.to_us
File "bench/encoding/encoding.ml", line 54, characters 18-35:
54 | ~short_hash:short_hash_staged H.of_raw_string H.to_raw_string
^^^^^^^^^^^^^^^^^
Error: This expression has type (?seed:int -> t -> int) Repr__Type.staged
but an expression was expected of type ?seed:int -> t -> int
File "src/recorder.ml", line 57, characters 63-64:
57 | let _, size = decode_int32 (really_input_string in_ 4) 0 in
^
Error: This expression has type int but an expression was expected of type
int ref
File "bench/log.ml", line 23, characters 42-58:
23 | let dt = Mtime_clock.count counter |> Mtime.Span.to_ms in
^^^^^^^^^^^^^^^^
Error: Unbound value Mtime.Span.to_ms
File "tests/log.ml", line 23, characters 42-58:
23 | let dt = Mtime_clock.count counter |> Mtime.Span.to_ms in
^^^^^^^^^^^^^^^^
Error: Unbound value Mtime.Span.to_ms
File "tests/common.ml", line 110, characters 42-58:
110 | let dt = Mtime_clock.count counter |> Mtime.Span.to_ms in
^^^^^^^^^^^^^^^^
Error: Unbound value Mtime.Span.to_ms
```
### Conan
Failure on debian-12-4.14+flambda_opam-2.1
```
[ERROR] Package conflict!
* Incompatible packages:
- conan-unix >= dev
- (invariant) -> ocaml-options-only-flambda -> ocaml-option-flambda
You can temporarily relax the switch invariant with `--update-invariant'
```
### cowabloga
On alpine-3.19-5.1_opam-2.1 and other distributions:
```
Warning 70 [missing-mli]: Cannot find interface file.
(cd _build/default && /home/opam/.opam/5.1/bin/ocamlc.opt -w @1..3@5..28@30..39@43@46..47@49..57@61..62-40 -strict-sequence -strict-formats -short-paths -keep-locs -w A-4-41-44 -warn-error +1..49 -strict-sequence -principal -g -bin-annot -I lib/.cowabloga.objs/byte -I /home/opam/.opam/5.1/lib/angstrom -I /home/opam/.opam/5.1/lib/bigstringaf -I /home/opam/.opam/5.1/lib/cow -I /home/opam/.opam/5.1/lib/cstruct -I /home/opam/.opam/5.1/lib/ezjsonm -I /home/opam/.opam/5.1/lib/hex -I /home/opam/.opam/5.1/lib/jsonm -I /home/opam/.opam/5.1/lib/lwt -I /home/opam/.opam/5.1/lib/magic-mime -I /home/opam/.opam/5.1/lib/omd -I /home/opam/.opam/5.1/lib/re -I /home/opam/.opam/5.1/lib/seq -I /home/opam/.opam/5.1/lib/sexplib0 -I /home/opam/.opam/5.1/lib/stringext -I /home/opam/.opam/5.1/lib/uri -I /home/opam/.opam/5.1/lib/uucp -I /home/opam/.opam/5.1/lib/uunf -I /home/opam/.opam/5.1/lib/uutf -I /home/opam/.opam/5.1/lib/xmlm -intf-suffix .ml -no-alias-deps -opaque -open Cowabloga -o lib/.cowabloga.objs/byte/cowabloga__Blog.cmo -c -impl lib/blog.ml)
File "lib/blog.ml", line 101, characters 14-35:
101 | let to_html ?(sep=default_separator) ~feed ~entries =
^^^^^^^^^^^^^^^^^^^^^
Error (warning 16 [unerasable-optional-argument]): this optional argument cannot be erased.
(cd _build/default && /home/opam/.opam/5.1/bin/ocamlc.opt -w @1..3@5..28@30..39@43@46..47@49..57@61..62-40 -strict-sequence -strict-formats -short-paths -keep-locs -w A-4-41-44 -warn-error +1..49 -strict-sequence -principal -g -bin-annot -I lib/.cowabloga.objs/byte -I /home/opam/.opam/5.1/lib/angstrom -I /home/opam/.opam/5.1/lib/bigstringaf -I /home/opam/.opam/5.1/lib/cow -I /home/opam/.opam/5.1/lib/cstruct -I /home/opam/.opam/5.1/lib/ezjsonm -I /home/opam/.opam/5.1/lib/hex -I /home/opam/.opam/5.1/lib/jsonm -I /home/opam/.opam/5.1/lib/lwt -I /home/opam/.opam/5.1/lib/magic-mime -I /home/opam/.opam/5.1/lib/omd -I /home/opam/.opam/5.1/lib/re -I /home/opam/.opam/5.1/lib/seq -I /home/opam/.opam/5.1/lib/sexplib0 -I /home/opam/.opam/5.1/lib/stringext -I /home/opam/.opam/5.1/lib/uri -I /home/opam/.opam/5.1/lib/uucp -I /home/opam/.opam/5.1/lib/uunf -I /home/opam/.opam/5.1/lib/uutf -I /home/opam/.opam/5.1/lib/xmlm -no-alias-deps -opaque -open Cowabloga -o lib/.cowabloga.objs/byte/cowabloga__Feed.cmo -c -impl lib/feed.ml)
File "lib/feed.ml", line 1:
Warning 70 [missing-mli]: Cannot find interface file.
(cd _build/default && /home/opam/.opam/5.1/bin/ocamlopt.opt -w @1..3@5..28@30..39@43@46..47@49..57@61..62-40 -strict-sequence -strict-formats -short-paths -keep-locs -w A-4-41-44 -warn-error +1..49 -strict-sequence -principal -g -I lib/.cowabloga.objs/byte -I lib/.cowabloga.objs/native -I /home/opam/.opam/5.1/lib/angstrom -I /home/opam/.opam/5.1/lib/bigstringaf -I /home/opam/.opam/5.1/lib/cow -I /home/opam/.opam/5.1/lib/cstruct -I /home/opam/.opam/5.1/lib/ezjsonm -I /home/opam/.opam/5.1/lib/hex -I /home/opam/.opam/5.1/lib/jsonm -I /home/opam/.opam/5.1/lib/lwt -I /home/opam/.opam/5.1/lib/magic-mime -I /home/opam/.opam/5.1/lib/omd -I /home/opam/.opam/5.1/lib/re -I /home/opam/.opam/5.1/lib/seq -I /home/opam/.opam/5.1/lib/sexplib0 -I /home/opam/.opam/5.1/lib/stringext -I /home/opam/.opam/5.1/lib/uri -I /home/opam/.opam/5.1/lib/uucp -I /home/opam/.opam/5.1/lib/uunf -I /home/opam/.opam/5.1/lib/uutf -I /home/opam/.opam/5.1/lib/xmlm -intf-suffix .ml -no-alias-deps -opaque -open Cowabloga -o lib/.cowabloga.objs/native/cowabloga__Blog.cmx -c -impl lib/blog.ml)
File "lib/blog.ml", line 101, characters 14-35:
101 | let to_html ?(sep=default_separator) ~feed ~entries =
^^^^^^^^^^^^^^^^^^^^^
Error (warning 16 [unerasable-optional-argument]): this optional argument cannot be erased.
(cd _build/default && /home/opam/.opam/5.1/bin/ocamlc.opt -w @1..3@5..28@30..39@43@46..47@49..57@61..62-40 -strict-sequence -strict-formats -short-paths -keep-locs -g -bin-annot -I lib_test/.serve.eobjs/byte -I /home/opam/.opam/5.1/lib/angstrom -I /home/opam/.opam/5.1/lib/astring -I /home/opam/.opam/5.1/lib/base64 -I /home/opam/.opam/5.1/lib/bigstringaf -I /home/opam/.opam/5.1/lib/bytes -I /home/opam/.opam/5.1/lib/cohttp -I /home/opam/.opam/5.1/lib/cohttp-lwt -I /home/opam/.opam/5.1/lib/cohttp-lwt-unix -I /home/opam/.opam/5.1/lib/conduit -I /home/opam/.opam/5.1/lib/conduit-lwt -I /home/opam/.opam/5.1/lib/conduit-lwt-unix -I /home/opam/.opam/5.1/lib/cow -I /home/opam/.opam/5.1/lib/cstruct -I /home/opam/.opam/5.1/lib/domain-name -I /home/opam/.opam/5.1/lib/ezjsonm -I /home/opam/.opam/5.1/lib/fmt -I /home/opam/.opam/5.1/lib/hex -I /home/opam/.opam/5.1/lib/ipaddr -I /home/opam/.opam/5.1/lib/ipaddr-sexp -I /home/opam/.opam/5.1/lib/ipaddr/unix -I /home/opam/.opam/5.1/lib/jsonm -I /home/opam/.opam/5.1/lib/logs -I /home/opam/.opam/5.1/lib/lwt -I /home/opam/.opam/5.1/lib/lwt/unix -I /home/opam/.opam/5.1/lib/macaddr -I /home/opam/.opam/5.1/lib/magic-mime -I /home/opam/.opam/5.1/lib/ocaml/threads -I /home/opam/.opam/5.1/lib/ocaml/unix -I /home/opam/.opam/5.1/lib/ocplib-endian -I /home/opam/.opam/5.1/lib/ocplib-endian/bigstring -I /home/opam/.opam/5.1/lib/omd -I /home/opam/.opam/5.1/lib/parsexp -I /home/opam/.opam/5.1/lib/ppx_sexp_conv/runtime-lib -I /home/opam/.opam/5.1/lib/re -I /home/opam/.opam/5.1/lib/seq -I /home/opam/.opam/5.1/lib/sexplib -I /home/opam/.opam/5.1/lib/sexplib0 -I /home/opam/.opam/5.1/lib/stringext -I /home/opam/.opam/5.1/lib/uri -I /home/opam/.opam/5.1/lib/uri-sexp -I /home/opam/.opam/5.1/lib/uri/services -I /home/opam/.opam/5.1/lib/uucp -I /home/opam/.opam/5.1/lib/uunf -I /home/opam/.opam/5.1/lib/uutf -I /home/opam/.opam/5.1/lib/xmlm -I lib/.cowabloga.objs/byte -no-alias-deps -opaque -o lib_test/.serve.eobjs/byte/serve.cmo -c -impl lib_test/serve.ml)
File "lib_test/serve.ml", line 36, characters 12-36:
36 | let ctx = Cohttp_lwt_unix_net.init () in
^^^^^^^^^^^^^^^^^^^^^^^^
Error: Unbound module Cohttp_lwt_unix_net
```
### irmin
```
"/usr/bin/env" "bash" "-c" "opam exec -- opam-dune-lint" failed with exit status 1
2024-03-13 22:40.54: Job failed: Failed: Build failed
```
### irmin-watcher
```
$ git clone https://github.com/mirage/irmin-watcher.git
$ cd irmin-watcher
$ sudo apk add libffi-dev
$ opam install . --deps-only --with-test -y
$ dune build
$ dune test
```
```
$ opam install . --deps-only -y
<><> Processing actions <><><><><><><><><><><><><><><><><><><><><><><><><><><><>
-> installed conf-pkg-config.3
[ERROR] The compilation of conf-libffi failed at "/usr/bin/pkg-config libffi".
...
File "test/dune", line 3, characters 50-64:
3 | (libraries alcotest logs.fmt irmin-watcher mtime mtime.clock.os))
^^^^^^^^^^^^^^
Error: Library "mtime.clock.os" not found.
```
1. Update mtime dependency in dune-project to use:
(mtime (and :with-test (>= "2.0.0")))
```
File "test/test.ml", line 135, characters 15-31:
135 | let dt = Mtime.Span.to_us (Mtime_clock.elapsed ()) in
^^^^^^^^^^^^^^^^
Error: Unbound value Mtime.Span.to_us
```
Update test/test.ml from Mtime.Span.to_us to Mtime.Span.to_float_ns.
Reference:
1. cca - Mtime.Span.to_float.ns https://github.com/codinuum/cca/commit/7e900b68b3799252d9cac4cc397c439205371651
Docker Source:
1. https://hub.docker.com/r/ocaml/opam/tags?page=1&name=alpine-3.19-ocaml-5.1
## Attempt II: Using dev-containers
### Start the container
```
$ sudo docker run -it alpine:3.19.1 sh
```
### Install dependenciess
```
$ apk add --update alpine-sdk build-base curl git bzip2 bash
$ mkdir /usr/dev/ocaml
$ mkdir -p /usr/dev/ocaml/bin /usr/dev/ocaml/lib</pre>
# wget https://raw.githubusercontent.com/avsm/ocaml-devcontainers/main/install-tools.sh
# wget https://raw.githubusercontent.com/avsm/ocaml-devcontainers/main/install-ocaml.sh
# chmod +x *.sh
# /root/install-ocaml.sh 5.1.1
```
References:
1. Dockerfile.apk. https://github.com/avsm/ocaml-devcontainers/blob/main/Dockerfile.apk
## Attempt I: Manual opam install
### Install dependencies
```
# apk update
# apk add make nano patch build-base \
bubblewrap rsync git sudo bash \
mercurial
```
Note: build-base provides cc.
### Install OPAM
```
# wget https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh
# sh install.sh
```
### Create user opam
```
~ # adduser opam
Changing password for opam
New password:
Bad password: too short
Retype password:
passwd: password for opam changed by root
```
```
# visudo
```
Add
```
opam ALL=(ALL:ALL) ALL
```
Update /etc/passwd to set default shell as /bin/bash for opam user.
### Set sh redirect to bash
```
# ln -sf /bin/bash /bin/sh
```
### Initialize opam
```
# sudo su - opam
$ opam init
```
The error
```
$ opam init
No configuration file found, using built-in defaults.
Checking for available remotes: rsync and local, git, mercurial.
- you won't be able to use darcs repositories unless you install the darcs command on your system.
[ERROR] Sandboxing is not working on your platform alpine:
"~/.opam/opam-init/hooks/sandbox.sh build sh -c echo SUCCESS >$TMPDIR/opam-sandbox-check-out && cat $TMPDIR/opam-sandbox-check-out; rm -f
$TMPDIR/opam-sandbox-check-out" exited with code 1
Do you want to disable it? Note that this will result in less secure package builds, so please ensure that you have some other isolation mechanisms in place (such as
running within a container or virtual machine). [y/N]
```
References:
1. Push deprecated containers when rotating out distributions. https://github.com/ocurrent/docker-base-images/issues/57