├── .ocp-indent ├── src ├── debug.ocp ├── client │ ├── opamClientGlobals.ml │ ├── opamClientGlobals.mli │ ├── client.ocp │ ├── opamGitVersion.mli │ ├── opamPinCommand.mli │ ├── opamConfigCommand.mli │ ├── opamSwitchCommand.mli │ ├── opamMain.mli │ ├── opamRepositoryCommand.mli │ ├── opamClientConfig.mli │ └── opamClientConfig.ml ├── opam.ocp ├── solver │ ├── solver.ocp │ ├── opamSolverConfig.mli │ └── opamActionGraph.mli ├── state │ ├── state.ocp │ ├── opamScript.mli │ ├── opamOCaml.mli │ ├── opamAction.mli │ ├── opamStateConfig.mli │ ├── opamOCaml.ml │ └── opamSolution.mli ├── repository │ ├── repository.ocp │ ├── opamGit.mli │ ├── opamHg.mli │ ├── opamDarcs.mli │ ├── opamHTTP.mli │ ├── opamLocal.mli │ ├── opamRepositoryConfig.mli │ ├── opamDownload.mli │ ├── opamVCS.mli │ ├── opamRepositoryBackend.mli │ ├── opamDarcs.ml │ ├── opamRepositoryPath.ml │ ├── opamRepositoryBackend.ml │ ├── opamHg.ml │ └── opamRepositoryConfig.ml ├── core │ ├── core.ocp │ ├── opamCompat.ml.4.02 │ ├── opamCompat.mli.4.02 │ ├── opamCompat.ml.4.01 │ ├── opamCompat.mli.4.01 │ ├── opamVersion.mli │ ├── opamVersionCompare.mli │ ├── opamCoreConfig.mli │ ├── opamVersion.ml.in │ ├── opamJson.mli │ └── opamCoreConfig.ml ├── format │ ├── format.ocp │ ├── opamLexer.mli │ ├── opamLineLexer.mli │ ├── opamRepositoryName.ml │ ├── opamRepositoryName.mli │ ├── opamSwitch.ml │ ├── opamSwitch.mli │ ├── opamFormatConfig.mli │ ├── opamCompiler.mli │ ├── opamFormatConfig.ml │ ├── opamLineLexer.mll │ ├── opamVariable.mli │ └── opamVariable.ml └── tools │ ├── tools.ocp │ ├── opam_stats.mli │ ├── opam_mk_repo.mli │ ├── opam_repo_check.mli │ ├── opam_admin_top.mli │ ├── opam_admin.ml │ ├── opam_check.ml │ ├── opam_depexts_change.ml │ ├── opam_repo_check.ml │ └── opam_rename.ml ├── tests ├── packages │ ├── P1-1 │ │ ├── README │ │ ├── build.sh │ │ ├── p1.ml │ │ ├── P1.config.in │ │ └── P1.install │ ├── P1-2 │ │ ├── README │ │ ├── build.sh │ │ ├── p1.ml │ │ ├── P1.install │ │ └── P1.config.in │ ├── P2 │ │ ├── p2.ml │ │ ├── P2.install │ │ ├── config.in │ │ ├── P2.config.in │ │ ├── README │ │ └── build.sh │ ├── P3 │ │ ├── README │ │ ├── p3.ml │ │ ├── p3_bar.ml │ │ ├── P3.config.in │ │ ├── build.sh │ │ ├── P3.install │ │ └── myocamlbuild.ml │ ├── P5 │ │ ├── p5.ml │ │ ├── README │ │ └── build.sh │ ├── P4 │ │ ├── README │ │ ├── P4.install │ │ ├── _tags │ │ ├── p4.ml │ │ └── build.sh │ ├── P4-1.opam │ ├── P4-3.opam │ ├── P1-2.opam │ ├── P4-2.opam │ ├── P2.opam │ ├── P3.opam │ ├── P5.opam │ └── P1-1.opam ├── compilers │ ├── 20.comp │ └── 10+a+b.comp ├── test-TEST.sh ├── results │ ├── install-P1 │ ├── install-opt │ ├── reinstall-P2 │ ├── install-remove-P1 │ ├── install-P1-P2-P3-P4 │ ├── install-upgrade-P2 │ └── README.tests ├── README.unittest └── init-repo.sh ├── doc ├── dev-manual │ ├── htmlmacros.hva │ ├── dev-manual.pdf │ ├── Makefile │ └── dev-manual.css ├── pages │ ├── index.menu │ ├── About.md │ └── Tricks.md ├── release │ └── readme.md └── Makefile ├── .merlin ├── shell ├── dot_ocamlinit ├── opam_switch_eval.sh ├── bootstrap-ocaml.sh ├── crunch.ml ├── md5check.ml ├── get-git-id.ml └── opam_installer.sh ├── admin-scripts ├── Makefile ├── add-build-deps.ml ├── add-github-dev.ml ├── cudf-debug.ml ├── lint.ml ├── depopts_to_conflicts.ml └── extract_mini_repository.sh ├── AUTHORS ├── CONTRIBUTING.md ├── opam.install ├── .travis.yml ├── Makefile.config.in ├── opam ├── appveyor.yml ├── .gitignore ├── src_ext └── patches │ ├── dose │ └── 0003-Removed-hard-failure-cases-in-favor-of-finer-diagnos.patch │ └── cmdliner │ └── backport_pre_4_00_0.patch ├── META.in ├── opam-devel.opam ├── .travis-ci.sh └── Makefile /.ocp-indent: -------------------------------------------------------------------------------- 1 | normal 2 | strict_else=auto 3 | -------------------------------------------------------------------------------- /src/debug.ocp: -------------------------------------------------------------------------------- 1 | comp += [ "-g"] 2 | link += [ "-g"] 3 | -------------------------------------------------------------------------------- /tests/packages/P1-1/README: -------------------------------------------------------------------------------- 1 | A very useful package 2 | -------------------------------------------------------------------------------- /tests/packages/P1-2/README: -------------------------------------------------------------------------------- 1 | A very useful package 2 | -------------------------------------------------------------------------------- /tests/packages/P2/p2.ml: -------------------------------------------------------------------------------- 1 | let g () = 2 | P1.x () 3 | -------------------------------------------------------------------------------- /tests/packages/P3/README: -------------------------------------------------------------------------------- 1 | Testing version names 2 | -------------------------------------------------------------------------------- /tests/packages/P5/p5.ml: -------------------------------------------------------------------------------- 1 | let g () = 2 | P1.x () 3 | -------------------------------------------------------------------------------- /tests/packages/P4/README: -------------------------------------------------------------------------------- 1 | Testing transitive closure 2 | -------------------------------------------------------------------------------- /tests/packages/P5/README: -------------------------------------------------------------------------------- 1 | Testing optional dependencies 2 | -------------------------------------------------------------------------------- /doc/dev-manual/htmlmacros.hva: -------------------------------------------------------------------------------- 1 | \loadcssfile{./dev-manual.css} 2 | -------------------------------------------------------------------------------- /src/client/opamClientGlobals.ml: -------------------------------------------------------------------------------- 1 | 2 | let search_files = ["findlib"] 3 | -------------------------------------------------------------------------------- /.merlin: -------------------------------------------------------------------------------- 1 | PKG ocamlgraph cmdliner dose cudf re jsonm 2 | 3 | S src/* 4 | B src/* -------------------------------------------------------------------------------- /tests/packages/P3/p3.ml: -------------------------------------------------------------------------------- 1 | let z () = 2 | try P1.x () 3 | with _ -> 0 4 | -------------------------------------------------------------------------------- /tests/packages/P4/P4.install: -------------------------------------------------------------------------------- 1 | bin: [ 2 | "p4.foo" { "p4" } 3 | "p4.foo" 4 | ] -------------------------------------------------------------------------------- /tests/packages/P1-1/build.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh -eu 2 | 3 | ocamlbuild p1.cma p1.cmxa 4 | -------------------------------------------------------------------------------- /tests/packages/P1-1/p1.ml: -------------------------------------------------------------------------------- 1 | let x () = 2 | try Random.int 10 3 | with _ -> 0 4 | -------------------------------------------------------------------------------- /tests/packages/P1-2/build.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh -eu 2 | 3 | ocamlbuild p1.cma p1.cmxa 4 | -------------------------------------------------------------------------------- /tests/packages/P4/_tags: -------------------------------------------------------------------------------- 1 | <*.{byte,native}>: use_p2, use_p3 2 | <*.ml>: use_p2, use_p3 -------------------------------------------------------------------------------- /tests/packages/P1-2/p1.ml: -------------------------------------------------------------------------------- 1 | let x () = 2 | failwith "the new version is not very good" 3 | -------------------------------------------------------------------------------- /tests/packages/P3/p3_bar.ml: -------------------------------------------------------------------------------- 1 | let f () = 2 | Printf.printf "foo\n%!" 3 | 4 | let _ = 5 | P3.z () 6 | -------------------------------------------------------------------------------- /doc/dev-manual/dev-manual.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mjambon/opam/master/doc/dev-manual/dev-manual.pdf -------------------------------------------------------------------------------- /tests/packages/P2/P2.install: -------------------------------------------------------------------------------- 1 | lib: [ 2 | "p2.cma" 3 | "p2.cmxa" 4 | "p2.a" 5 | "p2.cmi" 6 | ] 7 | -------------------------------------------------------------------------------- /src/opam.ocp: -------------------------------------------------------------------------------- 1 | comp += [ "-g" "-w" "+a-4-44" "-safe-string" ] 2 | link += [ "-g" "-w" "+a-4-44" "-safe-string" ] 3 | -------------------------------------------------------------------------------- /tests/compilers/20.comp: -------------------------------------------------------------------------------- 1 | opam-version: "1" 2 | version: "20" 3 | preinstalled: true 4 | env: [ 5 | [ TEST="1" ] 6 | ] 7 | -------------------------------------------------------------------------------- /tests/packages/P2/config.in: -------------------------------------------------------------------------------- 1 | Foo is %{P1:FOO}% 2 | 3 | Foo also contains a variable with %{P1:l}%. Funny, isn't it? 4 | -------------------------------------------------------------------------------- /shell/dot_ocamlinit: -------------------------------------------------------------------------------- 1 | let () = 2 | try Topdirs.dir_directory (Sys.getenv "OCAML_TOPLEVEL_PATH") 3 | with Not_found -> () 4 | ;; -------------------------------------------------------------------------------- /src/client/opamClientGlobals.mli: -------------------------------------------------------------------------------- 1 | 2 | (** Extra files included in `opam search\ *) 3 | 4 | val search_files: string list 5 | -------------------------------------------------------------------------------- /shell/opam_switch_eval.sh: -------------------------------------------------------------------------------- 1 | function opam-switch-eval () { 2 | opam switch "$@" --no-warning 3 | eval $(opam config env) 4 | } 5 | -------------------------------------------------------------------------------- /tests/packages/P1-2/P1.install: -------------------------------------------------------------------------------- 1 | lib: [ 2 | "_build/p1.cma" 3 | "_build/p1.cmxa" 4 | "_build/p1.a" 5 | "_build/p1.cmi" 6 | ] 7 | -------------------------------------------------------------------------------- /tests/compilers/10+a+b.comp: -------------------------------------------------------------------------------- 1 | opam-version: "1" 2 | version: "10" 3 | preinstalled: true 4 | env: [ 5 | [ TEST="1" ] 6 | ] 7 | packages: [ "P1" "P2" "P3" "P4" ] 8 | -------------------------------------------------------------------------------- /tests/packages/P4-1.opam: -------------------------------------------------------------------------------- 1 | opam-version: "1" 2 | name: "P4" 3 | version: "1" 4 | maintainer: "contact@ocamlpro.com" 5 | depends: [ "P2" "P3" ] 6 | build: [ "./build.sh" ] 7 | -------------------------------------------------------------------------------- /tests/packages/P4-3.opam: -------------------------------------------------------------------------------- 1 | opam-version: "1" 2 | name: "P4" 3 | version: "3" 4 | maintainer: "contact@ocamlpro.com" 5 | depends: [ "P2" "P3" ] 6 | build: [ "./build.sh" ] 7 | -------------------------------------------------------------------------------- /tests/packages/P2/P2.config.in: -------------------------------------------------------------------------------- 1 | asmcomp: "-I %{lib}%/P2" 2 | bytecomp: "-I %{lib}%/P2" 3 | asmlink: "-I %{lib}%/P2 p2.cmxa" 4 | bytelink: "-I %{lib}%/P2 p2.cma" 5 | requires: "p1" 6 | -------------------------------------------------------------------------------- /tests/packages/P2/README: -------------------------------------------------------------------------------- 1 | An other very useful package 2 | 3 | The description can go on multiple lines. The first line is the package synopsis, 4 | and the rest is the package description. 5 | -------------------------------------------------------------------------------- /tests/test-TEST.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ -f $1 ]; then 4 | . $1 5 | fi 6 | 7 | if [ x${TEST} != x$2 ]; then 8 | echo "Error: TEST=${TEST} instead of $2" 9 | exit 2 10 | fi 11 | -------------------------------------------------------------------------------- /tests/packages/P3/P3.config.in: -------------------------------------------------------------------------------- 1 | asmcomp : "-I %{lib}%/P3" 2 | bytecomp: "-I %{lib}%/P3" 3 | asmlink : "-I %{lib}%/P3 p3.cmxa p3_bar.cmxa" 4 | bytelink: "-I %{lib}%/P3 p3.cma p3_bar.cma" 5 | requires: "p1" 6 | -------------------------------------------------------------------------------- /tests/packages/P1-1/P1.config.in: -------------------------------------------------------------------------------- 1 | asmcomp: "-I %{lib}%/P1" 2 | bytecomp: "-I %{lib}%/P1" 3 | asmlink: "-I %{lib}%/P1 p1.cmxa" 4 | bytelink: "-I %{lib}%/P1 p1.cma" 5 | LOCAL: "local" 6 | l: "L" 7 | FOO: "foo" 8 | bar: true -------------------------------------------------------------------------------- /tests/packages/P1-2/P1.config.in: -------------------------------------------------------------------------------- 1 | asmcomp: "-I %{lib}%/P1" 2 | bytecomp: "-I %{lib}%/P1" 3 | asmlink: "-I %{lib}%/P1 p1.cmxa" 4 | bytelink: "-I %{lib}%/P1 p1.cma" 5 | LOCAL: "local" 6 | l: "L" 7 | FOO: "foo" 8 | bar: true -------------------------------------------------------------------------------- /tests/packages/P1-2.opam: -------------------------------------------------------------------------------- 1 | opam-version: "1" 2 | name: "P1" 3 | version: "2" 4 | ocaml-version: [ < "20" ] 5 | maintainer: "contact@ocamlpro.com" 6 | substs: [ "P1.config" ] 7 | libraries: [ "p1" ] 8 | build: [ "./build.sh" ] 9 | -------------------------------------------------------------------------------- /tests/packages/P4-2.opam: -------------------------------------------------------------------------------- 1 | opam-version: "1" 2 | name: "P4" 3 | version: "2" 4 | maintainer: "contact@ocamlpro.com" 5 | depends: [ 6 | "P1" { = "1" } 7 | "P2" 8 | "P3" 9 | ] 10 | build: [ "./build.sh" ] 11 | -------------------------------------------------------------------------------- /tests/packages/P4/p4.ml: -------------------------------------------------------------------------------- 1 | let f = 2 | try P3_bar.f (); P1.x () 3 | with _ -> P3.z () 4 | 5 | let () = 6 | let t = 7 | try Sys.getenv "TEST" 8 | with _ -> "" in 9 | Printf.printf "TEST=%s\n%!" t 10 | -------------------------------------------------------------------------------- /tests/packages/P2.opam: -------------------------------------------------------------------------------- 1 | opam-version: "1" 2 | name: "P2" 3 | version: "1" 4 | maintainer: "contact@ocamlpro.com" 5 | substs: [ "config" "P2.config" ] 6 | depends: [ "P1" ] 7 | libraries: [ "p2" ] 8 | build: [ "./build.sh" ] 9 | -------------------------------------------------------------------------------- /tests/packages/P3.opam: -------------------------------------------------------------------------------- 1 | opam-version: "1" 2 | name: "P3" 3 | version: "1~weird-version.test" 4 | maintainer: "contact@ocamlpro.com" 5 | depends: [ "P1" ] 6 | substs: [ "P3.config" ] 7 | libraries: [ "p3" "p3_bar" ] 8 | build: [ "./build.sh" ] -------------------------------------------------------------------------------- /tests/results/install-P1: -------------------------------------------------------------------------------- 1 | Available packages for system: 2 | P1 1 A very useful package 3 | P2 -- An other very useful package 4 | P3 -- Testing version names 5 | P4 -- Testing transitive closure 6 | P5 -- Testing optional dependencies 7 | -------------------------------------------------------------------------------- /tests/results/install-opt: -------------------------------------------------------------------------------- 1 | Available packages for system: 2 | P1 -- A very useful package 3 | P2 -- An other very useful package 4 | P3 -- Testing version names 5 | P4 -- Testing transitive closure 6 | P5 -- Testing optional dependencies 7 | -------------------------------------------------------------------------------- /tests/results/reinstall-P2: -------------------------------------------------------------------------------- 1 | Available packages for system: 2 | P1 1 A very useful package 3 | P2 1 An other very useful package 4 | P3 -- Testing version names 5 | P4 -- Testing transitive closure 6 | P5 -- Testing optional dependencies 7 | -------------------------------------------------------------------------------- /tests/packages/P3/build.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh -eu 2 | 3 | echo "Building P3 version ${OPAM_PACKAGE_VERSION}" 4 | 5 | if [ "x${OPAM_PACKAGE_NAME}" = "xP3" ]; then 6 | ocamlbuild p3.cma p3.cmxa p3_bar.cma p3_bar.cmxa 7 | else 8 | exit 1 9 | fi 10 | -------------------------------------------------------------------------------- /tests/packages/P5/build.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh -eu 2 | 3 | FLAGS="-I `${OPAM} config var P1:lib`" 4 | 5 | echo "Bytecode Compilation" 6 | ocamlopt ${FLAGS} -a p5.ml -o p5.cmxa 7 | 8 | echo "Native Compilation" 9 | ocamlc ${FLAGS} -a p5.ml -o p5.cma 10 | -------------------------------------------------------------------------------- /tests/results/install-remove-P1: -------------------------------------------------------------------------------- 1 | Available packages for system: 2 | P1 -- A very useful package 3 | P2 -- An other very useful package 4 | P3 -- Testing version names 5 | P4 -- Testing transitive closure 6 | P5 -- Testing optional dependencies 7 | -------------------------------------------------------------------------------- /tests/packages/P1-1/P1.install: -------------------------------------------------------------------------------- 1 | lib: [ 2 | "_build/p1.cmi" 3 | "_build/p1.cma" 4 | "_build/p1.cmxa" 5 | "_build/p1.a" 6 | "?_build/this_file_will_not_exits_but_that's_ok" 7 | ] 8 | share: [ "build.sh" ] 9 | doc: [ 10 | "_build/p1.cmi" { "foo/bar/index.html" } 11 | ] -------------------------------------------------------------------------------- /tests/packages/P3/P3.install: -------------------------------------------------------------------------------- 1 | lib: [ 2 | (* p3 *) 3 | "_build/p3.cma" 4 | "_build/p3.cmxa" 5 | "_build/p3.a" 6 | "_build/p3.cmi" 7 | 8 | (* p3_bar *) 9 | "_build/p3_bar.cma" 10 | "_build/p3_bar.cmxa" 11 | "_build/p3_bar.a" 12 | "_build/p3_bar.cmi" 13 | ] 14 | -------------------------------------------------------------------------------- /tests/packages/P2/build.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh -eu 2 | 3 | OFLAGS="`${OPAM} config var P1:asmcomp`" 4 | CFLAGS="`${OPAM} config var P1:bytecomp`" 5 | 6 | echo "Bytecode Compilation" 7 | ocamlopt ${OFLAGS} -a p2.ml -o p2.cmxa 8 | 9 | echo "Native Compilation" 10 | ocamlc ${CFLAGS} -a p2.ml -o p2.cma 11 | -------------------------------------------------------------------------------- /tests/packages/P4/build.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh -e 2 | 3 | echo "Building P4 with ${OPAM}" 4 | LIBDIR="`${OPAM} config var lib`" 5 | COMP="-I ${LIBDIR}/P1 -I ${LIBDIR}/P2 -I ${LIBDIR}/P3" 6 | LINK="p1.cmxa p2.cmxa p3.cmxa p3_bar.cmxa" 7 | 8 | ocamlopt ${COMP} ${LINK} p4.ml -o p4.foo 9 | 10 | echo "TEST=${TEST}" 11 | -------------------------------------------------------------------------------- /doc/dev-manual/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: all 2 | all: dev-manual.pdf 3 | html: dev-manual.html 4 | 5 | %.pdf: %.tex 6 | pdflatex $* 7 | pdflatex $* 8 | 9 | %.html: %.tex 10 | hevea -fix htmlmacros.hva $< 11 | 12 | %.txt: %.html 13 | links -dump $< > $@ 14 | 15 | clean: 16 | rm -f *~ *.log *toc *.out *.bbl *.blg *aux *.html 17 | -------------------------------------------------------------------------------- /tests/results/install-P1-P2-P3-P4: -------------------------------------------------------------------------------- 1 | Available packages for system: 2 | P1 1 A very useful package 3 | P2 1 An other very useful package 4 | P3 1~weird-version.test Testing version names 5 | P4 1 Testing transitive closure 6 | P5 -- Testing optional dependencies 7 | -------------------------------------------------------------------------------- /tests/results/install-upgrade-P2: -------------------------------------------------------------------------------- 1 | Available packages for system: 2 | P1 1 A very useful package 3 | P2 1 An other very useful package 4 | P3 1~weird-version.test Testing version names 5 | P4 1 Testing transitive closure 6 | P5 -- Testing optional dependencies 7 | -------------------------------------------------------------------------------- /shell/bootstrap-ocaml.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -ex 2 | 3 | V=ocaml-4.02.1 4 | URL=http://caml.inria.fr/pub/distrib/ocaml-4.02/${V}.tar.gz 5 | mkdir -p bootstrap 6 | cd bootstrap 7 | if [ ! -e ${V}.tar.gz ]; then 8 | curl -OL ${URL} 9 | fi 10 | tar -zxvf ${V}.tar.gz 11 | cd ${V} 12 | ./configure -prefix `pwd`/../ocaml 13 | make world opt 14 | make install 15 | -------------------------------------------------------------------------------- /src/solver/solver.ocp: -------------------------------------------------------------------------------- 1 | begin library "opam-solver" 2 | 3 | files = [ 4 | "opamSolverConfig.ml" 5 | "opamActionGraph.ml" 6 | "opamCudf.ml" 7 | "opamHeuristic.ml" 8 | "opamSolver.ml" 9 | ] 10 | 11 | requires = [ 12 | "dose3.common" 13 | "dose3.algo" 14 | "opam-core" 15 | "opam-format" 16 | ] 17 | 18 | end 19 | -------------------------------------------------------------------------------- /src/state/state.ocp: -------------------------------------------------------------------------------- 1 | comp += [ "-w" "-48" ] 2 | 3 | begin library "opam-state" 4 | 5 | files = [ 6 | "opamPath.ml" 7 | "opamStateConfig.ml" 8 | "opamOCaml.ml" 9 | "opamScript.ml" 10 | "opamState.ml" 11 | "opamAction.ml" 12 | "opamSolution.ml" 13 | ] 14 | 15 | requires = [ 16 | "opam-core" 17 | "opam-solver" 18 | "opam-repository" 19 | ] 20 | 21 | end 22 | -------------------------------------------------------------------------------- /admin-scripts/Makefile: -------------------------------------------------------------------------------- 1 | %: %.ml 2 | sed 's/^#.*//' $< >$*-tmp.ml 3 | ocamlfind ocamlc -package opam-lib,opam-lib.repository -linkpkg ../src/tools/opam_admin_top.ml $*-tmp.ml -o $@ 4 | rm $*-tmp.ml 5 | 6 | couverture: couverture.ml 7 | sed 's/^#.*//' $< >couverture-tmp.ml 8 | ocamlfind ocamlopt -package re.glob,opam-lib.state -linkpkg ../src/tools/opam_admin_top.ml couverture-tmp.ml -o $@ 9 | rm couverture-tmp.ml 10 | -------------------------------------------------------------------------------- /tests/packages/P5.opam: -------------------------------------------------------------------------------- 1 | (* API version *) 2 | opam-version: "1" 3 | name: "P5" 4 | version: "1" 5 | maintainer: "contact@ocamlpro.com" 6 | depends: [ "P1" ] 7 | depopts: [ "P2" ] 8 | build: [ [ "./build.sh" ] 9 | [ "mkdir" "-p" "%{lib}%/p5" ] 10 | [ "touch" "%{lib}%/p5/p2_present" ] {P2:installed} 11 | [ "touch" "%{lib}%/p5/p2_absent" ] {!P2:installed} ] 12 | remove: [ "rm" "-rf" "%{lib}%/p5" ] 13 | -------------------------------------------------------------------------------- /doc/pages/index.menu: -------------------------------------------------------------------------------- 1 | # Contains the documentation menu with the following syntax: 2 | # without extension -> A menu title 3 | # .md -> A markdown page 4 | # empty -> A menu divider 5 | #source: https://github.com/ocaml/opam/tree/master/doc/pages 6 | OPAM 1.2 DOCUMENTATION 7 | 8 | Install.md 9 | Usage.md 10 | 11 | FAQ.md 12 | Tricks.md 13 | Packaging.md 14 | Specifying_Solver_Preferences.md 15 | 16 | Manual.md 17 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Thomas Gazagnaire 2 | Anil Madhavapeddy 3 | Fabrice Le Fessant 4 | Frederic Tuong 5 | Louis Gesbert 6 | Guillem Rieu 7 | Vincent Bernardoff 8 | Roberto Di Cosmo 9 | Ralf Treinen 10 | -------------------------------------------------------------------------------- /src/repository/repository.ocp: -------------------------------------------------------------------------------- 1 | begin library "opam-repository" 2 | 3 | files = [ 4 | "opamRepositoryConfig.ml" 5 | "opamDownload.ml" 6 | "opamRepositoryBackend.ml" 7 | "opamRepositoryPath.ml" 8 | "opamHTTP.ml" 9 | "opamLocal.ml" 10 | "opamVCS.ml" 11 | "opamGit.ml" 12 | "opamDarcs.ml" 13 | "opamHg.ml" 14 | "opamRepository.ml" 15 | ] 16 | 17 | requires = [ 18 | "opam-core" 19 | "opam-format" 20 | ] 21 | 22 | end 23 | -------------------------------------------------------------------------------- /shell/crunch.ml: -------------------------------------------------------------------------------- 1 | let add_stdin buf = 2 | try 3 | while true do 4 | let line = input_line stdin in 5 | Buffer.add_string buf line; 6 | Buffer.add_char buf '\n' 7 | done 8 | with End_of_file -> 9 | () 10 | 11 | let () = 12 | let name = Sys.argv.(1) in 13 | let buf = Buffer.create 1024 in 14 | add_stdin buf; 15 | let contents = Buffer.contents buf in 16 | Printf.printf "let %s =\n\"%s\"\n\n" 17 | name 18 | (String.escaped contents) 19 | -------------------------------------------------------------------------------- /src/core/core.ocp: -------------------------------------------------------------------------------- 1 | begin library "opam-core" 2 | sort = false 3 | files = [ 4 | "opamCompat.ml" 5 | "opamJson.ml" 6 | "opamCoreConfig.ml" 7 | "opamStd.ml" 8 | "opamConsole.ml" 9 | "opamVersionCompare.ml" 10 | "opamVersion.ml" 11 | "opamProcess.ml" 12 | "opamParallel.ml" 13 | "opamSystem.ml" 14 | "opamFilename.ml" 15 | ] 16 | 17 | requires = [ 18 | "unix" 19 | "ocamlgraph" 20 | "re.str" 21 | "jsonm" 22 | ] 23 | 24 | end 25 | -------------------------------------------------------------------------------- /tests/packages/P3/myocamlbuild.ml: -------------------------------------------------------------------------------- 1 | let deps = [ "P1" ] 2 | 3 | open Ocamlbuild_plugin 4 | 5 | let libdir = 6 | Ocamlbuild_pack.My_unix.run_and_open 7 | (Printf.sprintf "%s config var lib" 8 | (Unix.getenv "OPAM")) 9 | input_line 10 | 11 | let includes = 12 | Printf.sprintf "-I %s/P1 -I %s/P2" libdir libdir 13 | 14 | let add_dep p = 15 | flag ["ocaml"; "compile"] & S[Sh includes] 16 | 17 | let _ = dispatch & function 18 | | After_rules -> List.iter add_dep deps 19 | | _ -> () 20 | -------------------------------------------------------------------------------- /shell/md5check.ml: -------------------------------------------------------------------------------- 1 | let file, md5 = 2 | if Array.length Sys.argv <> 3 then ( 3 | Printf.eprintf "usage: ocaml %s \n" Sys.argv.(0); 4 | exit 1 5 | ) else 6 | Sys.argv.(1), Sys.argv.(2) 7 | 8 | let md5_of_file = 9 | Digest.to_hex (Digest.file file) 10 | 11 | let () = 12 | if md5 <> md5_of_file then ( 13 | Printf.eprintf 14 | "MD5 for %s differ:\n\ 15 | \ expected: %s\n\ 16 | \ actual: %s\n" 17 | file md5 md5_of_file; 18 | Sys.remove file 19 | ) else 20 | Printf.printf "%s has the expected MD5.\n" file 21 | -------------------------------------------------------------------------------- /src/format/format.ocp: -------------------------------------------------------------------------------- 1 | begin library "opam-format" 2 | sort = false 3 | files = [ 4 | "opamFormatConfig.ml" 5 | "opamSwitch.ml" 6 | "opamPackage.ml" 7 | "opamFormula.ml" 8 | "opamCompiler.ml" 9 | "opamVariable.ml" 10 | "opamRepositoryName.ml" 11 | "opamTypes.mli" 12 | "opamTypesBase.ml" 13 | "opamFormat.ml" 14 | "opamParser.mly" 15 | "opamLexer.mll" 16 | "opamLineLexer.mll" 17 | "opamFilter.ml" 18 | "opamFile.ml" 19 | ] 20 | 21 | requires = [ 22 | "opam-core" 23 | "re.pcre" 24 | ] 25 | 26 | end 27 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Bug reports and feature requests for **the OPAM tool** should be reported on: 2 | 3 | * http://github.com/ocaml/opam/issues 4 | (please include the output of `opam config report` whenever possible) 5 | 6 | **Packaging issues** or requests for a new package should be reported on: 7 | 8 | * http://github.com/ocaml/opam-repository/issues 9 | 10 | **General queries** can be addressed at: 11 | 12 | * http://lists.ocaml.org/listinfo/platform 13 | (for the both the tool & packages) 14 | 15 | * http://lists.ocaml.org/listinfo/opam-devel 16 | (for the tool and its evolution) 17 | -------------------------------------------------------------------------------- /src/client/client.ocp: -------------------------------------------------------------------------------- 1 | comp += [ "-w" "-48" ] 2 | 3 | begin library "opam-client" 4 | 5 | files = [ 6 | "opamClientConfig.ml" 7 | "opamSwitchCommand.ml" 8 | "opamConfigCommand.ml" 9 | "opamRepositoryCommand.ml" 10 | "opamPinCommand.ml" 11 | "opamClient.ml" 12 | "opamGitVersion.ml" 13 | "opamArg.ml" 14 | ] 15 | 16 | requires = [ 17 | "opam-state" 18 | "re.glob" 19 | "cmdliner" 20 | ] 21 | 22 | end 23 | 24 | begin program "opam" 25 | 26 | files = [ 27 | "opamMain.ml" 28 | ] 29 | requires = [ 30 | "opam-client" 31 | ] 32 | 33 | end 34 | -------------------------------------------------------------------------------- /src/tools/tools.ocp: -------------------------------------------------------------------------------- 1 | comp += [ "-w" "-48" ] 2 | 3 | begin program "opam-check" 4 | files = [ "opam_check.ml" ] 5 | requires = [ "opam-client" ] 6 | end 7 | 8 | begin program "opam-admin" 9 | files = [ 10 | "opam_mk_repo.ml" 11 | "opam_repo_check.ml" 12 | "opam_stats.ml" 13 | "opam_depexts_change.ml" 14 | (* "opam_findlib.ml" *) 15 | "opam_rename.ml" 16 | "opam_admin.ml" 17 | ] 18 | requires = [ "opam-client" ] 19 | end 20 | 21 | begin program "opam-installer" 22 | files = [ 23 | "opam_installer.ml" 24 | ] 25 | requires = [ "opam-client" ] 26 | end 27 | 28 | begin program "opamlfind" 29 | files = [ 30 | "opamlfind.ml" 31 | ] 32 | requires = [ "unix" ] 33 | end 34 | -------------------------------------------------------------------------------- /tests/results/README.tests: -------------------------------------------------------------------------------- 1 | 2 | # All tests are performed in a clean repository 3 | 4 | Initial state of the repository 5 | 6 | Available packages for system: 7 | P1 -- A very useful package 8 | P2 -- An other very useful package 9 | P3 -- Testing version names 10 | P4 -- Testing transitive closure 11 | P5 -- Testing optional dependencies 12 | 13 | 14 | * install-P1 15 | install P1 16 | 17 | * install-P1-P2-P3-P4 18 | install P1, P2, P3, P4 19 | 20 | * install-remove-P1 21 | install P1 and then remove P1 22 | 23 | * install-upgrade-P2 24 | install P4 and then upgrade P2 25 | 26 | * reinstall-P2 27 | install P2 and the re-install P2 28 | 29 | * install_opt 30 | install P5 , install P2, remove P5, remove P2, remove P1 31 | -------------------------------------------------------------------------------- /opam.install: -------------------------------------------------------------------------------- 1 | bin: [ 2 | "src/opam" 3 | "src/opam-admin" 4 | "src/opam-installer" 5 | ] 6 | man: [ 7 | "?doc/man/opam.1" 8 | "?doc/man/opam-admin.1" 9 | "?doc/man/opam-admin-check.1" 10 | "?doc/man/opam-admin-depexts.1" 11 | "?doc/man/opam-admin-libs.1" 12 | "?doc/man/opam-admin-make.1" 13 | "?doc/man/opam-admin-stats.1" 14 | "?doc/man/opam-config.1" 15 | "?doc/man/opam-init.1" 16 | "?doc/man/opam-install.1" 17 | "?doc/man/opam-installer.1" 18 | "?doc/man/opam-list.1" 19 | "?doc/man/opam-pin.1" 20 | "?doc/man/opam-reinstall.1" 21 | "?doc/man/opam-remove.1" 22 | "?doc/man/opam-repository.1" 23 | "?doc/man/opam-search.1" 24 | "?doc/man/opam-show.1" 25 | "?doc/man/opam-switch.1" 26 | "?doc/man/opam-update.1" 27 | "?doc/man/opam-upgrade.1" 28 | ] 29 | -------------------------------------------------------------------------------- /tests/README.unittest: -------------------------------------------------------------------------------- 1 | 2 | # to create a new unit test 3 | 4 | * clean the test repository : 5 | 6 | ./init-repo.sh -c 7 | 8 | * init the test repository : 9 | 10 | ./init-repo.sh -i 11 | 12 | * load a inital scenario (this command can be invoked multiple times): 13 | 14 | ./init-repo.sh -s 1 15 | ./init-repo.sh -s 2 16 | 17 | * install/remove/upgrade : 18 | 19 | OPAM_ROOT=/tmp/OPAM.ROOT PATH=/tmp/OPAM.BIN:$PATH opam --yes --root /tmp/OPAM.ROOT install P4 20 | 21 | * crearte a new expected result file in as 22 | 23 | OPAM_ROOT=/tmp/OPAM.ROOT PATH=/tmp/OPAM.BIN:$PATH \ 24 | opam --yes --root /tmp/OPAM.ROOT list > results/new-expected-result 25 | 26 | * Make sure that the result correct ! 27 | 28 | * Add a new test case in the file tests.py 29 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | script: bash -ex .travis-ci.sh 3 | matrix: 4 | include: 5 | - os: linux 6 | env: OCAML_VERSION=4.02.3 OPAM_TEST=1 EXTERNAL_SOLVER= 7 | - os: linux 8 | env: OCAML_VERSION=4.02.3 OPAM_TEST=1 EXTERNAL_SOLVER=aspcud 9 | - os: linux 10 | env: OCAML_VERSION=4.02.3 OPAM_TEST= 11 | - os: linux 12 | env: OCAML_VERSION=4.01.0 OPAM_TEST= 13 | - os: linux 14 | env: OCAML_VERSION=4.00.1 OPAM_TEST= 15 | - os: linux 16 | env: OCAML_VERSION=3.12.1 OPAM_TEST= 17 | - os: osx 18 | env: OCAML_VERSION=4.02.2 OPAM_TEST=1 EXTERNAL_SOLVER= 19 | - os: osx 20 | env: OCAML_VERSION=4.02.2 OPAM_TEST= 21 | notifications: 22 | email: 23 | - opam-commits@lists.ocaml.org 24 | irc: 25 | - "chat.freenode.net#opam" 26 | -------------------------------------------------------------------------------- /admin-scripts/add-build-deps.ml: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env opam-admin.top 2 | 3 | #directory "+../opam-lib";; 4 | open Opam_admin_top;; 5 | 6 | (* Add the "build" dependency flag to all ocamlfind depends *) 7 | 8 | let to_build = List.map OpamPackage.Name.of_string ["ocamlfind"] 9 | 10 | let addbuild (pkg, (flags, cstr) as atom) = 11 | if List.mem pkg to_build && not (List.mem OpamTypes.Depflag_Build flags) then 12 | OpamFormula.Atom (pkg, (OpamTypes.Depflag_Build::flags, cstr)) 13 | else 14 | OpamFormula.Atom atom 15 | ;; 16 | 17 | iter_packages ~opam:(fun _ opam0 -> 18 | let open OpamFile.OPAM in 19 | let opam = opam0 in 20 | let opam = with_depends opam @@ OpamFormula.map addbuild @@ depends opam in 21 | let opam = with_depopts opam @@ OpamFormula.map addbuild @@ depopts opam in 22 | let opam = if opam <> opam0 23 | then with_opam_version opam @@ OpamVersion.of_string "1.2" 24 | else opam 25 | in 26 | opam) 27 | () 28 | -------------------------------------------------------------------------------- /Makefile.config.in: -------------------------------------------------------------------------------- 1 | OCAMLVERSION = @OCAMLVERSION@ 2 | OCAML_4 = @ocaml_4@ 3 | OCAML_4_01 = @ocaml_4_01@ 4 | OCAML_4_02 = @ocaml_4_02@ 5 | datarootdir = @datarootdir@ 6 | prefix = @prefix@ 7 | mandir = @mandir@ 8 | version = @PACKAGE_VERSION@ 9 | FETCH = @fetch@ 10 | HAS_PACKAGES = @hasalldeps@ 11 | USE_BYTE := $(if $(subst no,,@OCAMLOPT@),,true) 12 | PACKS = @OCAML_PKG_unix@ @OCAML_PKG_extlib@ @OCAML_PKG_re@ @OCAML_PKG_re_emacs@ @OCAML_PKG_re_str@ @OCAML_PKG_re_perl@ @OCAML_PKG_re_pcre@ @OCAML_PKG_re_glob@ @OCAML_PKG_cmdliner@ @OCAML_PKG_ocamlgraph@ @OCAML_PKG_cudf@ @OCAML_PKG_dose3_common@ @OCAML_PKG_dose3_algo@ @OCAML_PKG_jsonm@ 13 | 14 | OCAMLFIND = @OCAMLFIND@ 15 | OCAML = @OCAML@ 16 | OCAMLC = @OCAMLC@ 17 | OCAMLOPT = @OCAMLOPT@ 18 | OCAMLDEP = @OCAMLDEP@ 19 | OCAMLLEX = @OCAMLLEX@ 20 | OCAMLYACC = @OCAMLYACC@ 21 | OCAMLMKLIB = @OCAMLMKLIB@ 22 | OCAMLDOC = @OCAMLDOC@ 23 | 24 | export OCAMLVERSION OCAMLFIND OCAML OCAMLC OCAMLOPT OCAMLDEP OCAMLLEX OCAMLYACC OCAMLMKLIB OCAMLDOC 25 | -------------------------------------------------------------------------------- /opam: -------------------------------------------------------------------------------- 1 | opam-version: "1.2" 2 | name: "opam-lib" 3 | version: "1.3.0~dev" 4 | maintainer: "opam-devel@lists.ocaml.org" 5 | homepage: "https://opam.ocaml.org/" 6 | dev-repo: "https://github.com/ocaml/opam.git" 7 | bug-reports: "https://github.com/ocaml/opam/issues" 8 | authors: [ 9 | "Thomas Gazagnaire " 10 | "Anil Madhavapeddy " 11 | "Fabrice Le Fessant " 12 | "Frederic Tuong " 13 | "Louis Gesbert " 14 | "Guillem Rieu " 15 | "Vincent Bernardoff " 16 | "Roberto Di Cosmo " 17 | ] 18 | build: [ 19 | ["./configure"] 20 | [make] 21 | [make "-C" "src" "../opam-lib.install"] 22 | ] 23 | depends: [ 24 | "ocamlgraph" 25 | "cmdliner" 26 | "dose" {>= "3.2.2+opam" & < "4"} 27 | "cudf" 28 | "re" {>= "1.2.0"} 29 | "ocamlfind" {build} 30 | "jsonm" 31 | ] 32 | -------------------------------------------------------------------------------- /admin-scripts/add-github-dev.ml: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env opam-admin.top 2 | #directory "+../opam-lib";; 3 | open Opam_admin_top;; 4 | 5 | #use "topfind";; 6 | #require "re";; 7 | 8 | let github_re = 9 | Re.compile (Re_perl.re "https?://([^/]*github.com/.*)/archive/.*");; 10 | 11 | iter_packages_gen @@ fun nv ~prefix:_ ~opam ~descr:_ ~url ~dot_install:_ -> 12 | let opam = 13 | if OpamFile.OPAM.dev_repo opam <> None then opam else 14 | match url with 15 | | None -> opam 16 | | Some u -> 17 | match OpamFile.URL.(kind u, url u) with 18 | | `http, (addr,None) when Re.execp github_re addr -> 19 | let substrings = Re.exec github_re addr in 20 | let git = Printf.sprintf "git://%s" (Re.get substrings 1) in 21 | let opam = 22 | OpamFile.OPAM.with_dev_repo opam (Some (OpamTypes.Git (git,None))) 23 | in 24 | OpamFile.OPAM.with_opam_version opam (OpamVersion.of_string "1.2") 25 | | _ -> opam 26 | in 27 | opam, `Keep, `Keep, `Keep 28 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | platform: 2 | - x86 3 | 4 | environment: 5 | global: 6 | CYG_ROOT: C:/cygwin 7 | CYG_CACHE: C:/cygwin/var/cache/setup 8 | CYG_MIRROR: http://mirrors.kernel.org/sourceware/cygwin/ 9 | matrix: 10 | - 11 | CYG_ARCH: x86 12 | 13 | init: 14 | - 'echo System architecture: %PLATFORM%' 15 | 16 | install: 17 | - 'appveyor DownloadFile http://cygwin.com/setup-%CYG_ARCH%.exe -FileName setup.exe' 18 | - 'setup.exe -qnNdO -R "%CYG_ROOT%" -s "%CYG_MIRROR%" -l "%CYG_CACHE%" -P make -P git -P gcc-core -P ocaml -P ocaml-camlp4 -P ocaml-compiler-libs -P curl -P libncurses-devel -P m4 -P unzip >NUL' 19 | - 'setup.exe -qnNdO -R "%CYG_ROOT%" -s "%CYG_MIRROR%" -l "%CYG_CACHE%" -P libmpfr-devel -P patch -P flexdll >NUL' 20 | - '%CYG_ROOT%/bin/bash -lc "cygcheck -dc cygwin"' 21 | 22 | build_script: 23 | - '%CYG_ROOT%/bin/bash -lc "cd \"$OLDPWD\" && env DJDIR="workaround" ./configure && make lib-ext && make && make install"' 24 | - '%CYG_ROOT%/bin/bash -lc "opam init -y -a"' 25 | - '%CYG_ROOT%/bin/bash -lc "opam install -y -v ocamlfind"' 26 | -------------------------------------------------------------------------------- /src/core/opamCompat.ml.4.02: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2014 OCamlPro *) 4 | (* *) 5 | (* All rights reserved.This file is distributed under the terms of the *) 6 | (* GNU Lesser General Public License version 3.0 with linking *) 7 | (* exception. *) 8 | (* *) 9 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 10 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 11 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 12 | (* License for more details. *) 13 | (* *) 14 | (**************************************************************************) 15 | 16 | module Bytes = Bytes 17 | module Buffer = Buffer 18 | module Filename = Filename 19 | -------------------------------------------------------------------------------- /src/core/opamCompat.mli.4.02: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2014 OCamlPro *) 4 | (* *) 5 | (* All rights reserved.This file is distributed under the terms of the *) 6 | (* GNU Lesser General Public License version 3.0 with linking *) 7 | (* exception. *) 8 | (* *) 9 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 10 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 11 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 12 | (* License for more details. *) 13 | (* *) 14 | (**************************************************************************) 15 | 16 | module Bytes = Bytes 17 | module Buffer = Buffer 18 | module Filename = Filename 19 | -------------------------------------------------------------------------------- /src/tools/opam_stats.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2012-2015 OCamlPro *) 4 | (* Copyright 2012 INRIA *) 5 | (* *) 6 | (* All rights reserved.This file is distributed under the terms of the *) 7 | (* GNU Lesser General Public License version 3.0 with linking *) 8 | (* exception. *) 9 | (* *) 10 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 11 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 12 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 13 | (* License for more details. *) 14 | (* *) 15 | (**************************************************************************) 16 | 17 | val process: unit -> unit 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | _obuild/ 2 | bootstrap/ 3 | .*.swp 4 | src_ext/cudf/ 5 | src_ext/dose/ 6 | src_ext/cmdliner/ 7 | src_ext/extlib/ 8 | src_ext/re/ 9 | src_ext/graph/ 10 | src_ext/*.stamp 11 | src_ext/*.tbz 12 | src_ext/*.tar.gz 13 | *.tar.bz2 14 | *.annot 15 | *.tar.gz 16 | *~ 17 | .#* 18 | ocp-build.root 19 | ocp-build.root.old 20 | ocp-get 21 | ocp-get-server 22 | ocp-build.root.old.old 23 | # debug files 24 | *.log 25 | *.cudf 26 | *.dot 27 | # Generated files: 28 | *.cmo 29 | *.cmx 30 | *.cmi 31 | *.cmt 32 | *.cmti 33 | *.cma 34 | *.cmxa 35 | *.cmxs 36 | *.a 37 | *.o 38 | META 39 | opam-lib.install 40 | Makefile.config 41 | config.log 42 | config.status 43 | src/client/opamGitVersion.ml 44 | src/state/opamScript.ml 45 | src/core/opamVersion.ml 46 | src/format/opamLexer.ml 47 | src/format/opamLineLexer.ml 48 | src/format/opamParser.ml 49 | src/format/opamParser.mli 50 | src/core/opamCompat.ml 51 | src/core/opamCompat.mli 52 | src/opam 53 | src/opam-admin 54 | src/opam-installer 55 | src/opam-check 56 | src/opamlfind 57 | ._d 58 | ._ncdi 59 | ._bcdi 60 | aclocal.m4 61 | autom4te.cache 62 | # doc 63 | doc/dev-manual/*aux 64 | doc/dev-manual/*.html 65 | doc/dev-manual/*toc 66 | doc/html 67 | doc/man-html 68 | doc/tutorials/opam.wiki 69 | doc/dev-manual/*.out 70 | doc/man 71 | -------------------------------------------------------------------------------- /src/client/opamGitVersion.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2014 OCamlPro *) 4 | (* Copyright 2012 INRIA *) 5 | (* *) 6 | (* All rights reserved.This file is distributed under the terms of the *) 7 | (* GNU Lesser General Public License version 3.0 with linking *) 8 | (* exception. *) 9 | (* *) 10 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 11 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 12 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 13 | (* License for more details. *) 14 | (* *) 15 | (**************************************************************************) 16 | 17 | val version: string option 18 | -------------------------------------------------------------------------------- /tests/packages/P1-1.opam: -------------------------------------------------------------------------------- 1 | (* API version *) 2 | opam-version: "1" 3 | 4 | name: "P1" 5 | 6 | # Test 7 | # Toto 8 | 9 | (* Version are arbitrary strings *) 10 | version: "1" 11 | 12 | maintainer: "contact@ocamlpro.com" 13 | 14 | (* The command to run *) 15 | build: [ 16 | [ "./build.sh" ] # HAHAH 17 | [ "this" "should" "never" "run" ] { ocaml-version > "100" } 18 | [ make "this" ocaml-version "also" ] { os = "NO" } 19 | [ "echo" "HAHA!" ] { ocaml-version = "10" } 20 | [ "echo" make share ocaml-version ] 21 | [ "this as well" { os = "myOS" } ] 22 | ] 23 | 24 | os: [ !"NO" | ( !"NO" & !"YES") ] 25 | ocaml-version: [ ="system" | ="20" | ="10" ] 26 | 27 | (* List of files to substitute env variables *) 28 | substs: [ "P1.config" ] 29 | 30 | (* Libraries *) 31 | libraries: [ "p1" ] 32 | 33 | (* External dependencies *) 34 | depexts: [ 35 | [ ["debian" "amd64"] ["foo" "bar"] ] 36 | [ ["osx" ] ["foobar"] ] 37 | ] 38 | 39 | messages: [ "I'll always bother you displaying this message" ] 40 | 41 | post-messages: [ "Thanks SO MUCH for installing this humble package" 42 | "Everything went well" {success} 43 | "Nooo, something went wrong, this makes me feel sooo sad..." {failure} ] 44 | 45 | bug-reports: "TEST.com" -------------------------------------------------------------------------------- /doc/release/readme.md: -------------------------------------------------------------------------------- 1 | ## Steps to follow for each release 2 | 3 | * Update version (and copyright year) in `configure.ac`, `shell/opam_installer.sh` 4 | * Run `make configure` to regenerate `./configure` 5 | * Run `make tests`, `opam-rt` (with and without aspcud) -- now checked by travis 6 | * Run `make doc` to re-generate the API documetation 7 | 8 | -- 9 | 10 | * update the CHANGELOG 11 | * tag the release (git tag -a 1.2.1; git push origin 1.2.1) 12 | * create a release on github based on your tag (https://github.com/ocaml/opam/releases/new) 13 | 14 | -- 15 | 16 | * Generate an inclusive source tarball (and the binary for your current arch while you're at it): 17 | ``` 18 | ./shell/release.sh full-archive binary publish -n git-name:git-token 19 | ``` 20 | * Check that it's been properly uploaded on https://github.com/ocaml/opam/releases 21 | * Ask people on other archs (and with write access to opam) to run 22 | ``` 23 | wget https://raw.github.com/ocaml/opam/master/shell/release.sh && \ 24 | bash -ue ./release.sh -t $VERSION 25 | ``` 26 | 27 | -- 28 | 29 | * Add some news about the release on the platform blog 30 | * Update the installation instructions in doc/pages 31 | * Update the opam-lib, opamfu, opam2web opam packages 32 | * Announce ! (platform-list, caml-list) 33 | -------------------------------------------------------------------------------- /src/format/opamLexer.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2012-2015 OCamlPro *) 4 | (* Copyright 2012 INRIA *) 5 | (* *) 6 | (* All rights reserved.This file is distributed under the terms of the *) 7 | (* GNU Lesser General Public License version 3.0 with linking *) 8 | (* exception. *) 9 | (* *) 10 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 11 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 12 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 13 | (* License for more details. *) 14 | (* *) 15 | (**************************************************************************) 16 | 17 | val token: Lexing.lexbuf -> OpamParser.token 18 | -------------------------------------------------------------------------------- /src/format/opamLineLexer.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2012-2015 OCamlPro *) 4 | (* Copyright 2012 INRIA *) 5 | (* *) 6 | (* All rights reserved.This file is distributed under the terms of the *) 7 | (* GNU Lesser General Public License version 3.0 with linking *) 8 | (* exception. *) 9 | (* *) 10 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 11 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 12 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 13 | (* License for more details. *) 14 | (* *) 15 | (**************************************************************************) 16 | 17 | val main: Lexing.lexbuf -> string list list 18 | -------------------------------------------------------------------------------- /src_ext/patches/dose/0003-Removed-hard-failure-cases-in-favor-of-finer-diagnos.patch: -------------------------------------------------------------------------------- 1 | From 43c0a01d18e442dd8d51b21630a784c0c1dad0f5 Mon Sep 17 00:00:00 2001 2 | From: Louis Gesbert 3 | Date: Fri, 18 Jul 2014 15:50:24 +0200 4 | Subject: [PATCH 3/3] Removed hard failure cases, in favor of finer diagnostics 5 | 6 | --- 7 | algo/depsolver.ml | 5 ----- 8 | 1 file changed, 5 deletions(-) 9 | 10 | diff --git a/algo/depsolver.ml b/algo/depsolver.ml 11 | index 5815f8a..3f25cd8 100644 12 | --- a/algo/depsolver.ml 13 | +++ b/algo/depsolver.ml 14 | @@ -37,11 +37,6 @@ let reason map universe = 15 | let globalid = Cudf.universe_size universe in 16 | List.filter_map (function 17 | |Diagnostic_int.Dependency(i,vl,il) when i = globalid -> None 18 | - |Diagnostic_int.Missing(i,vl) when i = globalid -> 19 | - fatal "the package encoding global constraints can't be missing" 20 | - |Diagnostic_int.Conflict(i,j,vpkg) when i = globalid || j = globalid -> 21 | - fatal "the package encoding global constraints can't be in conflict" 22 | - 23 | |Diagnostic_int.Dependency(i,vl,il) -> Some ( 24 | Diagnostic.Dependency(from_sat (map#inttovar i),vl,List.map (fun i -> from_sat (map#inttovar i)) il) 25 | ) 26 | -- 27 | 2.1.4 28 | 29 | -------------------------------------------------------------------------------- /src/repository/opamGit.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2012-2015 OCamlPro *) 4 | (* Copyright 2012 INRIA *) 5 | (* *) 6 | (* All rights reserved.This file is distributed under the terms of the *) 7 | (* GNU Lesser General Public License version 3.0 with linking *) 8 | (* exception. *) 9 | (* *) 10 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 11 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 12 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 13 | (* License for more details. *) 14 | (* *) 15 | (**************************************************************************) 16 | 17 | (** Git repository backend *) 18 | 19 | module B: OpamRepositoryBackend.S 20 | -------------------------------------------------------------------------------- /src/repository/opamHg.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2012-2015 OCamlPro *) 4 | (* Copyright 2012 INRIA *) 5 | (* *) 6 | (* All rights reserved.This file is distributed under the terms of the *) 7 | (* GNU Lesser General Public License version 3.0 with linking *) 8 | (* exception. *) 9 | (* *) 10 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 11 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 12 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 13 | (* License for more details. *) 14 | (* *) 15 | (**************************************************************************) 16 | 17 | (** Git repository backend *) 18 | 19 | module B: OpamRepositoryBackend.S 20 | -------------------------------------------------------------------------------- /src/repository/opamDarcs.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2012-2015 OCamlPro *) 4 | (* Copyright 2012 INRIA *) 5 | (* *) 6 | (* All rights reserved.This file is distributed under the terms of the *) 7 | (* GNU Lesser General Public License version 3.0 with linking *) 8 | (* exception. *) 9 | (* *) 10 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 11 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 12 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 13 | (* License for more details. *) 14 | (* *) 15 | (**************************************************************************) 16 | 17 | (** Darcs repository backend *) 18 | 19 | module B: OpamRepositoryBackend.S 20 | -------------------------------------------------------------------------------- /src/tools/opam_mk_repo.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2012-2015 OCamlPro *) 4 | (* Copyright 2012 INRIA *) 5 | (* *) 6 | (* All rights reserved.This file is distributed under the terms of the *) 7 | (* GNU Lesser General Public License version 3.0 with linking *) 8 | (* exception. *) 9 | (* *) 10 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 11 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 12 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 13 | (* License for more details. *) 14 | (* *) 15 | (**************************************************************************) 16 | 17 | type args 18 | val args: args Cmdliner.Term.t 19 | val process: args -> unit 20 | -------------------------------------------------------------------------------- /src/tools/opam_repo_check.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2012-2015 OCamlPro *) 4 | (* Copyright 2012 INRIA *) 5 | (* *) 6 | (* All rights reserved.This file is distributed under the terms of the *) 7 | (* GNU Lesser General Public License version 3.0 with linking *) 8 | (* exception. *) 9 | (* *) 10 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 11 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 12 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 13 | (* License for more details. *) 14 | (* *) 15 | (**************************************************************************) 16 | 17 | type args 18 | val args: args Cmdliner.Term.t 19 | val process: args -> unit 20 | -------------------------------------------------------------------------------- /src/format/opamRepositoryName.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2012-2015 OCamlPro *) 4 | (* Copyright 2012 INRIA *) 5 | (* *) 6 | (* All rights reserved.This file is distributed under the terms of the *) 7 | (* GNU Lesser General Public License version 3.0 with linking *) 8 | (* exception. *) 9 | (* *) 10 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 11 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 12 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 13 | (* License for more details. *) 14 | (* *) 15 | (**************************************************************************) 16 | 17 | include OpamStd.AbstractString 18 | 19 | let default = of_string "default" 20 | -------------------------------------------------------------------------------- /src/state/opamScript.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2012-2015 OCamlPro *) 4 | (* Copyright 2012 INRIA *) 5 | (* *) 6 | (* All rights reserved.This file is distributed under the terms of the *) 7 | (* GNU Lesser General Public License version 3.0 with linking *) 8 | (* exception. *) 9 | (* *) 10 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 11 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 12 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 13 | (* License for more details. *) 14 | (* *) 15 | (**************************************************************************) 16 | 17 | val complete : string 18 | val complete_zsh : string 19 | val switch_eval : string 20 | -------------------------------------------------------------------------------- /shell/get-git-id.ml: -------------------------------------------------------------------------------- 1 | let file = 2 | if Array.length Sys.argv <> 2 then ( 3 | Printf.eprintf "usage: ocaml %s \n" Sys.argv.(0); 4 | exit 1 5 | ) else 6 | Sys.argv.(1) 7 | 8 | let read file = 9 | if Sys.file_exists file then 10 | let ic = open_in_bin file in 11 | Some (input_line ic) 12 | else 13 | None 14 | 15 | let write file contents = 16 | let write () = 17 | let oc = open_out file in 18 | output_string oc contents; 19 | output_char oc '\n'; 20 | close_out oc in 21 | match read file with 22 | | None -> write () 23 | | Some actual -> if actual <> contents then write () 24 | 25 | let (/) = Filename.concat 26 | 27 | let git file = ".git" / file 28 | 29 | let () = 30 | let version_none () = 31 | write file "let version = None" in 32 | match read (git "HEAD") with 33 | | None -> version_none () 34 | | Some s -> 35 | let reference = 36 | try (* look for "ref: refs/heads/..." *) 37 | let c = String.rindex s ' ' in 38 | let namedref = String.sub s (c+1) (String.length s -c-1) in 39 | read (git namedref) 40 | with Not_found -> (* detached state, .git/HEAD contains sha1 *) 41 | Some s in 42 | match reference with 43 | | None -> version_none () 44 | | Some sha1 -> write file (Printf.sprintf "let version = Some %S" sha1) 45 | -------------------------------------------------------------------------------- /META.in: -------------------------------------------------------------------------------- 1 | version = "@PACKAGE_VERSION@" 2 | description = "OCaml Package Manager base API" 3 | requires = "ocamlgraph, unix, re, re.str, jsonm" 4 | archive(byte) = "opam-core.cma" 5 | archive(native) = "opam-core.cmxa" 6 | 7 | package "format" ( 8 | version = "@PACKAGE_VERSION@" 9 | archive(byte) = "opam-format.cma" 10 | archive(native) = "opam-format.cmxa" 11 | requires = "re.pcre, opam-lib" 12 | ) 13 | 14 | package "repository" ( 15 | version = "@PACKAGE_VERSION@" 16 | archive(byte) = "opam-repository.cma" 17 | archive(native) = "opam-repository.cmxa" 18 | requires = "opam-lib, opam-lib.format" 19 | ) 20 | 21 | package "solver" ( 22 | version = "@PACKAGE_VERSION@" 23 | archive(byte) = "opam-solver.cma" 24 | archive(native) = "opam-solver.cmxa" 25 | requires = "cudf, dose3.common, dose3.algo, opam-lib, opam-lib.format" 26 | ) 27 | 28 | package "state" ( 29 | version = "@PACKAGE_VERSION@" 30 | archive(byte) = "opam-state.cma" 31 | archive(native) = "opam-state.cmxa" 32 | requires = "opam-lib, opam-lib.format, opam-lib.solver, opam-lib.repository" 33 | ) 34 | 35 | package "client" ( 36 | version = "@PACKAGE_VERSION@" 37 | archive(byte) = "opam-client.cma" 38 | archive(native) = "opam-client.cmxa" 39 | requires = "cmdliner, re.glob, opam-lib, opam-lib.format, opam-lib.solver, opam-lib.repository, opam-lib.state" 40 | ) 41 | -------------------------------------------------------------------------------- /src/format/opamRepositoryName.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2012-2015 OCamlPro *) 4 | (* Copyright 2012 INRIA *) 5 | (* *) 6 | (* All rights reserved.This file is distributed under the terms of the *) 7 | (* GNU Lesser General Public License version 3.0 with linking *) 8 | (* exception. *) 9 | (* *) 10 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 11 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 12 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 13 | (* License for more details. *) 14 | (* *) 15 | (**************************************************************************) 16 | 17 | (** Repository names *) 18 | 19 | include OpamStd.ABSTRACT 20 | 21 | (** Default repository name *) 22 | val default: t 23 | -------------------------------------------------------------------------------- /src/format/opamSwitch.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2012-2015 OCamlPro *) 4 | (* Copyright 2012 INRIA *) 5 | (* *) 6 | (* All rights reserved.This file is distributed under the terms of the *) 7 | (* GNU Lesser General Public License version 3.0 with linking *) 8 | (* exception. *) 9 | (* *) 10 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 11 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 12 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 13 | (* License for more details. *) 14 | (* *) 15 | (**************************************************************************) 16 | 17 | include OpamStd.AbstractString 18 | 19 | let system = of_string "system" 20 | 21 | let not_installed s = 22 | OpamConsole.error_and_exit 23 | "The compiler switch %s is not installed." 24 | (to_string s) 25 | -------------------------------------------------------------------------------- /src/format/opamSwitch.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2012-2015 OCamlPro *) 4 | (* Copyright 2012 INRIA *) 5 | (* *) 6 | (* All rights reserved.This file is distributed under the terms of the *) 7 | (* GNU Lesser General Public License version 3.0 with linking *) 8 | (* exception. *) 9 | (* *) 10 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 11 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 12 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 13 | (* License for more details. *) 14 | (* *) 15 | (**************************************************************************) 16 | 17 | (** Compiler switch names *) 18 | 19 | include OpamStd.ABSTRACT 20 | 21 | (** System switch name *) 22 | val system: t 23 | 24 | (** Display an error message when a switch is not installed. *) 25 | val not_installed: t -> 'a 26 | -------------------------------------------------------------------------------- /src/repository/opamHTTP.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2012-2015 OCamlPro *) 4 | (* Copyright 2012 INRIA *) 5 | (* *) 6 | (* All rights reserved.This file is distributed under the terms of the *) 7 | (* GNU Lesser General Public License version 3.0 with linking *) 8 | (* exception. *) 9 | (* *) 10 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 11 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 12 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 13 | (* License for more details. *) 14 | (* *) 15 | (**************************************************************************) 16 | 17 | (** Curl repository backend *) 18 | 19 | module B: OpamRepositoryBackend.S 20 | 21 | open OpamTypes 22 | 23 | val make_index_tar_gz: repository_root -> unit 24 | 25 | val make_urls_txt: write:bool -> repository_root -> file_attribute_set 26 | -------------------------------------------------------------------------------- /src_ext/patches/cmdliner/backport_pre_4_00_0.patch: -------------------------------------------------------------------------------- 1 | diff -Naur cmdliner-0.9.7/src/cmdliner.ml cmdliner-0.9.7.patched/src/cmdliner.ml 2 | --- cmdliner-0.9.7/src/cmdliner.ml 2015-02-06 11:33:44.000000000 +0100 3 | +++ cmdliner-0.9.7.patched/src/cmdliner.ml 2015-02-18 23:04:04.000000000 +0100 4 | @@ -830,7 +830,7 @@ 5 | | None -> if names = [] then "ARGUMENTS" else "OPTIONS" 6 | | Some s -> s 7 | in 8 | - { id = arg_id (); absent = Val (Lazy.from_val ""); 9 | + { id = arg_id (); absent = Val (lazy ""); 10 | doc = doc; docv = docv; docs = docs; 11 | p_kind = All; o_kind = Flag; o_names = List.rev_map dash names; 12 | o_all = false; } 13 | @@ -924,7 +924,7 @@ 14 | 15 | let opt_all ?vopt (parse, print) v a = 16 | if is_pos a then invalid_arg err_not_opt else 17 | - let a = { a with absent = Val (Lazy.from_val ""); o_all = true; 18 | + let a = { a with absent = Val (lazy ""); o_all = true; 19 | o_kind = match vopt with 20 | | None -> Opt | Some dv -> Opt_vopt (str_of_pp print dv) } 21 | in 22 | @@ -949,7 +949,7 @@ 23 | let pos ?(rev = false) k (parse, print) v a = 24 | if is_opt a then invalid_arg err_not_pos else 25 | let a = { a with p_kind = Nth (rev, k); 26 | - absent = Val (Lazy.from_val (str_of_pp print v)) } 27 | + absent = Val (lazy (str_of_pp print v)) } 28 | in 29 | let convert _ cl = match Cmdline.pos_arg cl a with 30 | | [] -> v 31 | -------------------------------------------------------------------------------- /opam-devel.opam: -------------------------------------------------------------------------------- 1 | opam-version: "1.2" 2 | name: "opam-test-beta" 3 | version: "1.3.0~dev" 4 | maintainer: "opam-devel@lists.ocaml.org" 5 | authors: [ 6 | "Thomas Gazagnaire " 7 | "Louis Gesbert " 8 | ] 9 | homepage: "https://opam.ocaml.org" 10 | bug-reports: "https://github.com/ocaml/opam/issues" 11 | dev-repo: "https://github.com/ocaml/opam" 12 | build: [ 13 | ["./configure"] 14 | [make "opam"] 15 | ] 16 | install: [ 17 | ["sh" "-c" "echo \"%{version}%\" > \"%{root}%/opam.version\""] 18 | ["install" "--backup" "-m" "755" "src/opam" "%{root}%/opam"] 19 | ] 20 | remove: ["rm" "-f" "%{root}%/opam" "%{root}%/opam.version"] 21 | depends: [ 22 | "ocamlgraph" 23 | "cmdliner" 24 | "dose" {>= "3.3"} 25 | "cudf" 26 | "re" {>= "1.2.0"} 27 | "ocamlfind" 28 | "jsonm" 29 | ] 30 | # Restrict self-upgrade to "official" versions, just in case 31 | available: [ 32 | opam-version >= "1.2" & 33 | (compiler = "3.12.1" | 34 | compiler = "4.00.0" | 35 | compiler = "4.00.1" | 36 | compiler = "4.01.0" | 37 | compiler = "4.02.0" | 38 | compiler = "4.02.1" | 39 | (compiler = "system" & ocaml-version >= "3.12.1" & ocaml-version <= "4.02.0")) 40 | ] 41 | post-messages: [ " 42 | IMPORTANT: The new version of OPAM has been installed to %{root}%, and it will \ 43 | be used by default for ALL switches. In case of trouble, use `--no-self-upgrade' \ 44 | to bypass, or remove `opam' and `opam-version' from %{root}% to revert. 45 | " {success} 46 | ] 47 | -------------------------------------------------------------------------------- /doc/Makefile: -------------------------------------------------------------------------------- 1 | ifndef OPAM 2 | OPAM = ../src/opam 3 | endif 4 | BINDIR = $(dir $(OPAM)) 5 | SRCDIR = $(wildcard ../src/*) 6 | 7 | TOPICS = $(shell $(OPAM) help topics) 8 | 9 | ifndef OPAM_ADMIN 10 | OPAM_ADMIN = $(BINDIR)/opam-admin 11 | endif 12 | TOPICS_ADMIN = check depexts findlib make rename stats 13 | HELPFMT = --help=groff 14 | 15 | ifndef OPAM_INSTALLER 16 | OPAM_INSTALLER = $(BINDIR)/opam-installer 17 | endif 18 | 19 | SRCEXTDIR = ../src_ext/lib 20 | INCLUDE = $(patsubst %,-I %,$(SRCDIR) $(SRCEXTDIR)) 21 | 22 | .PHONY: man html dev-manual pages 23 | all: man dev html pages 24 | 25 | man: 26 | rm -rf man 27 | mkdir -p man 28 | $(OPAM) $(HELPFMT) > man/opam.1 29 | for i in $(TOPICS); do\ 30 | $(OPAM) $$i $(HELPFMT) > man/opam-$$i.1;\ 31 | done 32 | $(OPAM_ADMIN) $(HELPFMT) > man/opam-admin.1 33 | for i in $(TOPICS_ADMIN); do\ 34 | $(OPAM_ADMIN) $$i $(HELPFMT) > man/opam-admin-$$i.1;\ 35 | done 36 | $(OPAM_INSTALLER) $(HELPFMT) > man/opam-installer.1 37 | 38 | man-html: man 39 | rm -rf $@ 40 | mkdir -p $@ 41 | for f in $(wildcard man/*); do\ 42 | man2html -r $$f > man-html/$$(basename $$f .1).html;\ 43 | done 44 | 45 | dev: 46 | $(MAKE) -C dev-manual 47 | 48 | html: 49 | rm -rf html 50 | mkdir -p html/ 51 | ocamldoc $(INCLUDE) ../src/*/*.mli ../src/*/*.ml -html -d html/ || true 52 | 53 | pages/%.html: pages/%.md 54 | omd $^ -o $@ 55 | 56 | PAGES=$(wildcard pages/*.md) 57 | 58 | pages: $(PAGES:.md=.html) 59 | 60 | clean: 61 | rm -rf man html man-html pages/*.html 62 | $(MAKE) -C dev-manual clean 63 | -------------------------------------------------------------------------------- /src/repository/opamLocal.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2012-2015 OCamlPro *) 4 | (* Copyright 2012 INRIA *) 5 | (* *) 6 | (* All rights reserved.This file is distributed under the terms of the *) 7 | (* GNU Lesser General Public License version 3.0 with linking *) 8 | (* exception. *) 9 | (* *) 10 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 11 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 12 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 13 | (* License for more details. *) 14 | (* *) 15 | (**************************************************************************) 16 | 17 | (** Rsync repository backend *) 18 | 19 | module B: OpamRepositoryBackend.S 20 | 21 | open OpamTypes 22 | 23 | val rsync_dirs: ?args:string list -> ?exclude_vcdirs:bool -> 24 | OpamFilename.Dir.t -> OpamFilename.Dir.t -> 25 | OpamFilename.Dir.t download OpamProcess.job 26 | val rsync_file: ?args:string list -> OpamFilename.t -> OpamFilename.t -> 27 | OpamFilename.t download OpamProcess.job 28 | -------------------------------------------------------------------------------- /src/state/opamOCaml.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2015 OCamlPro *) 4 | (* *) 5 | (* All rights reserved.This file is distributed under the terms of the *) 6 | (* GNU Lesser General Public License version 3.0 with linking *) 7 | (* exception. *) 8 | (* *) 9 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 10 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 11 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 12 | (* License for more details. *) 13 | (* *) 14 | (**************************************************************************) 15 | 16 | (** Some detection of OCaml version and installation specifics. Base functions 17 | lookup in the PATH, [system_*] functions extract the OPAMROOT paths before 18 | looking up*) 19 | 20 | val ocaml_version: string option Lazy.t 21 | val ocaml_opt_available: bool Lazy.t 22 | val ocaml_native_available: bool Lazy.t 23 | val ocaml_natdynlink_available: bool Lazy.t 24 | val system_ocamlc_version: string option Lazy.t 25 | val system_ocamlc_where: string option Lazy.t 26 | val system_compiler: OpamCompiler.t option Lazy.t 27 | -------------------------------------------------------------------------------- /src/format/opamFormatConfig.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2015 OCamlPro *) 4 | (* *) 5 | (* All rights reserved.This file is distributed under the terms of the *) 6 | (* GNU Lesser General Public License version 3.0 with linking *) 7 | (* exception. *) 8 | (* *) 9 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 10 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 11 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 12 | (* License for more details. *) 13 | (* *) 14 | (**************************************************************************) 15 | 16 | type t = private { 17 | strict : bool; 18 | (** Fail early with errors in OPAM files *) 19 | skip_version_checks : bool; 20 | (** Ignore mismatching OPAM versions in files *) 21 | all_parens : bool; 22 | (** Affects the OPAM format printer; for backwards-compatibility *) 23 | } 24 | 25 | type 'a options_fun = 26 | ?strict:bool -> 27 | ?skip_version_checks:bool -> 28 | ?all_parens:bool -> 29 | 'a 30 | 31 | include OpamStd.Config.Sig 32 | with type t := t 33 | and type 'a options_fun := 'a options_fun 34 | -------------------------------------------------------------------------------- /src/core/opamCompat.ml.4.01: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2014 OCamlPro *) 4 | (* *) 5 | (* All rights reserved.This file is distributed under the terms of the *) 6 | (* GNU Lesser General Public License version 3.0 with linking *) 7 | (* exception. *) 8 | (* *) 9 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 10 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 11 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 12 | (* License for more details. *) 13 | (* *) 14 | (**************************************************************************) 15 | 16 | module Bytes = struct 17 | include String 18 | let sub_string = sub 19 | let empty = "" 20 | let of_string x = String.copy x 21 | let to_string x = String.copy x 22 | let blit_string = String.blit 23 | external unsafe_to_string : t -> string = "%identity" 24 | external unsafe_of_string : string -> t = "%identity" 25 | end 26 | 27 | module Buffer = struct 28 | include Buffer 29 | let add_subbytes = add_substring 30 | end 31 | 32 | module Filename = struct 33 | include Filename 34 | let get_temp_dir_name () = temp_dir_name 35 | end 36 | -------------------------------------------------------------------------------- /src/repository/opamRepositoryConfig.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2015 OCamlPro *) 4 | (* *) 5 | (* All rights reserved.This file is distributed under the terms of the *) 6 | (* GNU Lesser General Public License version 3.0 with linking *) 7 | (* exception. *) 8 | (* *) 9 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 10 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 11 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 12 | (* License for more details. *) 13 | (* *) 14 | (**************************************************************************) 15 | 16 | (** Toggles parsing of the tool's output to detect errors 17 | (curl returns 0 on a 404) *) 18 | type dl_tool_kind = [ `Curl | `Default ] 19 | 20 | type t = { 21 | download_tool: (OpamTypes.arg list * dl_tool_kind) Lazy.t; 22 | retries: int; 23 | force_checksums: bool option; 24 | } 25 | 26 | type 'a options_fun = 27 | ?download_tool:(OpamTypes.arg list * dl_tool_kind) Lazy.t -> 28 | ?retries:int -> 29 | ?force_checksums:bool option -> 30 | 'a 31 | 32 | include OpamStd.Config.Sig 33 | with type t := t 34 | and type 'a options_fun := 'a options_fun 35 | -------------------------------------------------------------------------------- /src/core/opamCompat.mli.4.01: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2014 OCamlPro *) 4 | (* *) 5 | (* All rights reserved.This file is distributed under the terms of the *) 6 | (* GNU Lesser General Public License version 3.0 with linking *) 7 | (* exception. *) 8 | (* *) 9 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 10 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 11 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 12 | (* License for more details. *) 13 | (* *) 14 | (**************************************************************************) 15 | 16 | module Bytes : sig 17 | include module type of String 18 | val empty : t 19 | val of_string : string -> t 20 | val to_string : t -> string 21 | val sub_string : t -> int -> int -> string 22 | val blit_string : string -> int -> t -> int -> int -> unit 23 | external unsafe_to_string : t -> string = "%identity" 24 | external unsafe_of_string : string -> t = "%identity" 25 | end 26 | 27 | module Buffer : sig 28 | include module type of Buffer with type t = Buffer.t 29 | val add_subbytes : t -> Bytes.t -> int -> int -> unit 30 | end 31 | 32 | module Filename : sig 33 | include module type of Filename 34 | val get_temp_dir_name : unit -> string 35 | end 36 | -------------------------------------------------------------------------------- /src/repository/opamDownload.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2012-2015 OCamlPro *) 4 | (* Copyright 2012 INRIA *) 5 | (* *) 6 | (* All rights reserved.This file is distributed under the terms of the *) 7 | (* GNU Lesser General Public License version 3.0 with linking *) 8 | (* exception. *) 9 | (* *) 10 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 11 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 12 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 13 | (* License for more details. *) 14 | (* *) 15 | (**************************************************************************) 16 | 17 | (** downloads a file from an URL, using Curl, Wget, or a custom configured 18 | tool, to the given directory. Returns the downloaded filename. 19 | FIXME: The source OpamFilename.t is indeed a URL. *) 20 | val download: 21 | overwrite:bool -> ?compress:bool -> ?checksum:string -> 22 | OpamFilename.t -> OpamFilename.Dir.t -> 23 | OpamFilename.t OpamProcess.job 24 | 25 | (** As [download], but with a specified output filename. *) 26 | val download_as: 27 | overwrite:bool -> ?compress:bool -> ?checksum:string -> 28 | OpamFilename.t -> OpamFilename.t -> 29 | unit OpamProcess.job 30 | -------------------------------------------------------------------------------- /src/client/opamPinCommand.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2012-2015 OCamlPro *) 4 | (* Copyright 2012 INRIA *) 5 | (* *) 6 | (* All rights reserved.This file is distributed under the terms of the *) 7 | (* GNU Lesser General Public License version 3.0 with linking *) 8 | (* exception. *) 9 | (* *) 10 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 11 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 12 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 13 | (* License for more details. *) 14 | (* *) 15 | (**************************************************************************) 16 | 17 | (** Pin subcommand. *) 18 | 19 | open OpamTypes 20 | 21 | (** Pin a package. Returns [Some is_same_version] if the package should be 22 | reinstalled (or upgraded if [is_same_version] is false) *) 23 | val pin: name -> ?version:version -> pin_option -> bool option 24 | 25 | (** Let the user edit a pinned package's opam file. 26 | Returns [Some is_same_version] if the package should be rebuilt. 27 | raises [Not_found] if no valid opam file is available and the user didn't 28 | succeed in producing one. *) 29 | val edit: OpamState.state -> name -> bool option 30 | 31 | (** Unpin packages. Returns the list of packages that should be rebuilt *) 32 | val unpin: ?state:OpamState.state -> name list -> name list 33 | 34 | (** List the pinned packages. *) 35 | val list: short:bool -> unit -> unit 36 | -------------------------------------------------------------------------------- /admin-scripts/cudf-debug.ml: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env opam-admin.top 2 | 3 | #directory "+../cudf";; 4 | #directory "+../dose3";; 5 | #directory "+../opam-lib";; 6 | open Opam_admin_top;; 7 | 8 | let cudf2opam_name cpkg = 9 | OpamPackage.Name.of_string 10 | (try Cudf.lookup_package_property cpkg OpamCudf.s_source 11 | with Not_found -> Common.CudfAdd.decode cpkg.Cudf.package) 12 | 13 | let cudf2opam_version cpkg = 14 | OpamPackage.Version.of_string 15 | (try Cudf.lookup_package_property cpkg OpamCudf.s_source_number 16 | with Not_found -> Printf.sprintf "#cudf%d" cpkg.Cudf.version) 17 | 18 | let cudf_pp cpkg = 19 | OpamPackage.Name.to_string (cudf2opam_name cpkg), 20 | OpamPackage.Version.to_string (cudf2opam_version cpkg), 21 | [] 22 | 23 | let rebuild_version_map univ = 24 | Cudf.fold_packages (fun acc cpkg -> 25 | let nv = 26 | OpamPackage.create (cudf2opam_name cpkg) (cudf2opam_version cpkg) 27 | in 28 | OpamPackage.Map.add nv cpkg.Cudf.version acc 29 | ) 30 | OpamPackage.Map.empty univ 31 | 32 | let _ = 33 | match Cudf_parser.load_from_file Sys.argv.(1) with 34 | | Some preamble, univ, Some req -> 35 | begin match Algo.Depsolver.check_request ~explain:true (preamble, univ, req) with 36 | | Algo.Depsolver.Unsat (Some f) -> 37 | OpamConsole.msg "== DOSE MESSAGE ==\n"; 38 | flush stdout; 39 | Algo.Diagnostic.fprintf_human 40 | ~pp:cudf_pp 41 | Format.err_formatter 42 | f; 43 | flush stderr; 44 | let version_map = rebuild_version_map univ in 45 | begin match OpamCudf.make_conflicts ~version_map univ f with 46 | | OpamTypes.Conflicts cs -> 47 | OpamConsole.msg "== OPAM MESSAGE ==\n%s\n" 48 | (OpamCudf.string_of_conflict (fun a -> Printf.sprintf "%s unavailable" (OpamFormula.string_of_atom a)) cs) 49 | | _ -> prerr_endline "unhandled case" 50 | end 51 | | _ -> () 52 | end 53 | | _ -> OpamConsole.error_and_exit "unsupported cudf file" 54 | -------------------------------------------------------------------------------- /doc/dev-manual/dev-manual.css: -------------------------------------------------------------------------------- 1 | /* ==== general presentation ==== */ 2 | body { 3 | padding: 0.4em 16% 3em 8%; 4 | } 5 | h1, h1 a, 6 | h2, h2 a, 7 | h3, h3 a { 8 | padding: 0 0 0 0.4em; 9 | } 10 | .titlemain, 11 | .titlerest { 12 | padding: 0.2em 3.8em; 13 | } 14 | pre { 15 | padding: 0.2em 0.4em; 16 | margin: 0.4em 0.6em; 17 | } 18 | p { 19 | padding: 0 0 0 0.8em; 20 | } 21 | dt { 22 | padding: 0 0 0 0.6em; 23 | } 24 | h1 { font-size: 1.6em; } 25 | h2 { font-size: 1.4em; } 26 | h3 { font-size: 1.2em; } 27 | h1 a { font-size: 1.0em; } 28 | h2 a { font-size: 1.0em; } 29 | h3 a { font-size: 1.0em; } 30 | a { 31 | text-decoration: none; 32 | } 33 | a:hover { 34 | text-decoration: underline; 35 | } 36 | 37 | /* ==== morning colors ==== */ 38 | body { 39 | color: #333; 40 | background-color: #F0F0F0; 41 | } 42 | pre { 43 | color: #224; 44 | background: #DDE; 45 | border: 1px solid #8AC; 46 | } 47 | h1, h1 a, 48 | h2, h2 a, 49 | h3, h3 a { 50 | color: #228; 51 | background: #CDF; 52 | } 53 | a { 54 | color: #08C; 55 | } 56 | a:hover { 57 | color: #06E; 58 | background: #DEF; 59 | } 60 | 61 | /* ==== evening colors ==== *\ 62 | body { 63 | color: #CCC; 64 | background-color: #226; 65 | } 66 | pre { 67 | color: #BDF; 68 | background: #447; 69 | border: 1px solid #46A; 70 | } 71 | h1, h1 a, 72 | h2, h2 a, 73 | h3, h3 a { 74 | color: #CCC; 75 | background: #359; 76 | } 77 | a { 78 | color: #6CF; 79 | } 80 | a:hover { 81 | color: #9EF; 82 | background: #448; 83 | } 84 | */ 85 | 86 | /* ==== sunny colors ==== *\ 87 | body { 88 | color: #333; 89 | background-color: #ffcd95; 90 | } 91 | pre { 92 | color: #422; 93 | background: #fdb50b; 94 | border: 1px solid #832809; 95 | } 96 | h1, h1 a, 97 | h2, h2 a, 98 | h3, h3 a { 99 | color: #672910; 100 | background: #ff9a0a; 101 | } 102 | a { 103 | color: #b94a48; 104 | } 105 | a:hover { 106 | color: #91310b; 107 | background: #fccb0d; 108 | } 109 | */ 110 | -------------------------------------------------------------------------------- /src/core/opamVersion.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2012-2015 OCamlPro *) 4 | (* Copyright 2012 INRIA *) 5 | (* *) 6 | (* All rights reserved.This file is distributed under the terms of the *) 7 | (* GNU Lesser General Public License version 3.0 with linking *) 8 | (* exception. *) 9 | (* *) 10 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 11 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 12 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 13 | (* License for more details. *) 14 | (* *) 15 | (**************************************************************************) 16 | 17 | (** OPAM versions *) 18 | 19 | include OpamStd.ABSTRACT 20 | 21 | (** The current OPAM version *) 22 | val current: t 23 | 24 | (** Extracts the major version *) 25 | val major: t -> t 26 | 27 | (** Major+minor version, strips the patch version *) 28 | val nopatch: t -> t 29 | 30 | (** The current OPAM version, truncated (only MAJOR.MINOR) *) 31 | val current_nopatch: t 32 | 33 | (** The 'git' version of OPAM *) 34 | val git: unit -> t option 35 | 36 | (** Side-effect to set the git version later in the build *) 37 | val set_git: string -> unit 38 | 39 | (** The full version (current + git) *) 40 | val full: unit -> t 41 | 42 | (** Magic string, always of length 8 *) 43 | val magic: unit -> string 44 | 45 | (** Display the version message *) 46 | val message: unit -> unit 47 | 48 | (** Version comparison *) 49 | val compare: t -> t -> int 50 | -------------------------------------------------------------------------------- /admin-scripts/lint.ml: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env opam-admin.top 2 | 3 | #directory "+../opam-lib";; 4 | open Opam_admin_top;; 5 | 6 | let includes = ref [] 7 | let excludes = ref [] 8 | let short = ref false 9 | let list = ref false 10 | 11 | let usage = 12 | "Arguments:\n\ 13 | \ -s\tshort format, don't print explanations\n\ 14 | \ -l\tlist format, only print package names\n\ 15 | \ [N]\tshow only the listed warnings\n\ 16 | \ -[N]\tskip any packages that trigger any of these warnings\n\ 17 | " 18 | 19 | let () = 20 | let args = match Array.to_list Sys.argv with 21 | | _::args -> args 22 | | [] -> [] 23 | in 24 | List.iter (function 25 | | "-s" -> short := true 26 | | "-l" -> list := true 27 | | a -> 28 | try 29 | if String.length a > 0 && a.[0] = '-' then 30 | excludes := 0 - int_of_string a :: !excludes 31 | else 32 | includes := int_of_string a :: !includes 33 | with Failure _ -> 34 | OpamConsole.msg "%s" usage; 35 | OpamStd.Sys.exit 2) 36 | args 37 | 38 | let () = 39 | let quiet = !short || !list in 40 | iter_packages ~quiet ~opam:(fun nv opam -> 41 | let w = OpamFile.OPAM.validate opam in 42 | if List.exists (fun (n,_,_) -> List.mem n !excludes) w then opam else 43 | let w = 44 | if !includes = [] then w 45 | else List.filter (fun (n,_,_) -> List.mem n !includes) w 46 | in 47 | if w <> [] then 48 | if !list then 49 | print_endline (OpamPackage.to_string nv) 50 | else if !short then 51 | OpamConsole.msg "%s %s\n" (OpamPackage.to_string nv) 52 | (OpamStd.List.concat_map " " (fun (n,k,_) -> 53 | OpamConsole.colorise 54 | (match k with `Warning -> `yellow | `Error -> `red) 55 | (string_of_int n)) 56 | w) 57 | else 58 | OpamConsole.msg "\r\027[KIn %s:\n%s\n" 59 | (OpamPackage.to_string nv) 60 | (OpamFile.OPAM.warns_to_string w); 61 | opam 62 | ) () 63 | -------------------------------------------------------------------------------- /src/solver/opamSolverConfig.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2015 OCamlPro *) 4 | (* *) 5 | (* All rights reserved.This file is distributed under the terms of the *) 6 | (* GNU Lesser General Public License version 3.0 with linking *) 7 | (* exception. *) 8 | (* *) 9 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 10 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 11 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 12 | (* License for more details. *) 13 | (* *) 14 | (**************************************************************************) 15 | 16 | type t = private { 17 | cudf_file: string option; 18 | solver_timeout: float; 19 | external_solver: OpamTypes.arg list option Lazy.t; 20 | solver_preferences_default: string Lazy.t option; 21 | solver_preferences_upgrade: string Lazy.t option; 22 | solver_preferences_fixup: string Lazy.t option; 23 | } 24 | 25 | type 'a options_fun = 26 | ?cudf_file:string option -> 27 | ?solver_timeout:float -> 28 | ?external_solver:OpamTypes.arg list option Lazy.t -> 29 | ?solver_preferences_default:string Lazy.t option -> 30 | ?solver_preferences_upgrade:string Lazy.t option -> 31 | ?solver_preferences_fixup:string Lazy.t option -> 32 | 'a 33 | 34 | include OpamStd.Config.Sig 35 | with type t := t 36 | and type 'a options_fun := 'a options_fun 37 | 38 | val external_solver_command: 39 | input:string -> output:string -> criteria:string -> string list option 40 | 41 | val criteria: OpamTypes.solver_criteria -> string 42 | -------------------------------------------------------------------------------- /src/tools/opam_admin_top.mli: -------------------------------------------------------------------------------- 1 | (** Small lib for writing opam-repo admin scripts *) 2 | 3 | (** The current repo (taken from CWD !) *) 4 | val repo : OpamTypes.repository 5 | 6 | (** All defined packages in the current repo *) 7 | val packages : OpamPackage.Set.t 8 | 9 | (** All defined compilers in the current repo *) 10 | val compilers : OpamCompiler.Set.t 11 | 12 | open OpamFile 13 | 14 | type 'a action = [`Update of 'a | `Remove | `Keep ] 15 | 16 | (** Maps on the files of every package. Only changed files are written back to 17 | disk. *) 18 | val iter_packages_gen: 19 | ?quiet:bool -> 20 | (OpamPackage.t -> 21 | prefix:string option -> 22 | opam:OPAM.t -> 23 | descr:Descr.t option -> 24 | url:URL.t option -> 25 | dot_install:Dot_install.t option -> 26 | OPAM.t * Descr.t action * URL.t action * Dot_install.t action) 27 | -> unit 28 | 29 | (** Turn a list of glob patterns into a proper filtering function on 30 | package names. *) 31 | val filter_packages: string list -> (OpamPackage.t -> bool) 32 | 33 | (** Quicker interface when considering a single type of file *) 34 | val iter_packages: 35 | ?quiet:bool -> 36 | ?filter:(OpamPackage.t -> bool) -> 37 | ?f:(OpamPackage.t -> string option -> OPAM.t -> unit) -> 38 | ?opam:(OpamPackage.t -> OPAM.t -> OPAM.t) -> 39 | ?descr:(OpamPackage.t -> Descr.t -> Descr.t) -> 40 | ?url:(OpamPackage.t -> URL.t -> URL.t) -> 41 | ?dot_install:(OpamPackage.t -> Dot_install.t -> Dot_install.t) -> 42 | unit -> unit 43 | 44 | (** Similarly for compiler descriptions *) 45 | val iter_compilers_gen: 46 | ?quiet:bool -> 47 | (OpamCompiler.t -> 48 | prefix:string option -> 49 | comp:Comp.t -> 50 | descr:Descr.t option -> 51 | Comp.t * Descr.t action) 52 | -> unit 53 | 54 | (** Turn a list of glob patterns into a proper filtering function on 55 | compiler names. *) 56 | val filter_compilers: string list -> (OpamCompiler.t -> bool) 57 | 58 | val iter_compilers: 59 | ?quiet:bool -> 60 | ?filter:(OpamCompiler.t -> bool) -> 61 | ?f:(OpamCompiler.t -> string option -> Comp.t -> unit) -> 62 | ?comp:(OpamCompiler.t -> Comp.t -> Comp.t) -> 63 | ?descr:(OpamCompiler.t -> Descr.t -> Descr.t) -> 64 | unit -> unit 65 | -------------------------------------------------------------------------------- /src/format/opamCompiler.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2012-2015 OCamlPro *) 4 | (* Copyright 2012 INRIA *) 5 | (* *) 6 | (* All rights reserved.This file is distributed under the terms of the *) 7 | (* GNU Lesser General Public License version 3.0 with linking *) 8 | (* exception. *) 9 | (* *) 10 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 11 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 12 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 13 | (* License for more details. *) 14 | (* *) 15 | (**************************************************************************) 16 | 17 | (** Compiler names and versions *) 18 | 19 | (** OCaml compiler versions *) 20 | module Version: sig 21 | 22 | include OpamStd.ABSTRACT 23 | 24 | (** Compiler constraint *) 25 | type constr = (OpamFormula.relop * t) OpamFormula.formula 26 | 27 | (** Compare OCaml versions *) 28 | val compare: t -> t -> int 29 | 30 | (** Evaluate a relational operator between OCaml versions *) 31 | val eval_relop: OpamFormula.relop -> t -> t -> bool 32 | end 33 | 34 | (** Compiler names *) 35 | include OpamStd.ABSTRACT 36 | 37 | (** Return the compiler version *) 38 | val version: t -> Version.t 39 | 40 | (** Convert a filename into a compiler name. This function extract 41 | [name] from {i /path/to/$name.comp}. *) 42 | val of_filename: OpamFilename.t -> t option 43 | 44 | (** List the compiler available in the global state. *) 45 | val list: OpamFilename.Dir.t -> Set.t 46 | 47 | (** List the compiler available in a directory (and their prefix) *) 48 | val prefixes: OpamFilename.Dir.t -> string option Map.t 49 | 50 | (** System compiler *) 51 | val system: t 52 | -------------------------------------------------------------------------------- /src/format/opamFormatConfig.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2015 OCamlPro *) 4 | (* *) 5 | (* All rights reserved.This file is distributed under the terms of the *) 6 | (* GNU Lesser General Public License version 3.0 with linking *) 7 | (* exception. *) 8 | (* *) 9 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 10 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 11 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 12 | (* License for more details. *) 13 | (* *) 14 | (**************************************************************************) 15 | 16 | type t = { 17 | strict: bool; 18 | skip_version_checks: bool; 19 | all_parens: bool; 20 | } 21 | 22 | type 'a options_fun = 23 | ?strict:bool -> 24 | ?skip_version_checks:bool -> 25 | ?all_parens:bool -> 26 | 'a 27 | 28 | let default = { 29 | strict = false; 30 | skip_version_checks = false; 31 | all_parens = false; 32 | } 33 | 34 | let setk k t 35 | ?strict 36 | ?skip_version_checks 37 | ?all_parens 38 | = 39 | let (+) x opt = match opt with Some x -> x | None -> x in 40 | k { 41 | strict = t.strict + strict; 42 | skip_version_checks = t.skip_version_checks + skip_version_checks; 43 | all_parens = t.all_parens + all_parens; 44 | } 45 | 46 | let set t = setk (fun x () -> x) t 47 | 48 | (* Global configuration reference *) 49 | 50 | let r = ref default 51 | 52 | let update ?noop:_ = setk (fun cfg () -> r := cfg) !r 53 | 54 | let initk k = 55 | let open OpamStd.Config in 56 | setk (setk (fun c -> r := c; k)) !r 57 | ?strict:(env_bool "STRICT") 58 | ?skip_version_checks:(env_bool "SKIPVERSIONCHECKS") 59 | ?all_parens:(env_bool "ALLPARENS") 60 | 61 | let init ?noop:_ = initk (fun () -> ()) 62 | -------------------------------------------------------------------------------- /doc/pages/About.md: -------------------------------------------------------------------------------- 1 | # OPAM 2 | 3 | ### Why OPAM ? 4 | 5 | [OCamlPro](http://www.ocamlpro.com/) has decided to start writing a brand new package manager for [OCaml](http://www.ocaml.org) in the beginning of 2012, after looking at the state of affairs in the OCaml community and not being completely satisfied with the existing solutions, especially regarding the management of dependency constraints between packages. Existing technologies such as [GODI](http://godi.camlcity.org/), [oasis](http://oasis.forge.ocamlcore.org/), [odb](http://oasis.ocamlcore.org/dev/odb/) and [ocamlbrew](https://github.com/hcarty/ocamlbrew) did contain lots of good ideas that have been shamelessly stolen but the final user-experience was not so great -- and due to disagreements with some of the architectural choices done in these tools, so it wasn't so easy to contribute to fix the existing flaws. Thus OCamlPro started to discuss the specification of a new package manager with folks from [Jane Street](http://www.janestreet.com/) who decided to fund the project and from the [Mancoosi project](http://www.mancoosi.org/) to integrate state-of-the-art dependency management technologies. 6 | 7 | After few months of hard-work, and continuous support and resources from [OCamlLabs](http://www.cl.cam.ac.uk/projects/ocamllabs/) and [INRIA](http://www.inria.fr/) (through funding by the [Feder DORM](http://zenika.github.io/DORM/) project), this effort finally gave birth to the [first official release](http://www.ocamlpro.com/blog/2013/03/14/opam-1.0.0.html) of OPAM in March 2013. 8 | 9 | ### Getting Support 10 | 11 | OPAM has been created and is maintained by [OCamlPro](http://www.ocamlpro.com/). Bug reports and feature requests for the OPAM tool should be reported on [OPAM's issue-tracker](https://github.com/ocaml/opam/issues). Packaging issues or requests for a new package can be reported on the [official repository's issue-tracker](https://github.com/ocaml/opam-repository/issues). 12 | 13 | General queries for both the tool and the packages could be addressed on the [OCaml-platform mailing-list](http://lists.ocaml.org/listinfo/platform) and insights and evolution of OPAM internals can discussed on the [OPAM-devel mailing-list](http://lists.ocaml.org/listinfo/opam-devel). 14 | 15 | Standard commercial terms and support on OPAM, as well as training and consulting services, are provided by [OCamlPro](http://www.ocamlpro.com/). 16 | -------------------------------------------------------------------------------- /src/format/opamLineLexer.mll: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2012-2015 OCamlPro *) 4 | (* Copyright 2012 INRIA *) 5 | (* *) 6 | (* All rights reserved.This file is distributed under the terms of the *) 7 | (* GNU Lesser General Public License version 3.0 with linking *) 8 | (* exception. *) 9 | (* *) 10 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 11 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 12 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 13 | (* License for more details. *) 14 | (* *) 15 | (**************************************************************************) 16 | 17 | { 18 | 19 | type token = 20 | | WORD of string 21 | | NEWLINE 22 | | EOF 23 | 24 | let word = Buffer.create 57 25 | 26 | } 27 | 28 | let normalchar = [^' ' '\t' '\n' '\\'] 29 | 30 | rule main = parse 31 | | '\n' { Lexing.new_line lexbuf; NEWLINE } 32 | | [' ' '\t']+ { main lexbuf } 33 | | (normalchar* as w) '\\' 34 | { Buffer.reset word ; Buffer.add_string word w; escaped lexbuf } 35 | | (normalchar* as w) 36 | { WORD w } 37 | | eof { EOF } 38 | 39 | and escaped = parse 40 | | (_ normalchar*) as w '\\' 41 | { Buffer.add_string word w; escaped lexbuf } 42 | | (_ normalchar*) as w 43 | { Buffer.add_string word w; WORD (Buffer.contents word) } 44 | 45 | { 46 | 47 | let main lexbuf = 48 | let rec aux lines words = 49 | match main lexbuf with 50 | | WORD "" -> aux lines words 51 | | WORD s -> aux lines (s::words) 52 | | NEWLINE -> 53 | let lines = if words = [] then lines else List.rev words::lines in 54 | aux lines [] 55 | | EOF -> 56 | let lines = if words = [] then lines else List.rev words::lines in 57 | List.rev lines 58 | in 59 | aux [] [] 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/core/opamVersionCompare.mli: -------------------------------------------------------------------------------- 1 | (******************************************************************************) 2 | (* This file is part of the Dose library http://www.irill.org/software/dose *) 3 | (* *) 4 | (* Copyright (C) 2009-2011 Pietro Abate *) 5 | (* *) 6 | (* This library is free software: you can redistribute it and/or modify *) 7 | (* it under the terms of the GNU Lesser General Public License as *) 8 | (* published by the Free Software Foundation, either version 3 of the *) 9 | (* License, or (at your option) any later version. A special linking *) 10 | (* exception to the GNU Lesser General Public License applies to this *) 11 | (* library, see the COPYING file for more information. *) 12 | (* *) 13 | (* Work developed with the support of the Mancoosi Project *) 14 | (* http://www.mancoosi.org *) 15 | (* *) 16 | (******************************************************************************) 17 | 18 | 19 | (** Functions for manipulating and comparing Debian version strings. 20 | Compliant with Debian policy version 3.9.2. and Debian developers 21 | reference version 3.4.6 *) 22 | 23 | (** {2 Comparing debian version strings} *) 24 | 25 | (** The following functions compare any two strings, that is these 26 | functions do not check whether the arguments are really legal 27 | debian versions. If the arguments are debian version strings, then 28 | the result is as required by debian policy. Note that two strings 29 | may be equivalent, that is denote the same debian version, even 30 | when they differ in syntax, as for instance "0:1.2.00" and 31 | "1.02-0". 32 | *) 33 | 34 | (** @return [true] iff the two strings define the same version. Hence, 35 | the result may be true even when the two string differ 36 | syntactically. *) 37 | val equal : string -> string -> bool 38 | 39 | (** [compare x y] returns 0 if x is eqivalent to y, -1 if x is smaller 40 | than y, and 1 if x is greater than y. This is consistent with 41 | [Pervasives.compare]. *) 42 | val compare : string -> string -> int 43 | -------------------------------------------------------------------------------- /src/format/opamVariable.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2012-2015 OCamlPro *) 4 | (* Copyright 2012 INRIA *) 5 | (* *) 6 | (* All rights reserved.This file is distributed under the terms of the *) 7 | (* GNU Lesser General Public License version 3.0 with linking *) 8 | (* exception. *) 9 | (* *) 10 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 11 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 12 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 13 | (* License for more details. *) 14 | (* *) 15 | (**************************************************************************) 16 | 17 | (** {2 Variable names} *) 18 | 19 | include OpamStd.ABSTRACT 20 | 21 | (** Shortcut to variables *) 22 | type variable = t 23 | 24 | (** Variable contents *) 25 | type variable_contents = 26 | | B of bool 27 | | S of string 28 | 29 | (** Pretty print of variable contents *) 30 | val string_of_variable_contents: variable_contents -> string 31 | 32 | 33 | module Full: sig 34 | 35 | (** Fully qualified variable. *) 36 | 37 | include OpamStd.ABSTRACT 38 | 39 | type scope = 40 | | Global (** Note: this is attributed to unqualified variables, and may 41 | also design self-referring ones *) 42 | | Self (** Variable in a package-specific file referring to that 43 | package [_:varname] *) 44 | | Package of OpamPackage.Name.t (** [pkgname:varname] *) 45 | 46 | (** Returns the scope of the variable *) 47 | val scope: t -> scope 48 | 49 | (** Returns the unqualified variable name *) 50 | val variable: t -> variable 51 | 52 | val is_global: t -> bool 53 | 54 | (** Return the package corresponding to the scope of the variable *) 55 | val package: ?self:OpamPackage.Name.t -> t -> OpamPackage.Name.t option 56 | 57 | (** Create a variable local for a given library/syntax extension *) 58 | val create: OpamPackage.Name.t -> variable -> t 59 | 60 | (** Create a global variable *) 61 | val global: variable -> t 62 | 63 | end 64 | -------------------------------------------------------------------------------- /src/client/opamConfigCommand.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2012-2015 OCamlPro *) 4 | (* Copyright 2012 INRIA *) 5 | (* *) 6 | (* All rights reserved.This file is distributed under the terms of the *) 7 | (* GNU Lesser General Public License version 3.0 with linking *) 8 | (* exception. *) 9 | (* *) 10 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 11 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 12 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 13 | (* License for more details. *) 14 | (* *) 15 | (**************************************************************************) 16 | 17 | (** Configuration commands *) 18 | 19 | open OpamTypes 20 | 21 | (** Display the current environment. Booleans csh, sexp and fish set an alternative 22 | output (unspecified if more than one is true, sh-style by default). 23 | [inplace_path] changes how the PATH variable is updated when there is already 24 | an opam entry: either at the same rank, or pushed in front. *) 25 | val env: csh:bool -> sexp:bool -> fish:bool -> inplace_path:bool -> unit 26 | 27 | (** Display the content of all available variables; global summary if the list 28 | is empty, package name "-" is understood as global configuration *) 29 | val list: name list -> unit 30 | 31 | (** Display the content of a given variable *) 32 | val variable: full_variable -> unit 33 | 34 | (** Substitute files *) 35 | val subst: basename list -> unit 36 | 37 | (** Prints expansion of variables in string *) 38 | val expand: string -> unit 39 | 40 | (** Sets or unsets switch config variables *) 41 | val set: full_variable -> string option -> unit 42 | 43 | (** Update the global and user configuration to use OPAM. *) 44 | val setup: user_config option -> global_config option -> unit 45 | 46 | (** Display the global and user configuration for OPAM. *) 47 | val setup_list: shell -> filename -> unit 48 | 49 | (** Execute a command in a subshell, after variable expansion *) 50 | val exec: inplace_path:bool -> string list -> unit 51 | -------------------------------------------------------------------------------- /src/repository/opamVCS.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2012-2015 OCamlPro *) 4 | (* Copyright 2012 INRIA *) 5 | (* *) 6 | (* All rights reserved.This file is distributed under the terms of the *) 7 | (* GNU Lesser General Public License version 3.0 with linking *) 8 | (* exception. *) 9 | (* *) 10 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 11 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 12 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 13 | (* License for more details. *) 14 | (* *) 15 | (**************************************************************************) 16 | 17 | (** Generic backend for version-control systems. *) 18 | 19 | open OpamTypes 20 | 21 | (** Each backend should implement this signature. *) 22 | module type VCS = sig 23 | 24 | val name: repository_kind 25 | 26 | (** Test whether the given repository is correctly initialized. *) 27 | val exists: repository -> bool 28 | 29 | (** Init a repository. *) 30 | val init: repository -> unit OpamProcess.job 31 | 32 | (** Fetch changes from upstream. This is supposed to put the changes 33 | in a staging area. 34 | Be aware that the remote URL might have been changed, so make sure 35 | to update accordingly. *) 36 | val fetch: repository -> unit OpamProcess.job 37 | 38 | (** Reset the master branch of the repository to match the remote 39 | repository state. *) 40 | val reset: repository -> unit OpamProcess.job 41 | 42 | (** Check whether the staging area is empty. Returns true if not (eg. there is 43 | an update pending) *) 44 | val diff: repository -> bool OpamProcess.job 45 | 46 | (** Return the HEAD revision. *) 47 | val revision: repository -> string OpamProcess.job 48 | 49 | (** Returns the list of files under version control *) 50 | val versionned_files: repository -> string list OpamProcess.job 51 | 52 | (** Returns the absolute directory name for vc data (e.g. 53 | [.../project/.git]) *) 54 | val vc_dir: repository -> dirname 55 | end 56 | 57 | (** Create a backend from a [VCS] implementation. *) 58 | module Make(VCS: VCS): OpamRepositoryBackend.S 59 | -------------------------------------------------------------------------------- /src/tools/opam_admin.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2012-2015 OCamlPro *) 4 | (* Copyright 2012 INRIA *) 5 | (* *) 6 | (* All rights reserved.This file is distributed under the terms of the *) 7 | (* GNU Lesser General Public License version 3.0 with linking *) 8 | (* exception. *) 9 | (* *) 10 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 11 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 12 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 13 | (* License for more details. *) 14 | (* *) 15 | (**************************************************************************) 16 | 17 | open Cmdliner 18 | 19 | let default_cmd = 20 | let doc = "Administration tool for local repositories." in 21 | Term.(ret (pure (`Help (`Pager, None)))), 22 | Term.info "opam-admin" ~version:OpamVersion.(to_string current) ~doc 23 | 24 | let make_repo_cmd = 25 | let doc = "Initialize a repo for serving files." in 26 | Term.(Opam_mk_repo.(pure process $ args)), 27 | Term.info "make" ~doc 28 | 29 | let check_repo_cmd = 30 | let doc = "Check a local repo for errors." in 31 | Term.(Opam_repo_check.(pure process $ args)), 32 | Term.info "check" ~doc 33 | 34 | let stats_cmd = 35 | let doc = "Compute statistics." in 36 | Term.(Opam_stats.(pure process $ pure ())), 37 | Term.info "stats" ~doc 38 | 39 | let depexts_cmd = 40 | let doc = "Add external dependencies." in 41 | Term.(Opam_depexts_change.(pure process $ args)), 42 | Term.info "depexts" ~doc 43 | (* 44 | let findlib_cmd = 45 | let doc = "Add findlib information." in 46 | Term.(Opam_findlib.(pure process $ args)), 47 | Term.info "findlib" ~doc 48 | *) 49 | let rename_cmd = 50 | let doc = "Rename a package." in 51 | Term.(Opam_rename.(pure process $ args)), 52 | Term.info "rename" ~doc 53 | 54 | let () = 55 | OpamSystem.init (); 56 | try 57 | match 58 | Term.eval_choice ~catch:false 59 | default_cmd [ 60 | make_repo_cmd; check_repo_cmd; stats_cmd; 61 | depexts_cmd; (*findlib_cmd;*) rename_cmd; 62 | ] 63 | with 64 | | `Error _ -> exit 2 65 | | _ -> exit 0 66 | with 67 | | OpamStd.Sys.Exit i -> exit i 68 | -------------------------------------------------------------------------------- /doc/pages/Tricks.md: -------------------------------------------------------------------------------- 1 | > The following are beyond the scope of the [FAQ](FAQ.html), but have been found 2 | > useful for specific use-cases or for advanced users. 3 | 4 | #### Simulate actions from the current switch state (for debugging) 5 | 6 | - `opam upgrade --show-actions` (stop at the action summary dialog) 7 | - `opam upgrade --dry-run` (display only) 8 | - if you really want to try out the results: 9 | * `opam switch export testing-state.export` 10 | * `opam switch tmp-testing --alias-of system` 11 | * `opam switch import testing-state.export --fake` 12 | * try actions with `--fake` (registers them in OPAM, but doesn't actually 13 | run the build/install commands) 14 | * revert to normal: `opam switch ; opam switch remove tmp-testing` 15 | - Experiment with the solver: 16 | * `opam --cudf=cudf-file` 17 | * or `opam config cudf-universe >cudf-file-1.cudf` 18 | * run e.g. aspcud with `aspcud cudf-file-1.cudf /dev/stdout CRITERIA` 19 | * `admin-scripts/cudf-debug.ml cudf-file-1.cudf` may help with conflicts 20 | 21 | --- 22 | 23 | #### Install in all switches 24 | 25 | Not supported natively at the moment, but it's being considered. Quick hack: 26 | ``` 27 | for switch in $(opam switch list -s -i); do 28 | opam install --switch $switch PACKAGE 29 | done 30 | ``` 31 | You may want to add `--yes` if you're confident. 32 | 33 | --- 34 | 35 | #### Update OPAM environment within emacs 36 | 37 | You may use the following snippet to define an `opam-env` function: 38 | 39 | ```lisp 40 | (defun opam-env () 41 | (interactive nil) 42 | (dolist (var (car (read-from-string (shell-command-to-string "opam config env --sexp")))) 43 | (setenv (car var) (cadr var)))) 44 | ``` 45 | 46 | You may want to run this at emacs startup if it doesn't inherit the proper shell 47 | environment. 48 | 49 | --- 50 | 51 | #### Easily provide a set of packages for a group of users to install 52 | 53 | The easiest way is to create a package with your prerequisites as `depends` and 54 | have them pin that. A quick way to host the file is to use a 55 | [Gist](https://gist.github.com). Create one with minimal contents and listing 56 | your packages as dependencies -- the file name **has** to be `opam`: 57 | 58 | ``` 59 | opam-version: "1.2" 60 | name: "ocaml101" 61 | version: "0.1" 62 | maintainer: "Louis Gesbert " 63 | depends: [ "menhir" { = "20140422" } 64 | "merlin" { >= "2" } 65 | "ocp-indent" 66 | "ocp-index" ] 67 | ``` 68 | 69 | Save that and get the `HTTPS clone URL`. All that is needed then is to run: 70 | 71 | ```shell 72 | $ opam pin add ocaml101 73 | ``` 74 | 75 | Furthermore, `opam update` will then pick up any modification you made to the gist. 76 | -------------------------------------------------------------------------------- /src/client/opamSwitchCommand.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2012-2015 OCamlPro *) 4 | (* Copyright 2012 INRIA *) 5 | (* *) 6 | (* All rights reserved.This file is distributed under the terms of the *) 7 | (* GNU Lesser General Public License version 3.0 with linking *) 8 | (* exception. *) 9 | (* *) 10 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 11 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 12 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 13 | (* License for more details. *) 14 | (* *) 15 | (**************************************************************************) 16 | 17 | (** Switch commands. *) 18 | 19 | open OpamTypes 20 | 21 | (** Install a new switch. Returns a continuation that must be run to install the 22 | packages, but only needs a switch lock. *) 23 | val install_cont: 24 | quiet:bool -> warning:bool -> update_config:bool -> switch -> compiler -> 25 | switch * (unit -> unit) 26 | 27 | (** Like [install_cont] but runs the continuation already *) 28 | val install: 29 | quiet:bool -> warning:bool -> update_config:bool -> switch -> compiler -> unit 30 | 31 | (** Install a compiler's base packages *) 32 | val install_packages: switch -> compiler -> unit 33 | 34 | (** Import a file which contains the packages to install. *) 35 | val import: filename option -> unit 36 | 37 | (** Export a file which contains the installed packages. *) 38 | val export: filename option -> unit 39 | 40 | (** Remove the given compiler switch. *) 41 | val remove: switch -> unit 42 | 43 | (** Switch to the given compiler switch. Returns a continuation like [install] *) 44 | val switch_cont: 45 | ?compiler:compiler -> quiet:bool -> warning:bool -> switch -> 46 | switch * (unit -> unit) 47 | 48 | (** Like [switch_cont] but runs the continuation already. *) 49 | val switch: ?compiler:compiler -> quiet:bool -> warning:bool -> switch -> unit 50 | 51 | (** Reinstall the given compiler switch. *) 52 | val reinstall: switch -> unit 53 | 54 | (** Display the current compiler switch. *) 55 | val show: unit -> unit 56 | 57 | (** List all the available compiler switches. *) 58 | val list: print_short:bool -> installed:bool -> all:bool -> unit 59 | -------------------------------------------------------------------------------- /src/solver/opamActionGraph.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2014 OCamlPro *) 4 | (* Copyright 2012 INRIA *) 5 | (* *) 6 | (* All rights reserved.This file is distributed under the terms of the *) 7 | (* GNU Lesser General Public License version 3.0 with linking *) 8 | (* exception. *) 9 | (* *) 10 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 11 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 12 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 13 | (* License for more details. *) 14 | (* *) 15 | (**************************************************************************) 16 | 17 | open OpamTypes 18 | 19 | module type ACTION = sig 20 | type package 21 | module Pkg: GenericPackage with type t = package 22 | include OpamParallel.VERTEX with type t = package action 23 | val to_string: [< t ] -> string 24 | val to_aligned_strings: [< t ] list -> string list 25 | end 26 | 27 | module MakeAction (P: GenericPackage) : ACTION with type package = P.t and type t = P.t OpamTypes.action 28 | 29 | module type SIG = sig 30 | type package 31 | include OpamParallel.GRAPH with type V.t = package OpamTypes.action 32 | 33 | (** Reduces a graph of atomic or concrete actions (only removals, installs and 34 | builds) by turning removal+install to reinstalls or up/down-grades, best 35 | for display. Dependency ordering won't be as accurate though, as there is 36 | no proper ordering of (reinstall a, reinstall b) if b depends on a. The 37 | resulting graph contains at most one action per package name. 38 | 39 | There is no guarantee however that the resulting graph is acyclic. *) 40 | val reduce: t -> t 41 | 42 | (** Expand install actions, adding a build action preceding them. *) 43 | val explicit: t -> t 44 | end 45 | 46 | module Make (A: ACTION) : SIG with type package = A.package 47 | 48 | (** Some messages that may be used for displaying actions. Single utf8 chars if 49 | the corresponding option is set, otherwise words. *) 50 | val action_strings: 51 | ?utf8:bool -> 'a highlevel_action -> string 52 | 53 | (** Colorise string according to the action *) 54 | val action_color: 'a highlevel_action -> string -> string 55 | -------------------------------------------------------------------------------- /src/client/opamMain.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2012-2015 OCamlPro *) 4 | (* Copyright 2012 INRIA *) 5 | (* *) 6 | (* All rights reserved.This file is distributed under the terms of the *) 7 | (* GNU Lesser General Public License version 3.0 with linking *) 8 | (* exception. *) 9 | (* *) 10 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 11 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 12 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 13 | (* License for more details. *) 14 | (* *) 15 | (**************************************************************************) 16 | 17 | open Cmdliner 18 | 19 | (** {2 Commands} *) 20 | 21 | (** Type of commands *) 22 | type command = unit Term.t * Term.info 23 | 24 | (** [run default commdands at_exit] build a binary which takes 25 | [commands] as subcommand and [default] as default argument 26 | (ie. which will be executed when no subcommand is 27 | given). [at_exit] is executed before the program exits. *) 28 | val run:command -> command list -> unit 29 | 30 | (** The default list of commands *) 31 | val commands: command list 32 | 33 | (** opam *) 34 | val default: command 35 | 36 | (** opam init *) 37 | val init: command 38 | 39 | (** opam list *) 40 | val list: command 41 | 42 | (** opam show *) 43 | val show: command 44 | 45 | (** opam search *) 46 | val search: command 47 | 48 | (** opam install *) 49 | val install: command 50 | 51 | (** opam remove *) 52 | val remove: command 53 | 54 | (** opam reinstall *) 55 | val reinstall: command 56 | 57 | (** opam update *) 58 | val update: command 59 | 60 | (** opam upgrade *) 61 | val upgrade: command 62 | 63 | (** opam config *) 64 | val config: command 65 | 66 | (** opam repository *) 67 | val repository: command 68 | 69 | (** opam switch *) 70 | val switch: command 71 | 72 | (** opam pin *) 73 | val pin: ?unpin_only:bool -> unit -> command 74 | 75 | (** opam help *) 76 | val help: command 77 | 78 | (** Create an alias for an existing command. [options] can be used to 79 | add extra options after the original command in the doc. *) 80 | val make_command_alias: 81 | unit Term.t * Term.info -> ?options:string -> string -> unit Term.t * Term.info 82 | -------------------------------------------------------------------------------- /src/client/opamRepositoryCommand.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2012-2015 OCamlPro *) 4 | (* Copyright 2012 INRIA *) 5 | (* *) 6 | (* All rights reserved.This file is distributed under the terms of the *) 7 | (* GNU Lesser General Public License version 3.0 with linking *) 8 | (* exception. *) 9 | (* *) 10 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 11 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 12 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 13 | (* License for more details. *) 14 | (* *) 15 | (**************************************************************************) 16 | 17 | (** Repository sub-command functions. *) 18 | 19 | open OpamState.Types 20 | open OpamTypes 21 | 22 | (** Update the given repository from its upstream. Returns a concurrency-safe 23 | state update function *) 24 | val update: t -> repository -> 25 | (OpamState.state -> OpamState.state) OpamProcess.job 26 | 27 | (** Update the package index. *) 28 | val update_package_index: t -> t 29 | 30 | (** Update the compiler index. *) 31 | val update_compiler_index: t -> t 32 | 33 | (** Update the given dev packages. *) 34 | val update_dev_packages: t -> verbose:bool -> package_set -> package_set 35 | 36 | (** Fix the compiler descriptions and display the changes if [verbose] 37 | is set. *) 38 | val fix_compiler_descriptions: t -> verbose:bool -> compiler_set updates 39 | 40 | (** Fix the the package descriptions and display the changes if 41 | [verbose] is set. *) 42 | val fix_package_descriptions: t -> verbose:bool -> package_set updates 43 | 44 | (** Fix all the package and compiler descriptions. *) 45 | val fix_descriptions: ?save_cache:bool -> ?verbose:bool -> t -> unit 46 | 47 | (** List the available repositories. *) 48 | val list: short:bool -> unit 49 | 50 | (** Add a new repository. *) 51 | val add: repository_name -> repository_kind -> address -> priority:int option -> unit 52 | 53 | (** Remove a repository. *) 54 | val remove: repository_name -> unit 55 | 56 | (** Set a repository priority. *) 57 | val priority: repository_name -> priority:int -> unit 58 | 59 | (** Change the registered address of a repo *) 60 | val set_url: repository_name -> address -> unit 61 | -------------------------------------------------------------------------------- /src/repository/opamRepositoryBackend.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2015 OCamlPro *) 4 | (* *) 5 | (* All rights reserved.This file is distributed under the terms of the *) 6 | (* GNU Lesser General Public License version 3.0 with linking *) 7 | (* exception. *) 8 | (* *) 9 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 10 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 11 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 12 | (* License for more details. *) 13 | (* *) 14 | (**************************************************************************) 15 | 16 | open OpamTypes 17 | 18 | (** Backend signature *) 19 | module type S = sig 20 | 21 | val name: repository_kind 22 | 23 | (** [pull_url package local_dir checksum remote_url] pull the contents of 24 | [remote_url] into [local_dir]. Can return either a file or a 25 | directory. [checksum] is the optional expected checksum. *) 26 | val pull_url: package -> dirname -> string option -> address -> generic_file download OpamProcess.job 27 | 28 | (** [pull_repo] pull the contents of a repository. *) 29 | val pull_repo: repository -> unit OpamProcess.job 30 | 31 | (** [pull_archive repo archive] pull [archive] in the given 32 | repository. *) 33 | val pull_archive: repository -> filename -> filename download OpamProcess.job 34 | 35 | (** Return the (optional) revision of a given repository. Only useful 36 | for VCS backends. *) 37 | val revision: repository -> version option OpamProcess.job 38 | 39 | end 40 | 41 | (** Pretty-print *) 42 | val to_string: repository -> string 43 | val to_json: repository -> json 44 | 45 | (** Compare repositories *) 46 | val compare: repository -> repository -> int 47 | 48 | (** The address for the default OPAM repository (currently: 49 | https://opam.ocaml.org/) *) 50 | val default_address: address 51 | 52 | (** The default OPAM repository (named "default", upstream at 53 | [default_address]) *) 54 | val default: unit -> repository 55 | 56 | (** Create a local repository on a given path *) 57 | val local: dirname -> repository 58 | 59 | (** [check_digest file expected] check that the [file] digest is the 60 | one [expected]. *) 61 | val check_digest: filename -> string option -> bool 62 | -------------------------------------------------------------------------------- /src/repository/opamDarcs.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2012-2015 OCamlPro *) 4 | (* Copyright 2012 INRIA *) 5 | (* *) 6 | (* All rights reserved.This file is distributed under the terms of the *) 7 | (* GNU Lesser General Public License version 3.0 with linking *) 8 | (* exception. *) 9 | (* *) 10 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 11 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 12 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 13 | (* License for more details. *) 14 | (* *) 15 | (**************************************************************************) 16 | 17 | open OpamTypes 18 | open OpamFilename.Op 19 | open OpamProcess.Job.Op 20 | 21 | module Darcs = struct 22 | 23 | let name = `darcs 24 | 25 | let exists repo = 26 | OpamFilename.exists_dir (repo.repo_root / "_darcs") 27 | 28 | let darcs repo = 29 | let dir = OpamFilename.Dir.to_string repo.repo_root in 30 | fun ?verbose ?env args -> 31 | OpamSystem.make_command ~dir ?verbose ?env "darcs" args 32 | 33 | let init repo = 34 | OpamProcess.Job.of_list 35 | [ darcs repo [ "init" ]; 36 | darcs repo [ "get" ; fst repo.repo_address; "--lazy" ] ] 37 | @@+ function 38 | | None -> Done () 39 | | Some (_,err) -> OpamSystem.process_error err 40 | 41 | (* With darcs, it is apparently easier to compute a diff between 42 | remote and local, without fething at all. So we set fetch to be a 43 | no-op. *) 44 | let fetch _ = 45 | Done () 46 | 47 | (* Merge is actually a full pull *) 48 | let reset repo = 49 | darcs repo [ "pull"; fst repo.repo_address; "--all"; "--quiet" ] 50 | @@> fun r -> 51 | OpamSystem.raise_on_process_error r; 52 | Done () 53 | 54 | (* Difference between remote and local is a 'pull --dry-run' *) 55 | let diff repo = 56 | darcs repo [ "pull" ; fst repo.repo_address; "--dry-run" ; "--quiet" ] 57 | @@> fun r -> 58 | OpamSystem.raise_on_process_error r; 59 | Done (r.OpamProcess.r_stdout <> []) 60 | 61 | let revision _ = 62 | Done "" 63 | 64 | let versionned_files repo = 65 | darcs repo [ "show" ; "files" ] 66 | @@> fun r -> 67 | OpamSystem.raise_on_process_error r; 68 | Done r.OpamProcess.r_stdout 69 | 70 | let vc_dir repo = OpamFilename.Op.(repo.repo_root / "_darcs") 71 | 72 | end 73 | 74 | module B = OpamVCS.Make(Darcs) 75 | -------------------------------------------------------------------------------- /shell/opam_installer.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -ue 4 | 5 | # (c) Copyright Fabrice Le Fessant INRIA/OCamlPro 2013 6 | # (c) Copyright Louis Gesbert OCamlPro 2014-2015 7 | 8 | VERSION='1.2.2' 9 | 10 | default_ocaml=4.02.1 11 | 12 | usage() { 13 | cat <&2 36 | for s in "$@"; do echo $s; done 37 | exit 1 38 | } 39 | 40 | 41 | TMP=${TMPDIR:-/tmp} 42 | 43 | dlerror () { 44 | error "Couldn't download $url" \ 45 | "There may not yet be a binary release for your architecture or OS, sorry." 46 | } 47 | 48 | getopam() { 49 | opamfile=$2 50 | url=$1/$opamfile 51 | 52 | if which wget >/dev/null; then 53 | wget -q -O "$TMP/$opamfile" "$url" || dlerror 54 | else 55 | curl -s -L -o "$TMP/$opamfile" "$url" || dlerror 56 | fi 57 | } 58 | 59 | if [ $# -lt 1 ] || [ $# -gt 2 ] || [ "${1#-}" != "$1" ]; then 60 | echo "OPAM binary installer v. $VERSION" 61 | usage 62 | fi 63 | 64 | BINDIR=$1 65 | COMP=${2:-$default_ocaml} 66 | 67 | file="opam-$VERSION-$(uname -m || echo unknown)-$(uname -s || echo unknown)" 68 | 69 | echo Downloading OPAM... 70 | getopam "https://github.com/ocaml/opam/releases/download/$VERSION" $file 71 | 72 | mkdir -p "$BINDIR" 2>/dev/null || true 73 | if [ ! -w "$BINDIR" ]; then 74 | echo "You don't have write access to $BINDIR: sudo may ask for your password" 75 | if [ ! -d "$BINDIR" ]; then sudo mkdir -p "$BINDIR"; fi 76 | sudo install -g root -o root -m 755 $TMP/$file $BINDIR/opam 77 | else 78 | install -m 755 $TMP/$file $BINDIR/opam 79 | fi 80 | rm -f $TMP/$file 81 | 82 | OPAM=$(which opam || echo "$BINDIR/opam") 83 | if [ "$OPAM" != "$BINDIR/opam" ]; then 84 | echo "WARNING: you have a different version of OPAM installed at $OPAM" 85 | echo "It is highly recommended that you remove it." 86 | read -p "[press enter to continue]" x 87 | OPAM="$BINDIR/opam" 88 | fi 89 | 90 | if [ "$(id -u)" = "0" ]; then 91 | echo "Running as super-user: not running OPAM initialization." 92 | echo "You'll want to run \"$OPAM init --comp $COMP\" as user" 93 | else 94 | echo "Initializing with compiler $COMP" 95 | "$OPAM" init --comp "$COMP" 96 | fi 97 | 98 | echo "Installation done. If you need to uninstall, simply remove $BINDIR/opam" 99 | echo "and ~/.opam" 100 | -------------------------------------------------------------------------------- /.travis-ci.sh: -------------------------------------------------------------------------------- 1 | # Git should be configured properely to run the tests 2 | git config --global user.email "travis@example.com" 3 | git config --global user.name "Travis CI" 4 | 5 | install_on_linux () { 6 | # Install OCaml PPAs 7 | case "$OCAML_VERSION" in 8 | 3.12.1) ppa=avsm/ocaml312+opam12 ;; 9 | 4.00.1) ppa=avsm/ocaml40+opam12 ;; 10 | 4.01.0) ppa=avsm/ocaml41+opam12 ;; 11 | 4.02.3) ppa=avsm/ocaml42+opam12 ;; 12 | *) echo Unknown $OCAML_VERSION; exit 1 ;; 13 | esac 14 | 15 | echo "yes" | sudo add-apt-repository ppa:$ppa 16 | sudo apt-get update -qq 17 | sudo apt-get install -qq ocaml ocaml-native-compilers camlp4-extra time $EXTERNAL_SOLVER ${OPAM_TEST:+opam} 18 | } 19 | 20 | install_on_osx () { 21 | curl -OL "http://xquartz.macosforge.org/downloads/SL/XQuartz-2.7.6.dmg" 22 | sudo hdiutil attach XQuartz-2.7.6.dmg 23 | sudo installer -verbose -pkg /Volumes/XQuartz-2.7.6/XQuartz.pkg -target / 24 | case "$OCAML_VERSION" in 25 | 4.02.1) brew update; brew install ocaml;; 26 | 4.03.0) brew update; brew install ocaml --HEAD ;; 27 | *) echo Skipping $OCAML_VERSION on OSX; exit 0 ;; 28 | esac 29 | if [ -n "$EXTERNAL_SOLVER$OPAM_TEST" ]; then 30 | brew install $EXTERNAL_SOLVER ${OPAM_TEST:+opam} 31 | fi 32 | } 33 | 34 | case $TRAVIS_OS_NAME in 35 | osx) install_on_osx ;; 36 | linux) install_on_linux ;; 37 | esac 38 | 39 | OCAMLV=$(ocaml -vnum) 40 | echo === OCaml version $OCAMLV === 41 | if [ "$OCAMLV" != "$OCAML_VERSION" ]; then 42 | echo "OCaml version doesn't match: travis script needs fixing" 43 | exit 12 44 | fi 45 | 46 | export OPAMYES=1 47 | export OCAMLRUNPARAM=b 48 | 49 | if [ "$OPAM_TEST" = "1" ]; then 50 | # Compile OPAM using the system libraries (install them using OPAM) 51 | # ignore the warnings 52 | 53 | echo "Bootstrapping for opam with:" 54 | opam config report 55 | 56 | # We still have OPAM 1.1 on Homebrew 57 | OPAMV=$(opam --version) 58 | if [ "${OPAMV%.*}" = "1.1" ]; then 59 | opam init https://opam.ocaml.org/1.1 60 | else 61 | opam init 62 | fi 63 | 64 | eval `opam config env` 65 | opam install ocamlfind lwt cohttp ssl cmdliner ocamlgraph dose.3.3 cudf re jsonm 66 | ./configure 67 | make 68 | # overwrite the previous install of OPAM with the new binary 69 | # and libraries 70 | sudo make install 71 | make libinstall prefix=$(opam config var prefix) 72 | # Compile and run opam-rt 73 | wget https://github.com/ocaml/opam-rt/archive/master.tar.gz -O opam-rt.tar.gz 74 | tar xvfz opam-rt.tar.gz 75 | cd opam-rt-* 76 | make 77 | OPAMEXTERNALSOLVER=$EXTERNAL_SOLVER make KINDS="local git" run 78 | else 79 | # Compile OPAM from sources and run the basic tests 80 | ./configure 81 | make lib-ext 82 | make 83 | make opam-check 84 | make tests > tests.log 2>&1 || (tail -1000 tests.log && exit 1) 85 | # Let's see basic tasks works 86 | sudo make install 87 | opam init 88 | opam install lwt 89 | opam list 90 | fi 91 | -------------------------------------------------------------------------------- /src/core/opamCoreConfig.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2015 OCamlPro *) 4 | (* *) 5 | (* All rights reserved.This file is distributed under the terms of the *) 6 | (* GNU Lesser General Public License version 3.0 with linking *) 7 | (* exception. *) 8 | (* *) 9 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 10 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 11 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 12 | (* License for more details. *) 13 | (* *) 14 | (**************************************************************************) 15 | 16 | type t = private { 17 | debug_level : int; 18 | (** Controls debug messages, 0 to disable *) 19 | verbose_level : int; 20 | (** Controls printing of external commands and output, 0 to disable, more 21 | means print more low-level commands *) 22 | color : [ `Always | `Never | `Auto ]; 23 | (** Console ANSI color control *) 24 | utf8 : [ `Extended | `Always | `Never | `Auto ]; 25 | (** Controls usage of UTF8 in OPAM-generated messages. Extended adds camel 26 | emojis *) 27 | disp_status_line: [ `Always | `Never | `Auto ]; 28 | (** Controls on-line display of parallel commands being run, using ANSI 29 | escapes *) 30 | answer : bool option; 31 | (** Affects interactive questions in OpamConsole: auto-answer with the given 32 | bool if Some *) 33 | safe_mode : bool; 34 | (** Fail on writes or delays, don't ask questions (for quick queries, e.g. 35 | for shell completion) *) 36 | lock_retries : int; 37 | log_dir : string; 38 | (** Where to store log and temporary files (output from commands...) *) 39 | keep_log_dir : bool; 40 | (** Whether to cleanup temporary and log files on exit *) 41 | errlog_length : int; 42 | (** The number of log lines displayed on process error. 0 for all *) 43 | } 44 | 45 | type 'a options_fun = 46 | ?debug_level:int -> 47 | ?verbose_level:int -> 48 | ?color:[ `Always | `Never | `Auto ] -> 49 | ?utf8:[ `Extended | `Always | `Never | `Auto ] -> 50 | ?disp_status_line:[ `Always | `Never | `Auto ] -> 51 | ?answer:bool option -> 52 | ?safe_mode:bool -> 53 | ?lock_retries:int -> 54 | ?log_dir:string -> 55 | ?keep_log_dir:bool -> 56 | ?errlog_length:int -> 57 | 'a 58 | 59 | val default : t 60 | 61 | val set : t -> (unit -> t) options_fun 62 | 63 | val setk : (t -> 'a) -> t -> 'a options_fun 64 | 65 | val r : t ref 66 | 67 | val update : ?noop:_ -> (unit -> unit) options_fun 68 | -------------------------------------------------------------------------------- /src/tools/opam_check.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2012-2015 OCamlPro *) 4 | (* Copyright 2012 INRIA *) 5 | (* *) 6 | (* All rights reserved.This file is distributed under the terms of the *) 7 | (* GNU Lesser General Public License version 3.0 with linking *) 8 | (* exception. *) 9 | (* *) 10 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 11 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 12 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 13 | (* License for more details. *) 14 | (* *) 15 | (**************************************************************************) 16 | 17 | (* Utility helper to check if a given set of packages is installed *) 18 | 19 | let usage = "opam-check [--root root] [-l label] +" 20 | 21 | let label = ref "" 22 | let root_dir_ref = ref "" 23 | let spec = Arg.align [ 24 | ("--root", Arg.Set_string root_dir_ref, " Set opam path"); 25 | ("-l" , Arg.Set_string label , " Set a test label"); 26 | ("--version", Arg.Unit OpamVersion.message , " Display version information"); 27 | ] 28 | 29 | let packages = ref [] 30 | let ano x = packages := x :: !packages 31 | 32 | let () = 33 | Arg.parse spec ano usage; 34 | let root_dir = match !root_dir_ref with 35 | | "" -> None 36 | | d -> Some (OpamFilename.Dir.of_string d) 37 | in 38 | OpamSystem.init(); 39 | OpamStd.Config.init(); 40 | OpamFormatConfig.init(); 41 | OpamRepositoryConfig.init(); 42 | OpamSolverConfig.init(); 43 | OpamStateConfig.init 44 | ?root_dir 45 | () 46 | 47 | 48 | let packages = OpamPackage.Set.of_list (List.map OpamPackage.of_string !packages) 49 | 50 | let installed () = 51 | let root = OpamStateConfig.(!r.root_dir) in 52 | let config = OpamFile.Config.read (OpamPath.config root) in 53 | let version = OpamFile.Config.switch config in 54 | OpamFile.Installed.safe_read (OpamPath.Switch.installed root version) 55 | 56 | let () = 57 | let installed = installed () in 58 | let diff1 = OpamPackage.Set.diff packages installed in 59 | let diff2 = OpamPackage.Set.diff installed packages in 60 | let diff = OpamPackage.Set.union diff1 diff2 in 61 | let label = if !label = "" then "" else Printf.sprintf "[%s] " !label in 62 | if not (OpamPackage.Set.is_empty diff) then ( 63 | OpamConsole.error "%swaiting for: %s" label (OpamPackage.Set.to_string diff1); 64 | OpamConsole.error "%sgot: %s" label (OpamPackage.Set.to_string diff2); 65 | exit 1 66 | ) 67 | -------------------------------------------------------------------------------- /tests/init-repo.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | TEST_DIR=/tmp 4 | OPAM_ROOT=$TEST_DIR/OPAM.ROOT 5 | OPAM_REPO=$TEST_DIR/OPAM.REPO 6 | BIN=$TEST_DIR/OPAM.BIN 7 | REPO=test 8 | 9 | BINARIES=opam 10 | 11 | # opam in the path should not be a requirement 12 | ENV="OCAMLRUNPARAM=b OPAMDEBUG=2 OPAM_ROOT=$OPAM_ROOT PATH=$BIN:$PATH" 13 | ENV="OCAMLRUNPARAM=b OPAM_ROOT=$OPAM_ROOT PATH=$BIN:$PATH" 14 | OPAM="$ENV opam --yes --root $OPAM_ROOT" 15 | 16 | function binaries() { 17 | mkdir -p $BIN 18 | for bin in $BINARIES; do \ 19 | cp ../_obuild/$bin/$bin.asm $BIN/$bin ; \ 20 | done 21 | } 22 | 23 | function opam_clean() { 24 | rm -rf $ARCHIVES 25 | rm -rf $OPAM_ROOT $BIN 26 | rm -rf $OPAM_REPO 27 | } 28 | 29 | function opam_init() { 30 | mkdir -p $OPAM_REPO 31 | binaries 32 | eval $OPAM init -no-base-packages $REPO $OPAM_REPO -kind rsync 33 | } 34 | 35 | function opam_upload_stage1() { 36 | 37 | cd packages 38 | eval $OPAM upload -opam P1-1.opam -descr P1-1/README -archive P1-1.tar.gz -repo $REPO 39 | eval $OPAM upload -opam P2.opam -descr P2/README -archive P2.tar.gz -repo $REPO 40 | eval $OPAM upload -opam P3.opam -descr P3/README -archive P3.tar.gz -repo $REPO 41 | eval $OPAM upload -opam P4-1.opam -descr P4/README -archive P4.tar.gz -repo $REPO 42 | eval $OPAM upload -opam P5.opam -descr P5/README -archive P5.tar.gz -repo $REPO 43 | cd - 44 | 45 | cp compilers/* $OPAM_REPO/compilers/ 46 | # update the list of available packages with the one being updated 47 | eval $OPAM update 48 | } 49 | 50 | function opam_upload_stage2() { 51 | 52 | cd packages 53 | eval $OPAM upload -opam P1-2.opam -descr P1-2/README -archive P1-2.tar.gz -repo $REPO 54 | eval $OPAM upload -opam P4-2.opam -descr P4/README -archive P4.tar.gz -repo $REPO 55 | eval $OPAM upload -opam P4-3.opam -descr P4/README -archive P4.tar.gz -repo $REPO 56 | cd - 57 | 58 | # update the list of available packages with the one being updated 59 | eval $OPAM update 60 | } 61 | function usage() { 62 | DESCRIPTION="Opam unittest init functions" 63 | cat << EOF 64 | usage: $0 options 65 | 66 | $DESCRIPTION 67 | 68 | OPTIONS: 69 | -h Show this message 70 | -v Verbose 71 | -d Debug 72 | -i Init 73 | -c Clean 74 | EOF 75 | } 76 | 77 | VERBOSE= 78 | DEBUG= 79 | INIT= 80 | CLEAN= 81 | STAGE= 82 | 83 | while getopts "vhdcis:" flag 84 | do 85 | case "$flag" in 86 | d) set -x ; DEBUG=true;; 87 | v) VERBOSE=true ;; 88 | i) INIT=true ;; 89 | s) STAGE=$OPTARG ;; 90 | c) CLEAN=true ;; 91 | h) usage ; exit 0 ;; 92 | esac 93 | # echo "$flag" $OPTIND $OPTARG 94 | done 95 | 96 | if [ -n "$INIT" ]; then 97 | opam_clean 98 | opam_init 99 | fi 100 | 101 | if [ -n "$STAGE" ]; then 102 | if [ $STAGE = "1" ]; then 103 | opam_upload_stage1 104 | fi 105 | 106 | if [ $STAGE = "2" ]; then 107 | opam_upload_stage2 108 | fi 109 | fi 110 | 111 | if [ -n "$CLEAN" ]; then 112 | opam_clean 113 | fi 114 | 115 | exit 0 116 | 117 | 118 | -------------------------------------------------------------------------------- /admin-scripts/depopts_to_conflicts.ml: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env opam-admin.top 2 | 3 | #directory "+../opam-lib";; 4 | open Opam_admin_top;; 5 | 6 | iter_packages ~opam:(fun _ opam -> 7 | let depopts = 8 | let formula = OpamFile.OPAM.depopts opam in 9 | let names = 10 | OpamStd.List.remove_duplicates @@ 11 | List.map fst @@ 12 | OpamFormula.atoms @@ 13 | OpamFormula.formula_of_extended ~filter:(fun _ -> true) @@ 14 | formula in 15 | OpamFormula.ors @@ 16 | List.rev_map (fun n -> 17 | let flags = 18 | OpamStd.List.remove_duplicates @@ 19 | OpamFormula.fold_left (fun acc (name,(flags,_)) -> 20 | if name = n then flags @ acc else acc) 21 | [] formula 22 | in 23 | OpamFormula.Atom (n, (flags,OpamFormula.Empty))) 24 | names 25 | in 26 | let conflicts = (* add complement of the depopts as conflicts *) 27 | let module NM = OpamPackage.Name.Map in 28 | let depopts = (* get back a map (name => version_constraint) *) 29 | (* XXX this takes _all_ the atoms not considering con/disjunctions *) 30 | OpamFormula.fold_left (fun acc (name,(_,f)) -> 31 | try 32 | NM.add name ((OpamFormula.ors [f; NM.find name acc])) acc 33 | with Not_found -> NM.add name f acc) 34 | NM.empty 35 | (OpamFile.OPAM.depopts opam) in 36 | let neg_depopts = 37 | NM.fold (fun name f acc -> 38 | if f = OpamFormula.Empty then acc else 39 | let f = OpamFormula.(neg (fun (op,v) -> neg_relop op, v) f) in 40 | match OpamFormula.to_cnf (OpamFormula.Atom (name,f)) with 41 | | [] -> acc 42 | | [conj] -> conj @ acc 43 | | [x;y] when x = y -> x @ acc 44 | | cnf -> 45 | (* Formula is not a conjunction, we are left with no choice 46 | but to enumerate *) 47 | let f = 48 | OpamFormula.to_atom_formula @@ OpamFormula.ands @@ 49 | List.map OpamFormula.of_disjunction cnf in 50 | let conflict_packages = 51 | OpamPackage.Set.filter 52 | (fun pkg -> 53 | OpamFormula.eval (fun atom -> OpamFormula.check atom pkg) f) 54 | (OpamPackage.packages_of_name packages name) 55 | in 56 | OpamPackage.Set.fold (fun nv acc -> 57 | (OpamPackage.name nv, Some (`Eq, OpamPackage.version nv)) 58 | :: acc) 59 | conflict_packages acc) 60 | depopts [] in 61 | let conflicts = OpamFile.OPAM.conflicts opam in 62 | let add_conflicts = 63 | let c = OpamFormula.to_disjunction conflicts in 64 | List.filter (fun f -> not (List.mem f c)) neg_depopts in 65 | OpamFormula.ands (conflicts :: [OpamFormula.of_disjunction add_conflicts]) 66 | in 67 | let opam = OpamFile.OPAM.with_depopts opam depopts in 68 | let opam = OpamFile.OPAM.with_conflicts opam conflicts in 69 | opam) 70 | () 71 | ;; 72 | -------------------------------------------------------------------------------- /src/format/opamVariable.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2012-2015 OCamlPro *) 4 | (* Copyright 2012 INRIA *) 5 | (* *) 6 | (* All rights reserved.This file is distributed under the terms of the *) 7 | (* GNU Lesser General Public License version 3.0 with linking *) 8 | (* exception. *) 9 | (* *) 10 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 11 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 12 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 13 | (* License for more details. *) 14 | (* *) 15 | (**************************************************************************) 16 | 17 | include OpamStd.AbstractString 18 | 19 | type variable = t 20 | 21 | type variable_contents = 22 | | B of bool 23 | | S of string 24 | 25 | let string_of_variable_contents = function 26 | | B b -> string_of_bool b 27 | | S s -> s 28 | 29 | module Full = struct 30 | 31 | type scope = 32 | | Global 33 | | Self 34 | | Package of OpamPackage.Name.t 35 | 36 | type t = { 37 | scope: scope; 38 | variable: variable; 39 | } 40 | 41 | let variable t = t.variable 42 | let scope t = t.scope 43 | let package ?self t = match t.scope with 44 | | Package p -> Some p 45 | | Self -> self 46 | | Global -> None 47 | 48 | let create package variable = 49 | let scope = 50 | if OpamPackage.Name.to_string package = "_" then Self 51 | else Package package 52 | in 53 | { scope; variable } 54 | 55 | let global variable = 56 | { scope = Global; variable } 57 | 58 | let is_global variable = match variable.scope with 59 | | Global -> true 60 | | Self | Package _ -> false 61 | 62 | let of_string s = 63 | match OpamStd.String.rcut_at s ':' with 64 | | None -> global (of_string s) 65 | | Some ("_",v) -> 66 | { scope = Self; variable = of_string v } 67 | | Some (p,v) -> 68 | create (OpamPackage.Name.of_string p) (of_string v) 69 | 70 | let to_string t = 71 | let prefix = 72 | match t.scope with 73 | | Global -> "" 74 | | Self -> "_:" 75 | | Package p -> OpamPackage.Name.to_string p ^ ":" 76 | in 77 | prefix ^ to_string t.variable 78 | 79 | let to_json x = 80 | `String (to_string x) 81 | 82 | module O = struct 83 | type tmp = t 84 | type t = tmp 85 | let compare = compare 86 | let to_string = to_string 87 | let to_json = to_json 88 | end 89 | 90 | module Set = OpamStd.Set.Make(O) 91 | 92 | module Map = OpamStd.Map.Make(O) 93 | 94 | end 95 | -------------------------------------------------------------------------------- /src/core/opamVersion.ml.in: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2012-2015 OCamlPro *) 4 | (* Copyright 2012 INRIA *) 5 | (* *) 6 | (* All rights reserved.This file is distributed under the terms of the *) 7 | (* GNU Lesser General Public License version 3.0 with linking *) 8 | (* exception. *) 9 | (* *) 10 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 11 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 12 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 13 | (* License for more details. *) 14 | (* *) 15 | (**************************************************************************) 16 | 17 | type t = string 18 | 19 | let to_string x = x 20 | 21 | let of_string x = x 22 | 23 | let to_json x = `String x 24 | 25 | let compare v w = OpamVersionCompare.compare v w 26 | 27 | module O = struct 28 | type t = string 29 | let to_string = to_string 30 | let to_json = to_json 31 | let compare = compare 32 | end 33 | 34 | module Set = OpamStd.Set.Make(O) 35 | 36 | module Map = OpamStd.Map.Make(O) 37 | 38 | let current_raw = "@PACKAGE_VERSION@" 39 | 40 | let current = of_string current_raw 41 | 42 | let major v = 43 | try 44 | let i = String.index v '.' in 45 | of_string (String.sub v 0 i) 46 | with Not_found -> v 47 | 48 | let nopatch v = 49 | try 50 | let i = String.index v '.' in 51 | let i = String.index_from v (i+1) '.' in 52 | (String.sub v 0 i) 53 | with Not_found -> 54 | let rec f i = 55 | if i >= String.length v then v 56 | else match String.get v i with 57 | | '0'..'9' | '.' -> f (i+1) 58 | | _ -> String.sub v 0 i 59 | in 60 | f 0 61 | 62 | let current_nopatch = nopatch current_raw 63 | 64 | let message () = 65 | Printf.printf "\n\ 66 | %s version %s\n\ 67 | \n\ 68 | Copyright (C) 2012 OCamlPro - INRIA, 2013-2015 OCamlPro\n\ 69 | \n\ 70 | This is free software; see the source for copying conditions. There is NO\n\ 71 | warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n" 72 | Sys.argv.(0) current_raw; 73 | exit 0 74 | 75 | let gitversion = ref None 76 | 77 | let set_git s = gitversion := Some s 78 | 79 | let git () = 80 | match !gitversion with 81 | | None -> None 82 | | Some v -> Some (of_string v) 83 | 84 | let full () = 85 | let git_version = match git () with 86 | | None -> "" 87 | | Some v -> Printf.sprintf " (%s)" (to_string v) in 88 | Printf.sprintf "%s%s" (to_string current) git_version 89 | 90 | let magic () = 91 | let hash = Hashtbl.hash (full ()) in 92 | String.sub (Printf.sprintf "%08X" hash) 0 8 93 | -------------------------------------------------------------------------------- /src/repository/opamRepositoryPath.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2012-2015 OCamlPro *) 4 | (* Copyright 2012 INRIA *) 5 | (* *) 6 | (* All rights reserved.This file is distributed under the terms of the *) 7 | (* GNU Lesser General Public License version 3.0 with linking *) 8 | (* exception. *) 9 | (* *) 10 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 11 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 12 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 13 | (* License for more details. *) 14 | (* *) 15 | (**************************************************************************) 16 | 17 | open OpamTypes 18 | open OpamFilename.Op 19 | 20 | let root t = t.repo_root 21 | 22 | let update_cache t = root t // "update.cache" 23 | 24 | let create root name = root / "repo" / OpamRepositoryName.to_string name 25 | 26 | let repo t = root t // "repo" 27 | 28 | let remote_repo t = 29 | OpamFilename.raw_dir (fst t.repo_address) // "repo" 30 | 31 | let raw_config root name = 32 | root / "repo" / OpamRepositoryName.to_string name // "config" 33 | 34 | let config t = root t // "config" 35 | 36 | let packages_dir t = root t / "packages" 37 | 38 | let remote_packages_dir t = 39 | OpamFilename.raw_dir (fst t.repo_address) / "packages" 40 | 41 | let packages t prefix nv = 42 | match prefix with 43 | | None -> packages_dir t / OpamPackage.to_string nv 44 | | Some p -> packages_dir t / p / OpamPackage.to_string nv 45 | 46 | let opam t prefix nv = packages t prefix nv // "opam" 47 | 48 | let descr t prefix nv = packages t prefix nv // "descr" 49 | 50 | let url t prefix nv = packages t prefix nv // "url" 51 | 52 | let files t prefix nv = packages t prefix nv / "files" 53 | 54 | let archives_dir t = root t / "archives" 55 | 56 | let archive t nv = archives_dir t // (OpamPackage.to_string nv ^ "+opam.tar.gz") 57 | 58 | let remote_archive t nv = 59 | OpamFilename.raw_dir (fst t.repo_address) 60 | / "archives" 61 | // (OpamPackage.to_string nv ^ "+opam.tar.gz") 62 | 63 | let upload_dir t = root t / "upload" 64 | 65 | let compilers_dir t = root t / "compilers" 66 | 67 | let remote_compilers_dir t = 68 | OpamFilename.raw_dir (fst t.repo_address) / "compilers" 69 | 70 | let compiler_comp t prefix c = 71 | match prefix with 72 | | None -> compilers_dir t // (OpamCompiler.to_string c ^ ".comp") 73 | | Some p -> compilers_dir t / p // (OpamCompiler.to_string c ^ ".comp") 74 | 75 | let compiler_descr t prefix c = 76 | match prefix with 77 | | None -> compilers_dir t // (OpamCompiler.to_string c ^ ".descr") 78 | | Some p -> compilers_dir t / p // (OpamCompiler.to_string c ^ ".descr") 79 | -------------------------------------------------------------------------------- /src/core/opamJson.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2012-2015 OCamlPro *) 4 | (* *) 5 | (* All rights reserved.This file is distributed under the terms of the *) 6 | (* GNU Lesser General Public License version 3.0 with linking *) 7 | (* exception. *) 8 | (* *) 9 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 10 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 11 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 12 | (* License for more details. *) 13 | (* *) 14 | (**************************************************************************) 15 | 16 | type t = 17 | [ `Null | `Bool of bool | `Float of float| `String of string 18 | | `A of t list | `O of (string * t) list ] 19 | 20 | val to_string: t -> string 21 | 22 | val of_string: string -> t 23 | 24 | val append: string -> t -> unit 25 | 26 | val flush: out_channel -> unit 27 | 28 | (*--------------------------------------------------------------------------- 29 | Copyright (c) 2012 Daniel C. Bünzli 30 | All rights reserved. 31 | 32 | Redistribution and use in source and binary forms, with or without 33 | modification, are permitted provided that the following conditions 34 | are met: 35 | 36 | 1. Redistributions of source code must retain the above copyright 37 | notice, this list of conditions and the following disclaimer. 38 | 39 | 2. Redistributions in binary form must reproduce the above 40 | copyright notice, this list of conditions and the following 41 | disclaimer in the documentation and/or other materials provided 42 | with the distribution. 43 | 44 | 3. Neither the name of Daniel C. Bünzli nor the names of 45 | contributors may be used to endorse or promote products derived 46 | from this software without specific prior written permission. 47 | 48 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 49 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 50 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 51 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 52 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 53 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 54 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 55 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 56 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 57 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 58 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 59 | ---------------------------------------------------------------------------*) 60 | -------------------------------------------------------------------------------- /src/state/opamAction.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2012-2015 OCamlPro *) 4 | (* Copyright 2012 INRIA *) 5 | (* *) 6 | (* All rights reserved.This file is distributed under the terms of the *) 7 | (* GNU Lesser General Public License version 3.0 with linking *) 8 | (* exception. *) 9 | (* *) 10 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 11 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 12 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 13 | (* License for more details. *) 14 | (* *) 15 | (**************************************************************************) 16 | 17 | (** OPAM actions *) 18 | 19 | open OpamTypes 20 | open OpamState.Types 21 | 22 | (** [download t pkg] downloads the source of the package [pkg] into 23 | the local cache. Returns the downloaded file or directory. *) 24 | val download_package: t -> package -> 25 | [ `Error of string | `Successful of generic_file option ] OpamProcess.job 26 | 27 | (** [extract_package t source pkg] extracts and patches the already 28 | downloaded [source] of the package [pkg]. See {!download_package} 29 | to download the sources. *) 30 | val extract_package: t -> generic_file option -> package -> unit 31 | 32 | (** [build_package t source pkg] builds the package [pkg] from its 33 | already downloaded [source]. Returns [None] on success, [Some exn] 34 | on error. See {!download_package} to download the source. *) 35 | val build_package: 36 | t -> generic_file option -> package -> exn option OpamProcess.job 37 | 38 | (** [install_package t pkg] installs an already built package. Returns 39 | [None] on success, [Some exn] on error. Do not update OPAM's 40 | metadata. See {!build_package} to build the package. *) 41 | val install_package: 42 | t -> package -> exn option OpamProcess.job 43 | 44 | (** Find out if the package source is needed for uninstall *) 45 | val removal_needs_download: t -> package -> bool 46 | 47 | (** Remove a package. *) 48 | val remove_package: t -> metadata:bool -> ?keep_build:bool -> ?silent:bool -> package -> unit OpamProcess.job 49 | 50 | (** Removes auxiliary files related to a package, after checking that 51 | they're not needed (even in other switches) *) 52 | val cleanup_package_artefacts: t -> package -> unit 53 | 54 | (** Compute the set of packages which will need to be downloaded to apply a 55 | solution. Takes a graph of atomic actions. *) 56 | val sources_needed: t -> OpamSolver.ActionGraph.t -> package_set 57 | 58 | (** Update package metadata *) 59 | val update_metadata: 60 | t -> 61 | installed:package_set -> 62 | installed_roots:package_set -> 63 | reinstall:package_set -> 64 | t 65 | -------------------------------------------------------------------------------- /src/repository/opamRepositoryBackend.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2015 OCamlPro *) 4 | (* *) 5 | (* All rights reserved.This file is distributed under the terms of the *) 6 | (* GNU Lesser General Public License version 3.0 with linking *) 7 | (* exception. *) 8 | (* *) 9 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 10 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 11 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 12 | (* License for more details. *) 13 | (* *) 14 | (**************************************************************************) 15 | 16 | open OpamTypes 17 | open OpamTypesBase 18 | 19 | module type S = sig 20 | val name: repository_kind 21 | val pull_url: package -> dirname -> string option -> address -> 22 | generic_file download OpamProcess.job 23 | val pull_repo: repository -> unit OpamProcess.job 24 | val pull_archive: repository -> filename -> filename download OpamProcess.job 25 | val revision: repository -> version option OpamProcess.job 26 | end 27 | 28 | let compare r1 r2 = 29 | match compare r2.repo_priority r1.repo_priority with 30 | | 0 -> compare r2.repo_name r1.repo_name 31 | | x -> x 32 | 33 | let to_string r = 34 | Printf.sprintf "%s(%d %s %s)" 35 | (OpamRepositoryName.to_string r.repo_name) 36 | r.repo_priority 37 | (string_of_repository_kind r.repo_kind) 38 | (string_of_address r.repo_address) 39 | 40 | let default_address = "https://opam.ocaml.org", None 41 | 42 | let default () = { 43 | repo_name = OpamRepositoryName.default; 44 | repo_kind = `http; 45 | repo_address = default_address; 46 | repo_priority = 0; 47 | repo_root = 48 | OpamFilename.Dir.of_string OpamRepositoryName.(to_string default); 49 | } 50 | 51 | let local dirname = { 52 | repo_name = OpamRepositoryName.of_string "local"; 53 | repo_root = dirname; 54 | repo_address = ("", None); 55 | repo_kind = `local; 56 | repo_priority = 0; 57 | } 58 | 59 | let to_json r = 60 | `O [ ("name", OpamRepositoryName.to_json r.repo_name); 61 | ("kind", `String (string_of_repository_kind r.repo_kind)); 62 | ] 63 | 64 | let check_digest filename = function 65 | | Some expected 66 | when OpamRepositoryConfig.(!r.force_checksums) <> Some false -> 67 | let actual = OpamFilename.digest filename in 68 | if actual = expected then true 69 | else 70 | (OpamConsole.error 71 | "Bad checksum for %s:\n\ 72 | \ - %s [expected result]\n\ 73 | \ - %s [actual result]\n\ 74 | Metadata might be out of date, in this case run `opam update`.\n" 75 | (OpamFilename.to_string filename) expected actual; 76 | false) 77 | | _ -> true 78 | -------------------------------------------------------------------------------- /src/tools/opam_depexts_change.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2012-2015 OCamlPro *) 4 | (* Copyright 2012 INRIA *) 5 | (* *) 6 | (* All rights reserved.This file is distributed under the terms of the *) 7 | (* GNU Lesser General Public License version 3.0 with linking *) 8 | (* exception. *) 9 | (* *) 10 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 11 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 12 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 13 | (* License for more details. *) 14 | (* *) 15 | (**************************************************************************) 16 | 17 | (* Script to check that a given repository is well-typed (or well-parsed) *) 18 | open OpamTypes 19 | 20 | type args = { 21 | pkg: name; 22 | os: string list; 23 | deps: string list; 24 | } 25 | 26 | let package_name = 27 | let parse str = 28 | try `Ok (OpamPackage.Name.of_string str) 29 | with Failure msg -> `Error msg 30 | in 31 | let print ppf pkg = Format.pp_print_string ppf (OpamPackage.Name.to_string pkg) in 32 | parse, print 33 | 34 | let args = 35 | let open Cmdliner in 36 | let os = 37 | let doc = "Operating system tag" in 38 | Arg.(value & opt_all string [] & info ["os"] ~doc) 39 | in 40 | let deps = 41 | let doc = "Extdep tag" in 42 | Arg.(value & opt_all string [] & info ["dep"] ~doc) 43 | in 44 | let pkg = 45 | let doc = "OPAM package name" in 46 | Arg.(required & pos 1 (some package_name) None & info [] ~doc) 47 | in 48 | Term.(pure (fun os deps pkg -> { os; deps; pkg }) $ os $ deps $ pkg) 49 | 50 | let process args = 51 | 52 | let repo = OpamRepositoryBackend.local (OpamFilename.cwd ()) in 53 | 54 | let packages = OpamRepository.packages_with_prefixes repo in 55 | 56 | (* packages *) 57 | OpamPackage.Map.iter (fun package prefix -> 58 | OpamConsole.msg "Processing (package) %s\n" (OpamPackage.to_string package); 59 | (* OPAM *) 60 | let opam_f = OpamRepositoryPath.opam repo prefix package in 61 | let opam = OpamFile.OPAM.read opam_f in 62 | let pkgname = OpamFile.OPAM.name opam in 63 | if pkgname = args.pkg then begin 64 | let depexts = 65 | let os = OpamStd.String.Set.of_list args.os in 66 | let deps = OpamStd.String.Set.of_list args.deps in 67 | match OpamFile.OPAM.depexts opam with 68 | | None -> OpamStd.String.SetMap.of_list [ os, deps ] 69 | | Some depexts' -> (* TODO: Replace existing entry? *) 70 | OpamStd.String.SetMap.add os deps depexts' 71 | in 72 | let opam = OpamFile.OPAM.with_depexts opam (Some depexts) in 73 | OpamFile.OPAM.write opam_f opam; 74 | end; 75 | ) packages 76 | -------------------------------------------------------------------------------- /src/client/opamClientConfig.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2015 OCamlPro *) 4 | (* *) 5 | (* All rights reserved.This file is distributed under the terms of the *) 6 | (* GNU Lesser General Public License version 3.0 with linking *) 7 | (* exception. *) 8 | (* *) 9 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 10 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 11 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 12 | (* License for more details. *) 13 | (* *) 14 | (**************************************************************************) 15 | 16 | type t = private { 17 | print_stats: bool; 18 | sync_archives: bool; 19 | pin_kind_auto: bool; 20 | autoremove: bool; 21 | editor: string; 22 | } 23 | 24 | type 'a options_fun = 25 | ?print_stats:bool -> 26 | ?sync_archives:bool -> 27 | ?pin_kind_auto:bool -> 28 | ?autoremove:bool -> 29 | ?editor:string -> 30 | 'a 31 | (* constraint 'a = 'b -> 'c *) 32 | 33 | include OpamStd.Config.Sig 34 | with type t := t 35 | and type 'a options_fun := 'a options_fun 36 | 37 | (** Extra files included in [opam search] *) 38 | val search_files: string list 39 | 40 | (** Load the global configuration file (opamroot/config) and initialise all opam 41 | sub-libraries, overriding the given arguments *) 42 | 43 | val opam_init: 44 | ?root_dir:OpamTypes.dirname -> 45 | ?strict:bool -> 46 | ?skip_version_checks:bool -> 47 | ?all_parens:bool -> 48 | ?log_dir:OpamTypes.dirname -> 49 | ?print_stats:bool -> 50 | ?sync_archives:bool -> 51 | ?pin_kind_auto:bool -> 52 | ?autoremove:bool -> 53 | ?editor:string -> 54 | ?current_switch:OpamSwitch.t -> 55 | ?switch_from:[ `Command_line | `Default | `Env ] -> 56 | ?jobs:int Lazy.t -> 57 | ?dl_jobs:int -> 58 | ?external_tags:string list -> 59 | ?keep_build_dir:bool -> 60 | ?no_base_packages:bool -> 61 | ?build_test:bool -> 62 | ?build_doc:bool -> 63 | ?show:bool -> 64 | ?dryrun:bool -> 65 | ?fake:bool -> 66 | ?makecmd:string Lazy.t -> 67 | ?json_out:string option -> 68 | ?cudf_file:string option -> 69 | ?solver_timeout:float -> 70 | ?external_solver:OpamTypes.arg list option Lazy.t -> 71 | ?solver_preferences_default:string Lazy.t option -> 72 | ?solver_preferences_upgrade:string Lazy.t option -> 73 | ?solver_preferences_fixup:string Lazy.t option -> 74 | ?download_tool:(OpamTypes.arg list * OpamRepositoryConfig.dl_tool_kind) Lazy.t -> 75 | ?retries:int -> 76 | ?force_checksums:bool option -> 77 | ?debug_level:int -> 78 | ?verbose_level:int -> 79 | ?color:[ `Always | `Auto | `Never ] -> 80 | ?utf8:[ `Always | `Auto | `Extended | `Never ] -> 81 | ?disp_status_line:[ `Always | `Auto | `Never ] -> 82 | ?answer:bool option -> 83 | ?safe_mode:bool -> 84 | ?lock_retries:int -> 85 | ?keep_log_dir:bool -> 86 | ?errlog_length:int -> 87 | unit -> unit 88 | -------------------------------------------------------------------------------- /src/state/opamStateConfig.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2015 OCamlPro *) 4 | (* *) 5 | (* All rights reserved.This file is distributed under the terms of the *) 6 | (* GNU Lesser General Public License version 3.0 with linking *) 7 | (* exception. *) 8 | (* *) 9 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 10 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 11 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 12 | (* License for more details. *) 13 | (* *) 14 | (**************************************************************************) 15 | 16 | open OpamTypes 17 | 18 | type t = private { 19 | root_dir: OpamFilename.Dir.t; 20 | current_switch: OpamSwitch.t; 21 | switch_from: [ `Env | `Command_line | `Default ]; 22 | jobs: int Lazy.t; 23 | dl_jobs: int; 24 | external_tags: string list; 25 | keep_build_dir: bool; 26 | no_base_packages: bool; 27 | build_test: bool; 28 | build_doc: bool; 29 | show: bool; 30 | dryrun: bool; 31 | fake: bool; 32 | makecmd: string Lazy.t; 33 | json_out: string option; 34 | } 35 | 36 | type 'a options_fun = 37 | ?root_dir:OpamFilename.Dir.t -> 38 | ?current_switch:OpamSwitch.t -> 39 | ?switch_from:[ `Env | `Command_line | `Default ] -> 40 | ?jobs:(int Lazy.t) -> 41 | ?dl_jobs:int -> 42 | ?external_tags:string list -> 43 | ?keep_build_dir:bool -> 44 | ?no_base_packages:bool -> 45 | ?build_test:bool -> 46 | ?build_doc:bool -> 47 | ?show:bool -> 48 | ?dryrun:bool -> 49 | ?fake:bool -> 50 | ?makecmd:string Lazy.t -> 51 | ?json_out:string option -> 52 | 'a 53 | 54 | include OpamStd.Config.Sig 55 | with type t := t 56 | and type 'a options_fun := 'a options_fun 57 | 58 | (** Get the initial opam root value (from default, env or optional argument). 59 | This allows to get it before doing the init, which is useful to get the 60 | configuration file used to fill some options to init() *) 61 | val opamroot: ?root_dir:dirname -> unit -> dirname 62 | 63 | (** Loads the global configuration file, protecting against concurrent writes *) 64 | val load: dirname -> OpamFile.Config.t option 65 | 66 | (** Writes the global configuration file, protecting against concurrent reads *) 67 | val write: dirname -> OpamFile.Config.t -> unit 68 | 69 | (** Filters flagged dependencies in an ext_formula using the currently set 70 | options (doc, test). Build dependencies are included *) 71 | val filter_deps: ?dev:bool -> ext_formula -> formula 72 | 73 | (** Loads the config file from the OPAM root and updates default values for all 74 | related OpamXxxConfig modules. Doesn't read the env yet, the [init] 75 | functions should still be called afterwards. OpamFormat should be 76 | initialised beforehand, as it may impact the config file loading. 77 | 78 | Returns true if a config file was found and could be read, false 79 | otherwise *) 80 | val load_defaults: OpamFilename.Dir.t -> bool 81 | -------------------------------------------------------------------------------- /src/core/opamCoreConfig.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2015 OCamlPro *) 4 | (* *) 5 | (* All rights reserved.This file is distributed under the terms of the *) 6 | (* GNU Lesser General Public License version 3.0 with linking *) 7 | (* exception. *) 8 | (* *) 9 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 10 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 11 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 12 | (* License for more details. *) 13 | (* *) 14 | (**************************************************************************) 15 | 16 | open OpamCompat 17 | 18 | type t = { 19 | debug_level: int; 20 | verbose_level: int; 21 | color: [ `Always | `Never | `Auto ]; 22 | utf8: [ `Extended | `Always | `Never | `Auto ]; 23 | disp_status_line: [ `Always | `Never | `Auto ]; 24 | answer: bool option; 25 | safe_mode: bool; 26 | lock_retries: int; 27 | log_dir: string; 28 | keep_log_dir: bool; 29 | errlog_length: int; 30 | } 31 | 32 | type 'a options_fun = 33 | ?debug_level:int -> 34 | ?verbose_level:int -> 35 | ?color:[ `Always | `Never | `Auto ] -> 36 | ?utf8:[ `Extended | `Always | `Never | `Auto ] -> 37 | ?disp_status_line:[ `Always | `Never | `Auto ] -> 38 | ?answer:bool option -> 39 | ?safe_mode:bool -> 40 | ?lock_retries:int -> 41 | ?log_dir:string -> 42 | ?keep_log_dir:bool -> 43 | ?errlog_length:int -> 44 | 'a 45 | 46 | let default = { 47 | debug_level = 0; 48 | verbose_level = 0; 49 | color = `Auto; 50 | utf8 = `Auto; 51 | disp_status_line = `Auto; 52 | answer = None; 53 | safe_mode = false; 54 | lock_retries = 5; 55 | log_dir = 56 | (let user = try Unix.getlogin() with Unix.Unix_error _ -> "xxx" in 57 | let base = Printf.sprintf "opam-%s-%d" user (Unix.getpid()) in 58 | Filename.(concat (get_temp_dir_name ()) base)); 59 | keep_log_dir = false; 60 | errlog_length = 12; 61 | } 62 | 63 | let setk k t 64 | ?debug_level 65 | ?verbose_level 66 | ?color 67 | ?utf8 68 | ?disp_status_line 69 | ?answer 70 | ?safe_mode 71 | ?lock_retries 72 | ?log_dir 73 | ?keep_log_dir 74 | ?errlog_length 75 | = 76 | let (+) x opt = match opt with Some x -> x | None -> x in 77 | k { 78 | debug_level = t.debug_level + debug_level; 79 | verbose_level = t.verbose_level + verbose_level; 80 | color = t.color + color; 81 | utf8 = t.utf8 + utf8; 82 | disp_status_line = t.disp_status_line + disp_status_line; 83 | answer = t.answer + answer; 84 | safe_mode = t.safe_mode + safe_mode; 85 | lock_retries = t.lock_retries + lock_retries; 86 | log_dir = t.log_dir + log_dir; 87 | keep_log_dir = t.keep_log_dir + keep_log_dir; 88 | errlog_length = t.errlog_length + errlog_length; 89 | } 90 | 91 | let set t = setk (fun x () -> x) t 92 | 93 | (* Global configuration reference *) 94 | 95 | let r = ref default 96 | 97 | let update ?noop:_ = setk (fun cfg () -> r := cfg) !r 98 | -------------------------------------------------------------------------------- /src/tools/opam_repo_check.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2012-2015 OCamlPro *) 4 | (* Copyright 2012 INRIA *) 5 | (* *) 6 | (* All rights reserved.This file is distributed under the terms of the *) 7 | (* GNU Lesser General Public License version 3.0 with linking *) 8 | (* exception. *) 9 | (* *) 10 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 11 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 12 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 13 | (* License for more details. *) 14 | (* *) 15 | (**************************************************************************) 16 | 17 | (* Script to check that a given repository is well-typed (or well-parsed) *) 18 | open OpamFilename.Op 19 | 20 | type args = { 21 | normalize: bool; 22 | } 23 | 24 | let args = 25 | let open Cmdliner in 26 | let normalize = 27 | let doc = "Normalize all files in the repository." in 28 | Arg.(value & flag & info ["n";"normalize"] ~doc) 29 | in 30 | Term.(pure (fun normalize -> { normalize }) $ normalize) 31 | 32 | let process args = 33 | 34 | let write f_write fic st = 35 | if args.normalize then f_write fic st in 36 | 37 | let repo = OpamRepositoryBackend.local (OpamFilename.cwd ()) in 38 | 39 | let packages = OpamRepository.packages_with_prefixes repo in 40 | 41 | (* packages *) 42 | OpamPackage.Map.iter (fun package prefix -> 43 | OpamConsole.msg "Processing package %s\n" (OpamPackage.to_string package); 44 | 45 | (* OPAM *) 46 | let opam = OpamRepositoryPath.opam repo prefix package in 47 | write OpamFile.OPAM.write opam (OpamFile.OPAM.read opam); 48 | 49 | (* Descr *) 50 | let descr = OpamRepositoryPath.descr repo prefix package in 51 | if OpamFilename.exists descr then 52 | write OpamFile.Descr.write descr (OpamFile.Descr.read descr); 53 | 54 | (* URL *) 55 | let url = OpamRepositoryPath.url repo prefix package in 56 | if OpamFilename.exists url then 57 | write OpamFile.URL.write url (OpamFile.URL.read url); 58 | 59 | (* Dot_install *) 60 | let dot_install = 61 | OpamRepositoryPath.files repo prefix package 62 | // (OpamPackage.Name.to_string (OpamPackage.name package) ^ ".install") in 63 | if OpamFilename.exists dot_install then 64 | write 65 | OpamFile.Dot_install.write dot_install 66 | (OpamFile.Dot_install.read dot_install); 67 | 68 | ) packages; 69 | 70 | (* compilers *) 71 | let compilers = OpamRepository.compilers_with_prefixes repo in 72 | OpamCompiler.Map.iter (fun c prefix -> 73 | let comp = OpamRepositoryPath.compiler_comp repo prefix c in 74 | let descr = OpamRepositoryPath.compiler_descr repo prefix c in 75 | OpamConsole.msg "Processing compiler %s\n" (OpamCompiler.to_string c); 76 | write OpamFile.Comp.write comp (OpamFile.Comp.read comp); 77 | if OpamFilename.exists descr then 78 | write OpamFile.Descr.write descr (OpamFile.Descr.read descr); 79 | ) compilers 80 | -------------------------------------------------------------------------------- /src/state/opamOCaml.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2015 OCamlPro *) 4 | (* *) 5 | (* All rights reserved.This file is distributed under the terms of the *) 6 | (* GNU Lesser General Public License version 3.0 with linking *) 7 | (* exception. *) 8 | (* *) 9 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 10 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 11 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 12 | (* License for more details. *) 13 | (* *) 14 | (**************************************************************************) 15 | 16 | open OpamTypesBase 17 | 18 | let log fmt = OpamConsole.log "CLIENTGLOBALS" fmt 19 | 20 | (* Detect OCaml specifics (all done lazily) *) 21 | 22 | let reset_env = lazy ( 23 | let env = OpamStd.Env.list () in 24 | let env = 25 | let path_sep = OpamStd.Sys.path_sep () in 26 | let path_sep_str = String.make 1 path_sep in 27 | List.rev_map (fun (k,v as c) -> 28 | match k with 29 | | "PATH" -> 30 | k, String.concat path_sep_str 31 | (OpamStd.Env.reset_value path_sep 32 | ~prefix:OpamStateConfig.(OpamFilename.Dir.to_string !r.root_dir) 33 | v) 34 | | _ -> c 35 | ) env in 36 | let env = List.rev_map (fun (k,v) -> k^"="^v) env in 37 | Array.of_list env 38 | ) 39 | 40 | let ocaml_cmd ~system cmd = 41 | let env = if system then Some (Lazy.force reset_env) else None in 42 | try 43 | match 44 | OpamSystem.read_command_output ?env ~verbose:false [ "ocamlc" ; cmd ] 45 | with 46 | | h::_ -> Some (OpamStd.String.strip h) 47 | | [] -> 48 | log "ERROR: ocamlc found but `ocamlc %s` is empty." cmd; 49 | None 50 | with OpamSystem.Command_not_found _ -> 51 | log "%s ocamlc not found" (if system then "system" else "opam"); 52 | None 53 | 54 | let exists_alongside_ocamlc name = 55 | let path = try OpamStd.Env.get "PATH" with Not_found -> "" in 56 | let path = OpamStd.String.split path (OpamStd.Sys.path_sep ()) in 57 | let ocamlc_dir = 58 | List.fold_left (function 59 | | None -> fun d -> 60 | if Sys.file_exists (Filename.concat d "ocamlc") then Some d else None 61 | | s -> fun _ -> s) 62 | None path 63 | in 64 | match ocamlc_dir with 65 | | Some d -> Sys.file_exists (Filename.concat d name) 66 | | None -> false 67 | 68 | let ocaml_version = lazy (ocaml_cmd ~system:false "-version") 69 | let ocaml_where = lazy (ocaml_cmd ~system:false "-where") 70 | let ocaml_opt_available = lazy (exists_alongside_ocamlc "ocamlc.opt") 71 | let ocaml_native_available = lazy (exists_alongside_ocamlc "ocamlopt") 72 | let ocaml_natdynlink_available = lazy OpamStd.Option.Op.( 73 | (Lazy.force ocaml_where >>| fun d -> 74 | Sys.file_exists (Filename.concat d "dynlink.cmxa")) 75 | +! false 76 | ) 77 | 78 | let system_ocamlc_version = lazy (ocaml_cmd ~system:true "-version") 79 | let system_ocamlc_where = lazy (ocaml_cmd ~system:true "-where") 80 | let system_compiler = lazy ( 81 | OpamStd.Option.Op.(Lazy.force system_ocamlc_version >>| 82 | OpamCompiler.of_string) 83 | ) 84 | -------------------------------------------------------------------------------- /admin-scripts/extract_mini_repository.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | set -e 4 | 5 | if [ $# = 0 ]; then 6 | cat < /dev/null || true 95 | done 96 | 97 | ## Convert the required compilers as packages 98 | 99 | "${SOURCE_DIR}"/compilers-to-packages.ml 100 | 101 | ## Fetch the packages and compilers archives 102 | 103 | for version in ${COMPILERS}; do 104 | opam admin make --resolve --compiler ${version} ocaml.${version} ${PACKAGES} 105 | done 106 | 107 | ## Remove the unrequired package "versions 108 | 109 | unrequired_version() { 110 | case "$1" in 111 | base-*) 112 | return 1;; 113 | *) 114 | for version in archives/* 115 | do 116 | if [ "${version}" = "archives/$1+opam.tar.gz" ]; then return 1; fi 117 | done 118 | esac 119 | return 0 120 | } 121 | 122 | for dir in packages/*/* 123 | do 124 | if unrequired_version "${dir##packages/*/}"; then 125 | rm -r "${dir}" 126 | fi 127 | done 128 | 129 | # Remove empty directories in "packages/" 130 | 131 | for dir in packages/* 132 | do 133 | rmdir "${dir}" 2> /dev/null || true 134 | done 135 | 136 | ## Remove unrequired files 137 | 138 | rm -f .gitignore .travis-ci-install.sh .travis-ci.sh .travis.yml README.md 139 | 140 | ## Build the archive 141 | 142 | cd "${WORK_DIR}" 143 | tar czf "${TARGET_DIR}/opam-mini-repository.tar.gz" ${REPO_DIR_NAME} 144 | -------------------------------------------------------------------------------- /src/client/opamClientConfig.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2015 OCamlPro *) 4 | (* *) 5 | (* All rights reserved.This file is distributed under the terms of the *) 6 | (* GNU Lesser General Public License version 3.0 with linking *) 7 | (* exception. *) 8 | (* *) 9 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 10 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 11 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 12 | (* License for more details. *) 13 | (* *) 14 | (**************************************************************************) 15 | 16 | type t = { 17 | print_stats: bool; 18 | sync_archives: bool; 19 | pin_kind_auto: bool; 20 | autoremove: bool; 21 | editor: string; 22 | } 23 | 24 | let default = { 25 | print_stats = false; 26 | sync_archives = false; 27 | pin_kind_auto = true; 28 | autoremove = false; 29 | editor = "nano"; 30 | } 31 | 32 | type 'a options_fun = 33 | ?print_stats:bool -> 34 | ?sync_archives:bool -> 35 | ?pin_kind_auto:bool -> 36 | ?autoremove:bool -> 37 | ?editor:string -> 38 | 'a 39 | 40 | let setk k t 41 | ?print_stats 42 | ?sync_archives 43 | ?pin_kind_auto 44 | ?autoremove 45 | ?editor 46 | = 47 | let (+) x opt = match opt with Some x -> x | None -> x in 48 | k { 49 | print_stats = t.print_stats + print_stats; 50 | sync_archives = t.sync_archives + sync_archives; 51 | pin_kind_auto = t.pin_kind_auto + pin_kind_auto; 52 | autoremove = t.autoremove + autoremove; 53 | editor = t.editor + editor; 54 | } 55 | 56 | let set t = setk (fun x () -> x) t 57 | 58 | let r = ref default 59 | 60 | let update ?noop:_ = setk (fun cfg () -> r := cfg) !r 61 | 62 | let initk k = 63 | let open OpamStd.Config in 64 | let open OpamStd.Option.Op in 65 | let editor = 66 | env_string "EDITOR" ++ OpamStd.Env.(getopt "VISUAL" ++ getopt "EDITOR") 67 | in 68 | setk (setk (fun c -> r := c; k)) !r 69 | ?print_stats:(env_bool "STATS") 70 | ?sync_archives:(env_bool "SYNCARCHIVES") 71 | ?pin_kind_auto:(env_bool "PINKINDAUTO") 72 | ?autoremove:(env_bool "AUTOREMOVE") 73 | ?editor 74 | 75 | let init ?noop:_ = initk (fun () -> ()) 76 | 77 | let search_files = ["findlib"] 78 | 79 | open OpamStd.Op 80 | 81 | let opam_init ?root_dir ?strict = 82 | (* (i) get root dir *) 83 | let root = OpamStateConfig.opamroot ?root_dir () in 84 | 85 | (* (ii) load conf file and set defaults *) 86 | (* the init for OpamFormat is done in advance since (a) it has an effect on 87 | loading the global config (b) the global config has no effect on it *) 88 | OpamFormatConfig.initk ?strict @@ fun ?log_dir -> 89 | let initialised = OpamStateConfig.load_defaults root in 90 | 91 | (* (iii) load from env and options using OpamXxxConfig.init *) 92 | let log_dir = 93 | if log_dir = None && initialised 94 | then Some OpamFilename.(Dir.to_string Op.(root / "log")) 95 | else None 96 | in 97 | (fun () -> ()) |> 98 | OpamStd.Config.initk ?log_dir |> 99 | OpamRepositoryConfig.initk |> 100 | OpamSolverConfig.initk |> 101 | OpamStateConfig.initk ~root_dir:root |> 102 | initk 103 | -------------------------------------------------------------------------------- /src/repository/opamHg.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2012-2015 OCamlPro *) 4 | (* Copyright 2012 INRIA *) 5 | (* *) 6 | (* All rights reserved.This file is distributed under the terms of the *) 7 | (* GNU Lesser General Public License version 3.0 with linking *) 8 | (* exception. *) 9 | (* *) 10 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 11 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 12 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 13 | (* License for more details. *) 14 | (* *) 15 | (**************************************************************************) 16 | 17 | open OpamTypes 18 | open OpamFilename.Op 19 | open OpamProcess.Job.Op 20 | 21 | module Hg = struct 22 | 23 | let name = `hg 24 | 25 | let exists repo = 26 | OpamFilename.exists_dir (repo.repo_root / ".hg") 27 | 28 | let hg repo = 29 | let dir = OpamFilename.Dir.to_string repo.repo_root in 30 | fun ?verbose ?env args -> 31 | OpamSystem.make_command ~dir ?verbose ?env "hg" args 32 | 33 | let init repo = 34 | hg repo [ "init" ] @@> fun r -> 35 | OpamSystem.raise_on_process_error r; 36 | OpamFilename.write 37 | OpamFilename.Op.(repo.repo_root / ".hg" // "hgrc") 38 | (Printf.sprintf "[paths]\ndefault = %s\n" (fst repo.repo_address)); 39 | Done () 40 | 41 | let fetch repo = 42 | let check_and_fix_remote = 43 | hg repo [ "showconfig" ; "paths.default" ] 44 | @@> fun r -> 45 | OpamSystem.raise_on_process_error r; 46 | if r.OpamProcess.r_stdout <> [fst repo.repo_address] then ( 47 | OpamFilename.rmdir OpamFilename.Op.(repo.repo_root / ".hg"); 48 | init repo 49 | ) else Done () 50 | in 51 | check_and_fix_remote @@+ fun () -> 52 | hg repo [ "pull" ] @@> fun r -> 53 | OpamSystem.raise_on_process_error r; 54 | Done () 55 | 56 | let revision repo = 57 | hg repo [ "id"; "-i" ] @@> fun r -> 58 | OpamSystem.raise_on_process_error r; 59 | match r.OpamProcess.r_stdout with 60 | | [] -> Done "" 61 | | full::_ -> 62 | if String.length full > 8 then Done (String.sub full 0 8) 63 | else Done full 64 | 65 | let unknown_commit commit = 66 | OpamSystem.internal_error "Unknown mercurial revision/branch/bookmark: %s." 67 | commit 68 | 69 | let reset repo = 70 | let commit = match snd repo.repo_address with 71 | | None -> "tip" 72 | | Some c -> c 73 | in 74 | hg repo [ "update" ; "--clean"; commit ] @@> fun r -> 75 | if OpamProcess.is_failure r then unknown_commit commit; 76 | Done () 77 | 78 | let diff repo = 79 | let commit = match snd repo.repo_address with 80 | | None -> "tip" 81 | | Some c -> c in 82 | hg repo [ "diff" ; "--stat" ; "-r" ; commit ] @@> fun r -> 83 | if OpamProcess.is_failure r then unknown_commit commit; 84 | Done (r.OpamProcess.r_stdout <> []) 85 | 86 | let versionned_files repo = 87 | hg repo [ "locate" ] @@> fun r -> 88 | OpamSystem.raise_on_process_error r; 89 | Done r.OpamProcess.r_stdout 90 | 91 | let vc_dir repo = OpamFilename.Op.(repo.repo_root / ".hg") 92 | 93 | end 94 | 95 | module B = OpamVCS.Make(Hg) 96 | -------------------------------------------------------------------------------- /src/state/opamSolution.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2012-2015 OCamlPro *) 4 | (* Copyright 2012 INRIA *) 5 | (* *) 6 | (* All rights reserved.This file is distributed under the terms of the *) 7 | (* GNU Lesser General Public License version 3.0 with linking *) 8 | (* exception. *) 9 | (* *) 10 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 11 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 12 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 13 | (* License for more details. *) 14 | (* *) 15 | (**************************************************************************) 16 | 17 | (** Applying solver solutions *) 18 | 19 | open OpamTypes 20 | 21 | (** Resolve an user request *) 22 | val resolve: 23 | ?verbose:bool -> 24 | OpamState.state -> 25 | user_action -> 26 | orphans:package_set -> 27 | atom request -> 28 | (OpamSolver.solution, OpamCudf.conflict) result 29 | 30 | (** Apply a solution returned by the solver. If [ask] is not 31 | specified, prompts the user whenever the solution isn't 32 | obvious from the request *) 33 | val apply: 34 | ?ask:bool -> 35 | OpamState.state -> 36 | user_action -> 37 | requested:OpamPackage.Name.Set.t -> 38 | OpamSolver.solution -> 39 | solver_result 40 | 41 | (** Call the solver to get a solution and then call [apply]. If [ask] is not 42 | specified, prompts the user whenever the solution isn't obvious from the 43 | request *) 44 | val resolve_and_apply: 45 | ?ask:bool -> 46 | OpamState.state -> 47 | user_action -> 48 | requested:OpamPackage.Name.Set.t -> 49 | orphans:package_set -> 50 | atom request -> 51 | solver_result 52 | 53 | (** Raise an error if no solution is found or in case of error. *) 54 | val check_solution: OpamState.state -> solver_result -> unit 55 | 56 | (** {2 Atoms} *) 57 | 58 | (** Return an atom with a strict version constraint *) 59 | val eq_atom: name -> version -> atom 60 | 61 | (** Return a simple atom, with no version constrain, from a package*) 62 | val atom_of_package: package -> atom 63 | 64 | (** Returns an atom with a strict version constraint from a package *) 65 | val eq_atom_of_package: package -> atom 66 | 67 | (** Return a list of simple atoms (ie. with no version constraints) 68 | from a set of packages *) 69 | val atoms_of_packages: package_set -> atom list 70 | 71 | (** Return a list of constrained atoms from a set of packages *) 72 | val eq_atoms_of_packages: package_set -> atom list 73 | 74 | (** Checks that the atoms can possibly be verified (individually) in a package 75 | set. Displays an error and exits otherwise. [permissive] just changes the 76 | error message. *) 77 | val check_availability: ?permissive: bool -> 78 | OpamState.state -> OpamPackage.Set.t -> atom list -> unit 79 | 80 | (** Takes a "raw" list of atoms (from the user), and match it to existing 81 | packages. Match packages with the wrong capitalisation, and raises errors on 82 | non-existing packages, and unavailable ones unless [permissive] is set. 83 | Exits with a message on error. *) 84 | val sanitize_atom_list: ?permissive: bool -> OpamState.state -> atom list -> atom list 85 | 86 | (** {2 Stats} *) 87 | val sum: stats -> int 88 | -------------------------------------------------------------------------------- /src/tools/opam_rename.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2014 Thomas Gazagnaire *) 4 | (* *) 5 | (* All rights reserved.This file is distributed under the terms of the *) 6 | (* GNU Lesser General Public License version 3.0 with linking *) 7 | (* exception. *) 8 | (* *) 9 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 10 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 11 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 12 | (* License for more details. *) 13 | (* *) 14 | (**************************************************************************) 15 | 16 | (* Script to add findlib info *) 17 | open OpamTypes 18 | 19 | module StringSet = OpamStd.String.Set 20 | 21 | type args = { 22 | src: name; 23 | dst: name; 24 | } 25 | 26 | let args = 27 | let open Cmdliner in 28 | let src = 29 | let doc = "Name of the source package." in 30 | Arg.(required & pos 0 (some string) None & info ~doc []) in 31 | let dst = 32 | let doc = "Name of the destination package." in 33 | Arg.(required & pos 1 (some string) None & info ~doc []) in 34 | Term.(pure (fun src dst -> 35 | let src = OpamPackage.Name.of_string src in 36 | let dst = OpamPackage.Name.of_string dst in 37 | { src; dst } 38 | ) $ src $ dst) 39 | 40 | let process args = 41 | let repo = OpamRepositoryBackend.local (OpamFilename.cwd ()) in 42 | let packages = OpamRepository.packages_with_prefixes repo in 43 | OpamPackage.Map.iter (fun package prefix -> 44 | if OpamPackage.name package = args.src then ( 45 | let new_pkg = 46 | OpamPackage.create args.dst (OpamPackage.version package) 47 | in 48 | if OpamPackage.Map.mem new_pkg packages then ( 49 | OpamConsole.warning 50 | "Cannot rename %s to %s as the package already exists, skipping." 51 | (OpamPackage.to_string package) (OpamPackage.to_string new_pkg); 52 | ) else ( 53 | OpamConsole.msg "Processing %s\n" (OpamPackage.to_string package); 54 | let path = OpamRepositoryPath.packages repo prefix package in 55 | let new_path = 56 | let prefix = match prefix with 57 | | None -> None 58 | | Some _ -> Some (OpamPackage.Name.to_string args.dst) 59 | in 60 | OpamRepositoryPath.packages repo prefix new_pkg 61 | in 62 | OpamFilename.move_dir ~src:path ~dst:new_path; 63 | (* XXX: do we want to rename the findlib packages as well ?? *) 64 | ) 65 | ) else ( 66 | let opam_f = OpamRepositoryPath.opam repo prefix package in 67 | let opam = OpamFile.OPAM.read opam_f in 68 | let rename (n, c) = 69 | if n = args.src then Atom (args.dst, c) else Atom (n, c) 70 | in 71 | let depends = OpamFormula.map rename (OpamFile.OPAM.depends opam) in 72 | let depopts = OpamFormula.map rename (OpamFile.OPAM.depopts opam) in 73 | let new_opam = 74 | OpamFile.OPAM.with_depends 75 | (OpamFile.OPAM.with_depopts opam depopts) 76 | depends 77 | in 78 | 79 | if opam <> new_opam then ( 80 | OpamConsole.msg "Processing %s\n" (OpamPackage.to_string package); 81 | OpamFile.OPAM.write opam_f new_opam 82 | ); 83 | )) 84 | packages 85 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | -include Makefile.config 2 | 3 | all: opam-lib opam opam-admin opam-installer 4 | @ 5 | 6 | ALWAYS: 7 | @ 8 | 9 | opam-lib opam opam-admin opam-installer all: ALWAYS 10 | 11 | #backwards-compat 12 | compile with-ocamlbuild: all 13 | @ 14 | install-with-ocamlbuild: install 15 | @ 16 | libinstall-with-ocamlbuild: libinstall 17 | @ 18 | 19 | byte: 20 | $(MAKE) all USE_BYTE=true 21 | 22 | src/%: 23 | $(MAKE) -C src $* 24 | 25 | %: 26 | $(MAKE) -C src $@ 27 | 28 | lib-ext: 29 | $(MAKE) -C src_ext lib-ext 30 | 31 | download-ext: 32 | $(MAKE) -C src_ext archives 33 | 34 | clean-ext: 35 | $(MAKE) -C src_ext distclean 36 | 37 | clean: 38 | $(MAKE) -C src $@ 39 | $(MAKE) -C doc $@ 40 | 41 | OPAMINSTALLER_FLAGS = --prefix $(DESTDIR)$(prefix) 42 | OPAMINSTALLER_FLAGS += --mandir $(DESTDIR)$(mandir) 43 | 44 | # With ocamlfind, prefer to install to the standard directory rather 45 | # than $(prefix) if there are no overrides 46 | ifndef DESTDIR 47 | ifneq ($(OCAMLFIND),no) 48 | LIBINSTALL_DIR ?= $(shell $(OCAMLFIND) printconf destdir) 49 | endif 50 | endif 51 | 52 | ifneq ($(LIBINSTALL_DIR),) 53 | OPAMINSTALLER_FLAGS += --libdir $(LIBINSTALL_DIR) 54 | endif 55 | 56 | opam-lib.install: 57 | $(MAKE) -C src ../opam-lib.install 58 | 59 | libinstall: opam-lib.install 60 | $(if $(wildcard src_ext/lib/*),$(error Installing the opam libraries is incompatible with embedding the dependencies. Run 'make clean-ext' and try again)) 61 | src/opam-installer $(OPAMINSTALLER_FLAGS) opam-lib.install 62 | 63 | install: 64 | src/opam-installer $(OPAMINSTALLER_FLAGS) opam.install 65 | 66 | libuninstall: 67 | src/opam-installer -u $(OPAMINSTALLER_FLAGS) opam-lib.install 68 | 69 | uninstall: 70 | src/opam-installer -u $(OPAMINSTALLER_FLAGS) opam.install 71 | 72 | .PHONY: tests tests-local tests-git 73 | tests: opam opam-admin opam-check 74 | $(MAKE) -C tests all 75 | 76 | # tests-local, tests-git 77 | tests-%: opam opam-admin opam-check 78 | $(MAKE) -C tests $* 79 | 80 | .PHONY: doc 81 | doc: all 82 | $(MAKE) -C doc 83 | 84 | .PHONY: man man-html 85 | man man-html: opam opam-admin opam-installer 86 | $(MAKE) -C doc $@ 87 | 88 | configure: configure.ac m4/*.m4 89 | aclocal -I m4 90 | autoconf 91 | 92 | release-tag: 93 | git tag -d latest || true 94 | git tag -a latest -m "Latest release" 95 | git tag -a $(version) -m "Release $(version)" 96 | 97 | 98 | $(OPAM_FULL).tar.gz: 99 | $(MAKE) -C src_ext distclean 100 | $(MAKE) -C src_ext downloads 101 | rm -f $(OPAM_FULL) $(OPAM_FULL).tar.gz 102 | ln -s . 103 | 104 | fastlink: 105 | @$(foreach b,opam opam-admin opam-installer opam-check,\ 106 | ln -sf ../_obuild/$b/$b.asm src/$b;) 107 | @$(foreach l,core format solver repository state client,\ 108 | $(foreach e,a cma cmxa,ln -sf ../_obuild/opam-$l/opam-$l.$e src/opam-$l.$e;)\ 109 | ln -sf $(addprefix ../../,\ 110 | $(foreach e,o cmo cmx cmxs cmi cmt cmti,$(wildcard _obuild/opam-$l/*.$e)))\ 111 | src/$l/;) 112 | 113 | rmartefacts: ALWAYS 114 | @rm -f $(addprefix src/, opam opam-admin opam-installer opam-check) 115 | @$(foreach l,core format solver repository state client,\ 116 | $(foreach e,a cma cmxa,rm -f src/opam-$l.$e;)\ 117 | $(foreach e,o cmo cmx cmxs cmi cmt cmti,rm -f $(wildcard src/$l/*.$e);)) 118 | 119 | prefast: rmartefacts src/client/opamGitVersion.ml src/state/opamScript.ml src/core/opamCompat.ml src/core/opamCompat.mli 120 | @ocp-build -init 121 | 122 | fast: prefast 123 | @ocp-build 124 | @$(MAKE) fastlink 125 | 126 | fastclean: rmartefacts 127 | @ocp-build -clean 2>/dev/null || ocp-build clean 2>/dev/null 128 | 129 | cold: 130 | ./shell/bootstrap-ocaml.sh 131 | env PATH="$$PATH:`pwd`/bootstrap/ocaml/bin" ./configure $(CONFIGURE_ARGS) 132 | env PATH="$$PATH:`pwd`/bootstrap/ocaml/bin" $(MAKE) lib-ext 133 | env PATH="$$PATH:`pwd`/bootstrap/ocaml/bin" $(MAKE) 134 | -------------------------------------------------------------------------------- /src/repository/opamRepositoryConfig.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* *) 3 | (* Copyright 2015 OCamlPro *) 4 | (* *) 5 | (* All rights reserved.This file is distributed under the terms of the *) 6 | (* GNU Lesser General Public License version 3.0 with linking *) 7 | (* exception. *) 8 | (* *) 9 | (* OPAM is distributed in the hope that it will be useful, but WITHOUT *) 10 | (* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) 11 | (* or FITNESS FOR A PARTICULAR PURPOSE.See the GNU General Public *) 12 | (* License for more details. *) 13 | (* *) 14 | (**************************************************************************) 15 | 16 | open OpamTypes 17 | 18 | type dl_tool_kind = [ `Curl | `Default ] 19 | 20 | type t = { 21 | download_tool: (OpamTypes.arg list * dl_tool_kind) Lazy.t; 22 | retries: int; 23 | force_checksums: bool option; 24 | } 25 | 26 | type 'a options_fun = 27 | ?download_tool:(OpamTypes.arg list * dl_tool_kind) Lazy.t -> 28 | ?retries:int -> 29 | ?force_checksums:bool option -> 30 | 'a 31 | 32 | let default = { 33 | download_tool = lazy ( 34 | try 35 | let tools = 36 | if OpamStd.Sys.(os () = Darwin) 37 | then ["wget", `Default; "curl", `Curl] 38 | else ["curl", `Curl; "wget", `Default] 39 | in 40 | let cmd, kind = 41 | List.find (fun (c,_) -> OpamSystem.command_exists c) tools 42 | in 43 | [ CIdent cmd, None ], kind 44 | with Not_found -> 45 | OpamConsole.error_and_exit 46 | "Could not find a suitable download command. Please make sure you \ 47 | have either \"curl\" or \"wget\" installed, or specify a custom \ 48 | command through variable OPAMFETCH." 49 | ); 50 | retries = 3; 51 | force_checksums = None; 52 | } 53 | 54 | let setk k t 55 | ?download_tool 56 | ?retries 57 | ?force_checksums 58 | = 59 | let (+) x opt = match opt with Some x -> x | None -> x in 60 | k { 61 | download_tool = t.download_tool + download_tool; 62 | retries = t.retries + retries; 63 | force_checksums = t.force_checksums + force_checksums; 64 | } 65 | 66 | let set t = setk (fun x () -> x) t 67 | 68 | let r = ref default 69 | 70 | let update ?noop:_ = setk (fun cfg () -> r := cfg) !r 71 | 72 | let initk k = 73 | let open OpamStd.Config in 74 | let open OpamStd.Option.Op in 75 | let download_tool = 76 | env_string "FETCH" >>| (fun s -> 77 | let args = OpamStd.String.split s ' ' in 78 | let c = List.map (fun a -> OpamTypes.CString a, None) args in 79 | let kind = match c with 80 | | (CIdent "curl", None)::_ -> `Curl 81 | | (CString s, None)::_ 82 | when OpamStd.String.ends_with ~suffix:"curl" s -> `Curl 83 | | _ -> `Default 84 | in 85 | lazy (c, kind) 86 | ) 87 | >>+ fun () -> 88 | env_string "CURL" >>| (fun s -> 89 | lazy ([CString s, None], `Curl)) 90 | in 91 | let force_checksums = 92 | match env_bool "REQUIRECHECKSUMS", env_bool "NOCHECKSUMS" with 93 | | Some true, _ -> Some (Some true) 94 | | _, Some true -> Some (Some false) 95 | | None, None -> None 96 | | _ -> Some None 97 | in 98 | setk (setk (fun c -> r := c; k)) !r 99 | ?download_tool 100 | ?retries:(env_int "RETRIES") 101 | ?force_checksums 102 | 103 | let init ?noop:_ = initk (fun () -> ()) 104 | --------------------------------------------------------------------------------