summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2008-10-27 11:39:47 +0000
committerPascal Rigaux <pixel@mandriva.com>2008-10-27 11:39:47 +0000
commitbb0fabd2c2bffcf3def2c8c538921305d09ec298 (patch)
tree5eebe0255014a1d1a9950098902fd990dcdee2ad
parentb494812daced7acbb49aaf27671cde8a4f055b7e (diff)
downloadurpmi-bb0fabd2c2bffcf3def2c8c538921305d09ec298.tar
urpmi-bb0fabd2c2bffcf3def2c8c538921305d09ec298.tar.gz
urpmi-bb0fabd2c2bffcf3def2c8c538921305d09ec298.tar.bz2
urpmi-bb0fabd2c2bffcf3def2c8c538921305d09ec298.tar.xz
urpmi-bb0fabd2c2bffcf3def2c8c538921305d09ec298.zip
- implement urpme --env
- handle urpme --auto-orphans --env
-rw-r--r--urpm.pm1
-rw-r--r--urpm/args.pm2
-rw-r--r--urpm/orphans.pm4
-rw-r--r--urpme12
4 files changed, 12 insertions, 7 deletions
diff --git a/urpm.pm b/urpm.pm
index 93d0c992..016f002d 100644
--- a/urpm.pm
+++ b/urpm.pm
@@ -152,6 +152,7 @@ sub set_env {
$urpm->{prefer_vendor_list} = "$env/prefer.vendor.list";
$urpm->{statedir} = $env;
$urpm->{env_rpmdb} = "$env/rpmdb.cz";
+ $urpm->{env_dir} = $env;
}
sub set_files {
diff --git a/urpm/args.pm b/urpm/args.pm
index 35a3068c..e5db95a3 100644
--- a/urpm/args.pm
+++ b/urpm/args.pm
@@ -417,7 +417,7 @@ foreach my $k ('allow-medium-change', 'auto', 'auto-select', 'clean', 'force', '
}
$options_spec{gurpmi2} = $options_spec{gurpmi};
-foreach my $k ("test!", "force", "root=s", "use-distrib=s",
+foreach my $k ("test!", "force", "root=s", "use-distrib=s", 'env=s',
'repackage', 'noscripts', 'auto', 'auto-orphans', 'justdb',
"parallel=s")
{
diff --git a/urpm/orphans.pm b/urpm/orphans.pm
index 53abb41c..ceb9a3e0 100644
--- a/urpm/orphans.pm
+++ b/urpm/orphans.pm
@@ -25,7 +25,7 @@ sub installed_packages_packed {
#- side-effects: none
sub unrequested_list__file {
my ($urpm) = @_;
- "$urpm->{root}/var/lib/rpm/installed-through-deps.list";
+ ($urpm->{env_dir} || "$urpm->{root}/var/lib/rpm") . '/installed-through-deps.list';
}
#- side-effects: none
sub unrequested_list {
@@ -65,7 +65,7 @@ sub _installed_req_and_unreq_and_update_unrequested_list {
# update the list (to filter dups and now-removed-pkgs)
output_safe(unrequested_list__file($urpm),
join('', sort map { $_->name . "\n" } @$unreq),
- ".old");
+ ".old") if !$urpm->{env_dir};
($req, $unreq, $unrequested);
}
diff --git a/urpme b/urpme
index 7dfc1301..6653a514 100644
--- a/urpme
+++ b/urpme
@@ -32,7 +32,7 @@ use urpm::orphans;
$ENV{PATH} = "/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin";
delete @ENV{qw(ENV BASH_ENV IFS CDPATH)};
-our ($test, $parallel, $force);
+our ($test, $parallel, $force, $env);
my $yesexpr =
#-PO: Add here the keys which might be pressed in the "Yes"-case.
N("Yy");
@@ -69,7 +69,9 @@ my @cmdline_pkgs_to_remove = @ARGV;
my $state = {};
-if ($< && !$test) {
+if ($env) {
+ urpm::set_env($urpm, $env);
+} elsif ($< && !$test) {
$urpm->{fatal}(1, N("Only superuser is allowed to remove packages"));
}
@@ -83,7 +85,7 @@ unless ($test) {
}
#- just configure parallel mode if available.
-my $_urpmi_lock = urpm::lock::urpmi_db($urpm, '', wait => $options{wait_lock});
+my $_urpmi_lock = !$env && urpm::lock::urpmi_db($urpm, '', wait => $options{wait_lock});
urpm::media::configure($urpm,
synthesis => ($parallel ? 'none' : ''),
parallel => $parallel,
@@ -154,7 +156,7 @@ my $msg =
. (@orphans ? P("(orphan package)", "(orphan packages)", scalar(@orphans)) . "\n" .
add_leading_spaces(join("\n", sort @orphans) . "\n") : ());
-if ($urpm->{options}{auto}) {
+if ($urpm->{options}{auto} || $env) {
$test and print STDOUT $msg;
} elsif ($parallel || @toremove > @cmdline_pkgs_to_remove) {
print STDOUT $msg;
@@ -166,6 +168,8 @@ print $test ?
N("testing removal of %s", join(' ', sort @toremove)) :
N("removing %s", join(' ', sort @toremove)), "\n";
+exit 0 if $env;
+
my %remove_options = (
test => $test,
force => $force,