package opam_bin_lib

  1. Overview
  2. Docs
The opam-bin tool is a simple framework to use `opam` with binary packages

Install

dune-project
 Dependency

Authors

Maintainers

Sources

v1.2.0.tar.gz
sha256=1d061f53870a3212133c6713207e040fca9c76a1b81696049599f1a84b44e76c

doc/src/opam_bin_lib/commandWrapInstall.ml.html

Source file commandWrapInstall.ml

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
53
54
55
56
57
58
(**************************************************************************)
(*                                                                        *)
(*    Copyright 2020 OCamlPro & Origin Labs                               *)
(*                                                                        *)
(*  All rights reserved. This file is distributed under the terms of the  *)
(*  GNU Lesser General Public License version 2.1, with the special       *)
(*  exception on linking described in the file LICENSE.                   *)
(*                                                                        *)
(**************************************************************************)

open Ezcmd.TYPES

let cmd_name = "wrap-install"

(* We check:
   * if `_bincached/` exists, we have found a binary archive in the
     cache. We go in that directory where we should find:
     * `bin-package.version`: we should move this file to
       "%{prefix}%/etc/opam-bin/packages/%{name}%". Once the file has been
       moved, we use its absence as a marker that we shouldn't redo the
       installation
     * `bin-package.config`: optional. to be copied into
      "%{prefix}%/.opam-switch/config/%{name}%.config"
     * a directory: it is the content of the binary archive, to be copied
      into "%{prefix}%"
   * if `_binsource` exists, we are in a source archive and should exec
      the installation steps

   NOTE: we could move the installation part in a pre-install command.
 *)

let action args =
  Misc.make_cache_dir ();
  match args with
  | name :: version :: _depends :: cmd ->
      let nvo = Some ( Printf.sprintf "%s.%s" name version ) in
      Misc.log_cmd ~nvo cmd_name args ;
      if Sys.file_exists ( Globals.backup_source ~name )
      || Sys.file_exists ( Globals.backup_skip ~name )
      then
        Misc.call ~nvo (Array.of_list cmd)
  | _ ->
      Printf.eprintf
        "Unexpected args: usage is '%s %s name version depends cmd...'\n%!" Globals.command cmd_name;
      exit 2

let cmd =
  let args = ref [] in
  Arg.{
  cmd_name ;
  cmd_action = (fun () -> action !args) ;
  cmd_args = [
    [], Anons (fun list -> args := list),
    Ezcmd.info "args"
  ];
  cmd_man = [];
  cmd_doc = "(opam hook) Exec or not build commands";
}