Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Handle --packager-config in zypp_rpm
This is an attempt to handle a different --reposd-dir in the zypp_rpm
driver. Up to now the system repositories in /etc/zypp/repos.d were
used.

To specify a different set of repositories for zypp a parser for a
simple zypper.conf is added in this patch. It just looks for reposdir=
in section main, like this:

 [main]
 reposdir=/path/to/other/repofiles

If the config file provided via "--packager-config my_zypp.conf" is
valid the other directory is passed to zypper, otherwise the system
repos.d is used like its done in current code.

Depending on the kind of provided repos, the current code may fail to
import a repo in non-interactive mode. This happens if the repo data are
not properly signed. For this reason the option --no-gpg-checks is added
by this patch.

Finally, the parser uses ocaml-inifiles to read the config file. This is
a new build dependency. inifiles should be available in various
distributions, copies of the original sources can be found via google.

This patch has received some light testing, I sent it out to the list
for further comments. Particular about the new inifiles dependency..

Signed-off-by: Olaf Hering <olaf@aepfle.de>
  • Loading branch information
olafhering authored and rwmjones committed Jun 4, 2013
1 parent 7b98faa commit 33d50fb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Makefile.am
Expand Up @@ -56,7 +56,7 @@ OBJECTS = $(XOBJECTS)
BEST = opt
endif

OCAMLPACKAGES = -package unix,str
OCAMLPACKAGES = -package unix,str,inifiles
OCAMLFLAGS = -warn-error CDEFLMPSUVXYZ

supermin: $(OBJECTS)
Expand Down
23 changes: 20 additions & 3 deletions src/supermin_zypp_rpm.ml
Expand Up @@ -45,6 +45,7 @@
*)
open Unix
open Printf
open Inifiles

open Supermin_package_handlers
open Supermin_utils
Expand All @@ -54,6 +55,19 @@ open Supermin_cmdline
(* Create a temporary directory for use by all the functions in this file. *)
let tmpdir = tmpdir ()

let get_repos_dir () =
let zypper_default = "/etc/zypp/repos.d" in
let parse_repos_dir path =
let cfg = new inifile path in
let dir = (try cfg#getval "main" "reposdir" with _ -> zypper_default) in
dir
in
let dir = (match packager_config with None -> zypper_default |
Some filename -> (try parse_repos_dir filename with _ -> zypper_default) ) in
dir

let repos_dir = get_repos_dir ()

let zypp_rpm_detect () =
(file_exists "/etc/SuSE-release") &&
Config.zypper <> "no" && Config.rpm <> "no"
Expand All @@ -75,10 +89,11 @@ pkg_cache_dir=%S
time zypper \
%s \
%s \
--root %S --reposd-dir /etc/zypp/repos.d \
--root %S --reposd-dir %S \
--cache-dir \"${cache_dir}\" \
--pkg-cache-dir \"${pkg_cache_dir}\" \
--gpg-auto-import-keys \
--no-gpg-checks \
--non-interactive \
install \
--auto-agree-with-licenses \
Expand All @@ -92,6 +107,7 @@ time zypper \
(match packager_config with None -> ""
| Some filename -> sprintf "--config %s" filename)
tmp_root
repos_dir
in
run_shell sh names;

Expand Down Expand Up @@ -129,9 +145,10 @@ unset LANG ${!LC_*}
zypper \
%s \
%s \
--root %S --reposd-dir /etc/zypp/repos.d \
--root %S --reposd-dir %S \
--cache-dir %S \
--gpg-auto-import-keys \
--no-gpg-checks \
--non-interactive \
--xml \
install \
Expand All @@ -146,7 +163,7 @@ zypper \
(if verbose then "--verbose --verbose" else "--quiet")
(match packager_config with None -> ""
| Some filename -> sprintf "--config %s" filename)
tmpdir tmpdir (String.concat " " (List.map Filename.quote names)) in
tmpdir repos_dir tmpdir (String.concat " " (List.map Filename.quote names)) in
let pkg_names = run_command_get_lines cmd in

(* Return list of package names, remove empty lines. *)
Expand Down

0 comments on commit 33d50fb

Please sign in to comment.