Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bits 'n bobs #3900

Merged
merged 5 commits into from
Jul 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ opam-installer: $(DUNE_DEP)
$(LN_S) -f _build/default/src/tools/opam_installer.exe $@$(EXE)

opam-admin.top: $(DUNE_DEP)
$(DUNE) build --profile=$(DUNE_PROFILE) $(DUNE_ARGS) src/tools/opam_admin_top.bc
$(LN_S) -f _build/default/src/tools/opam_admin_top.bc $@$(EXE)
$(DUNE) build --profile=$(DUNE_PROFILE) $(DUNE_ARGS) src/tools/opam_admin_topstart.bc
$(LN_S) -f _build/default/src/tools/opam_admin_topstart.bc $@$(EXE)

lib-ext:
$(MAKE) -j -C src_ext lib-ext
Expand Down
9 changes: 8 additions & 1 deletion admin-scripts/compilers-to-packages.ml
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,15 @@ OpamStd.String.Map.iter (fun c comp_file ->
in
OpamFilename.with_tmp_dir_job @@ fun dir ->
try
(* Download to package.patch, rather than allowing the name to be
guessed since, on Windows, some of the characters which are
valid in URLs are not valid in filenames *)
let f =
let base = OpamFilename.Base.of_string "package.patch" in
OpamFilename.create dir base
in
OpamProcess.Job.catch err
(OpamDownload.download ~overwrite:false url dir @@| fun f ->
(OpamDownload.download_as ~overwrite:false url f @@| fun () ->
Some (url, OpamFilename.digest f, None))
with e -> err e)
(OpamFile.Comp.patches comp)
Expand Down
9 changes: 8 additions & 1 deletion src/client/opamAdminRepoUpgrade.ml
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,14 @@ let do_upgrade repo_root =
OpamFilename.with_tmp_dir_job @@ fun dir ->
OpamProcess.Job.ignore_errors ~default:None
(fun () ->
OpamDownload.download ~overwrite:false url dir @@| fun f ->
(* Download to package.patch, rather than allowing the name to be
guessed since, on Windows, some of the characters which are
valid in URLs are not valid in filenames *)
let f =
let base = OpamFilename.Base.of_string "package.patch" in
OpamFilename.create dir base
in
OpamDownload.download_as ~overwrite:false url f @@| fun () ->
let hash = OpamHash.compute (OpamFilename.to_string f) in
Hashtbl.add url_md5 url hash;
Some hash)),
Expand Down
6 changes: 6 additions & 0 deletions src/client/opamInitDefaults.ml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ let default_compiler =
let eval_variables = [
OpamVariable.of_string "sys-ocaml-version", ["ocamlc"; "-vnum"],
"OCaml version present on your system independently of opam, if any";
OpamVariable.of_string "sys-ocaml-arch", ["sh"; "-c"; "ocamlc -config | tr -d '\\r' | grep '^architecture: ' | sed -e 's/.*: //' -e 's/i386/i686/' -e 's/amd64/x86_64/'"],
"Target architecture of the OCaml compiler present on your system";
OpamVariable.of_string "sys-ocaml-cc", ["sh"; "-c"; "ocamlc -config | tr -d '\\r' | grep '^ccomp_type: ' | sed -e 's/.*: //'"],
"Host C Compiler type of the OCaml compiler present on your system";
OpamVariable.of_string "sys-ocaml-libc", ["sh"; "-c"; "ocamlc -config | tr -d '\\r' | grep '^os_type: ' | sed -e 's/.*: //' -e 's/Win32/msvc/' -e '/^msvc$/!s/.*/libc/'"],
"Host C Runtime Library type of the OCaml compiler present on your system";
]

let os_filter os =
Expand Down
9 changes: 5 additions & 4 deletions src/state/opamFormatUpgrade.ml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ let upgrade_depexts_to_2_0_beta5 filename depexts =
None)
depexts

let v2_0 = OpamVersion.of_string "2.0"

