X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=src%2Ffebootstrap_debian.ml;h=8d0f75f930a999c35f3a6be8cdc10e52cb2ee571;hb=cce6569c63209685368ccc220d6a0c48d6b0900a;hp=e4b42afd073f6d23aebd3f58eb6d0a082fb4dcbc;hpb=2b1631439dc8dc4c6b8d7d78a5f3a5b2c08d83fd;p=febootstrap.git diff --git a/src/febootstrap_debian.ml b/src/febootstrap_debian.ml index e4b42af..8d0f75f 100644 --- a/src/febootstrap_debian.ml +++ b/src/febootstrap_debian.ml @@ -28,29 +28,24 @@ open Febootstrap_cmdline (* Create a temporary directory for use by all the functions in this file. *) let tmpdir = tmpdir () -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" && Config.aptitude <> "no" && Config.apt_cache <> "no" && Config.dpkg <> "no" +let installed_pkgs = ref [] + let debian_init () = - () + installed_pkgs := + run_command_get_lines "dpkg-query --show --showformat='${Package}\\n'" + +let get_installed_pkgs () = + match !installed_pkgs with + | [] -> assert false + | pkgs -> pkgs let rec debian_resolve_dependencies_and_download names = let cmd = - sprintf "%s depends --recurse -i %s | grep -v '^[<[:space:]]'" + sprintf "%s depends --recurse -i %s | grep -v '^[<[:space:]]' | grep -Ev ':\\w+\\b'" Config.apt_cache (String.concat " " (List.map Filename.quote names)) in let pkgs = run_command_get_lines cmd in @@ -67,13 +62,16 @@ let rec debian_resolve_dependencies_and_download names = not (List.exists (fun re -> Str.string_match re name 0) excludes) ) pkgs in - let present_pkgs, download_pkgs = List.partition ( - fun pkg -> List.exists ((=) pkg) (get_installed_pkgs ()) - ) pkgs in + let present_pkgs, download_pkgs = + if not use_installed then + [], pkgs + else + List.partition ( + fun pkg -> List.exists ((=) pkg) (get_installed_pkgs ()) + ) pkgs in - debug "wanted packages (present / download): %s / %s\n" - (String.concat " " present_pkgs) - (String.concat " " download_pkgs); + debug "packages already present: %s" (String.concat " " present_pkgs); + debug "wanted packages to download: %s" (String.concat " " download_pkgs); (* Download the packages. *) if (List.length download_pkgs > 0)