[Pkg-libvirt-commits] [libguestfs] 13/233: builder: Pass ~prog global (program name) around.

Hilko Bengen bengen at moszumanska.debian.org
Wed Feb 19 21:10:41 UTC 2014


This is an automated email from the git hooks/post-receive script.

bengen pushed a commit to branch experimental
in repository libguestfs.

commit 3e802605b52dccd2574353d5aff220de8d8eb3b8
Author: Richard W.M. Jones <rjones at redhat.com>
Date:   Tue Jan 7 17:30:20 2014 +0000

    builder: Pass ~prog global (program name) around.
---
 builder/builder.ml       |  8 ++++----
 builder/downloader.ml    | 17 +++++++++--------
 builder/downloader.mli   |  2 +-
 builder/index_parser.ml  |  4 ++--
 builder/index_parser.mli |  2 +-
 5 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/builder/builder.ml b/builder/builder.ml
index 84d5757..aca4ac9 100644
--- a/builder/builder.ml
+++ b/builder/builder.ml
@@ -138,7 +138,7 @@ let main () =
         fun (source, fingerprint) ->
           let sigchecker =
             Sigchecker.create ~debug ~gpg ~fingerprint ~check_signature in
-          Index_parser.get_index ~debug ~downloader ~sigchecker source
+          Index_parser.get_index ~prog ~debug ~downloader ~sigchecker source
       ) sources
     ) in
 
@@ -178,7 +178,7 @@ let main () =
             let template = name, revision in
             msg (f_"Downloading: %s") file_uri;
             let progress_bar = not quiet in
-            ignore (Downloader.download downloader ~template ~progress_bar
+            ignore (Downloader.download ~prog downloader ~template ~progress_bar
                       file_uri)
         ) index;
         exit 0
@@ -218,7 +218,7 @@ let main () =
       let template = arg, revision in
       msg (f_"Downloading: %s") file_uri;
       let progress_bar = not quiet in
-      Downloader.download downloader ~template ~progress_bar file_uri in
+      Downloader.download ~prog downloader ~template ~progress_bar file_uri in
     if delete_on_exit then unlink_on_exit template;
     template in
 
@@ -236,7 +236,7 @@ let main () =
         | { Index_parser.signature_uri = None } -> None
         | { Index_parser.signature_uri = Some signature_uri } ->
           let sigfile, delete_on_exit =
-            Downloader.download downloader signature_uri in
+            Downloader.download ~prog downloader signature_uri in
           if delete_on_exit then unlink_on_exit sigfile;
           Some sigfile in
 
diff --git a/builder/downloader.ml b/builder/downloader.ml
index 918227e..442a011 100644
--- a/builder/downloader.ml
+++ b/builder/downloader.ml
@@ -43,19 +43,19 @@ let create ~debug ~curl ~cache = {
   cache = cache;
 }
 
-let rec download t ?template ?progress_bar uri =
+let rec download ~prog t ?template ?progress_bar uri =
   match template with
   | None ->                       (* no cache, simple download *)
     (* Create a temporary name. *)
     let tmpfile = Filename.temp_file "vbcache" ".txt" in
-    download_to t ?progress_bar uri tmpfile;
+    download_to ~prog t ?progress_bar uri tmpfile;
     (tmpfile, true)
 
   | Some (name, revision) ->
     match t.cache with
     | None ->
       (* Not using the cache at all? *)
-      download t ?progress_bar uri
+      download t ~prog ?progress_bar uri
 
     | Some cachedir ->
       let filename = cache_of_name cachedir name revision in
@@ -64,11 +64,11 @@ let rec download t ?template ?progress_bar uri =
        * If not, download it.
        *)
       if not (Sys.file_exists filename) then
-        download_to t ?progress_bar uri filename;
+        download_to ~prog t ?progress_bar uri filename;
 
       (filename, false)
 
-and download_to t ?(progress_bar = false) uri filename =
+and download_to ~prog t ?(progress_bar = false) uri filename =
   (* Get the status code first to ensure the file exists. *)
   let cmd = sprintf "%s%s -g -o /dev/null -I -w '%%{http_code}' %s"
     t.curl
@@ -99,8 +99,8 @@ and download_to t ?(progress_bar = false) uri filename =
     | _ -> false
   in
   if bad_status_code status_code then (
-    eprintf (f_"virt-builder: failed to download %s: HTTP status code %s\n")
-      uri status_code;
+    eprintf (f_"%s: failed to download %s: HTTP status code %s\n")
+      prog uri status_code;
     exit 1
   );
 
@@ -120,7 +120,8 @@ and download_to t ?(progress_bar = false) uri filename =
   if t.debug then eprintf "%s\n%!" cmd;
   let r = Sys.command cmd in
   if r <> 0 then (
-    eprintf (f_"virt-builder: curl (download) command failed downloading '%s'\n") uri;
+    eprintf (f_"%s: curl (download) command failed downloading '%s'\n")
+      prog uri;
     exit 1
   );
 
diff --git a/builder/downloader.mli b/builder/downloader.mli
index 8cb7404..62d500d 100644
--- a/builder/downloader.mli
+++ b/builder/downloader.mli
@@ -32,7 +32,7 @@ type t
 val create : debug:bool -> curl:string -> cache:string option -> t
 (** Create the abstract type. *)
 
-val download : t -> ?template:(string*int) -> ?progress_bar:bool -> uri -> (filename * bool)
+val download : prog:string -> t -> ?template:(string*int) -> ?progress_bar:bool -> uri -> (filename * bool)
 (** Download the URI, returning the downloaded filename and a
     temporary file flag.  The temporary file flag is [true] iff
     the downloaded file is temporary and should be deleted by the
diff --git a/builder/index_parser.ml b/builder/index_parser.ml
index fb47e50..453a3a1 100644
--- a/builder/index_parser.ml
+++ b/builder/index_parser.ml
@@ -106,7 +106,7 @@ and field = string * string             (* key + value *)
 (* Calls yyparse in the C code. *)
 external parse_index : string -> sections = "virt_builder_parse_index"
 
-let get_index ~debug ~downloader ~sigchecker source =
+let get_index ~prog ~debug ~downloader ~sigchecker source =
   let corrupt_file () =
     eprintf (f_"\nThe index file downloaded from '%s' is corrupt.\nYou need to ask the supplier of this file to fix it and upload a fixed version.\n")
       source;
@@ -115,7 +115,7 @@ let get_index ~debug ~downloader ~sigchecker source =
 
   let rec get_index () =
     (* Get the index page. *)
-    let tmpfile, delete_tmpfile = Downloader.download downloader source in
+    let tmpfile, delete_tmpfile = Downloader.download ~prog downloader source in
 
     (* Check index file signature (also verifies it was fully
      * downloaded and not corrupted in transit).
diff --git a/builder/index_parser.mli b/builder/index_parser.mli
index 0b6317d..54f1807 100644
--- a/builder/index_parser.mli
+++ b/builder/index_parser.mli
@@ -35,4 +35,4 @@ and entry = {
   sigchecker : Sigchecker.t;
 }
 
-val get_index : debug:bool -> downloader:Downloader.t -> sigchecker:Sigchecker.t -> string -> index
+val get_index : prog:string -> debug:bool -> downloader:Downloader.t -> sigchecker:Sigchecker.t -> string -> index

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-libvirt/libguestfs.git



More information about the Pkg-libvirt-commits mailing list