From 3ac623701e5fe5ce94b22b4f40f72ee0161d5184 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 1 Sep 2011 10:43:46 +0100 Subject: [PATCH] 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. --- config.ml.in | 1 + configure.ac | 13 +++++++++++++ febootstrap_debian.ml | 30 +++++++++++++++++++++++++++++- 3 files changed, 43 insertions(+), 1 deletion(-) 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; -- 1.8.3.1