/[soft]/rpm/urpmi/trunk/urpmi.removemedia
ViewVC logotype

Contents of /rpm/urpmi/trunk/urpmi.removemedia

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1928 - (show annotations) (download)
Tue Sep 13 20:44:28 2011 UTC (12 years, 6 months ago) by dmorgan
File size: 2596 byte(s)
Import urpmi
1 #!/usr/bin/perl
2
3 # $Id: urpmi.removemedia 271299 2010-11-21 15:54:30Z peroyvind $
4
5 #- Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 MandrakeSoft SA
6 #- Copyright (C) 2005-2010 Mandriva SA
7 #-
8 #- This program is free software; you can redistribute it and/or modify
9 #- it under the terms of the GNU General Public License as published by
10 #- the Free Software Foundation; either version 2, or (at your option)
11 #- any later version.
12 #-
13 #- This program is distributed in the hope that it will be useful,
14 #- but WITHOUT ANY WARRANTY; without even the implied warranty of
15 #- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 #- GNU General Public License for more details.
17 #-
18 #- You should have received a copy of the GNU General Public License
19 #- along with this program; if not, write to the Free Software
20 #- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21
22 #- this program is based upon old urpmi.addmedia
23
24 use strict;
25 use urpm;
26 use urpm::msg;
27 use urpm::download;
28 use urpm::media;
29 use urpm::args;
30
31 $ENV{PATH} = "/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin";
32 delete @ENV{qw(ENV BASH_ENV IFS CDPATH)};
33
34 my @toremove;
35
36 sub usage {
37 my ($msg) = @_;
38 print N("usage: urpmi.removemedia (-a | <name> ...)
39 where <name> is a medium name to remove.
40 ") . N(" --help - print this help message.
41 ") . N(" -a - select all media.
42 ") . N(" -y - fuzzy match on media names.
43 ") . N(" -q - quiet mode.
44 ") . N(" -v - verbose mode.
45 ") . N(" --urpmi-root - use another root for urpmi db & rpm installation.
46 ") . $msg;
47 exit 1;
48 }
49
50
51 #- default option values
52 $options{strict_match} = 1;
53
54 our @cmdline; #- set by urpm::args
55
56 my $urpm = urpm->new_parse_cmdline or exit(1);
57
58 if ($< != 0) {
59 $urpm->{fatal}(1, N("Only superuser is allowed to remove media"));
60 }
61
62 my $_urpmi_lock = urpm::lock::urpmi_db($urpm, 'exclusive', wait => $options{wait_lock});
63 urpm::media::read_config($urpm, 'nocheck');
64 urpm::download::set_cmdline_proxy();
65 my @entries = map { $_->{name} } @{$urpm->{media}};
66
67 if ($options{all}) {
68 if (@cmdline) {
69 usage('');
70 } elsif (!@entries) {
71 print STDERR N("nothing to remove (use urpmi.addmedia to add a media)\n");
72 exit 0;
73 } else {
74 @toremove = @entries;
75 }
76 } else {
77 @toremove = @cmdline or usage(N("the entry to remove is missing\n(one of %s)\n", join(", ", @entries)));
78 }
79
80 my @selected = urpm::media::select_media_by_name($urpm, \@toremove, !$urpm->{options}{fuzzy})
81 or exit 1;
82
83 urpm::media::remove_media($urpm, \@selected);
84 urpm::media::write_urpmi_cfg($urpm);
85
86 exit(0);

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.30