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 /t/helper.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 't/helper.pm')
-rw-r--r-- | t/helper.pm | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/t/helper.pm b/t/helper.pm index 870baa2b..edf787d3 100644 --- a/t/helper.pm +++ b/t/helper.pm @@ -7,6 +7,7 @@ our @EXPORT = qw(need_root_and_prepare urpmi_addmedia urpmi_removemedia urpmi_update urpm_cmd run_urpm_cmd urpmi_cmd urpmi test_urpmi_fail urpme urpmi_cfg set_urpmi_cfg_global_options + create_media_d_cfg media_d_cfg system_ system_should_fail rpm_is_jbj_version check_installed_fullnames check_installed_names check_nothing_installed @@ -101,6 +102,31 @@ sub set_urpmi_cfg_global_options { ok(urpm::cfg::dump_config(urpmi_cfg(), $config), 'set_urpmi_cfg_global_options'); } +sub media_d_dir { + "$::pwd/root/etc/urpmi/media.d"; +} +sub media_d_cfg { + my ($name) = @_; + media_d_dir() . "/$name.cfg"; +} +sub create_media_d_cfg { + my ($name, @l) = @_; + + system("install -d " . media_d_dir()); + my $cfg = media_d_cfg($name); + -e $cfg and die "$cfg already exists\n"; + open(my $F, '>', $cfg); + + my $cnt = 1; + foreach my $h (@l) { + my %h = %$h; + my $section = delete $h{conf_file__rel_media} || $cnt++; + print $F "[$section]\n"; + print $F "$_ = $h->{$_}\n" foreach keys %$h; + } +} + + sub system_ { my ($cmd) = @_; system($cmd); |