let inject_debcheck_data =
  let rex = Pcre.regexp "^  package: (.*)$" in
  fun (bins : [`binary] Package.t PAMap.t)  architectures ->
    let a, b = if !Benl_clflags.quiet then ("\n"""else ("""\n"in
    let all_uninstallable_packages = List.map (fun arch_ref ->
      Benl_clflags.progress "Running dose-debcheck on %s..." arch_ref;
      let (ic, oc) as p = Unix.open_process "dose-debcheck --quiet --failures" in
      (* inefficiency: for each architecture, we iterate on all binary
         packages, not only on binary packages of said architectures *)

      PAMap.iter (fun (name, arch) pkg ->
        if arch = arch_ref then Package.print oc pkg
      ) bins;
      close_out oc;
      let rec loop accu =
        begin match (try Some (input_line ic) with End_of_file -> Nonewith
          | None ->
            if Package.Set.is_empty accu then
              Printf.eprintf "W: no uninstallable packages!\n%!";
            accu
          | Some line ->
            try
              let r = Pcre.exec ~rex line in
              let package = Pcre.get_substring r 1 in
              loop (Package.Set.add (Package.Name.of_string package) accu)
            with Not_found -> loop accu
        end
      in
      let result = loop Package.Set.empty in
      begin match Unix.close_process p with
        | Unix.WEXITED (0|1) -> ()
        | Unix.WEXITED i ->
          Printf.eprintf
            "%sW: subprocess dose-debcheck exited with code %d%s%!" a i b
        | Unix.WSIGNALED i ->
          Printf.eprintf
            "%sW: subprocess dose-debcheck died with signal %d%s%!" a i b
        | Unix.WSTOPPED i ->
          Printf.eprintf
            "%sW: subprocess dose-debcheck stopped with signal %d%s%!" a i b
      end;
      Benl_clflags.progress "\n";
      (arch_ref, result)
    ) architectures in
    PAMap.mapi (fun (name, arch) pkg ->
      let uninstallable_packages = List.assoc arch all_uninstallable_packages in
      if Package.Set.mem name uninstallable_packages
      then
        (* the following line is for compatibility only and should be
           removed eventually *)

        let pkg = Package.add "edos-debcheck" "uninstallable" pkg in
        Package.add "uninstallable" "yes" pkg
      else pkg
    ) bins