let pkgcheck callback solver failed tested id =
  let memo (tested,failed) res = 
    begin
      match res with
      |Diagnostic_int.Success(f_int) ->
          List.iter (fun i -> Array.unsafe_set tested i true) (f_int ())
      |Diagnostic_int.Failure _  -> incr failed
    end ; res
  in
  let req = Diagnostic_int.Sng id in
  let res =
    Util.Progress.progress progressbar_univcheck;
    if not(tested.(id)) then begin
      memo (tested,failed) (solve solver req)
    end
    else begin
      (* this branch is true only if the package was previously
       * added to the tested packages and therefore it is installable *)

      (* if all = true then the solver is called again to provide the list
       * of installed packages despite the fact the the package was already
       * tested. This is done to provide one installation set for each package
       * in the universe *)

      let f ?(all=false) () =
        if all then begin
          match solve solver req with
          |Diagnostic_int.Success(f_int) -> f_int ()
          |Diagnostic_int.Failure _ -> assert false (* impossible *)
        end else []
      in Diagnostic_int.Success(f) 
    end
  in
  match callback with
  |None -> ()
  |Some f -> f (res,req)