summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2011-10-14 15:22:23 +0100
committerRichard W.M. Jones <rjones@redhat.com>2011-10-14 15:22:23 +0100
commit3b66c431e6b5477db8f5c186c14c16506a2df018 (patch)
tree983f97b5ed4354588390999c39356bd21f69c2f3
parent768f02b0855f605a82a9fca83f4c63cd9399cc60 (diff)
downloadfebootstrap-3b66c431e6b5477db8f5c186c14c16506a2df018.tar.gz
febootstrap-3b66c431e6b5477db8f5c186c14c16506a2df018.tar.xz
febootstrap-3b66c431e6b5477db8f5c186c14c16506a2df018.zip
debian: Don't always try to run dpkg-query command.
Delay calling this until after debian_detect() has been called and we've decided to use the Debian backend. Otherwise this breaks non-dpkg backends. This fixes commit b8cea4656e5bf1b9e7bb2274ef968ea42b10e0df.
-rw-r--r--src/febootstrap_debian.ml23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/febootstrap_debian.ml b/src/febootstrap_debian.ml
index 7482ed4..e7fcffd 100644
--- a/src/febootstrap_debian.ml
+++ b/src/febootstrap_debian.ml
@@ -1,5 +1,5 @@
(* febootstrap 3
- * Copyright (C) 2009-2010 Red Hat Inc.
+ * Copyright (C) 2009-2011 Red Hat Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -28,8 +28,18 @@ open Febootstrap_cmdline
(* Create a temporary directory for use by all the functions in this file. *)
let tmpdir = tmpdir ()
-let installed_pkgs =
- run_command_get_lines "dpkg-query --show --showformat='${Package}\\n'"
+let get_installed_pkgs =
+ let pkgs = ref None in
+ let rec f () =
+ match !pkgs with
+ | None ->
+ pkgs :=
+ Some (run_command_get_lines
+ "dpkg-query --show --showformat='${Package}\\n'");
+ f ()
+ | Some pkgs -> pkgs
+ in
+ f
let debian_detect () =
file_exists "/etc/debian_version" &&
@@ -55,7 +65,7 @@ let rec debian_resolve_dependencies_and_download names =
) pkgs in
let present_pkgs, download_pkgs = List.partition (
- fun pkg -> List.exists ((=) pkg) installed_pkgs
+ fun pkg -> List.exists ((=) pkg) (get_installed_pkgs ())
) pkgs in
debug "wanted packages (present / download): %s / %s\n"
@@ -182,14 +192,15 @@ let debian_list_files_installed pkg =
files
let debian_list_files ?(use_installed=false) pkg =
- if use_installed && List.exists ((=) pkg) installed_pkgs then
+ 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 =
- if use_installed && List.exists (fun p -> p = pkg) installed_pkgs then
+ if use_installed && List.exists (fun p -> p = pkg) (get_installed_pkgs ())
+ then
file
else
tmpdir // pkg ^ ".d" // file