summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2007-11-28 17:30:27 +0000
committerPascal Rigaux <pixel@mandriva.com>2007-11-28 17:30:27 +0000
commitd4e05ef6ea05525bf3b14ff1990e8864763ccb0f (patch)
tree80aebafc46e648795fa96c59af42dcd18591f3a2
parentc8d5d629efb6f2a6f24e14c1e77404f30b4792a9 (diff)
downloadurpmi-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-xgurpmi23
-rw-r--r--urpm.pm11
-rw-r--r--urpm/media.pm5
-rwxr-xr-xurpmi11
4 files changed, 14 insertions, 16 deletions
diff --git a/gurpmi2 b/gurpmi2
index 53be46f3..23fda4e9 100755
--- a/gurpmi2
+++ b/gurpmi2
@@ -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;
}
diff --git a/urpm.pm b/urpm.pm
index 979370d8..2309bd58 100644
--- a/urpm.pm
+++ b/urpm.pm
@@ -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'))) {
diff --git a/urpmi b/urpmi
index 9ddb8e44..1d0e0095 100755
--- a/urpmi
+++ b/urpmi
@@ -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 = {};