[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
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
* Richard W.M. Jones:
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:
Uh, I just checked the changelog. this got added in 0.8.11, after the Squeeze release. I'll try to find another way for using the cache. Sorry for the noise. -Hilko
On Thu, Jun 16, 2011 at 01:25:11PM +0200, Hilko Bengen wrote:
* Richard W.M. Jones:
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:
Uh, I just checked the changelog. this got added in 0.8.11, after the Squeeze release. I'll try to find another way for using the cache.
Sorry for the noise.
Is patch 2 independent or shall I wait? Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top
* Richard W.M. Jones:
Uh, I just checked the changelog. this got added in 0.8.11, after the Squeeze release. I'll try to find another way for using the cache.
Sorry for the noise.
Is patch 2 independent or shall I wait?
I believe that aptitude does not have the --print-uris option, so one would still need to use apt-get for that. I'll test some more tonight and prepare another patch. Since this is the first time I have put my fingers into OCaml code, I'd appreciate some feedback regarding style and such. -Hilko
On Thu, Jun 16, 2011 at 02:06:15PM +0200, Hilko Bengen wrote:
* Richard W.M. Jones:
Uh, I just checked the changelog. this got added in 0.8.11, after the Squeeze release. I'll try to find another way for using the cache.
Sorry for the noise.
Is patch 2 independent or shall I wait?
I believe that aptitude does not have the --print-uris option, so one would still need to use apt-get for that.
I'll test some more tonight and prepare another patch.
Since this is the first time I have put my fingers into OCaml code, I'd appreciate some feedback regarding style and such.
Apart from git complaining about whitespace at the end of a couple of lines, I can't see any problem with the style of the code. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://et.redhat.com/~rjones/virt-df/
* Hilko Bengen:
I believe that aptitude does not have the --print-uris option, so one would still need to use apt-get for that.
I'll test some more tonight and prepare another patch.
My idea was to use apt-get -qq --print-uris --reinstall install $PACKAGES to get the information, but this didn't work because it will not list information for the files that are already present in the repository. :-( -Hilko
On Fri, Jun 17, 2011 at 01:02:21PM +0200, Hilko Bengen wrote:
* Hilko Bengen:
I believe that aptitude does not have the --print-uris option, so one would still need to use apt-get for that.
I'll test some more tonight and prepare another patch.
My idea was to use
apt-get -qq --print-uris --reinstall install $PACKAGES
to get the information, but this didn't work because it will not list information for the files that are already present in the repository. :-(
How long will it take for apt-get download to be widely available? Can we check for it and use it conditionally? Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into Xen guests. http://et.redhat.com/~rjones/virt-p2v
participants (2)
-
Hilko Bengen -
Richard W.M. Jones