#!/bin/zsh # Build script for OCaml topkg library set -e cd "$SRCDIR" export PATH="$PREFIX/bin:$PATH" export LD_LIBRARY_PATH="/usr/lib:${LD_LIBRARY_PATH:-}" export LIBRARY_PATH="/usr/lib:${LIBRARY_PATH:-}" # Build using the package build script ocaml pkg/pkg.ml build --pkg-name topkg # Install from .install file without opam-installer install_from_dotinstall() { local installfile="$1" prefix="$2" pkgname="$3" local section="" src dest dir while IFS= read -r line; do if [[ "$line" =~ '^([a-z_]+):' ]]; then section="${match[1]}" continue fi [[ -z "$section" || "$line" =~ '^\]' ]] && { [[ "$line" =~ '^\]' ]] && section=""; continue; } src="${${line#*\"}%%\"*}" [[ -z "$src" || ! -f "$src" ]] && continue if [[ "$line" =~ '\{"?([^}"]+)"?\}' ]]; then dest="${match[1]}" else dest="${src:t}" fi case "$section" in lib|libexec) dir="$prefix/lib/ocaml/$pkgname" ;; bin) dir="$prefix/bin" ;; share) dir="$prefix/share/$pkgname" ;; doc) dir="$prefix/doc/$pkgname" ;; man) dir="$prefix/man" ;; *) continue ;; esac mkdir -p "$dir/$(dirname "$dest")" cp "$src" "$dir/$dest" done < "$installfile" } install_from_dotinstall topkg.install "$PKGDIR$PREFIX" topkg [package] name = "ocaml-topkg" version = "1.1.1" description = "OCaml package release helper" homepage = "https://erratique.ch/software/topkg" license = "ISC" [dependencies] build = ["ocaml", "ocaml-findlib", "ocaml-ocamlbuild"] runtime = ["ocaml", "ocaml-findlib", "ocaml-ocamlbuild"] [[source]] file = "topkg-1.1.1.tbz" urls = [ "https://erratique.ch/software/topkg/releases/topkg-1.1.1.tbz" ] checksum = "skip" extract = true