From 59cd8a2660fd581a22202881da12f98f505effc6 Mon Sep 17 00:00:00 2001 From: Louis Gesbert Date: Mon, 31 Oct 2016 11:44:01 +0100 Subject: [PATCH 1/4] Make travis script more resilient Just wipe cache and retry with a clean opam init if the bootstrap install stage fails --- .travis-ci.sh | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/.travis-ci.sh b/.travis-ci.sh index 1456efbf67d..81cb1fa1eeb 100755 --- a/.travis-ci.sh +++ b/.travis-ci.sh @@ -6,6 +6,23 @@ PATH=~/local/bin:$PATH; export PATH TARGET="$1"; shift +# Install the build requirements into $OPAMBSROOT using the opam binary from the +# prepare step +install-bootstrap () { + opam init --root=$OPAMBSROOT --yes --no-setup --compiler=$OCAML_VERSION + eval $(opam config env --root=$OPAMBSROOT) + if [ "$OPAM_TEST" = "1" ]; then + opam install ocamlfind lwt.2.5.2 cohttp.0.20.2 ssl cmdliner dose3 jsonm opam-file-format --yes + # Allow use of ocamlfind packages in ~/local/lib + FINDCONF=$(ocamlfind printconf conf) + sed "s%^path=.*%path=\"$HOME/local/lib:$(opam config var lib)\"%" $FINDCONF >$FINDCONF.1 + mv $FINDCONF.1 $FINDCONF + else + opam install ocamlbuild --yes + fi + rm -f "$OPAMBSROOT"/log/* +} + case "$TARGET" in prepare) mkdir -p ~/local/bin @@ -16,20 +33,10 @@ case "$TARGET" in ;; install) # Note: this part is cached, and must be idempotent - if [ -d "$OPAMBSROOT" ]; then - opam update --root=$OPAMBSROOT - else - opam init --root=$OPAMBSROOT --yes --no-setup --compiler=$OCAML_VERSION - fi - eval $(opam config env --root=$OPAMBSROOT) - if [ "$OPAM_TEST" = "1" ]; then - opam install ocamlfind lwt.2.5.2 cohttp.0.20.2 ssl cmdliner dose3 jsonm opam-file-format --yes - # Allow use of ocamlfind packages in ~/local/lib - FINDCONF=$(ocamlfind printconf conf) - sed "s%^path=.*%path=\"$HOME/local/lib:$(opam config var lib)\"%" $FINDCONF >$FINDCONF.1 - mv $FINDCONF.1 $FINDCONF - else - opam install ocamlbuild --yes + # Re-init opam from scratch if the install fails + if [ -d $OPAMBSROOT ] + then install-bootstrap || { rm -rf $OPAMBSROOT; install-bootstrap; } + else install-bootstrap fi exit 0 ;; From 8b32c6158615683267e36c2ac636dbd9eb7a664d Mon Sep 17 00:00:00 2001 From: Louis Gesbert Date: Mon, 31 Oct 2016 15:35:47 +0100 Subject: [PATCH 2/4] Fix doc about openssl requirement --- doc/pages/Manual.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/pages/Manual.md b/doc/pages/Manual.md index a10f11de084..35e0fd4e91f 100644 --- a/doc/pages/Manual.md +++ b/doc/pages/Manual.md @@ -515,8 +515,8 @@ Additionally, the number of hexadecimal chars must match exactly what is expected by the corresponding algorithm (resp. 32, 64 and 128 for MD5, SHA256 and SHA512). -At the moment, use of SHA256 and SHA512 requires `openssl` to be installed on -the system. +If `openssl` is installed on the system, it will be used for faster computation +of SHA hashes. ## Specific file formats From 4feaee4a13f8698566bd8d2effd1ad33831a0a9f Mon Sep 17 00:00:00 2001 From: Louis Gesbert Date: Mon, 31 Oct 2016 15:36:08 +0100 Subject: [PATCH 3/4] Automatically list all versions of foo on 'opam list foo' --- src/client/opamMain.ml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/client/opamMain.ml b/src/client/opamMain.ml index 157dacf4999..74ab667f558 100644 --- a/src/client/opamMain.ml +++ b/src/client/opamMain.ml @@ -441,7 +441,9 @@ let list = the highest one available or the highest one). This flag disables this \ behaviour and shows all matching versions. This also changes the \ default display format to include package versions instead of just \ - package names (including when --short is set)." + package names (including when --short is set). This is automatically \ + turned on when a single non-pattern package name is provided on the \ + command-line." in let normalise = mk_flag ["normalise"] ~section:display_docs "Print the values of opam fields normalised" @@ -464,6 +466,14 @@ let list = let no_switch = no_switch || OpamStateConfig.(!r.current_switch) = None in + let all_versions = + all_versions || + state_selector = [] && match packages with + | [single] -> + (try ignore (OpamPackage.Name.of_string single); true + with Failure _ -> false) + | _ -> false + in let state_selector = if state_selector = [] then if no_switch then Empty From 4c4c281625e858daf21cff8008116106739a35ad Mon Sep 17 00:00:00 2001 From: Louis Gesbert Date: Mon, 31 Oct 2016 15:36:54 +0100 Subject: [PATCH 4/4] Fix "you can restore..." message after failure Don't advertise 'install --restore' when it won't be useful. --- src/state/opamSwitchState.ml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/state/opamSwitchState.ml b/src/state/opamSwitchState.ml index 3c1a07c49ea..9dd81a92f26 100644 --- a/src/state/opamSwitchState.ml +++ b/src/state/opamSwitchState.ml @@ -608,17 +608,23 @@ let do_backup lock st = match lock with | true -> OpamFilename.remove (OpamFile.filename file) | false -> (* Reload, in order to skip the message if there were no changes *) - if load_selections st.switch_global st.switch = previous_selections + let new_selections = load_selections st.switch_global st.switch in + if new_selections.sel_installed = previous_selections.sel_installed then OpamFilename.remove (OpamFile.filename file) else - prerr_string + OpamConsole.errmsg "%s" (OpamStd.Format.reformat (Printf.sprintf "\nThe former state can be restored with:\n\ - \ %s switch import %S\n\ - Or you can retry to install your package selection with:\n\ - \ %s install --restore\n%!" - Sys.argv.(0) (OpamFile.to_string file) Sys.argv.(0)))) + \ %s switch import %S\n" + Sys.argv.(0) (OpamFile.to_string file) ^ + if OpamPackage.Set.is_empty + (new_selections.sel_roots -- new_selections.sel_installed) + then "" else + Printf.sprintf + "Or you can retry to install your package selection with:\n\ + \ %s install --restore\n" + Sys.argv.(0)))) | _ -> fun _ -> () let with_ lock ?rt ?(switch=OpamStateConfig.get_switch ()) gt f =