diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2007-11-28 17:30:27 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2007-11-28 17:30:27 +0000 |
commit | d4e05ef6ea05525bf3b14ff1990e8864763ccb0f (patch) | |
tree | 80aebafc46e648795fa96c59af42dcd18591f3a2 | |
parent | c8d5d629efb6f2a6f24e14c1e77404f30b4792a9 (diff) | |
download | urpmi-d4e05ef6ea05525bf3b14ff1990e8864763ccb0f.tar urpmi-d4e05ef6ea05525bf3b14ff1990e8864763ccb0f.tar.gz urpmi-d4e05ef6ea05525bf3b14ff1990e8864763ccb0f.tar.bz2 urpmi-d4e05ef6ea05525bf3b14ff1990e8864763ccb0f.tar.xz urpmi-d4e05ef6ea05525bf3b14ff1990e8864763ccb0f.zip |
factorize default options, and have them by default in $urpm->{options}
-rwxr-xr-x | gurpmi2 | 3 | ||||
-rw-r--r-- | urpm.pm | 11 | ||||
-rw-r--r-- | urpm/media.pm | 5 | ||||
-rwxr-xr-x | urpmi | 11 |
4 files changed, 14 insertions, 16 deletions
@@ -132,9 +132,6 @@ sub configure_urpm() { searchmedia => $gurpmi::options{searchmedia}, ); $urpm->{options}{'verify-rpm'} = 0 if $gurpmi::options{'no-verify-rpm'}; - #- default options values - exists $urpm->{options}{$_} or $urpm->{options}{$_} = 1 foreach qw(post-clean verify-rpm split-length); - $urpm->{options}{'split-level'} = 1 unless exists $urpm->{options}{'split-level'}; $urpm; } @@ -24,6 +24,15 @@ sub shunt_ignorearch { eval q( sub URPM::Package::is_arch_compat { 1 } ); } +sub default_options { + { + 'split-level' => 1, + 'split-length' => 8, + 'verify-rpm' => 1, + 'post-clean' => 1, + }; +} + #- create a new urpm object. sub new { my ($class) = @_; @@ -35,7 +44,7 @@ sub new { obsoletes => {}, media => undef, - options => {}, + options => default_options(), fatal => sub { printf STDERR "%s\n", $_[1]; exit($_[0]) }, error => sub { printf STDERR "%s\n", $_[0] }, diff --git a/urpm/media.pm b/urpm/media.pm index 90fbd167..9cd588cb 100644 --- a/urpm/media.pm +++ b/urpm/media.pm @@ -145,11 +145,6 @@ sub read_config { eval { require urpm::ldap; urpm::ldap::load_ldap_media($urpm) }; - #- load default values - foreach (qw(post-clean verify-rpm)) { - exists $urpm->{options}{$_} or $urpm->{options}{$_} = 1; - } - #- read MD5 sums (not in urpmi.cfg but in a separate file) foreach (@{$urpm->{media}}) { if (my $md5sum = urpm::md5sum::from_MD5SUM("$urpm->{statedir}/MD5SUM", statedir_hdlist_or_synthesis($urpm, $_, 's'))) { @@ -47,8 +47,6 @@ our $src = 0; our $install_src = 0; our $clean = 0; our $noclean = 0; -my $split_level = 1; -my $split_length = 8; our $force = 0; our $parallel = ''; our $env = ''; @@ -95,8 +93,10 @@ usage: ") . N(" --split-level - split in small transaction if more than given packages are going to be installed or upgraded, default is %d. -", $split_level) . N(" --split-length - small transaction length, default is %d. -", $split_length) . N(" --fuzzy, -y - impose fuzzy search. +", urpm::default_options()->{'split-level'}) + . N(" --split-length - small transaction length, default is %d. +", urpm::default_options()->{'split-length'}) + . N(" --fuzzy, -y - impose fuzzy search. ") . N(" --src, -s - next package is a source package. ") . N(" --install-src - install only source package (no binaries). ") . N(" --clean - remove rpm from cache before anything else. @@ -382,9 +382,6 @@ if ($bug) { urpm::bug_report::rpmdb_to_synthesis($urpm, "$bug/rpmdb.cz", $urpm->{root}); } -#- get back activated default values of boolean options. -exists $urpm->{options}{'split-level'} or $urpm->{options}{'split-level'} = $split_level; -exists $urpm->{options}{'split-length'} or $urpm->{options}{'split-length'} = $split_length; urpm::select::set_priority_upgrade_option($urpm, $options{previous_priority_upgrade}); my $state = {}; |