Hilko Bengen
2011-Jun-15 22:26 UTC
[Libguestfs] [PATCH 1/2] use apt-get instead of aptitude
--- config.ml.in | 2 +- configure.ac | 2 +- febootstrap_debian.ml | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/config.ml.in b/config.ml.in index a8c008a..262c913 100644 --- a/config.ml.in +++ b/config.ml.in @@ -22,7 +22,7 @@ let package_version = "@PACKAGE_VERSION@" let yum = "@YUM@" let rpm = "@RPM@" let yumdownloader = "@YUMDOWNLOADER@" -let aptitude = "@APTITUDE@" +let apt_get = "@APTGET@" let dpkg = "@DPKG@" let pacman = "@PACMAN@" let host_cpu = "@host_cpu@" diff --git a/configure.ac b/configure.ac index bd9d39d..1a0302c 100644 --- a/configure.ac +++ b/configure.ac @@ -61,7 +61,7 @@ AC_CHECK_PROG(RPM,[rpm],[rpm],[no]) AC_CHECK_PROG(YUMDOWNLOADER,[yumdownloader],[yumdownloader],[no]) dnl For Debian handler. -AC_CHECK_PROG(APTITUDE,[aptitude],[aptitude],[no]) +AC_CHECK_PROG(APTGET,[apt-get],[apt-get],[no]) AC_CHECK_PROG(DPKG,[dpkg],[dpkg],[no]) dnl For ArchLinux handler. diff --git a/febootstrap_debian.ml b/febootstrap_debian.ml index f0d0be5..745a383 100644 --- a/febootstrap_debian.ml +++ b/febootstrap_debian.ml @@ -30,7 +30,7 @@ let tmpdir = tmpdir () let debian_detect () file_exists "/etc/debian_version" && - Config.aptitude <> "no" && Config.dpkg <> "no" + Config.apt_get <> "no" && Config.dpkg <> "no" let debian_resolve_dependencies_and_download names let cmd @@ -47,12 +47,12 @@ let debian_resolve_dependencies_and_download names (* Download the packages. *) let cmd - sprintf "cd %s && aptitude download %s" + sprintf "cd %s && apt-get download %s" (Filename.quote tmpdir) (String.concat " " (List.map Filename.quote pkgs)) in run_command cmd; - (* Find out what aptitude downloaded. *) + (* Find out what apt-get downloaded. *) let files = Sys.readdir tmpdir in let pkgs = List.map ( @@ -68,7 +68,7 @@ let debian_resolve_dependencies_and_download names raise Exit ) done; - eprintf "febootstrap: aptitude: error: no file was downloaded corresponding to package %s\n" pkg; + eprintf "febootstrap: apt-get: error: no file was downloaded corresponding to package %s\n" pkg; exit 1 with Exit -> !r -- 1.7.5.4
--- febootstrap_debian.ml | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+), 0 deletions(-) diff --git a/febootstrap_debian.ml b/febootstrap_debian.ml index 745a383..0bf50fc 100644 --- a/febootstrap_debian.ml +++ b/febootstrap_debian.ml @@ -27,6 +27,7 @@ open Febootstrap_cmdline (* Create a temporary directory for use by all the functions in this file. *) let tmpdir = tmpdir () +let apt_cache_dir = "/var/cache/apt/archives" let debian_detect () file_exists "/etc/debian_version" && @@ -45,6 +46,25 @@ let debian_resolve_dependencies_and_download names not (List.exists (fun re -> Str.string_match re name 0) excludes) ) pkgs in + (* Copy packages that are already present in cache *) + let cmd = sprintf "apt-get --print-uris download %s" + (String.concat " " (List.map Filename.quote pkgs)) in + let present_pkgs + List.filter (fun filename -> file_exists (sprintf "%s/%s" apt_cache_dir filename)) + (List.map (fun line -> + Scanf.sscanf line "%s %s %i %s" + (fun url filename size checksum -> filename)) + (run_command_get_lines cmd)) in + let cmd + sprintf "cd %s && cp -t . %s" + (Filename.quote tmpdir) + (String.concat " " + (List.map (fun filename -> + (Filename.quote + (sprintf "%s/%s" apt_cache_dir filename))) + present_pkgs)) in + run_command cmd; + (* Download the packages. *) let cmd sprintf "cd %s && apt-get download %s" -- 1.7.5.4
Richard W.M. Jones
2011-Jun-16 09:23 UTC
[Libguestfs] [PATCH 1/2] use apt-get instead of aptitude
On Thu, Jun 16, 2011 at 12:26:38AM +0200, Hilko Bengen wrote:> (* Download the packages. *) > let cmd > - sprintf "cd %s && aptitude download %s" > + sprintf "cd %s && apt-get download %s""apt-get download" doesn't appear to be a real command. It's not mentioned in the man page, and when I tried it, febootstrap said: E: Invalid operation download Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming blog: http://rwmj.wordpress.com Fedora now supports 80 OCaml packages (the OPEN alternative to F#) http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora
Seemingly Similar Threads
- [PATCH febootstrap] Some cleanups for Debian and Ubuntu
- [PATCH] febootstrap: Use contents of installed Debian packages instead of downloading and unpacking them.
- [PATCH] Eliminate duplicate entries from package list
- [PATCH 2/2] Use os-release to detect the distro
- Fwd: Re: febootstrap in Debian