List.flatten (
List.map (
fun pkg ->
- let files = ph.ph_list_files ~use_installed pkg in
+ let files = ph.ph_list_files pkg in
List.map (fun (filename, ft) -> filename, ft, pkg) files
) packages
) in
* original file from the package.
*)
else if config then (
- let outfile = ph.ph_get_file_from_package ~use_installed pkg path in
+ let outfile = ph.ph_get_file_from_package pkg path in
(* Note that the output config file might not be a regular file. *)
let statbuf = lstat outfile in
file_exists "/etc/debian_version" &&
Config.aptitude <> "no" && Config.apt_cache <> "no" && Config.dpkg <> "no"
+let debian_init () =
+ ()
+
let rec debian_resolve_dependencies_and_download names =
let cmd =
sprintf "%s depends --recurse -i %s | grep -v '^[<[:space:]]'"
) lines in
files
-let debian_list_files ?(use_installed=false) pkg =
+let debian_list_files pkg =
if use_installed && List.exists ((=) pkg) (get_installed_pkgs ()) then
debian_list_files_installed pkg
else
debian_list_files_downloaded pkg
(* Easy because we already unpacked the archive above. *)
-let debian_get_file_from_package ?(use_installed=false) pkg file =
+let debian_get_file_from_package pkg file =
if use_installed && List.exists (fun p -> p = pkg) (get_installed_pkgs ())
then
file
let () =
let ph = {
ph_detect = debian_detect;
+ ph_init = debian_init;
ph_resolve_dependencies_and_download =
debian_resolve_dependencies_and_download;
ph_list_files = debian_list_files;
type package_handler = {
ph_detect : unit -> bool;
+ ph_init : unit -> unit;
ph_resolve_dependencies_and_download : string list -> string list;
- ph_list_files : ?use_installed:bool -> string -> (string * file_type) list;
- ph_get_file_from_package : ?use_installed:bool -> string -> string -> string
+ ph_list_files : string -> (string * file_type) list;
+ ph_get_file_from_package : string -> string -> string
}
and file_type = {
ft_dir : bool;
let handler = ref None
-let check_system () =
+let rec check_system () =
try
handler := Some (
List.find (
fun (_, ph) ->
ph.ph_detect ()
) !handlers
- )
+ );
+ (get_package_handler ()).ph_init ()
with Not_found ->
eprintf "\
febootstrap: could not detect package manager used by this system or distro.
";
exit 1
-let rec get_package_handler () =
+and get_package_handler () =
match !handler with
| Some (_, ph) -> ph
| None ->
check_system ();
get_package_handler ()
-let rec get_package_handler_name () =
+and get_package_handler_name () =
match !handler with
| Some (name, _) -> name
| None ->
type package_handler = {
ph_detect : unit -> bool;
- (** Detect if the current system uses this package manager. *)
+ (** Detect if the current system uses this package manager. This is
+ called in turn on each package handler, until one returns [true]. *)
+
+ ph_init : unit -> unit;
+ (** After a package handler is selected, this function is called
+ which can optionally do any initialization that is required.
+ This is only called on the package handler if it has returned
+ [true] from {!ph_detect}. *)
ph_resolve_dependencies_and_download : string list -> string list;
(** [ph_resolve_dependencies_and_download pkgs]
Note this should also process the [excludes] list. *)
- ph_list_files : ?use_installed:bool -> string -> (string * file_type) list;
+ ph_list_files : string -> (string * file_type) list;
(** [ph_list_files pkg] lists the files and file metadata in the
package called [pkg] (a package file). *)
- ph_get_file_from_package : ?use_installed:bool -> string -> string -> string;
+ ph_get_file_from_package : string -> string -> string;
(** [ph_get_file_from_package pkg file] extracts the
single named file [file] from [pkg]. The path of the
extracted file is returned. *)
file_exists "/etc/arch-release" &&
Config.pacman <> "no"
+let pacman_init () =
+ if use_installed then
+ failwith "pacman driver doesn't support --use-installed"
+
let pacman_resolve_dependencies_and_download names =
let cmd =
sprintf "(for p in %s; do pactree -u $p; done) | awk '{print $1}' | sort -u"
List.sort compare pkgs
-let pacman_list_files ?(use_installed=false) pkg =
- if use_installed then
- failwith "pacman driver doesn't support --use-installed";
-
+let pacman_list_files pkg =
debug "unpacking %s ..." pkg;
(* We actually need to extract the file in order to get the
files
(* Easy because we already unpacked the archive above. *)
-let pacman_get_file_from_package ?(use_installed=false) pkg file =
- if use_installed then
- failwith "pacman driver doesn't support --use-installed";
-
+let pacman_get_file_from_package pkg file =
tmpdir // pkg ^ ".d" // file
let () =
let ph = {
ph_detect = pacman_detect;
+ ph_init = pacman_init;
ph_resolve_dependencies_and_download =
pacman_resolve_dependencies_and_download;
ph_list_files = pacman_list_files;
(file_exists "/etc/redhat-release" || file_exists "/etc/fedora-release") &&
Config.yum <> "no" && Config.rpm <> "no"
+let yum_rpm_init () =
+ if use_installed then
+ failwith "yum_rpm driver doesn't support --use-installed"
+
let yum_rpm_resolve_dependencies_and_download names =
(* Liberate this data from python. *)
let tmpfile = tmpdir // "names.tmp" in
sprintf "%s/%s-%s-%s.%s.rpm" tmpdir name version release arch
) pkgs
-let rec yum_rpm_list_files ?(use_installed=false) pkg =
- if use_installed then
- failwith "yum_rpm driver doesn't support --use-installed";
-
+let rec yum_rpm_list_files pkg =
(* Run rpm -qlp with some extra magic. *)
let cmd =
sprintf "rpm -q --qf '[%%{FILENAMES} %%{FILEFLAGS:fflags} %%{FILEMODES} %%{FILESIZES}\\n]' -p %s"
files
-let yum_rpm_get_file_from_package ?(use_installed=false) pkg file =
- if use_installed then
- failwith "yum_rpm driver doesn't support --use-installed";
-
+let yum_rpm_get_file_from_package pkg file =
debug "extracting %s from %s ..." file (Filename.basename pkg);
let outfile = tmpdir // file in
let () =
let ph = {
ph_detect = yum_rpm_detect;
+ ph_init = yum_rpm_init;
ph_resolve_dependencies_and_download =
yum_rpm_resolve_dependencies_and_download;
ph_list_files = yum_rpm_list_files;