/[soft]/rpmdrake/trunk/gurpmi.addmedia
ViewVC logotype

Contents of /rpmdrake/trunk/gurpmi.addmedia

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1130 - (show annotations) (download)
Fri May 6 14:15:49 2011 UTC (12 years, 11 months ago) by misc
File size: 4504 byte(s)
another round of plural fix from JohnR

1 #!/usr/bin/perl
2 #*****************************************************************************
3 #
4 # Copyright (c) 2004 Guillaume Cottenceau (gc at mandrakesoft dot com)
5 # Copyright (c) 2006-2007 Thierry Vignaud <tvignaud@mandriva.com>
6 # Copyright (c) 2004-2007 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 version 2, as
10 # published by the Free Software Foundation.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #
21 #*****************************************************************************
22 #
23 # $Id: gurpmi.addmedia 261187 2009-10-01 14:44:34Z tv $
24
25 use strict;
26
27 BEGIN {
28 @ARGV == 0 || "@ARGV" =~ /-h/ and do {
29 print "usage: gurpmi.addmedia [options] <name> <url> [with <relative_path>]
30 where <url> is one of
31 [file:/]/<path>
32 ftp://<login>:<password>\@<host>/<path>
33 ftp://<host>/<path>
34 http://<host>/<path>
35 removable://<path>
36
37 and [options] are from
38 --distrib install a set of media from a distribution
39 --silent-success don't show popup window on success
40 --update create an update medium,
41 or discard non-update media (when used with --distrib)
42 --mirrorlist <url> is a mirror list
43 ";
44 exit(0);
45 };
46 }
47 use Rpmdrake::init;
48 use Rpmdrake::open_db;
49
50 use lib qw(/usr/lib/libDrakX);
51 use urpm::media;
52 use common;
53 use any;
54
55 any::set_wm_hints_if_needed();
56
57 require_root_capability();
58
59 use rpmdrake;
60 use Getopt::Long;
61
62 use ugtk2 qw(:all);
63 $::isStandalone = 1;
64
65 readconf();
66
67 my $fromfile;
68 if (@ARGV == 1 && $ARGV[0] =~ /\.urpmi-media$/) {
69 @ARGV = map { s/^\s*//; s/\s*$//; $_ } split /\n/, cat_($ARGV[0]);
70 $fromfile = 1;
71 }
72
73 my ($update, $distrib, $silent_success) = (0, 0, 0);
74 my ($mirrorlist, $with_dir);
75
76 GetOptions(
77 'update' => \$update,
78 'distrib' => \$distrib,
79 'silent-success' => \$silent_success,
80 'mirrorlist=s' => \$mirrorlist,
81 'urpmi-root=s' => \$::rpmdrake_options{'urpmi-root'}[0],
82 );
83
84 # compatibility with -update:
85 if ($ARGV[0] =~ /^-?-update/) {
86 $update = 1;
87 shift @ARGV;
88 }
89
90 my @addmedia_args;
91 my @names;
92
93 while (@ARGV) {
94 my ($name, $url) = @ARGV;
95
96 if ($mirrorlist) {
97 ($with_dir, $url) = ($url, undef);
98 } elsif ($distrib) {
99 ($name, $url) = ('', $name);
100 } elsif ($url !~ m,^(([^:]*):/)?/,) {
101 interactive_msg('gurpmi.addmedia',
102 escape_text_for_TextView_markup_format(
103 N("bad <url> (for local directory, the path must be absolute)") . "\n\n$url"));
104 myexit(-1);
105 }
106 push @addmedia_args, [ $name, $url ];
107 push @names, $name;
108 shift @ARGV foreach 1 .. 2;
109 }
110
111 if ($mirrorlist && $distrib && !@addmedia_args) {
112 @addmedia_args = [ '' ];
113 }
114
115 $fromfile and do {
116 interactive_msg('gurpmi.addmedia',
117 N("%s
118
119 Is it ok to continue?",
120 $distrib || !@names
121 ? N("You are about to add new package media.
122 That means you will be able to add new software packages
123 to your system from these new media.")
124 : 1 < @names
125 ? N("You are about to add new package medium, %s.
126 That means you will be able to add new software packages
127 to your system from these new media.", join ", ", @names)
128 : N("You are about to add a new package medium, `%s'.
129 That means you will be able to add new software packages
130 to your system from that new medium.", $names[0])
131 ),
132 yesno => 1) or myexit(-1);
133 };
134
135 my $urpm = fast_open_urpmi_db();
136 my $success = 1;
137 foreach (@addmedia_args) {
138 #- NB: that short circuits
139 $success = $success && add_medium_and_check(
140 $urpm,
141 { distrib => $distrib },
142 $_->[0],
143 $_->[1],
144 if_(!$distrib, undef),
145 if_($update, update => $update, only_updates => $update),
146 mirrorlist => $mirrorlist,
147 if_($with_dir, 'with-dir' => $with_dir),
148 );
149 }
150 if ($success) {
151 my $message =
152 $distrib ? N("Successfully added media.")
153 : @names > 1
154 ? N("Successfully added media %s.", join ", ", @names)
155 : N("Successfully added medium `%s'.", $names[0]);
156 interactive_msg('gurpmi.addmedia', $message) if !$silent_success;
157 myexit(0);
158 } else {
159 myexit(-1);
160 }

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.30