opam: 1.2.2 -> 2.0.0 (#45806)
This commit is contained in:
parent
aed92ec2e9
commit
3fc7c5b591
|
@ -0,0 +1,92 @@
|
|||
{ stdenv, lib, fetchurl, makeWrapper,
|
||||
ocaml, unzip, ncurses, curl, aspcud
|
||||
}:
|
||||
|
||||
assert lib.versionAtLeast ocaml.version "3.12.1";
|
||||
|
||||
let
|
||||
srcs = {
|
||||
cudf = fetchurl {
|
||||
url = "https://gforge.inria.fr/frs/download.php/file/33593/cudf-0.7.tar.gz";
|
||||
sha256 = "92c8a9ed730bbac73f3513abab41127d966c9b9202ab2aaffcd02358c030a701";
|
||||
};
|
||||
extlib = fetchurl {
|
||||
url = "http://ocaml-extlib.googlecode.com/files/extlib-1.5.3.tar.gz";
|
||||
sha256 = "c095eef4202a8614ff1474d4c08c50c32d6ca82d1015387785cf03d5913ec021";
|
||||
};
|
||||
ocaml_re = fetchurl {
|
||||
url = "https://github.com/ocaml/ocaml-re/archive/ocaml-re-1.2.0.tar.gz";
|
||||
sha256 = "a34dd9d6136731436a963bbab5c4bbb16e5d4e21b3b851d34887a3dec451999f";
|
||||
};
|
||||
ocamlgraph = fetchurl {
|
||||
url = "http://ocamlgraph.lri.fr/download/ocamlgraph-1.8.5.tar.gz";
|
||||
sha256 = "d167466435a155c779d5ec25b2db83ad851feb42ebc37dca8ffa345ddaefb82f";
|
||||
};
|
||||
dose3 = fetchurl {
|
||||
url = "https://gforge.inria.fr/frs/download.php/file/34277/dose3-3.3.tar.gz";
|
||||
sha256 = "8dc4dae9b1a81bb3a42abb283df785ba3eb00ade29b13875821c69f03e00680e";
|
||||
};
|
||||
cmdliner = fetchurl {
|
||||
url = "http://erratique.ch/software/cmdliner/releases/cmdliner-0.9.7.tbz";
|
||||
sha256 = "9c19893cffb5d3c3469ee0cce85e3eeeba17d309b33b9ace31aba06f68f0bf7a";
|
||||
};
|
||||
uutf = fetchurl {
|
||||
url = "http://erratique.ch/software/uutf/releases/uutf-0.9.3.tbz";
|
||||
sha256 = "1f364f89b1179e5182a4d3ad8975f57389d45548735d19054845e06a27107877";
|
||||
};
|
||||
jsonm = fetchurl {
|
||||
url = "http://erratique.ch/software/jsonm/releases/jsonm-0.9.1.tbz";
|
||||
sha256 = "3fd4dca045d82332da847e65e981d8b504883571d299a3f7e71447d46bc65f73";
|
||||
};
|
||||
opam = fetchurl {
|
||||
url = "https://github.com/ocaml/opam/archive/1.2.2.zip";
|
||||
sha256 = "c590ce55ae69ec74f46215cf16a156a02b23c5f3ecb22f23a3ad9ba3d91ddb6e";
|
||||
};
|
||||
};
|
||||
in stdenv.mkDerivation rec {
|
||||
name = "opam-${version}";
|
||||
version = "1.2.2";
|
||||
|
||||
buildInputs = [ unzip curl ncurses ocaml makeWrapper ];
|
||||
|
||||
src = srcs.opam;
|
||||
|
||||
postUnpack = ''
|
||||
ln -sv ${srcs.cudf} $sourceRoot/src_ext/${srcs.cudf.name}
|
||||
ln -sv ${srcs.extlib} $sourceRoot/src_ext/${srcs.extlib.name}
|
||||
ln -sv ${srcs.ocaml_re} $sourceRoot/src_ext/${srcs.ocaml_re.name}
|
||||
ln -sv ${srcs.ocamlgraph} $sourceRoot/src_ext/${srcs.ocamlgraph.name}
|
||||
ln -sv ${srcs.dose3} $sourceRoot/src_ext/${srcs.dose3.name}
|
||||
ln -sv ${srcs.cmdliner} $sourceRoot/src_ext/${srcs.cmdliner.name}
|
||||
ln -sv ${srcs.uutf} $sourceRoot/src_ext/${srcs.uutf.name}
|
||||
ln -sv ${srcs.jsonm} $sourceRoot/src_ext/${srcs.jsonm.name}
|
||||
'';
|
||||
|
||||
preConfigure = ''
|
||||
substituteInPlace ./src_ext/Makefile --replace "%.stamp: %.download" "%.stamp:"
|
||||
'';
|
||||
|
||||
postConfigure = "make lib-ext";
|
||||
|
||||
# Dirty, but apparently ocp-build requires a TERM
|
||||
makeFlags = ["TERM=screen"];
|
||||
|
||||
# change argv0 to "opam" as a workaround for
|
||||
# https://github.com/ocaml/opam/issues/2142
|
||||
postInstall = ''
|
||||
mv $out/bin/opam $out/bin/.opam-wrapped
|
||||
makeWrapper $out/bin/.opam-wrapped $out/bin/opam \
|
||||
--argv0 "opam" \
|
||||
--suffix PATH : ${aspcud}/bin:${unzip}/bin:${curl}/bin
|
||||
'';
|
||||
|
||||
doCheck = false;
|
||||
|
||||
meta = with stdenv.lib; {
|
||||
description = "A package manager for OCaml";
|
||||
homepage = http://opam.ocamlpro.com/;
|
||||
maintainers = [ maintainers.henrytill ];
|
||||
platforms = platforms.all;
|
||||
license = licenses.lgpl21Plus;
|
||||
};
|
||||
}
|
|
@ -1,69 +1,87 @@
|
|||
{ stdenv, lib, fetchurl, makeWrapper,
|
||||
ocaml, unzip, ncurses, curl, aspcud
|
||||
{ stdenv, lib, fetchurl, makeWrapper, getconf,
|
||||
ocaml, unzip, ncurses, curl, aspcud, bubblewrap
|
||||
}:
|
||||
|
||||
assert lib.versionAtLeast ocaml.version "3.12.1";
|
||||
assert lib.versionAtLeast ocaml.version "4.02.3";
|
||||
|
||||
let
|
||||
srcs = {
|
||||
cmdliner = fetchurl {
|
||||
url = "http://erratique.ch/software/cmdliner/releases/cmdliner-1.0.2.tbz";
|
||||
sha256 = "18jqphjiifljlh9jg8zpl6310p3iwyaqphdkmf89acyaix0s4kj1";
|
||||
};
|
||||
cppo = fetchurl {
|
||||
url = "https://github.com/mjambon/cppo/archive/v1.6.4.tar.gz";
|
||||
sha256 = "0jdb7d21lfa3ck4k59mrqs5pljzq5rb504jq57nnrc6klljm42j7";
|
||||
};
|
||||
cudf = fetchurl {
|
||||
url = "https://gforge.inria.fr/frs/download.php/file/33593/cudf-0.7.tar.gz";
|
||||
sha256 = "92c8a9ed730bbac73f3513abab41127d966c9b9202ab2aaffcd02358c030a701";
|
||||
};
|
||||
extlib = fetchurl {
|
||||
url = "http://ocaml-extlib.googlecode.com/files/extlib-1.5.3.tar.gz";
|
||||
sha256 = "c095eef4202a8614ff1474d4c08c50c32d6ca82d1015387785cf03d5913ec021";
|
||||
};
|
||||
ocaml_re = fetchurl {
|
||||
url = "https://github.com/ocaml/ocaml-re/archive/ocaml-re-1.2.0.tar.gz";
|
||||
sha256 = "a34dd9d6136731436a963bbab5c4bbb16e5d4e21b3b851d34887a3dec451999f";
|
||||
};
|
||||
ocamlgraph = fetchurl {
|
||||
url = "http://ocamlgraph.lri.fr/download/ocamlgraph-1.8.5.tar.gz";
|
||||
sha256 = "d167466435a155c779d5ec25b2db83ad851feb42ebc37dca8ffa345ddaefb82f";
|
||||
url = "https://gforge.inria.fr/frs/download.php/36602/cudf-0.9.tar.gz";
|
||||
sha256 = "0771lwljqwwn3cryl0plny5a5dyyrj4z6bw66ha5n8yfbpcy8clr";
|
||||
};
|
||||
dose3 = fetchurl {
|
||||
url = "https://gforge.inria.fr/frs/download.php/file/34277/dose3-3.3.tar.gz";
|
||||
sha256 = "8dc4dae9b1a81bb3a42abb283df785ba3eb00ade29b13875821c69f03e00680e";
|
||||
url = "https://gforge.inria.fr/frs/download.php/file/36063/dose3-5.0.1.tar.gz";
|
||||
sha256 = "00yvyfm4j423zqndvgc1ycnmiffaa2l9ab40cyg23pf51qmzk2jm";
|
||||
};
|
||||
cmdliner = fetchurl {
|
||||
url = "http://erratique.ch/software/cmdliner/releases/cmdliner-0.9.7.tbz";
|
||||
sha256 = "9c19893cffb5d3c3469ee0cce85e3eeeba17d309b33b9ace31aba06f68f0bf7a";
|
||||
extlib = fetchurl {
|
||||
url = "http://ygrek.org.ua/p/release/ocaml-extlib/extlib-1.7.5.tar.gz";
|
||||
sha256 = "19slqf5bdj0rrph2w41giwmn6df2qm07942jn058pjkjrnk30d4s";
|
||||
};
|
||||
uutf = fetchurl {
|
||||
url = "http://erratique.ch/software/uutf/releases/uutf-0.9.3.tbz";
|
||||
sha256 = "1f364f89b1179e5182a4d3ad8975f57389d45548735d19054845e06a27107877";
|
||||
jbuilder = fetchurl {
|
||||
url = "https://github.com/ocaml/dune/releases/download/1.0+beta20/jbuilder-1.0.beta20.tbz";
|
||||
sha256 = "07hl9as5llffgd6hbw41rs76i1ibgn3n9r0dba5h0mdlkapcwb10";
|
||||
};
|
||||
jsonm = fetchurl {
|
||||
url = "http://erratique.ch/software/jsonm/releases/jsonm-0.9.1.tbz";
|
||||
sha256 = "3fd4dca045d82332da847e65e981d8b504883571d299a3f7e71447d46bc65f73";
|
||||
mccs = fetchurl {
|
||||
url = "https://github.com/AltGr/ocaml-mccs/archive/1.1+8.tar.gz";
|
||||
sha256 = "0xavfvxfrcf3lmry8ymma1yzy0hw3ijbx94c9zq3pzlwnylrapa4";
|
||||
};
|
||||
ocamlgraph = fetchurl {
|
||||
url = "http://ocamlgraph.lri.fr/download/ocamlgraph-1.8.8.tar.gz";
|
||||
sha256 = "0m9g16wrrr86gw4fz2fazrh8nkqms0n863w7ndcvrmyafgxvxsnr";
|
||||
};
|
||||
opam-file-format = fetchurl {
|
||||
url = "https://github.com/ocaml/opam-file-format/archive/2.0.0-rc2.tar.gz";
|
||||
sha256 = "1mgk08msp7hxn0hs0m82vky3yv6hcq4pw5402b3vhx4c49431jsb";
|
||||
};
|
||||
re = fetchurl {
|
||||
url = "https://github.com/ocaml/ocaml-re/releases/download/1.7.3/re-1.7.3.tbz";
|
||||
sha256 = "0nv933qfl8y9i19cqvhsalwzif3dkm28vg478rpnr4hgfqjlfryr";
|
||||
};
|
||||
result = fetchurl {
|
||||
url = "https://github.com/janestreet/result/releases/download/1.3/result-1.3.tbz";
|
||||
sha256 = "1lrnbxdq80gbhnp85mqp1kfk0bkh6q1c93sfz2qgnq2qyz60w4sk";
|
||||
};
|
||||
opam = fetchurl {
|
||||
url = "https://github.com/ocaml/opam/archive/1.2.2.zip";
|
||||
sha256 = "c590ce55ae69ec74f46215cf16a156a02b23c5f3ecb22f23a3ad9ba3d91ddb6e";
|
||||
url = "https://github.com/ocaml/opam/archive/2.0.0.zip";
|
||||
sha256 = "0m4ilsldrfkkn0vlvl119bk76j2pwvqvdi8mpg957z4kqflfbfp8";
|
||||
};
|
||||
};
|
||||
in stdenv.mkDerivation rec {
|
||||
name = "opam-${version}";
|
||||
version = "1.2.2";
|
||||
version = "2.0.0";
|
||||
|
||||
buildInputs = [ unzip curl ncurses ocaml makeWrapper ];
|
||||
buildInputs = [ unzip curl ncurses ocaml makeWrapper getconf ] ++ lib.optional stdenv.isLinux bubblewrap;
|
||||
|
||||
src = srcs.opam;
|
||||
|
||||
postUnpack = ''
|
||||
ln -sv ${srcs.cudf} $sourceRoot/src_ext/${srcs.cudf.name}
|
||||
ln -sv ${srcs.extlib} $sourceRoot/src_ext/${srcs.extlib.name}
|
||||
ln -sv ${srcs.ocaml_re} $sourceRoot/src_ext/${srcs.ocaml_re.name}
|
||||
ln -sv ${srcs.ocamlgraph} $sourceRoot/src_ext/${srcs.ocamlgraph.name}
|
||||
ln -sv ${srcs.dose3} $sourceRoot/src_ext/${srcs.dose3.name}
|
||||
ln -sv ${srcs.cmdliner} $sourceRoot/src_ext/${srcs.cmdliner.name}
|
||||
ln -sv ${srcs.uutf} $sourceRoot/src_ext/${srcs.uutf.name}
|
||||
ln -sv ${srcs.jsonm} $sourceRoot/src_ext/${srcs.jsonm.name}
|
||||
ln -sv ${srcs.cmdliner} $sourceRoot/src_ext/cmdliner.tbz
|
||||
ln -sv ${srcs.cppo} $sourceRoot/src_ext/cppo.tar.gz
|
||||
ln -sv ${srcs.cudf} $sourceRoot/src_ext/cudf.tar.gz
|
||||
ln -sv ${srcs.dose3} $sourceRoot/src_ext/dose3.tar.gz
|
||||
ln -sv ${srcs.extlib} $sourceRoot/src_ext/extlib.tar.gz
|
||||
ln -sv ${srcs.jbuilder} $sourceRoot/src_ext/jbuilder.tbz
|
||||
ln -sv ${srcs.mccs} $sourceRoot/src_ext/mccs.tar.gz
|
||||
ln -sv ${srcs.ocamlgraph} $sourceRoot/src_ext/ocamlgraph.tar.gz
|
||||
ln -sv ${srcs.opam-file-format} $sourceRoot/src_ext/opam-file-format.tar.gz
|
||||
ln -sv ${srcs.re} $sourceRoot/src_ext/re.tbz
|
||||
ln -sv ${srcs.result} $sourceRoot/src_ext/result.tbz
|
||||
'';
|
||||
|
||||
patches = [ ./opam-pull-3487.patch ./opam-shebangs.patch ./opam-mccs-darwin.patch ];
|
||||
|
||||
preConfigure = ''
|
||||
substituteInPlace ./src_ext/Makefile --replace "%.stamp: %.download" "%.stamp:"
|
||||
patchShebangs src/state/shellscripts
|
||||
'';
|
||||
|
||||
postConfigure = "make lib-ext";
|
||||
|
@ -71,13 +89,17 @@ in stdenv.mkDerivation rec {
|
|||
# Dirty, but apparently ocp-build requires a TERM
|
||||
makeFlags = ["TERM=screen"];
|
||||
|
||||
outputs = [ "out" "installer" ];
|
||||
setOutputFlags = false;
|
||||
|
||||
# change argv0 to "opam" as a workaround for
|
||||
# https://github.com/ocaml/opam/issues/2142
|
||||
postInstall = ''
|
||||
mv $out/bin/opam $out/bin/.opam-wrapped
|
||||
makeWrapper $out/bin/.opam-wrapped $out/bin/opam \
|
||||
--argv0 "opam" \
|
||||
--suffix PATH : ${aspcud}/bin:${unzip}/bin:${curl}/bin
|
||||
--suffix PATH : ${aspcud}/bin:${unzip}/bin:${curl}/bin:${lib.optionalString stdenv.isLinux "${bubblewrap}/bin:"}${getconf}/bin
|
||||
$out/bin/opam-installer --prefix=$installer opam-installer.install
|
||||
'';
|
||||
|
||||
doCheck = false;
|
||||
|
@ -87,6 +109,6 @@ in stdenv.mkDerivation rec {
|
|||
homepage = http://opam.ocamlpro.com/;
|
||||
maintainers = [ maintainers.henrytill ];
|
||||
platforms = platforms.all;
|
||||
license = licenses.lgpl21Plus;
|
||||
};
|
||||
}
|
||||
# Generated by: ./opam.nix.pl -v 2.0.0 -p opam-pull-3487.patch,opam-shebangs.patch,opam-mccs-darwin.patch
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
diff --git a/src_ext/patches/mccs/build-on-darwin.patch b/src_ext/patches/mccs/build-on-darwin.patch
|
||||
new file mode 100644
|
||||
index 00000000..157e2094
|
||||
--- /dev/null
|
||||
+++ b/src_ext/patches/mccs/build-on-darwin.patch
|
||||
@@ -0,0 +1,12 @@
|
||||
+diff --git a/src/context_flags.ml b/src/context_flags.ml
|
||||
+index 7470030..6e07370 100644
|
||||
+--- a/src/context_flags.ml
|
||||
++++ b/src/context_flags.ml
|
||||
+@@ -24,6 +24,7 @@ let ifc c x = if c then x else []
|
||||
+
|
||||
+ let cxxflags =
|
||||
+ let flags =
|
||||
++ (ifc (Config.system = "macosx") ["-x"; "c++"]) @
|
||||
+ (ifc (Sys.win32 && Config.ccomp_type = "msvc") ["/EHsc"]) @
|
||||
+ (ifc useGLPK ["-DUSEGLPK"]) @
|
||||
+ (ifc useCOIN ["-DUSECOIN"]) @
|
|
@ -0,0 +1,23 @@
|
|||
diff --git a/src/state/shellscripts/bwrap.sh b/src/state/shellscripts/bwrap.sh
|
||||
index 6f5d7dbea..3e1a3e1b4 100755
|
||||
--- a/src/state/shellscripts/bwrap.sh
|
||||
+++ b/src/state/shellscripts/bwrap.sh
|
||||
@@ -1,4 +1,6 @@
|
||||
-#!/bin/bash -ue
|
||||
+#!/usr/bin/env bash
|
||||
+
|
||||
+set -ue
|
||||
|
||||
if ! command -v bwrap >/dev/null; then
|
||||
echo "The 'bwrap' command was not found. Install 'bubblewrap' on your system, or" >&2
|
||||
@@ -11,7 +13,9 @@ fi
|
||||
|
||||
ARGS=(--unshare-net --new-session)
|
||||
ARGS=("${ARGS[@]}" --proc /proc --dev /dev)
|
||||
-ARGS=("${ARGS[@]}" --bind /tmp /tmp --tmpfs /run --tmpfs /var)
|
||||
+ARGS=("${ARGS[@]}" --bind "${TMPDIR:-/tmp}" /tmp)
|
||||
+ARGS=("${ARGS[@]}" --setenv TMPDIR /tmp --setenv TMP /tmp --setenv TEMPDIR /tmp --setenv TEMP /tmp)
|
||||
+ARGS=("${ARGS[@]}" --tmpfs /run --tmpfs /var)
|
||||
|
||||
add_mounts() {
|
||||
case "$1" in
|
|
@ -0,0 +1,128 @@
|
|||
diff --git a/src/client/opamInitDefaults.ml b/src/client/opamInitDefaults.ml
|
||||
index eca13a7c..1fd66f43 100644
|
||||
--- a/src/client/opamInitDefaults.ml
|
||||
+++ b/src/client/opamInitDefaults.ml
|
||||
@@ -35,11 +35,15 @@ let eval_variables = [
|
||||
let os_filter os =
|
||||
FOp (FIdent ([], OpamVariable.of_string "os", None), `Eq, FString os)
|
||||
|
||||
+let os_distribution_filter distro =
|
||||
+ FOp (FIdent ([], OpamVariable.of_string "os-distribution", None), `Eq, FString distro)
|
||||
+
|
||||
let linux_filter = os_filter "linux"
|
||||
let macos_filter = os_filter "macos"
|
||||
let openbsd_filter = os_filter "openbsd"
|
||||
let freebsd_filter = os_filter "freebsd"
|
||||
let sandbox_filter = FOr (linux_filter, macos_filter)
|
||||
+let nixos_filter = os_distribution_filter "nixos"
|
||||
|
||||
let gpatch_filter = FOr (openbsd_filter, freebsd_filter)
|
||||
let patch_filter = FNot gpatch_filter
|
||||
@@ -50,6 +54,11 @@ let wrappers ~sandboxing () =
|
||||
CString t, None;
|
||||
] in
|
||||
let w = OpamFile.Wrappers.empty in
|
||||
+ let w = { w with
|
||||
+ OpamFile.Wrappers.
|
||||
+ pre_build = [[CString "%{hooks}%/shebangs.sh", None], Some nixos_filter];
|
||||
+ }
|
||||
+ in
|
||||
if sandboxing then
|
||||
{ w with
|
||||
OpamFile.Wrappers.
|
||||
@@ -113,6 +122,7 @@ let required_tools ~sandboxing () =
|
||||
let init_scripts () = [
|
||||
("sandbox.sh", OpamScript.bwrap), Some bwrap_filter;
|
||||
("sandbox.sh", OpamScript.sandbox_exec), Some macos_filter;
|
||||
+ ("shebangs.sh", OpamScript.patch_shebangs), Some nixos_filter;
|
||||
]
|
||||
|
||||
module I = OpamFile.InitConfig
|
||||
diff --git a/src/state/opamScript.mli b/src/state/opamScript.mli
|
||||
index 03449970..83de0b53 100644
|
||||
--- a/src/state/opamScript.mli
|
||||
+++ b/src/state/opamScript.mli
|
||||
@@ -20,3 +20,4 @@ val env_hook : string
|
||||
val env_hook_zsh : string
|
||||
val env_hook_csh : string
|
||||
val env_hook_fish : string
|
||||
+val patch_shebangs : string
|
||||
diff --git a/src/state/shellscripts/patch_shebangs.sh b/src/state/shellscripts/patch_shebangs.sh
|
||||
new file mode 100755
|
||||
index 00000000..3ea84e2d
|
||||
--- /dev/null
|
||||
+++ b/src/state/shellscripts/patch_shebangs.sh
|
||||
@@ -0,0 +1,73 @@
|
||||
+#!/usr/bin/env bash
|
||||
+# This setup hook causes the fixup phase to rewrite all script
|
||||
+# interpreter file names (`#! /path') to paths found in $PATH. E.g.,
|
||||
+# /bin/sh will be rewritten to /nix/store/<hash>-some-bash/bin/sh.
|
||||
+# /usr/bin/env gets special treatment so that ".../bin/env python" is
|
||||
+# rewritten to /nix/store/<hash>/bin/python. Interpreters that are
|
||||
+# already in the store are left untouched.
|
||||
+
|
||||
+header() { echo "$1"; }
|
||||
+stopNest() { true; }
|
||||
+
|
||||
+fixupOutputHooks+=('if [ -z "$dontPatchShebangs" -a -e "$prefix" ]; then patchShebangs "$prefix"; fi')
|
||||
+
|
||||
+patchShebangs() {
|
||||
+ local dir="$1"
|
||||
+ header "patching script interpreter paths in $dir"
|
||||
+ local f
|
||||
+ local oldPath
|
||||
+ local newPath
|
||||
+ local arg0
|
||||
+ local args
|
||||
+ local oldInterpreterLine
|
||||
+ local newInterpreterLine
|
||||
+
|
||||
+ find "$dir" -type f -perm -0100 | while read f; do
|
||||
+ if [ "$(head -1 "$f" | head -c+2)" != '#!' ]; then
|
||||
+ # missing shebang => not a script
|
||||
+ continue
|
||||
+ fi
|
||||
+
|
||||
+ oldInterpreterLine=$(head -1 "$f" | tail -c+3)
|
||||
+ read -r oldPath arg0 args <<< "$oldInterpreterLine"
|
||||
+
|
||||
+ if $(echo "$oldPath" | grep -q "/bin/env$"); then
|
||||
+ # Check for unsupported 'env' functionality:
|
||||
+ # - options: something starting with a '-'
|
||||
+ # - environment variables: foo=bar
|
||||
+ if $(echo "$arg0" | grep -q -- "^-.*\|.*=.*"); then
|
||||
+ echo "unsupported interpreter directive \"$oldInterpreterLine\" (set dontPatchShebangs=1 and handle shebang patching yourself)"
|
||||
+ exit 1
|
||||
+ fi
|
||||
+ newPath="$(command -v "$arg0" || true)"
|
||||
+ else
|
||||
+ if [ "$oldPath" = "" ]; then
|
||||
+ # If no interpreter is specified linux will use /bin/sh. Set
|
||||
+ # oldpath="/bin/sh" so that we get /nix/store/.../sh.
|
||||
+ oldPath="/bin/sh"
|
||||
+ fi
|
||||
+ newPath="$(command -v "$(basename "$oldPath")" || true)"
|
||||
+ args="$arg0 $args"
|
||||
+ fi
|
||||
+
|
||||
+ # Strip trailing whitespace introduced when no arguments are present
|
||||
+ newInterpreterLine="$(echo "$newPath $args" | sed 's/[[:space:]]*$//')"
|
||||
+
|
||||
+ if [ -n "$oldPath" -a "${oldPath:0:${#NIX_STORE}}" != "$NIX_STORE" ]; then
|
||||
+ if [ -n "$newPath" -a "$newPath" != "$oldPath" ]; then
|
||||
+ echo "$f: interpreter directive changed from \"$oldInterpreterLine\" to \"$newInterpreterLine\""
|
||||
+ # escape the escape chars so that sed doesn't interpret them
|
||||
+ escapedInterpreterLine=$(echo "$newInterpreterLine" | sed 's|\\|\\\\|g')
|
||||
+ # Preserve times, see: https://github.com/NixOS/nixpkgs/pull/33281
|
||||
+ touch -r "$f" "$f.timestamp"
|
||||
+ sed -i -e "1 s|.*|#\!$escapedInterpreterLine|" "$f"
|
||||
+ touch -r "$f.timestamp" "$f"
|
||||
+ rm "$f.timestamp"
|
||||
+ fi
|
||||
+ fi
|
||||
+ done
|
||||
+
|
||||
+ stopNest
|
||||
+}
|
||||
+
|
||||
+patchShebangs .
|
|
@ -0,0 +1,130 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
use strict;
|
||||
use warnings qw<all>;
|
||||
use Getopt::Std;
|
||||
|
||||
my $gencmd = "# Generated by: " . join(" ", $0, @ARGV) . "\n";
|
||||
|
||||
our $opt_v;
|
||||
our $opt_p;
|
||||
our $opt_r;
|
||||
our $opt_t;
|
||||
getopts "v:p:t:r:";
|
||||
|
||||
my $OPAM_RELEASE = $opt_v // "2.0.0";
|
||||
my $OPAM_TAG = $opt_t // $OPAM_RELEASE;
|
||||
my $OPAM_GITHUB_REPO = $opt_r // "ocaml/opam";
|
||||
my $OPAM_RELEASE_URL = "https://github.com/$OPAM_GITHUB_REPO/archive/$OPAM_TAG.zip";
|
||||
my $OPAM_RELEASE_SHA256 = `nix-prefetch-url \Q$OPAM_RELEASE_URL\E`;
|
||||
chomp $OPAM_RELEASE_SHA256;
|
||||
|
||||
my $OPAM_BASE_URL = "https://raw.githubusercontent.com/$OPAM_GITHUB_REPO/$OPAM_TAG";
|
||||
my $OPAM_OPAM = `curl -L --url \Q$OPAM_BASE_URL\E/opam-devel.opam`;
|
||||
my($OCAML_MIN_VERSION) = $OPAM_OPAM =~ /^available: ocaml-version >= "(.*)"$/m
|
||||
or die "could not parse ocaml version bound\n";
|
||||
|
||||
print <<"EOF";
|
||||
{ stdenv, lib, fetchurl, makeWrapper, getconf,
|
||||
ocaml, unzip, ncurses, curl, aspcud, bubblewrap
|
||||
}:
|
||||
|
||||
assert lib.versionAtLeast ocaml.version "$OCAML_MIN_VERSION";
|
||||
|
||||
let
|
||||
srcs = {
|
||||
EOF
|
||||
|
||||
my %urls = ();
|
||||
my %md5s = ();
|
||||
|
||||
open(SOURCES, "-|", "curl", "-L", "--url", "$OPAM_BASE_URL/src_ext/Makefile.sources");
|
||||
while (<SOURCES>) {
|
||||
if (/^URL_(?!PKG_)([-\w]+)\s*=\s*(\S+)$/) {
|
||||
$urls{$1} = $2;
|
||||
} elsif (/^MD5_(?!PKG_)([-\w]+)\s*=\s*(\S+)$/) {
|
||||
$md5s{$1} = $2;
|
||||
}
|
||||
}
|
||||
for my $src (sort keys %urls) {
|
||||
my ($sha256,$store_path) = split /\n/, `nix-prefetch-url --print-path \Q$urls{$src}\E`;
|
||||
system "echo \Q$md5s{$src}\E' *'\Q$store_path\E | md5sum -c 1>&2";
|
||||
die "md5 check failed for $urls{$src}\n" if $?;
|
||||
print <<"EOF";
|
||||
$src = fetchurl {
|
||||
url = "$urls{$src}";
|
||||
sha256 = "$sha256";
|
||||
};
|
||||
EOF
|
||||
}
|
||||
|
||||
print <<"EOF";
|
||||
opam = fetchurl {
|
||||
url = "$OPAM_RELEASE_URL";
|
||||
sha256 = "$OPAM_RELEASE_SHA256";
|
||||
};
|
||||
};
|
||||
in stdenv.mkDerivation rec {
|
||||
name = "opam-\${version}";
|
||||
version = "$OPAM_RELEASE";
|
||||
|
||||
buildInputs = [ unzip curl ncurses ocaml makeWrapper getconf ] ++ lib.optional stdenv.isLinux bubblewrap;
|
||||
|
||||
src = srcs.opam;
|
||||
|
||||
postUnpack = ''
|
||||
EOF
|
||||
for my $src (sort keys %urls) {
|
||||
my($ext) = $urls{$src} =~ /(\.(?:t(?:ar\.|)|)(?:gz|bz2?))$/
|
||||
or die "could not find extension for $urls{$src}\n";
|
||||
print <<"EOF";
|
||||
ln -sv \${srcs.$src} \$sourceRoot/src_ext/$src$ext
|
||||
EOF
|
||||
}
|
||||
print <<'EOF';
|
||||
'';
|
||||
|
||||
EOF
|
||||
if (defined $opt_p) {
|
||||
print " patches = [ ";
|
||||
for my $patch (split /[, ]/, $opt_p) {
|
||||
$patch =~ s/^(?=[^\/]*$)/.\//;
|
||||
print "$patch ";
|
||||
}
|
||||
print "];\n\n";
|
||||
}
|
||||
print <<'EOF';
|
||||
preConfigure = ''
|
||||
substituteInPlace ./src_ext/Makefile --replace "%.stamp: %.download" "%.stamp:"
|
||||
patchShebangs src/state/shellscripts
|
||||
'';
|
||||
|
||||
postConfigure = "make lib-ext";
|
||||
|
||||
# Dirty, but apparently ocp-build requires a TERM
|
||||
makeFlags = ["TERM=screen"];
|
||||
|
||||
outputs = [ "out" "installer" ];
|
||||
setOutputFlags = false;
|
||||
|
||||
# change argv0 to "opam" as a workaround for
|
||||
# https://github.com/ocaml/opam/issues/2142
|
||||
postInstall = ''
|
||||
mv $out/bin/opam $out/bin/.opam-wrapped
|
||||
makeWrapper $out/bin/.opam-wrapped $out/bin/opam \
|
||||
--argv0 "opam" \
|
||||
--suffix PATH : ${aspcud}/bin:${unzip}/bin:${curl}/bin:${lib.optionalString stdenv.isLinux "${bubblewrap}/bin:"}${getconf}/bin
|
||||
$out/bin/opam-installer --prefix=$installer opam-installer.install
|
||||
'';
|
||||
|
||||
doCheck = false;
|
||||
|
||||
meta = with stdenv.lib; {
|
||||
description = "A package manager for OCaml";
|
||||
homepage = http://opam.ocamlpro.com/;
|
||||
maintainers = [ maintainers.henrytill ];
|
||||
platforms = platforms.all;
|
||||
};
|
||||
}
|
||||
EOF
|
||||
print $gencmd;
|
|
@ -7135,7 +7135,8 @@ with pkgs;
|
|||
|
||||
opaline = callPackage ../development/tools/ocaml/opaline { };
|
||||
|
||||
opam = callPackage ../development/tools/ocaml/opam {
|
||||
opam = callPackage ../development/tools/ocaml/opam { };
|
||||
opam_1_2 = callPackage ../development/tools/ocaml/opam/1.2.2.nix {
|
||||
inherit (ocaml-ng.ocamlPackages_4_05) ocaml;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue