Skip to content

Commit

Permalink
Merge pull request ocaml#3289 from OCamlPro/fixes
Browse files Browse the repository at this point in the history
A few fixes (install script, better messages, avoid unnecessary copy)
  • Loading branch information
AltGr authored Apr 13, 2018
2 parents 4dda03b + 9234554 commit 244e3f2
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 47 deletions.
6 changes: 4 additions & 2 deletions shell/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,17 @@ fi

FRESH=${FRESH:-0}

OPAMROOT=${OPAMROOT:-$HOME/.opam}

if [ ! -d "$OPAMROOT" ]; then FRESH=1; fi

if [ -z "$NOBACKUP" ] && [ ! "$FRESH" = 1 ] && [ -z "$RESTORE" ]; then
case "$EXISTING_OPAMV" in
2.*) NOBACKUP=1;;
*) NOBACKUP=0;;
esac
fi

OPAMROOT=${OPAMROOT:-$HOME/.opam}

xsudo() {
local CMD=$1; shift
local DST
Expand Down
11 changes: 8 additions & 3 deletions src/client/opamCommands.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1636,10 +1636,15 @@ let repository =
(update_repos name)
in
if scope = [`Current_switch] then
OpamConsole.msg
"Repository %s has been added to the selections of switch %s.\n"
OpamConsole.note
"Repository %s has been added to the selections of switch %s \
only.\n\
Run `opam repository add %s --all-switches|--set-default' to use it \
in all existing switches, or in newly created switches, \
respectively.\n"
(OpamRepositoryName.to_string name)
(OpamSwitch.to_string (OpamStateConfig.get_switch ()));
(OpamSwitch.to_string (OpamStateConfig.get_switch ()))
(OpamRepositoryName.to_string name);
`Ok ()
| Some `remove, names ->
let names = List.map OpamRepositoryName.of_string names in
Expand Down
9 changes: 5 additions & 4 deletions src/client/opamSolution.ml
Original file line number Diff line number Diff line change
Expand Up @@ -450,13 +450,13 @@ let parallel_apply t _action ~requested ?add_roots action_graph =
else
match action with
| `Build nv ->
let build_dir =
try OpamPackage.Map.find nv inplace
let is_inplace, build_dir =
try true, OpamPackage.Map.find nv inplace
with Not_found ->
let dir = OpamPath.Switch.build t.switch_global.root t.switch nv in
if not OpamClientConfig.(!r.reuse_build_dir) then
OpamFilename.rmdir dir;
dir
false, dir
in
let test =
OpamStateConfig.(!r.build_test) && OpamPackage.Set.mem nv requested
Expand All @@ -465,7 +465,8 @@ let parallel_apply t _action ~requested ?add_roots action_graph =
OpamStateConfig.(!r.build_doc) && OpamPackage.Set.mem nv requested
in
(if OpamFilename.exists_dir source_dir
then OpamFilename.copy_dir ~src:source_dir ~dst:build_dir
then (if not is_inplace then
OpamFilename.copy_dir ~src:source_dir ~dst:build_dir)
else OpamFilename.mkdir build_dir;
OpamAction.prepare_package_source t nv build_dir @@+ function
| Some exn -> store_time (); Done (`Exception exn)
Expand Down
22 changes: 0 additions & 22 deletions src/format/opamFormula.ml
Original file line number Diff line number Diff line change
Expand Up @@ -528,25 +528,3 @@ let simplify_version_set set f =
let set = fold_left (fun set (_relop, v) -> S.add v set) set f in
gen_formula (S.elements set) (check_version_formula f) |>
OpamStd.Option.default f

type 'a ext_package_formula =
(OpamPackage.Name.t * ('a * version_formula)) formula

let formula_of_extended ~filter =
map (fun (n, (kws,formula)) -> if filter kws then Atom (n, formula) else Empty)

let reduce_extended ~filter =
map (fun (n, (kws, formula)) ->
let kws =
List.fold_left (fun acc kw ->
match acc with
| None -> None
| Some kws -> match filter kw with
| Some true -> acc
| Some false -> None
| None -> Some (kw::kws))
(Some []) (List.rev kws)
in
match kws with
| None -> Empty
| Some kws -> Atom (n, (kws, formula)))
16 changes: 0 additions & 16 deletions src/format/opamFormula.mli
Original file line number Diff line number Diff line change
Expand Up @@ -210,19 +210,3 @@ val to_cnf: t -> atom cnf

(** Return an equivalent DNF formula *)
val to_dnf: t -> atom dnf

(** Formula over versionned packages with additional flags (used to handle
eg. build-deps) *)
type 'a ext_package_formula =
(OpamPackage.Name.t * ('a * version_formula)) formula

(** Turns an extended package formula to a normal formula, by filtering out
the packages on the flags of which [filter] returns [false]. *)
val formula_of_extended: filter:('a -> bool) -> 'a ext_package_formula -> t

(** Partially evaluates extended formula flags, removing the atom if it has a
flag on which [filter] is [Some false], and removing flags on which [filter]
is [Some true] *)
val reduce_extended:
filter:('a -> bool option) -> ('a list) ext_package_formula ->
('a list) ext_package_formula

0 comments on commit 244e3f2

Please sign in to comment.