diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2007-11-14 11:29:37 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2007-11-14 11:29:37 +0000 |
commit | 79b4dbe29da7619f21e8124b562c06b5628b94e1 (patch) | |
tree | 223c3db6850e9889ba0a7374f3673952f8ecb632 | |
parent | edabe9d4501ff5c70b18f85e15c4cd6fc0689cac (diff) | |
download | urpmi-79b4dbe29da7619f21e8124b562c06b5628b94e1.tar urpmi-79b4dbe29da7619f21e8124b562c06b5628b94e1.tar.gz urpmi-79b4dbe29da7619f21e8124b562c06b5628b94e1.tar.bz2 urpmi-79b4dbe29da7619f21e8124b562c06b5628b94e1.tar.xz urpmi-79b4dbe29da7619f21e8124b562c06b5628b94e1.zip |
add undocumented & unstable --tune-rpm option
(allow to test nofsync and private db)
-rw-r--r-- | urpm.pm | 34 | ||||
-rw-r--r-- | urpm/args.pm | 3 | ||||
-rw-r--r-- | urpm/install.pm | 4 |
3 files changed, 39 insertions, 2 deletions
@@ -93,6 +93,40 @@ sub create_var_lib_rpm { ]); } +sub modify_rpm_macro { + my ($name, $to_remove, $to_add) = @_; + + my $val = URPM::expand('%' . $name); + $val =~ s/$to_remove/$to_add/ or $val = join(' ', grep {$_} $val, $to_add); + URPM::add_macro("$name $val"); +} + +sub set_tune_rpm { + my ($urpm, $para) = @_; + + my %h = map { $_ => 1 } map { + if ($_ eq 'all') { + ('nofsync', 'private'); + } else { + $_; + } + } split(',', $para); + + $urpm->{tune_rpm} = \%h; +} + +sub tune_rpm { + my ($urpm) = @_; + + if ($urpm->{tune_rpm}{nofsync}) { + modify_rpm_macro('__dbi_other', 'fsync', 'nofsync'); + } + if ($urpm->{tune_rpm}{private}) { + urpm::sys::clean_rpmdb_shared_regions($urpm->{root}); + modify_rpm_macro('__dbi_other', 'usedbenv', 'private'); + } +} + sub protocol_from_url { my ($url) = @_; $url =~ m!^(\w+)(_[^:]*)?:! && $1; diff --git a/urpm/args.pm b/urpm/args.pm index cb4d0e9f..049aaafa 100644 --- a/urpm/args.pm +++ b/urpm/args.pm @@ -54,6 +54,7 @@ my %options_spec_all = ( 'urpmi-root=s' => sub { urpm::set_files($urpm, $_[1]) }, 'wait-lock' => \$options{wait_lock}, 'use-copied-hdlist' => sub { $urpm->{options}{use_copied_hdlist} = 1 }, + 'tune-rpm=s' => sub { urpm::set_tune_rpm($urpm, $_[1]) }, ); my %options_spec = ( @@ -423,6 +424,8 @@ sub parse_cmdline { $options{verbose} >= 0 or $urpm->{info} = sub {}; $options{verbose} > 0 or $urpm->{log} = sub {}; + $urpm->{tune_rpm} and urpm::tune_rpm($urpm); + if ($tool ne 'urpmi.addmedia' && $tool ne 'urpmi.update' && $options{probe_with} && !$options{usedistrib}) { die N("Can't use %s without %s", "--probe-$options{probe_with}", "--use-distrib"); diff --git a/urpm/install.pm b/urpm/install.pm index 1251c8e0..683047ce 100644 --- a/urpm/install.pm +++ b/urpm/install.pm @@ -254,8 +254,8 @@ sub install { } unlink @produced_deltas; - if ($urpm->{root} && !$options{test}) { - $urpm->{debug} and $urpm->{debug}("workaround bug in rpmlib by removing /var/lib/rpm/__db*"); + if ($urpm->{root} && !$options{test} || $urpm->{tune_rpm}{private}) { + $urpm->{root} && $urpm->{debug} and $urpm->{debug}("workaround bug in rpmlib by removing /var/lib/rpm/__db*"); urpm::sys::clean_rpmdb_shared_regions($urpm->{root}); } |