From 155b6952bb3fde46cee675c353e2462a09172c50 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 6 Dec 2010 16:44:46 +0000 Subject: [PATCH] Allow --verbose to control whether yum messages are verbose. Without --verbose, yum will be quiet for once. --- febootstrap_cmdline.ml | 3 ++- febootstrap_cmdline.mli | 4 ++++ febootstrap_yum_rpm.ml | 12 +++++++----- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/febootstrap_cmdline.ml b/febootstrap_cmdline.ml index 3ce1029..92fd677 100644 --- a/febootstrap_cmdline.ml +++ b/febootstrap_cmdline.ml @@ -77,6 +77,7 @@ let excludes = List.rev !excludes let names_mode = !names_mode let outputdir = !outputdir let packages = List.rev !packages +let verbose = !verbose let warnings = !warnings -let debug fs = ksprintf (fun str -> if !verbose then print_endline str) fs +let debug fs = ksprintf (fun str -> if verbose then print_endline str) fs diff --git a/febootstrap_cmdline.mli b/febootstrap_cmdline.mli index cbb6b87..bd4e46e 100644 --- a/febootstrap_cmdline.mli +++ b/febootstrap_cmdline.mli @@ -35,5 +35,9 @@ val outputdir : string val packages : string list (** List of packages or package names as supplied on the command line. *) +val verbose : bool + (** True if [--verbose] was given on the command line. + See also {!debug}. *) + val warnings : bool (** If true, print warnings. [--no-warnings] sets this to false. *) diff --git a/febootstrap_yum_rpm.ml b/febootstrap_yum_rpm.ml index 43021cc..075e4e0 100644 --- a/febootstrap_yum_rpm.ml +++ b/febootstrap_yum_rpm.ml @@ -34,13 +34,14 @@ let yum_rpm_detect () = let yum_rpm_resolve_dependencies_and_download names = (* Liberate this data from python. *) - let py = " + let py = sprintf " import yum import yum.misc import sys yb = yum.YumBase () -#yum.logginglevels.setDebugLevel(0) -- doesn't work? +yb.preconf.debuglevel = %d +yb.preconf.errorlevel = %d # Look up the base packages from the command line. deps = dict () @@ -68,10 +69,10 @@ while not stable: # Write it to a file because yum spews garbage on stdout. f = open (sys.argv[1], \"w\") for pkg in deps.keys (): - f.write (\"%s %s %s %s %s\\n\" % + f.write (\"%%s %%s %%s %%s %%s\\n\" %% (pkg.name, pkg.epoch, pkg.version, pkg.release, pkg.arch)) f.close () -" in +" (if verbose then 1 else 0) (if verbose then 1 else 0) in let tmpfile = tmpdir // "names.tmp" in run_python py (tmpfile :: names); let chan = open_in tmpfile in @@ -136,7 +137,8 @@ f.close () exit 1 ); - let cmd = sprintf "yumdownloader --destdir %s %s" + let cmd = sprintf "yumdownloader%s --destdir %s %s" + (if verbose then "" else " --quiet") (Filename.quote tmpdir) (String.concat " " (List.map Filename.quote pkgnames)) in run_command cmd; -- 1.8.3.1