Skip to content

Commit

Permalink
Merge pull request #2737 from OCamlPro/bla
Browse files Browse the repository at this point in the history
List all versions on 'opam list foo', etc.
  • Loading branch information
AltGr committed Nov 3, 2016
2 parents 6a12623 + 4c4c281 commit 86b1a77
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 23 deletions.
35 changes: 21 additions & 14 deletions .travis-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
;;
Expand Down
4 changes: 2 additions & 2 deletions doc/pages/Manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 11 additions & 1 deletion src/client/opamMain.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
18 changes: 12 additions & 6 deletions src/state/opamSwitchState.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down

0 comments on commit 86b1a77

Please sign in to comment.