diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2008-02-14 10:47:50 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2008-02-14 10:47:50 +0000 |
commit | df55c40c5806b754c3ca717a3d79a853c2c9982c (patch) | |
tree | 03d67eef378fcab884b103f0a1817c7a62b3da9c /urpm/media.pm | |
parent | fea31ffed0e831f446c6a4518483f24ae72a7588 (diff) | |
download | urpmi-df55c40c5806b754c3ca717a3d79a853c2c9982c.tar urpmi-df55c40c5806b754c3ca717a3d79a853c2c9982c.tar.gz urpmi-df55c40c5806b754c3ca717a3d79a853c2c9982c.tar.bz2 urpmi-df55c40c5806b754c3ca717a3d79a853c2c9982c.tar.xz urpmi-df55c40c5806b754c3ca717a3d79a853c2c9982c.zip |
- urpmi handles /etc/urpmi/media.d/*.cfg
as an alternative to using urpmi.addmedia
nb: need documentation
Diffstat (limited to 'urpm/media.pm')
-rw-r--r-- | urpm/media.pm | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/urpm/media.pm b/urpm/media.pm index ac66c3b2..0e056c63 100644 --- a/urpm/media.pm +++ b/urpm/media.pm @@ -11,6 +11,7 @@ use MDV::Distribconf; our @PER_MEDIA_OPT = qw( + conf_file__rel_media downloader ignore key-ids @@ -144,6 +145,7 @@ sub read_config { #- per-media options read_config_add_passwords($urpm, $config); + my @media; foreach my $m (@{$config->{media}}) { my $medium = _only_media_opts_read($m); @@ -154,9 +156,22 @@ sub read_config { $medium->{url} or $urpm->{error}("unable to find url in list file $medium->{name}, medium ignored"); } - add_existing_medium($urpm, $medium); + push @media, $medium; } + require File::Glob; + # we can't use perl's glob() because we allow spaces in filename + foreach my $conf_file (File::Glob::bsd_glob("$urpm->{configs_dir}/*.cfg")) { + $urpm->{debug} and $urpm->{debug}("parsing: $conf_file"); + my $conf = urpm::cfg::load_ini_config_file_raw($conf_file); + foreach my $medium (map { _only_media_opts_read($_) } @$conf) { + $medium->{conf_file} = $conf_file; + push @media, $medium; + } + } + + add_existing_medium($urpm, $_) foreach @media; + eval { require urpm::ldap; urpm::ldap::load_ldap_media($urpm) }; } @@ -172,7 +187,12 @@ sub check_existing_medium { N("unable to access list file of \"%s\", medium ignored", $medium->{name}); } elsif (!$medium->{ignore} && !-r any_synthesis($urpm, $medium)) { - $err = N("unable to access synthesis file of \"%s\", medium ignored", $medium->{name}); + if ($medium->{conf_file} && $< == 0) { + # no pb, we create on the fly + $medium->{force_auto_update} = 1; + } else { + $err = N("unable to access synthesis file of \"%s\", medium ignored", $medium->{name}); + } } if ($err) { $medium->{ignore} = 1; @@ -406,11 +426,16 @@ sub write_urpmi_cfg { #- avoid trashing exiting configuration if it wasn't loaded $urpm->{media} or return; + my %media_per_cfg; + foreach (grep { !$_->{external} } @{$urpm->{media}}) { + push @{$media_per_cfg{$_->{conf_file} || ''}}, _only_media_opts_write($_); + } + my $config = { #- global config options found in the config file, without the ones #- set from the command-line global => $urpm->{global_config}, - media => [ map { _only_media_opts_write($_) } grep { !$_->{external} } @{$urpm->{media}} ], + media => delete $media_per_cfg{''}, }; remove_passwords_and_write_private_netrc($urpm, $config); @@ -419,6 +444,13 @@ sub write_urpmi_cfg { $urpm->{log}(N("wrote config file [%s]", $urpm->{config})); + foreach my $conf_file (sort keys %media_per_cfg) { + urpm::cfg::write_ini_config($conf_file, $media_per_cfg{$conf_file}) + or $urpm->{fatal}(6, N("unable to write config file [%s]", $conf_file)); + + $urpm->{log}(N("wrote config file [%s]", $conf_file)); + } + #- everything should be synced now. delete $urpm->{modified}; } @@ -552,7 +584,7 @@ sub _auto_update_media { my $errors; foreach (grep { !$_->{ignore} && (!$options{update} || $_->{update}) && - _is_remote_virtual($_) } @{$urpm->{media} || []}) { + ($_->{force_auto_update} || _is_remote_virtual($_)) } @{$urpm->{media} || []}) { _update_medium($urpm, $_, %options) or $errors++; } !$errors; |