summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2011-09-01 10:43:46 +0100
committerRichard W.M. Jones <rjones@redhat.com>2011-09-01 10:43:46 +0100
commit3ac623701e5fe5ce94b22b4f40f72ee0161d5184 (patch)
tree4df7817e5aebda099838c1e9298012dc57003e5a
parent72101b100aa33b0b9879f9b18edfdd88c1aa2755 (diff)
downloadfebootstrap-3ac623701e5fe5ce94b22b4f40f72ee0161d5184.tar.gz
febootstrap-3ac623701e5fe5ce94b22b4f40f72ee0161d5184.tar.xz
febootstrap-3ac623701e5fe5ce94b22b4f40f72ee0161d5184.zip
debian: Include workaround for broken apt-cache depends --recurse.
Ubuntu 10.04 LTS has a broken apt-cache depends --recurse command which does not in fact recurse deeply enough to find all dependencies (this is fixed in Ubuntu 11.04). Include a workaround for this so we can use febootstrap on old Ubuntu versions.
-rw-r--r--config.ml.in1
-rw-r--r--configure.ac13
-rw-r--r--febootstrap_debian.ml30
3 files changed, 43 insertions, 1 deletions
diff --git a/config.ml.in b/config.ml.in
index fc8fbfe..26a8e3d 100644
--- a/config.ml.in
+++ b/config.ml.in
@@ -25,5 +25,6 @@ let yumdownloader = "@YUMDOWNLOADER@"
let aptitude = "@APTITUDE@"
let apt_cache = "@APT_CACHE@"
let dpkg = "@DPKG@"
+let apt_cache_depends_recurse_broken = @APT_CACHE_DEPENDS_RECURSE_BROKEN@
let pacman = "@PACMAN@"
let host_cpu = "@host_cpu@"
diff --git a/configure.ac b/configure.ac
index 6f0cdc7..0096a6f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -65,6 +65,19 @@ AC_CHECK_PROG(APTITUDE,[aptitude],[aptitude],[no])
AC_CHECK_PROG(APT_CACHE,[apt-cache],[apt-cache],[no])
AC_CHECK_PROG(DPKG,[dpkg],[dpkg],[no])
+dnl Include workaround for broken apt-cache depends --recurse (Ubuntu 10.04)?
+if test "x$APT_CACHE" != "xno"; then
+ AC_MSG_CHECKING([if apt-cache depends --recurse is broken])
+ if ! $APT_CACHE depends --recurse -i bash | grep -q '^libc6$'; then
+ AC_MSG_RESULT([yes])
+ APT_CACHE_DEPENDS_RECURSE_BROKEN=true
+ else
+ AC_MSG_RESULT([no])
+ APT_CACHE_DEPENDS_RECURSE_BROKEN=false
+ fi
+ AC_SUBST([APT_CACHE_DEPENDS_RECURSE_BROKEN])
+fi
+
dnl For ArchLinux handler.
AC_CHECK_PROG(PACMAN,[pacman],[pacman],[no])
diff --git a/febootstrap_debian.ml b/febootstrap_debian.ml
index f26df4a..23f3593 100644
--- a/febootstrap_debian.ml
+++ b/febootstrap_debian.ml
@@ -32,12 +32,17 @@ let debian_detect () =
file_exists "/etc/debian_version" &&
Config.aptitude <> "no" && Config.apt_cache <> "no" && Config.dpkg <> "no"
-let debian_resolve_dependencies_and_download names =
+let rec debian_resolve_dependencies_and_download names =
let cmd =
sprintf "%s depends --recurse -i %s | grep -v '^[<[:space:]]'"
Config.apt_cache
(String.concat " " (List.map Filename.quote names)) in
let pkgs = run_command_get_lines cmd in
+ let pkgs =
+ if Config.apt_cache_depends_recurse_broken then
+ workaround_broken_apt_cache_depends_recurse (sort_uniq pkgs)
+ else
+ pkgs in
(* Exclude packages matching [--exclude] regexps on the command line. *)
let pkgs =
@@ -78,6 +83,29 @@ let debian_resolve_dependencies_and_download names =
List.sort compare pkgs
+(* On Ubuntu 10.04 LTS, apt-cache depends --recurse is broken. It
+ * doesn't return the full list of dependencies. Therefore recurse
+ * into these dependencies one by one until we reach a fixpoint.
+ *)
+and workaround_broken_apt_cache_depends_recurse names =
+ debug "workaround for broken 'apt-cache depends --recurse' command:\n %s"
+ (String.concat " " names);
+
+ let names' =
+ List.map (
+ fun name ->
+ let cmd =
+ sprintf "%s depends --recurse -i %s | grep -v '^[<[:space:]]'"
+ Config.apt_cache (Filename.quote name) in
+ run_command_get_lines cmd
+ ) names in
+ let names' = List.flatten names' in
+ let names' = sort_uniq names' in
+ if names <> names' then
+ workaround_broken_apt_cache_depends_recurse names'
+ else
+ names
+
let debian_list_files pkg =
debug "unpacking %s ..." pkg;