summaryrefslogtreecommitdiffstats
path: root/src/febootstrap_yum_rpm.ml
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2011-10-18 14:07:33 +0100
committerRichard W.M. Jones <rjones@redhat.com>2011-10-18 14:07:33 +0100
commit2b1631439dc8dc4c6b8d7d78a5f3a5b2c08d83fd (patch)
treeb1c721756eca38c7d9cb7f7ab72b14172c6e1087 /src/febootstrap_yum_rpm.ml
parent3b66c431e6b5477db8f5c186c14c16506a2df018 (diff)
downloadfebootstrap-2b1631439dc8dc4c6b8d7d78a5f3a5b2c08d83fd.tar.gz
febootstrap-2b1631439dc8dc4c6b8d7d78a5f3a5b2c08d83fd.tar.xz
febootstrap-2b1631439dc8dc4c6b8d7d78a5f3a5b2c08d83fd.zip
Don't pass use_installed to every package handler function.
use_installed is a global variable (defined in febootstrap_cmdline.mli) so there's not much point in passing it around to every function that needs it. This commit removes the optional argument in favour of just using the global variable in each package handler. However we still need a place where we can bail if the --use-installed flag is used for package handlers which don't support this yet. Thus add a ph_init function is called after the right package handler has been detected but before it is used. This is a convenient place to put the --use-installed checking and any other initialization that is required.
Diffstat (limited to 'src/febootstrap_yum_rpm.ml')
-rw-r--r--src/febootstrap_yum_rpm.ml15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/febootstrap_yum_rpm.ml b/src/febootstrap_yum_rpm.ml
index 815c5ba..bfda11e 100644
--- a/src/febootstrap_yum_rpm.ml
+++ b/src/febootstrap_yum_rpm.ml
@@ -32,6 +32,10 @@ let yum_rpm_detect () =
(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
@@ -172,10 +176,7 @@ if verbose:
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"
@@ -231,10 +232,7 @@ let rec yum_rpm_list_files ?(use_installed=false) pkg =
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
@@ -247,6 +245,7 @@ let yum_rpm_get_file_from_package ?(use_installed=false) pkg file =
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;