Skip to content

Commit

Permalink
Display a warning if one of the base package is not installed
Browse files Browse the repository at this point in the history
  • Loading branch information
samoht committed Jan 14, 2013
1 parent 0fbc977 commit 97aa1f2
Showing 1 changed file with 38 additions and 24 deletions.
62 changes: 38 additions & 24 deletions src/client/opamState.ml
Original file line number Diff line number Diff line change
Expand Up @@ -351,10 +351,48 @@ let check_opam_version t =
OpamGlobals.exit 42
)

let get_compiler_packages t comp =
let comp = compiler t comp in
let available = OpamPackage.to_map (Lazy.force t.available_packages) in

let pkg_available, pkg_not =
List.partition
(fun (n, _) -> OpamPackage.Name.Map.mem n available)
(OpamFormula.atoms (OpamFile.Comp.packages comp)) in

(* check that all packages in [comp] are in [available] except for
"base-..." (depending if "-no-base-packages" is set or not) *)
let pkg_not = List.rev_map (function (n, _) -> n) pkg_not in
let pkg_not =
if not !OpamGlobals.no_base_packages then
pkg_not
else
List.filter (fun n -> not (List.mem n base_packages)) pkg_not in
if pkg_not <> [] then (
List.iter (OpamPackage.Name.to_string |> OpamGlobals.error "Package %s not found") pkg_not;
OpamGlobals.exit 1
);

pkg_available

let check_base_packages t =
let base_packages = get_compiler_packages t t.compiler in
let missing_packages =
List.filter
(fun (name,_) -> not (mem_installed_package_by_name t name))
base_packages in
if missing_packages <> [] then (
let names = List.map (fst |> OpamPackage.Name.to_string) missing_packages in
OpamGlobals.warning "Some of the compiler base packages are not installed. \
You should run:\n\n opam install %s\n\n"
(String.concat " " names)
)

(* Currently, only check that only installed packages have something
in $repo/tmp. This could be extended later on. *)
let consistency_checks t =
check_opam_version t;
check_base_packages t;
let clean repo_root nv =
let tmp_dir = OpamPath.Repository.tmp_dir repo_root nv in
if OpamFilename.exists_dir tmp_dir then (
Expand Down Expand Up @@ -682,30 +720,6 @@ let print_env_warning ?(add_profile = false) t =
opam_root
add_profile

let get_compiler_packages t comp =
let comp = compiler t comp in
let available = OpamPackage.to_map (Lazy.force t.available_packages) in

let pkg_available, pkg_not =
List.partition
(fun (n, _) -> OpamPackage.Name.Map.mem n available)
(OpamFormula.atoms (OpamFile.Comp.packages comp)) in

(* check that all packages in [comp] are in [available] except for
"base-..." (depending if "-no-base-packages" is set or not) *)
let pkg_not = List.rev_map (function (n, _) -> n) pkg_not in
let pkg_not =
if not !OpamGlobals.no_base_packages then
pkg_not
else
List.filter (fun n -> not (List.mem n base_packages)) pkg_not in
if pkg_not <> [] then (
List.iter (OpamPackage.Name.to_string |> OpamGlobals.error "Package %s not found") pkg_not;
OpamGlobals.exit 1
);

pkg_available

let add_switch root switch compiler =
log "add_switch switch=%s compiler=%s" (OpamSwitch.to_string switch) (OpamCompiler.to_string compiler);
let aliases_f = OpamPath.aliases root in
Expand Down

0 comments on commit 97aa1f2

Please sign in to comment.