--- src/febootstrap.ml | 4 ++-- src/febootstrap_cmdline.ml | 4 ++++ src/febootstrap_cmdline.mli | 3 +++ src/febootstrap_debian.ml | 8 ++++---- src/febootstrap_package_handlers.ml | 4 ++-- src/febootstrap_package_handlers.mli | 4 ++-- src/febootstrap_pacman.ml | 6 ++++-- src/febootstrap_yum_rpm.ml | 5 +++-- 8 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/febootstrap.ml b/src/febootstrap.ml index 7e48206..9b7dc88 100644 --- a/src/febootstrap.ml +++ b/src/febootstrap.ml @@ -67,7 +67,7 @@ let () = List.flatten ( List.map ( fun pkg -> - let files = ph.ph_list_files pkg in + let files = (ph.ph_list_files ~use_installed:use_installed pkg) in List.map (fun (filename, ft) -> filename, ft, pkg) files ) packages ) in @@ -320,7 +320,7 @@ let () = * original file from the package. *) else if config then ( - let outfile = ph.ph_get_file_from_package pkg path in + let outfile = ph.ph_get_file_from_package ~use_installed:use_installed pkg path in (* Note that the output config file might not be a regular file. *) let statbuf = lstat outfile in diff --git a/src/febootstrap_cmdline.ml b/src/febootstrap_cmdline.ml index 667e297..939afb7 100644 --- a/src/febootstrap_cmdline.ml +++ b/src/febootstrap_cmdline.ml @@ -23,6 +23,7 @@ let names_mode = ref false let outputdir = ref "." let packages = ref [] let save_temps = ref false +let use_installed = ref false let verbose = ref false let warnings = ref true let yum_config = ref None @@ -50,6 +51,8 @@ let argspec = Arg.align [ " Don't delete temporary files and directories on exit."; "--save-temps", Arg.Set save_temps, " Don't delete temporary files and directories on exit."; + "--use-installed", Arg.Set use_installed, + " Inspect installed packages for determining contents."; "-v", Arg.Set verbose, " Enable verbose output"; "--verbose", Arg.Set verbose, @@ -89,6 +92,7 @@ let names_mode = !names_mode let outputdir = !outputdir let packages = List.rev !packages let save_temps = !save_temps +let use_installed = !use_installed let verbose = !verbose let warnings = !warnings let yum_config = !yum_config diff --git a/src/febootstrap_cmdline.mli b/src/febootstrap_cmdline.mli index d948d80..a545012 100644 --- a/src/febootstrap_cmdline.mli +++ b/src/febootstrap_cmdline.mli @@ -38,6 +38,9 @@ val packages : string list val save_temps : bool (** True if [--save-temps] was given on the command line. *) +val use_installed : bool + (** True if [--use-installed] was given on the command line *) + val verbose : bool (** True if [--verbose] was given on the command line. See also {!debug}. *) diff --git a/src/febootstrap_debian.ml b/src/febootstrap_debian.ml index bb10f15..7482ed4 100644 --- a/src/febootstrap_debian.ml +++ b/src/febootstrap_debian.ml @@ -181,15 +181,15 @@ let debian_list_files_installed pkg = ) lines in files -let debian_list_files pkg = - if List.exists ((=) pkg) installed_pkgs then +let debian_list_files ?(use_installed=false) pkg = + if use_installed && List.exists ((=) pkg) 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 pkg file = - if List.exists (fun p -> p = pkg) installed_pkgs then +let debian_get_file_from_package ?(use_installed=false) pkg file = + if use_installed && List.exists (fun p -> p = pkg) installed_pkgs then file else tmpdir // pkg ^ ".d" // file diff --git a/src/febootstrap_package_handlers.ml b/src/febootstrap_package_handlers.ml index ad3a233..f627d2f 100644 --- a/src/febootstrap_package_handlers.ml +++ b/src/febootstrap_package_handlers.ml @@ -25,8 +25,8 @@ open Febootstrap_cmdline type package_handler = { ph_detect : unit -> bool; ph_resolve_dependencies_and_download : string list -> string list; - ph_list_files : string -> (string * file_type) list; - ph_get_file_from_package : string -> string -> string + ph_list_files : ?use_installed:bool -> string -> (string * file_type) list; + ph_get_file_from_package : ?use_installed:bool -> string -> string -> string } and file_type = { ft_dir : bool; diff --git a/src/febootstrap_package_handlers.mli b/src/febootstrap_package_handlers.mli index c28d81f..ebf0386 100644 --- a/src/febootstrap_package_handlers.mli +++ b/src/febootstrap_package_handlers.mli @@ -31,11 +31,11 @@ type package_handler = { Note this should also process the [excludes] list. *) - ph_list_files : string -> (string * file_type) list; + ph_list_files : ?use_installed:bool -> 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 : string -> string -> string; + ph_get_file_from_package : ?use_installed:bool -> 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. *) diff --git a/src/febootstrap_pacman.ml b/src/febootstrap_pacman.ml index 6691ebe..002ea6d 100644 --- a/src/febootstrap_pacman.ml +++ b/src/febootstrap_pacman.ml @@ -71,7 +71,8 @@ let pacman_resolve_dependencies_and_download names = List.sort compare pkgs -let pacman_list_files pkg = +(* fixme: use_installed *) +let pacman_list_files ?(use_installed=false) pkg = debug "unpacking %s ..." pkg; (* We actually need to extract the file in order to get the @@ -117,7 +118,8 @@ let pacman_list_files pkg = files (* Easy because we already unpacked the archive above. *) -let pacman_get_file_from_package pkg file = +(* fixme: use_installed *) +let pacman_get_file_from_package ?(use_installed=false) pkg file = tmpdir // pkg ^ ".d" // file let () = diff --git a/src/febootstrap_yum_rpm.ml b/src/febootstrap_yum_rpm.ml index 028492a..d208e8e 100644 --- a/src/febootstrap_yum_rpm.ml +++ b/src/febootstrap_yum_rpm.ml @@ -172,7 +172,7 @@ if verbose: sprintf "%s/%s-%s-%s.%s.rpm" tmpdir name version release arch ) pkgs -let rec yum_rpm_list_files pkg = +let rec yum_rpm_list_files ?(use_installed=false) pkg = (* Run rpm -qlp with some extra magic. *) let cmd = sprintf "rpm -q --qf '[%%{FILENAMES} %%{FILEFLAGS:fflags} %%{FILEMODES} %%{FILESIZES}\\n]' -p %s" @@ -228,7 +228,8 @@ let rec yum_rpm_list_files pkg = files -let yum_rpm_get_file_from_package pkg file = +(* fixme use_installed *) +let yum_rpm_get_file_from_package ?(use_installed=false) pkg file = debug "extracting %s from %s ..." file (Filename.basename pkg); let outfile = tmpdir // file in -- 1.7.6.3