From: Richard W.M. Jones Date: Mon, 6 Dec 2010 17:14:03 +0000 (+0000) Subject: Add --yum-config option to set a yum configuration file. X-Git-Tag: 3.1~1 X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=9fe97b84850c6b450d6af1c9185d80194206b608;p=febootstrap.git Add --yum-config option to set a yum configuration file. --- diff --git a/febootstrap.pod b/febootstrap.pod index c76b4eb..bf6c593 100644 --- a/febootstrap.pod +++ b/febootstrap.pod @@ -139,6 +139,14 @@ Enable verbose messages. Print the package name and version number, and exit. +=item B<--yum-config CONFIGFILE> + +(Yum/RPM package handler only). Use an alternate configuration file +instead of C. If you also want to specify alternate +repositories then you can put them in this file directly or add a +C option to this file. For more information on the file +format see L. + =back =head1 SEE ALSO diff --git a/febootstrap_cmdline.ml b/febootstrap_cmdline.ml index 92fd677..902e313 100644 --- a/febootstrap_cmdline.ml +++ b/febootstrap_cmdline.ml @@ -24,6 +24,7 @@ let outputdir = ref "." let packages = ref [] let verbose = ref false let warnings = ref true +let yum_config = ref None let print_version () = printf "%s %s\n" Config.package_name Config.package_version; @@ -32,6 +33,9 @@ let print_version () = let add_exclude re = excludes := Str.regexp re :: !excludes +let set_yum_config str = + yum_config := Some str + let argspec = Arg.align [ "--exclude", Arg.String add_exclude, "regexp Exclude packages matching regexp"; @@ -49,6 +53,8 @@ let argspec = Arg.align [ " Print package name and version, and exit"; "--version", Arg.Unit print_version, " Print package name and version, and exit"; + "--yum-config", Arg.String set_yum_config, + "file Set alternate yum configuration file"; ] let anon_fn str = packages := str :: !packages @@ -79,5 +85,6 @@ let outputdir = !outputdir let packages = List.rev !packages let verbose = !verbose let warnings = !warnings +let yum_config = !yum_config let debug fs = ksprintf (fun str -> if verbose then print_endline str) fs diff --git a/febootstrap_cmdline.mli b/febootstrap_cmdline.mli index bd4e46e..107e70a 100644 --- a/febootstrap_cmdline.mli +++ b/febootstrap_cmdline.mli @@ -41,3 +41,6 @@ val verbose : bool val warnings : bool (** If true, print warnings. [--no-warnings] sets this to false. *) + +val yum_config : string option + (** Yum configuration file. *) diff --git a/febootstrap_yum_rpm.ml b/febootstrap_yum_rpm.ml index ca38fe8..e70940d 100644 --- a/febootstrap_yum_rpm.ml +++ b/febootstrap_yum_rpm.ml @@ -43,6 +43,8 @@ import sys yb = yum.YumBase () yb.preconf.debuglevel = %d yb.preconf.errorlevel = %d +if %s: + yb.preconf.fn = %S yb.setCacheDir () # Look up the base packages from the command line. @@ -74,7 +76,12 @@ for pkg in deps.keys (): f.write (\"%%s %%s %%s %%s %%s\\n\" %% (pkg.name, pkg.epoch, pkg.version, pkg.release, pkg.arch)) f.close () -" (if verbose then 1 else 0) (if verbose then 1 else 0) tmpfile in +" + (if verbose then 1 else 0) + (if verbose then 1 else 0) + (match yum_config with None -> "False" | Some _ -> "True") + (match yum_config with None -> "" | Some filename -> filename) + tmpfile in run_python py names; let chan = open_in tmpfile in let lines = input_all_lines chan in @@ -138,8 +145,10 @@ f.close () exit 1 ); - let cmd = sprintf "yumdownloader%s --destdir %s %s" + let cmd = sprintf "yumdownloader%s%s --destdir %s %s" (if verbose then "" else " --quiet") + (match yum_config with None -> "" + | Some filename -> sprintf " -c %s" filename) (Filename.quote tmpdir) (String.concat " " (List.map Filename.quote pkgnames)) in run_command cmd;