[Pkg-libvirt-commits] [libguestfs] 18/87: builder: Pass ~prog global (program name) around.
Hilko Bengen
bengen at moszumanska.debian.org
Wed Feb 19 21:10:06 UTC 2014
This is an automated email from the git hooks/post-receive script.
bengen pushed a commit to branch debian
in repository libguestfs.
commit 3ec37fbedfcd07c740bcdc3474de18e1189d2e07
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.
(cherry picked from commit 3e802605b52dccd2574353d5aff220de8d8eb3b8)
---
builder/builder.ml | 8 ++++----
builder/downloader.ml | 17 +++++++++--------
builder/downloader.mli | 2 +-
builder/index_parser.ml | 8 ++++----
builder/index_parser.mli | 2 +-
5 files changed, 19 insertions(+), 18 deletions(-)
diff --git a/builder/builder.ml b/builder/builder.ml
index c814441..25ab8c4 100644
--- a/builder/builder.ml
+++ b/builder/builder.ml
@@ -131,7 +131,7 @@ let main () =
Sigchecker.create ~debug ~gpg ?fingerprint ~check_signature in
(* Download the source (index) file. *)
- let index = Index_parser.get_index ~debug ~downloader ~sigchecker source in
+ let index = Index_parser.get_index ~prog ~debug ~downloader ~sigchecker source in
(* Now handle the remaining modes. *)
let mode =
@@ -169,7 +169,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
@@ -208,7 +208,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
@@ -226,7 +226,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 b5a0cf0..326b395 100644
--- a/builder/index_parser.ml
+++ b/builder/index_parser.ml
@@ -97,10 +97,10 @@ let print_entry chan (name, { printable_name = printable_name;
let fieldname_rex = Str.regexp "^\\([][a-z0-9_]+\\)=\\(.*\\)$"
-let get_index ~debug ~downloader ~sigchecker source =
+let get_index ~prog ~debug ~downloader ~sigchecker source =
let rec corrupt_line line =
- eprintf (f_"virt-builder: error parsing index near this line:\n\n%s\n")
- line;
+ eprintf (f_"%s: error parsing index near this line:\n\n%s\n")
+ prog line;
corrupt_file ()
and 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")
@@ -110,7 +110,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 79df5ef..a9b328a 100644
--- a/builder/index_parser.mli
+++ b/builder/index_parser.mli
@@ -33,4 +33,4 @@ and entry = {
hidden : bool;
}
-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