let opam_file_from_1_2_to_2_0 ?filename opam =
let ocaml_pkgname = OpamPackage.Name.of_string "ocaml" in

Expand Down Expand Up @@ -160,7 +162,8 @@ let opam_file_from_1_2_to_2_0 ?filename opam =
aux available
in
let pkg_deps =
if NMap.mem ocaml_wrapper_pkgname pkg_deps ||
if OpamVersion.compare (OpamFile.OPAM.opam_version opam) v2_0 >= 0 ||
NMap.mem ocaml_wrapper_pkgname pkg_deps ||
OpamFile.OPAM.has_flag Pkgflag_Conf opam
then pkg_deps
else NMap.add ocaml_wrapper_pkgname Empty pkg_deps
Expand Down Expand Up @@ -329,7 +332,7 @@ let opam_file_from_1_2_to_2_0 ?filename opam =
| ft -> ft)
in
opam |>
OpamFile.OPAM.with_opam_version (OpamVersion.of_string "2.0") |>
OpamFile.OPAM.with_opam_version v2_0 |>
OpamFile.OPAM.with_depends depends |>
OpamFile.OPAM.with_depopts depopts |>
OpamFile.OPAM.with_conflicts conflicts |>
Expand Down Expand Up @@ -1039,8 +1042,6 @@ let from_2_0_beta_to_2_0_beta5 root conf =
(OpamFile.Config.eval_variables conf))
conf

let v2_0 = OpamVersion.of_string "2.0"

let from_2_0_beta5_to_2_0 _ conf = conf

let v2_1 = OpamVersion.of_string "2.1"
Expand Down
2 changes: 2 additions & 0 deletions src/state/opamPackageVar.ml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ let global_variable_names = [
configuration";
"root", "The current opam root directory";
"make", "The 'make' command to use";
"exe", "Suffix needed for executable filenames (Windows)";
]

let package_variable_names = [
Expand Down Expand Up @@ -67,6 +68,7 @@ let resolve_global gt full_var =
| "jobs" -> Some (V.int (OpamStateConfig.(Lazy.force !r.jobs)))
| "root" -> Some (V.string (OpamFilename.Dir.to_string gt.root))
| "make" -> Some (V.string OpamStateConfig.(Lazy.force !r.makecmd))
| "exe" -> Some (V.string (OpamStd.Sys.executable_name ""))
| _ -> None

(** Resolve switch-global variables only, as allowed by the 'available:'
Expand Down
22 changes: 15 additions & 7 deletions src/tools/dune
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
(executable
(library
(name opam_admin_top)
(public_name opam-admin.top)
(synopsis "OCaml Package Manager admin toplevel")
(modules opam_admin_top)
(libraries opam-client opam-file-format compiler-libs.toplevel re)
(wrapped false))

(executable
(name opam_admin_topstart)
(public_name opam-admin.top)
(package opam-admin)
(modes byte)
(modules opam_admin_topstart)
(libraries opam-admin.top)
(ocamlc_flags (:standard
(:include ../ocaml-flags-standard.sexp)
(:include ../ocaml-flags-configure.sexp)
(:include ../ocaml-context-flags.sexp)
-linkall))
(libraries opam-client opam-file-format compiler-libs.toplevel re))
-linkall)))

(install
(section bin)
(package opam-admin)
(files (opam_admin_top.bc as opam-admin.top)))
(rule (with-stdout-to opam_admin_topstart.ml (echo "include Opam_admin_top\n\nlet _ = Topmain.main ()")))

(executable
(name opam_check)
Expand Down
2 changes: 0 additions & 2 deletions src/tools/opam_admin_top.ml
Original file line number Diff line number Diff line change
Expand Up @@ -128,5 +128,3 @@ let filter fn patterns =
List.exists (fun re -> OpamStd.String.exact_match re str) regexps

let filter_packages = filter OpamPackage.to_string

let _ = Topmain.main ()