From 7a62087448c9a58ec1b9afe15977a24b55646f77 Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Tue, 9 Sep 2008 22:27:29 +0000 Subject: (db_open_or_die__) factorize some code (the name might have to be changed...) --- urpm.pm | 10 ++++++++++ urpm/install.pm | 9 +-------- urpm/select.pm | 9 +-------- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/urpm.pm b/urpm.pm index 49086c44..2ca2b95e 100644 --- a/urpm.pm +++ b/urpm.pm @@ -282,6 +282,16 @@ sub db_open_or_die_ { db_open_or_die($urpm, $urpm->{root}, $b_write_perm); } +sub db_open_or_die__ { + if ($options{rpmdb}) { + $db = new URPM; + $db->parse_synthesis($options{rpmdb}); + } else { + $db = urpm::db_open_or_die_($urpm); + } + $db; +} + # please use higher level function db_open_or_die_() sub db_open_or_die { my ($urpm, $root, $b_write_perm) = @_; diff --git a/urpm/install.pm b/urpm/install.pm index 8007e32b..8266fec4 100644 --- a/urpm/install.pm +++ b/urpm/install.pm @@ -44,14 +44,7 @@ sub build_transaction_set_ { #- build simplest transaction (no split). $urpm->build_transaction_set(undef, $state, split_length => 0); } else { - my $db; - - if ($options{rpmdb}) { - $db = new URPM; - $db->parse_synthesis($options{rpmdb}); - } else { - $db = urpm::db_open_or_die_($urpm); - } + my $db = db_open_or_die__(); my $sig_handler = sub { undef $db; exit 3 }; local $SIG{INT} = $sig_handler; diff --git a/urpm/select.pm b/urpm/select.pm index 3183eac8..b5f79580 100644 --- a/urpm/select.pm +++ b/urpm/select.pm @@ -248,14 +248,7 @@ sub resolve_dependencies { require urpm::parallel; #- help perl_checker; urpm::parallel::resolve_dependencies($urpm, $state, $requested, %options); } else { - my $db; - - if ($options{rpmdb}) { - $db = new URPM; - $db->parse_synthesis($options{rpmdb}); - } else { - $db = urpm::db_open_or_die_($urpm); - } + my $db = db_open_or_die__(); my $sig_handler = sub { undef $db; exit 3 }; local $SIG{INT} = $sig_handler; -- cgit v1.2.1