| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package urpm::args; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
889
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
31
|
|
|
5
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
36
|
|
|
6
|
1
|
|
|
1
|
|
11
|
no warnings 'once'; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
43
|
|
|
7
|
1
|
|
|
1
|
|
812
|
use Getopt::Long; |
|
|
1
|
|
|
|
|
10723
|
|
|
|
1
|
|
|
|
|
7
|
|
|
8
|
1
|
|
|
1
|
|
992
|
use urpm::download; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use urpm::msg; |
|
10
|
|
|
|
|
|
|
use urpm::util 'file2absolute_file'; |
|
11
|
|
|
|
|
|
|
use Exporter; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our @ISA = 'Exporter'; |
|
14
|
|
|
|
|
|
|
our @EXPORT = '%options'; |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# The program that invokes us |
|
17
|
|
|
|
|
|
|
(my $tool = $0) =~ s!.*/!!; |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# Configuration of Getopt. urpmf is a special case, because we need to |
|
20
|
|
|
|
|
|
|
# parse non-alphanumerical options (-! -( -)) |
|
21
|
|
|
|
|
|
|
my @configuration = qw(bundling no_ignore_case permute); |
|
22
|
|
|
|
|
|
|
push @configuration, 'pass_through' |
|
23
|
|
|
|
|
|
|
if $tool eq 'urpmf' || $tool eq 'urpmi.addmedia'; |
|
24
|
|
|
|
|
|
|
Getopt::Long::Configure(@configuration); |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# global urpm object to be passed by the main program |
|
27
|
|
|
|
|
|
|
my $urpm; |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# stores the values of the command-line options |
|
30
|
|
|
|
|
|
|
our %options = (verbose => 0); |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# used by urpmf |
|
33
|
|
|
|
|
|
|
sub add_param_closure { |
|
34
|
|
|
|
|
|
|
my (@tags) = @_; |
|
35
|
|
|
|
|
|
|
return sub { $::qf .= join $::separator, '', map { "%$_" } @tags }; |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
# debug code to display a nice message when exiting, |
|
39
|
|
|
|
|
|
|
# to ensure f*cking code (eg: Sys::Syslog) won't exit and break graphical interfaces |
|
40
|
|
|
|
|
|
|
END { $::debug_exit and print STDERR "EXITING (pid=$$)\n" } |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub set_debug { |
|
43
|
|
|
|
|
|
|
my ($urpm) = @_; |
|
44
|
|
|
|
|
|
|
$::debug_exit = 1; |
|
45
|
|
|
|
|
|
|
$options{verbose}++; |
|
46
|
|
|
|
|
|
|
$urpm->{debug} = $urpm->{debug_URPM} = sub { print STDERR "$_[0]\n" }; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub set_verbose { |
|
50
|
|
|
|
|
|
|
$options{verbose} += $_[0]; |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# options specifications for Getopt::Long |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
my %options_spec_all = ( |
|
56
|
|
|
|
|
|
|
'debug' => sub { set_debug($urpm) }, |
|
57
|
|
|
|
|
|
|
'debug-librpm' => sub { URPM::setVerbosity(7) }, # 7 == RPMLOG_DEBUG |
|
58
|
|
|
|
|
|
|
'q|quiet' => sub { set_verbose(-1) }, |
|
59
|
|
|
|
|
|
|
'v|verbose' => sub { set_verbose(1) }, |
|
60
|
|
|
|
|
|
|
'urpmi-root=s' => sub { urpm::set_files($urpm, $_[1]) }, |
|
61
|
|
|
|
|
|
|
'wait-lock' => \$options{wait_lock}, |
|
62
|
|
|
|
|
|
|
'use-copied-hdlist' => sub { $urpm->{options}{use_copied_hdlist} = 1 }, |
|
63
|
|
|
|
|
|
|
'tune-rpm=s' => sub { urpm::set_tune_rpm($urpm, $_[1]) }, |
|
64
|
|
|
|
|
|
|
"no-locales" => sub { $urpm::msg::no_translation = 1 }, |
|
65
|
|
|
|
|
|
|
"version" => sub { require urpm; print "$tool $urpm::VERSION\n"; exit(0) }, |
|
66
|
|
|
|
|
|
|
"help|h" => sub { |
|
67
|
|
|
|
|
|
|
if (defined &::usage) { ::usage() } else { die "No help defined\n" } |
|
68
|
|
|
|
|
|
|
}, |
|
69
|
|
|
|
|
|
|
); |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
my %options_spec = ( |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# warning: for gurpm, urpm is _not_ a real urpmi object, only options should be altered: |
|
74
|
|
|
|
|
|
|
gurpmi => { |
|
75
|
|
|
|
|
|
|
'media|mediums=s' => sub { $urpm->{options}{media} = 1 }, |
|
76
|
|
|
|
|
|
|
'searchmedia|search-media=s' => sub { $urpm->{options}{searchmedia} = 1 }, |
|
77
|
|
|
|
|
|
|
}, |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
urpmi => { |
|
80
|
|
|
|
|
|
|
update => \$::update, |
|
81
|
|
|
|
|
|
|
'media|mediums=s' => \$::media, |
|
82
|
|
|
|
|
|
|
'excludemedia|exclude-media=s' => \$::excludemedia, |
|
83
|
|
|
|
|
|
|
'sortmedia|sort-media=s' => \$::sortmedia, |
|
84
|
|
|
|
|
|
|
'searchmedia|search-media=s' => \$::searchmedia, |
|
85
|
|
|
|
|
|
|
'synthesis=s' => \$options{synthesis}, |
|
86
|
|
|
|
|
|
|
auto => sub { $urpm->{options}{auto} = 1 }, |
|
87
|
|
|
|
|
|
|
'allow-medium-change' => \$::allow_medium_change, |
|
88
|
|
|
|
|
|
|
'auto-select' => \$::auto_select, |
|
89
|
|
|
|
|
|
|
'auto-update' => sub { $::auto_update = $::auto_select = 1 }, |
|
90
|
|
|
|
|
|
|
'auto-orphans' => \$options{auto_orphans}, |
|
91
|
|
|
|
|
|
|
'no-remove|no-uninstall' => \$::no_remove, |
|
92
|
|
|
|
|
|
|
'no-install|noinstall' => \$::no_install, |
|
93
|
|
|
|
|
|
|
'keep!' => sub { $urpm->{options}{keep} = $_[1] }, |
|
94
|
|
|
|
|
|
|
'logfile=s' => \$::logfile, |
|
95
|
|
|
|
|
|
|
'split-level=s' => sub { $urpm->{options}{'split-level'} = $_[1] }, |
|
96
|
|
|
|
|
|
|
'split-length=s' => sub { $urpm->{options}{'split-length'} = $_[1] }, |
|
97
|
|
|
|
|
|
|
'fuzzy!' => sub { $urpm->{options}{fuzzy} = $_[1] }, |
|
98
|
|
|
|
|
|
|
'src|s' => sub { $urpm->{error}("option --src is deprecated, use --buildrequires instead (nb: it doesn't download src.rpm anymore)"); |
|
99
|
|
|
|
|
|
|
$options{buildrequires} = 1 }, |
|
100
|
|
|
|
|
|
|
'buildrequires' => \$options{buildrequires}, |
|
101
|
|
|
|
|
|
|
'install-src' => \$::install_src, |
|
102
|
|
|
|
|
|
|
clean => sub { $::clean = 1; $::noclean = 0 }, |
|
103
|
|
|
|
|
|
|
noclean => sub { |
|
104
|
|
|
|
|
|
|
$::clean = $urpm->{options}{'pre-clean'} = $urpm->{options}{'post-clean'} = 0; |
|
105
|
|
|
|
|
|
|
$::noclean = 1; |
|
106
|
|
|
|
|
|
|
}, |
|
107
|
|
|
|
|
|
|
'pre-clean!' => sub { $urpm->{options}{'pre-clean'} = $_[1] }, |
|
108
|
|
|
|
|
|
|
'post-clean!' => sub { $urpm->{options}{'post-clean'} = $_[1] }, |
|
109
|
|
|
|
|
|
|
'no-priority-upgrade' => sub { |
|
110
|
|
|
|
|
|
|
#- keep this option which is passed by older urpmi. |
|
111
|
|
|
|
|
|
|
#- since we can't know what the previous_priority_upgrade list was, |
|
112
|
|
|
|
|
|
|
#- just use a rubbish value which will mean list has changed |
|
113
|
|
|
|
|
|
|
$options{previous_priority_upgrade} = 'list_has_changed'; |
|
114
|
|
|
|
|
|
|
}, |
|
115
|
|
|
|
|
|
|
'previous-priority-upgrade=s' => \$options{previous_priority_upgrade}, |
|
116
|
|
|
|
|
|
|
force => \$::force, |
|
117
|
|
|
|
|
|
|
justdb => \$options{justdb}, |
|
118
|
|
|
|
|
|
|
replacepkgs => \$options{replacepkgs}, |
|
119
|
|
|
|
|
|
|
suggests => sub { |
|
120
|
|
|
|
|
|
|
$urpm->{fatal}(1, "Use --allow-recommends instead of --suggests"); |
|
121
|
|
|
|
|
|
|
}, |
|
122
|
|
|
|
|
|
|
'allow-suggests' => sub { |
|
123
|
|
|
|
|
|
|
warn "WARNING: --allow-suggests is deprecated. Use --allow-recommends instead\n"; |
|
124
|
|
|
|
|
|
|
$urpm->{options}{'no-recommends'} = 0 }, |
|
125
|
|
|
|
|
|
|
'allow-recommends' => sub { $urpm->{options}{'no-recommends'} = 0 }, |
|
126
|
|
|
|
|
|
|
'no-recommends' => sub { $urpm->{options}{'no-recommends'} = 1 }, |
|
127
|
|
|
|
|
|
|
'no-suggests' => sub { # COMPAT |
|
128
|
|
|
|
|
|
|
warn "WARNING: --no-suggests is deprecated. Use --no-recommends instead\n"; |
|
129
|
|
|
|
|
|
|
$urpm->{options}{'no-recommends'} = 1; |
|
130
|
|
|
|
|
|
|
}, |
|
131
|
|
|
|
|
|
|
'allow-nodeps' => sub { $urpm->{options}{'allow-nodeps'} = 1 }, |
|
132
|
|
|
|
|
|
|
'allow-force' => sub { $urpm->{options}{'allow-force'} = 1 }, |
|
133
|
|
|
|
|
|
|
'downgrade' => sub { $urpm->{options}{downgrade} = 1 }, |
|
134
|
|
|
|
|
|
|
'parallel=s' => \$::parallel, |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
'metalink!' => sub { $urpm->{options}{metalink} = $_[1] }, |
|
137
|
|
|
|
|
|
|
'download-all:s' => sub { $urpm->{options}{'download-all'} = $_[1] }, |
|
138
|
|
|
|
|
|
|
# deprecated in favor of --downloader xxx |
|
139
|
|
|
|
|
|
|
wget => sub { $urpm->{options}{downloader} = 'wget' }, |
|
140
|
|
|
|
|
|
|
curl => sub { $urpm->{options}{downloader} = 'curl' }, |
|
141
|
|
|
|
|
|
|
prozilla => sub { $urpm->{options}{downloader} = 'prozilla' }, |
|
142
|
|
|
|
|
|
|
aria2 => sub { $urpm->{options}{downloader} = 'aria2' }, |
|
143
|
|
|
|
|
|
|
'downloader=s' => sub { $urpm->{options}{downloader} = $_[1] }, |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
'curl-options=s' => sub { $urpm->{options}{'curl-options'} = $_[1] }, |
|
146
|
|
|
|
|
|
|
'rsync-options=s' => sub { $urpm->{options}{'rsync-options'} = $_[1] }, |
|
147
|
|
|
|
|
|
|
'wget-options=s' => sub { $urpm->{options}{'wget-options'} = $_[1] }, |
|
148
|
|
|
|
|
|
|
'prozilla-options=s' => sub { $urpm->{options}{'prozilla-options'} = $_[1] }, |
|
149
|
|
|
|
|
|
|
'aria2-options=s' => sub { $urpm->{options}{'aria2-options'} = $_[1] }, |
|
150
|
|
|
|
|
|
|
'limit-rate=s' => sub { $urpm->{options}{'limit-rate'} = $_[1] }, |
|
151
|
|
|
|
|
|
|
'resume!' => sub { $urpm->{options}{resume} = $_[1] }, |
|
152
|
|
|
|
|
|
|
'retry=s' => sub { $urpm->{options}{retry} = $_[1] }, |
|
153
|
|
|
|
|
|
|
'proxy=s' => sub { |
|
154
|
|
|
|
|
|
|
my (undef, $value) = @_; |
|
155
|
|
|
|
|
|
|
my ($proxy, $port) = urpm::download::parse_http_proxy($value) |
|
156
|
|
|
|
|
|
|
or die N("bad proxy declaration on command line\n"); |
|
157
|
|
|
|
|
|
|
$proxy .= ":1080" unless $port; |
|
158
|
|
|
|
|
|
|
urpm::download::set_cmdline_proxy(http_proxy => "http://$proxy/"); |
|
159
|
|
|
|
|
|
|
}, |
|
160
|
|
|
|
|
|
|
'proxy-user=s' => sub { |
|
161
|
|
|
|
|
|
|
my (undef, $value) = @_; |
|
162
|
|
|
|
|
|
|
if ($value eq 'ask') { #- should prompt for user/password |
|
163
|
|
|
|
|
|
|
urpm::download::set_cmdline_proxy(ask => 1); |
|
164
|
|
|
|
|
|
|
} else { |
|
165
|
|
|
|
|
|
|
$value =~ /(.+):(.+)/ or die N("bad proxy declaration on command line\n"); |
|
166
|
|
|
|
|
|
|
urpm::download::set_cmdline_proxy(user => $1, pwd => $2); |
|
167
|
|
|
|
|
|
|
} |
|
168
|
|
|
|
|
|
|
}, |
|
169
|
|
|
|
|
|
|
'bug=s' => \$options{bug}, |
|
170
|
|
|
|
|
|
|
'env=s' => \$::env, |
|
171
|
|
|
|
|
|
|
'verify-rpm!' => sub { $urpm->{options}{'verify-rpm'} = $_[1] }, |
|
172
|
|
|
|
|
|
|
'strict-arch!' => sub { $urpm->{options}{'strict-arch'} = $_[1] }, |
|
173
|
|
|
|
|
|
|
'norebuild!' => sub { $urpm->{options}{'build-hdlist-on-error'} = !$_[1] }, |
|
174
|
|
|
|
|
|
|
'test!' => \$::test, |
|
175
|
|
|
|
|
|
|
'debug__do_not_install' => \$options{debug__do_not_install}, |
|
176
|
|
|
|
|
|
|
deploops => \$options{deploops}, |
|
177
|
|
|
|
|
|
|
'skip=s' => \$options{skip}, |
|
178
|
|
|
|
|
|
|
'prefer=s' => \$options{prefer}, |
|
179
|
|
|
|
|
|
|
'root=s' => sub { set_root($urpm, $_[1]) }, |
|
180
|
|
|
|
|
|
|
'use-distrib=s' => sub { |
|
181
|
|
|
|
|
|
|
$options{usedistrib} = $_[1]; |
|
182
|
|
|
|
|
|
|
return if !$>; |
|
183
|
|
|
|
|
|
|
$urpm->{cachedir} = $urpm->valid_cachedir; |
|
184
|
|
|
|
|
|
|
$urpm->{statedir} = $urpm->valid_statedir; |
|
185
|
|
|
|
|
|
|
}, |
|
186
|
|
|
|
|
|
|
'probe-synthesis' => sub { $options{probe_with} = 'synthesis' }, |
|
187
|
|
|
|
|
|
|
'probe-hdlist' => sub { $options{probe_with} = 'synthesis' }, #- ignored, kept for compatibility |
|
188
|
|
|
|
|
|
|
'excludepath|exclude-path=s' => sub { $urpm->{options}{excludepath} = $_[1] }, |
|
189
|
|
|
|
|
|
|
'excludedocs|exclude-docs' => sub { $urpm->{options}{excludedocs} = 1 }, |
|
190
|
|
|
|
|
|
|
'ignoresize' => sub { $urpm->{options}{ignoresize} = 1 }, |
|
191
|
|
|
|
|
|
|
'ignorearch' => sub { $urpm->{options}{ignorearch} = 1 }, |
|
192
|
|
|
|
|
|
|
noscripts => sub { $urpm->{options}{noscripts} = 1 }, |
|
193
|
|
|
|
|
|
|
replacefiles => sub { $urpm->{options}{replacefiles} = 1 }, |
|
194
|
|
|
|
|
|
|
'more-choices' => sub { $urpm->{options}{morechoices} = 1 }, |
|
195
|
|
|
|
|
|
|
'expect-install!' => \$::urpm::main_loop::expect_install, |
|
196
|
|
|
|
|
|
|
'nolock' => \$options{nolock}, |
|
197
|
|
|
|
|
|
|
restricted => \$::restricted, |
|
198
|
|
|
|
|
|
|
'force-key' => \$::forcekey, |
|
199
|
|
|
|
|
|
|
a => \$::all, |
|
200
|
|
|
|
|
|
|
p => sub { $::use_provides = 1 }, |
|
201
|
|
|
|
|
|
|
P => sub { $::use_provides = 0 }, |
|
202
|
|
|
|
|
|
|
y => sub { $urpm->{options}{fuzzy} = 1 }, |
|
203
|
|
|
|
|
|
|
z => sub { $urpm->{options}{compress} = 1 }, |
|
204
|
|
|
|
|
|
|
}, |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
urpme => { |
|
207
|
|
|
|
|
|
|
a => \$options{matches}, |
|
208
|
|
|
|
|
|
|
restricted => \$options{restricted}, |
|
209
|
|
|
|
|
|
|
}, |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
#- see also below, autogenerated callbacks |
|
212
|
|
|
|
|
|
|
urpmf => { |
|
213
|
|
|
|
|
|
|
conffiles => add_param_closure('conf_files'), |
|
214
|
|
|
|
|
|
|
debug => \$::debug, |
|
215
|
|
|
|
|
|
|
'literal|l' => \$::literal, |
|
216
|
|
|
|
|
|
|
name => sub { |
|
217
|
|
|
|
|
|
|
add_param_closure('name')->(); |
|
218
|
|
|
|
|
|
|
#- Remove default tag in front if --name is explicitly given |
|
219
|
|
|
|
|
|
|
$::qf =~ s/^%default:?//; |
|
220
|
|
|
|
|
|
|
}, |
|
221
|
|
|
|
|
|
|
'qf=s' => \$::qf, |
|
222
|
|
|
|
|
|
|
'uniq|u' => \$::uniq, |
|
223
|
|
|
|
|
|
|
m => add_param_closure('media'), |
|
224
|
|
|
|
|
|
|
i => sub { $::pattern = 'i' }, |
|
225
|
|
|
|
|
|
|
I => sub { $::pattern = '' }, |
|
226
|
|
|
|
|
|
|
f => sub { $::full = 1 }, |
|
227
|
|
|
|
|
|
|
'F=s' => sub { $::separator = $_[1] }, |
|
228
|
|
|
|
|
|
|
'e=s' => sub { $::expr .= "($_[1])" }, |
|
229
|
|
|
|
|
|
|
a => sub { add_urpmf_binary_op('&&', '-a') }, |
|
230
|
|
|
|
|
|
|
o => sub { add_urpmf_binary_op('||', '-o') }, |
|
231
|
|
|
|
|
|
|
'<>' => sub { |
|
232
|
|
|
|
|
|
|
my $p = shift; |
|
233
|
|
|
|
|
|
|
if ($p =~ /^-?([!()])$/) { |
|
234
|
|
|
|
|
|
|
# This is for -! -( -) |
|
235
|
|
|
|
|
|
|
my $op = $1; |
|
236
|
|
|
|
|
|
|
$op eq ')' ? add_urpmf_close_paren() : add_urpmf_unary_op($op); |
|
237
|
|
|
|
|
|
|
} |
|
238
|
|
|
|
|
|
|
elsif ($p =~ /^--?(.+)/) { |
|
239
|
|
|
|
|
|
|
# unrecognized option |
|
240
|
|
|
|
|
|
|
die "Unknown option: $1\n"; |
|
241
|
|
|
|
|
|
|
} |
|
242
|
|
|
|
|
|
|
else { |
|
243
|
|
|
|
|
|
|
# This is for non-option arguments. |
|
244
|
|
|
|
|
|
|
add_urpmf_parameter($p); |
|
245
|
|
|
|
|
|
|
} |
|
246
|
|
|
|
|
|
|
}, |
|
247
|
|
|
|
|
|
|
}, |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
urpmq => { |
|
250
|
|
|
|
|
|
|
update => \$options{update}, |
|
251
|
|
|
|
|
|
|
'media|mediums=s' => \$options{media}, |
|
252
|
|
|
|
|
|
|
'excludemedia|exclude-media=s' => \$options{excludemedia}, |
|
253
|
|
|
|
|
|
|
'sortmedia|sort-media=s' => \$options{sortmedia}, |
|
254
|
|
|
|
|
|
|
'searchmedia|search-media=s' => \$options{searchmedia}, |
|
255
|
|
|
|
|
|
|
'auto-select' => sub { |
|
256
|
|
|
|
|
|
|
$options{deps} = $options{upgrade} = $options{auto_select} = 1; |
|
257
|
|
|
|
|
|
|
}, |
|
258
|
|
|
|
|
|
|
'fuzzy|y' => sub { $urpm->{options}{fuzzy} = 1; $options{all} = 1 }, |
|
259
|
|
|
|
|
|
|
'not-available' => \$options{not_available}, |
|
260
|
|
|
|
|
|
|
keep => \$options{keep}, |
|
261
|
|
|
|
|
|
|
list => \$options{list}, |
|
262
|
|
|
|
|
|
|
changelog => \$options{changelog}, |
|
263
|
|
|
|
|
|
|
conflicts => \$options{conflicts}, |
|
264
|
|
|
|
|
|
|
obsoletes => \$options{obsoletes}, |
|
265
|
|
|
|
|
|
|
provides => \$options{provides}, |
|
266
|
|
|
|
|
|
|
sourcerpm => \$options{sourcerpm}, |
|
267
|
|
|
|
|
|
|
'summary|S' => \$options{summary}, |
|
268
|
|
|
|
|
|
|
recommends => sub { |
|
269
|
|
|
|
|
|
|
$options{recommends} = 1; |
|
270
|
|
|
|
|
|
|
}, |
|
271
|
|
|
|
|
|
|
suggests => sub { |
|
272
|
|
|
|
|
|
|
$urpm->{error}("--suggests now displays the suggested packages, see --allow-suggests for previous behaviour"); |
|
273
|
|
|
|
|
|
|
$urpm->{error}("You should now use --recommends."); |
|
274
|
|
|
|
|
|
|
$options{recommends} = 1; |
|
275
|
|
|
|
|
|
|
}, |
|
276
|
|
|
|
|
|
|
'list-media:s' => sub { $options{list_media} = $_[1] || 'all' }, |
|
277
|
|
|
|
|
|
|
'list-url' => \$options{list_url}, |
|
278
|
|
|
|
|
|
|
'list-nodes' => \$options{list_nodes}, |
|
279
|
|
|
|
|
|
|
'list-aliases' => \$options{list_aliases}, |
|
280
|
|
|
|
|
|
|
'ignorearch' => \$options{ignorearch}, |
|
281
|
|
|
|
|
|
|
'dump-config' => \$options{dump_config}, |
|
282
|
|
|
|
|
|
|
'src|s' => \$options{src}, |
|
283
|
|
|
|
|
|
|
sources => \$options{sources}, |
|
284
|
|
|
|
|
|
|
force => \$options{force}, |
|
285
|
|
|
|
|
|
|
'parallel=s' => \$options{parallel}, |
|
286
|
|
|
|
|
|
|
'env=s' => \$options{env}, |
|
287
|
|
|
|
|
|
|
requires => sub { |
|
288
|
|
|
|
|
|
|
$urpm->{error}("--requires behaviour changed, use --requires-recursive to get the old behaviour"); |
|
289
|
|
|
|
|
|
|
$options{requires} = 1; |
|
290
|
|
|
|
|
|
|
}, |
|
291
|
|
|
|
|
|
|
'requires-recursive|d' => \$options{deps}, |
|
292
|
|
|
|
|
|
|
u => \$options{upgrade}, |
|
293
|
|
|
|
|
|
|
a => \$options{all}, |
|
294
|
|
|
|
|
|
|
'm|M' => sub { $options{deps} = $options{upgrade} = 1 }, |
|
295
|
|
|
|
|
|
|
c => \$options{complete}, |
|
296
|
|
|
|
|
|
|
g => \$options{group}, |
|
297
|
|
|
|
|
|
|
'whatprovides|p' => \$options{use_provides}, |
|
298
|
|
|
|
|
|
|
P => sub { $options{use_provides} = 0 }, |
|
299
|
|
|
|
|
|
|
R => sub { $urpm->{error}($options{what_requires} ? |
|
300
|
|
|
|
|
|
|
"option -RR is deprecated, use --whatrequires-recursive instead" : |
|
301
|
|
|
|
|
|
|
"option -R is deprecated, use --whatrequires instead"); |
|
302
|
|
|
|
|
|
|
$options{what_requires} and $options{what_requires_recursive} = 1; |
|
303
|
|
|
|
|
|
|
$options{what_requires} = 1 }, |
|
304
|
|
|
|
|
|
|
whatrequires => sub { $options{what_requires} = 1 }, |
|
305
|
|
|
|
|
|
|
'whatrequires-recursive' => sub { $options{what_requires_recursive} = $options{what_requires} = 1 }, |
|
306
|
|
|
|
|
|
|
Y => sub { $urpm->{options}{fuzzy} = 1; $options{all} = $options{caseinsensitive} = 1 }, |
|
307
|
|
|
|
|
|
|
i => \$options{info}, |
|
308
|
|
|
|
|
|
|
l => \$options{files}, |
|
309
|
|
|
|
|
|
|
r => sub { |
|
310
|
|
|
|
|
|
|
$options{version} = $options{release} = 1; |
|
311
|
|
|
|
|
|
|
}, |
|
312
|
|
|
|
|
|
|
f => sub { |
|
313
|
|
|
|
|
|
|
$options{version} = $options{release} = $options{arch} = 1; |
|
314
|
|
|
|
|
|
|
}, |
|
315
|
|
|
|
|
|
|
'<>' => sub { |
|
316
|
|
|
|
|
|
|
my $x = $_[0]; |
|
317
|
|
|
|
|
|
|
if ($x =~ /\.rpm$/) { |
|
318
|
|
|
|
|
|
|
if (-r $x) { push @::files, $x } |
|
319
|
|
|
|
|
|
|
else { |
|
320
|
|
|
|
|
|
|
print STDERR N("urpmq: cannot read rpm file \"%s\"\n", $x); |
|
321
|
|
|
|
|
|
|
$urpm::postponed_code = 1; |
|
322
|
|
|
|
|
|
|
} |
|
323
|
|
|
|
|
|
|
} elsif ($x =~ /^--?(.+)/) { # unrecognized option |
|
324
|
|
|
|
|
|
|
die "Unknown option: $1\n"; |
|
325
|
|
|
|
|
|
|
} else { |
|
326
|
|
|
|
|
|
|
if ($options{src}) { |
|
327
|
|
|
|
|
|
|
push @::src_names, $x; |
|
328
|
|
|
|
|
|
|
} else { |
|
329
|
|
|
|
|
|
|
push @::names, $x; |
|
330
|
|
|
|
|
|
|
} |
|
331
|
|
|
|
|
|
|
$options{src} = 0; #- reset switch for next package. |
|
332
|
|
|
|
|
|
|
} |
|
333
|
|
|
|
|
|
|
}, |
|
334
|
|
|
|
|
|
|
}, |
|
335
|
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
'urpmi.update' => { |
|
337
|
|
|
|
|
|
|
a => \$options{all}, |
|
338
|
|
|
|
|
|
|
c => sub {}, # obsolete |
|
339
|
|
|
|
|
|
|
f => sub { ++$options{force}; $options{probe_with} = 'rpms' if $options{force} == 2 }, |
|
340
|
|
|
|
|
|
|
z => sub { ++$options{compress} }, |
|
341
|
|
|
|
|
|
|
update => \$options{update}, |
|
342
|
|
|
|
|
|
|
'ignore!' => sub { $options{ignore} = $_[1] }, |
|
343
|
|
|
|
|
|
|
'force-key' => \$options{forcekey}, |
|
344
|
|
|
|
|
|
|
'no-md5sum' => \$options{nomd5sum}, |
|
345
|
|
|
|
|
|
|
'noa|d' => \my $_dummy, #- default, kept for compatibility |
|
346
|
|
|
|
|
|
|
'norebuild!' => sub { $urpm->{options}{'build-hdlist-on-error'} = !$_[1]; $options{force} = 0 }, |
|
347
|
|
|
|
|
|
|
'probe-rpms' => sub { $options{probe_with} = 'rpms' }, |
|
348
|
|
|
|
|
|
|
'<>' => sub { |
|
349
|
|
|
|
|
|
|
my ($p) = @_; |
|
350
|
|
|
|
|
|
|
if ($p =~ /^--?(.+)/) { # unrecognized option |
|
351
|
|
|
|
|
|
|
die "Unknown option: $1\n"; |
|
352
|
|
|
|
|
|
|
} |
|
353
|
|
|
|
|
|
|
push @::cmdline, $p; |
|
354
|
|
|
|
|
|
|
}, |
|
355
|
|
|
|
|
|
|
}, |
|
356
|
|
|
|
|
|
|
|
|
357
|
|
|
|
|
|
|
'urpmi.addmedia' => { |
|
358
|
|
|
|
|
|
|
'xml-info=s' => \$options{'xml-info'}, |
|
359
|
|
|
|
|
|
|
'no-probe' => sub { $options{probe_with} = undef }, |
|
360
|
|
|
|
|
|
|
distrib => sub { $options{distrib} = 1 }, |
|
361
|
|
|
|
|
|
|
'mirrorlist:s' => sub { $options{mirrorlist} = $_[1] || '$MIRRORLIST' }, |
|
362
|
|
|
|
|
|
|
zeroconf => sub { $options{zeroconf} = 1 }, |
|
363
|
|
|
|
|
|
|
interactive => sub { $options{interactive} = 1 }, |
|
364
|
|
|
|
|
|
|
'all-media' => sub { $options{allmedia} = 1 }, |
|
365
|
|
|
|
|
|
|
virtual => \$options{virtual}, |
|
366
|
|
|
|
|
|
|
nopubkey => \$options{nopubkey}, |
|
367
|
|
|
|
|
|
|
raw => \$options{raw}, |
|
368
|
|
|
|
|
|
|
'verify-rpm!' => sub { ${options}{'verify-rpm'} = $_[1] }, |
|
369
|
|
|
|
|
|
|
}, |
|
370
|
|
|
|
|
|
|
|
|
371
|
|
|
|
|
|
|
); |
|
372
|
|
|
|
|
|
|
|
|
373
|
|
|
|
|
|
|
# generate urpmf options callbacks |
|
374
|
|
|
|
|
|
|
sub add_urpmf_cmdline_tags { |
|
375
|
|
|
|
|
|
|
foreach my $k (@_) { |
|
376
|
|
|
|
|
|
|
$options_spec{urpmf}{$k} ||= add_param_closure($k); |
|
377
|
|
|
|
|
|
|
} |
|
378
|
|
|
|
|
|
|
} |
|
379
|
|
|
|
|
|
|
|
|
380
|
|
|
|
|
|
|
sub _current_urpmf_left_expr() { |
|
381
|
|
|
|
|
|
|
my $left = $::left_expr || $::expr && "$::expr || " || ''; |
|
382
|
|
|
|
|
|
|
$::left_expr = $::expr = undef; |
|
383
|
|
|
|
|
|
|
$left; |
|
384
|
|
|
|
|
|
|
} |
|
385
|
|
|
|
|
|
|
|
|
386
|
|
|
|
|
|
|
sub add_urpmf_binary_op { |
|
387
|
|
|
|
|
|
|
my ($op, $cmdline) = @_; |
|
388
|
|
|
|
|
|
|
$::left_expr and $urpm->{fatal}(1, N("unexpected expression %s", $::left_expr)); |
|
389
|
|
|
|
|
|
|
$::expr or $urpm->{fatal}(1, N("missing expression before %s", $cmdline)); |
|
390
|
|
|
|
|
|
|
|
|
391
|
|
|
|
|
|
|
($::expr, $::left_expr) = (undef, $::expr . " $op "); |
|
392
|
|
|
|
|
|
|
} |
|
393
|
|
|
|
|
|
|
sub add_urpmf_unary_op { |
|
394
|
|
|
|
|
|
|
my ($op) = @_; |
|
395
|
|
|
|
|
|
|
$::expr and $urpm->{fatal}(1, N("unexpected expression %s (suggestion: use -a or -o ?)", $::expr)); |
|
396
|
|
|
|
|
|
|
($::expr, $::left_expr) = (undef, $::left_expr . $op); |
|
397
|
|
|
|
|
|
|
} |
|
398
|
|
|
|
|
|
|
sub add_urpmf_close_paren() { |
|
399
|
|
|
|
|
|
|
$::expr or $urpm->{fatal}(1, N("no expression to close")); |
|
400
|
|
|
|
|
|
|
$::expr .= ')'; |
|
401
|
|
|
|
|
|
|
} |
|
402
|
|
|
|
|
|
|
sub add_urpmf_parameter { |
|
403
|
|
|
|
|
|
|
my ($p) = @_; |
|
404
|
|
|
|
|
|
|
|
|
405
|
|
|
|
|
|
|
if ($::literal) { |
|
406
|
|
|
|
|
|
|
$p = quotemeta $p; |
|
407
|
|
|
|
|
|
|
} else { |
|
408
|
|
|
|
|
|
|
$p =~ /\([^?|]*\)$/ and $urpm->{error}(N("by default urpmf awaits a regexp. you should use option \"--literal\"")); |
|
409
|
|
|
|
|
|
|
push @::raw_non_literals, $p; |
|
410
|
|
|
|
|
|
|
# quote "+" chars for packages with + in their names |
|
411
|
|
|
|
|
|
|
$p =~ s/\+/\\+/g; |
|
412
|
|
|
|
|
|
|
} |
|
413
|
|
|
|
|
|
|
$::expr = _current_urpmf_left_expr() . "m{$p}" . $::pattern; |
|
414
|
|
|
|
|
|
|
} |
|
415
|
|
|
|
|
|
|
|
|
416
|
|
|
|
|
|
|
# common options setup |
|
417
|
|
|
|
|
|
|
|
|
418
|
|
|
|
|
|
|
foreach my $k ('allow-medium-change', 'auto', 'auto-select', 'clean', 'download-all:s', 'force', 'expect-install!', 'justdb', 'no-priority-upgrade', 'noscripts', 'replacefiles', 'p', 'P', 'previous-priority-upgrade=s', 'root=s', 'test!', 'verify-rpm!', 'update', |
|
419
|
|
|
|
|
|
|
'split-level=s', 'split-length=s') |
|
420
|
|
|
|
|
|
|
{ |
|
421
|
|
|
|
|
|
|
$options_spec{gurpmi}{$k} = $options_spec{urpmi}{$k}; |
|
422
|
|
|
|
|
|
|
} |
|
423
|
|
|
|
|
|
|
$options_spec{gurpmi2} = $options_spec{gurpmi}; |
|
424
|
|
|
|
|
|
|
|
|
425
|
|
|
|
|
|
|
foreach my $k ("test!", "force", "root=s", "use-distrib=s", 'env=s', |
|
426
|
|
|
|
|
|
|
'noscripts', 'auto', 'auto-orphans', 'justdb', |
|
427
|
|
|
|
|
|
|
"parallel=s") |
|
428
|
|
|
|
|
|
|
{ |
|
429
|
|
|
|
|
|
|
$options_spec{urpme}{$k} = $options_spec{urpmi}{$k}; |
|
430
|
|
|
|
|
|
|
} |
|
431
|
|
|
|
|
|
|
foreach my $k ("root=s", "nolock", "use-distrib=s", "skip=s", "prefer=s", "synthesis=s", 'no-recommends', 'no-suggests', 'allow-recommends', 'allow-suggests', 'auto-orphans') |
|
432
|
|
|
|
|
|
|
{ |
|
433
|
|
|
|
|
|
|
$options_spec{urpmq}{$k} = $options_spec{urpmi}{$k}; |
|
434
|
|
|
|
|
|
|
} |
|
435
|
|
|
|
|
|
|
|
|
436
|
|
|
|
|
|
|
foreach my $k ("update", "media|mediums=s", |
|
437
|
|
|
|
|
|
|
"excludemedia|exclude-media=s", "sortmedia|sort-media=s", "use-distrib=s", |
|
438
|
|
|
|
|
|
|
"synthesis=s", "env=s") |
|
439
|
|
|
|
|
|
|
{ |
|
440
|
|
|
|
|
|
|
$options_spec{urpmf}{$k} = $options_spec{urpmi}{$k}; |
|
441
|
|
|
|
|
|
|
} |
|
442
|
|
|
|
|
|
|
|
|
443
|
|
|
|
|
|
|
foreach my $k ("wget", "curl", "prozilla", "aria2", 'downloader=s', "proxy=s", "proxy-user=s", |
|
444
|
|
|
|
|
|
|
'limit-rate=s', 'metalink!', |
|
445
|
|
|
|
|
|
|
"wget-options=s", "curl-options=s", "rsync-options=s", "prozilla-options=s", "aria2-options=s") |
|
446
|
|
|
|
|
|
|
{ |
|
447
|
|
|
|
|
|
|
$options_spec{'urpmi.addmedia'}{$k} = |
|
448
|
|
|
|
|
|
|
$options_spec{'urpmi.update'}{$k} = |
|
449
|
|
|
|
|
|
|
$options_spec{urpmq}{$k} = $options_spec{urpmi}{$k}; |
|
450
|
|
|
|
|
|
|
} |
|
451
|
|
|
|
|
|
|
|
|
452
|
|
|
|
|
|
|
foreach my $k ("f", "z", "update", "norebuild!", "probe-rpms", '<>') |
|
453
|
|
|
|
|
|
|
{ |
|
454
|
|
|
|
|
|
|
$options_spec{'urpmi.addmedia'}{$k} = $options_spec{'urpmi.update'}{$k}; |
|
455
|
|
|
|
|
|
|
} |
|
456
|
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
foreach my $k ("no-md5sum") |
|
458
|
|
|
|
|
|
|
{ |
|
459
|
|
|
|
|
|
|
$options_spec{urpmi}{$k} = $options_spec{'urpmi.addmedia'}{$k} = $options_spec{'urpmi.update'}{$k}; |
|
460
|
|
|
|
|
|
|
} |
|
461
|
|
|
|
|
|
|
|
|
462
|
|
|
|
|
|
|
foreach my $k ("a", '<>') { |
|
463
|
|
|
|
|
|
|
$options_spec{'urpmi.removemedia'}{$k} = $options_spec{'urpmi.update'}{$k}; |
|
464
|
|
|
|
|
|
|
} |
|
465
|
|
|
|
|
|
|
foreach my $k ("y") { |
|
466
|
|
|
|
|
|
|
$options_spec{'urpmi.removemedia'}{$k} = $options_spec{urpmi}{$k}; |
|
467
|
|
|
|
|
|
|
} |
|
468
|
|
|
|
|
|
|
|
|
469
|
|
|
|
|
|
|
foreach my $k ("probe-synthesis", "probe-hdlist") # probe-hdlist is obsolete |
|
470
|
|
|
|
|
|
|
{ |
|
471
|
|
|
|
|
|
|
$options_spec{'urpmi.addmedia'}{$k} = |
|
472
|
|
|
|
|
|
|
$options_spec{urpme}{$k} = |
|
473
|
|
|
|
|
|
|
$options_spec{urpmq}{$k} = $options_spec{urpmi}{$k}; |
|
474
|
|
|
|
|
|
|
} |
|
475
|
|
|
|
|
|
|
|
|
476
|
|
|
|
|
|
|
sub set_root { |
|
477
|
|
|
|
|
|
|
my ($urpm, $root) = @_; |
|
478
|
|
|
|
|
|
|
|
|
479
|
|
|
|
|
|
|
$urpm->{root} = file2absolute_file($root); |
|
480
|
|
|
|
|
|
|
|
|
481
|
|
|
|
|
|
|
if (!-d $urpm->{root}) { |
|
482
|
|
|
|
|
|
|
$urpm->{fatal}->(9, N("chroot directory doesn't exist")); |
|
483
|
|
|
|
|
|
|
} |
|
484
|
|
|
|
|
|
|
} |
|
485
|
|
|
|
|
|
|
|
|
486
|
|
|
|
|
|
|
sub set_verbosity() { |
|
487
|
|
|
|
|
|
|
$options{verbose} >= 0 or $urpm->{info} = sub {}; |
|
488
|
|
|
|
|
|
|
$options{verbose} > 0 or $urpm->{log} = sub {}; |
|
489
|
|
|
|
|
|
|
} |
|
490
|
|
|
|
|
|
|
|
|
491
|
|
|
|
|
|
|
sub parse_cmdline { |
|
492
|
|
|
|
|
|
|
my %args = @_; |
|
493
|
|
|
|
|
|
|
$urpm = $args{urpm}; |
|
494
|
|
|
|
|
|
|
foreach my $k (keys %{$args{defaults} || {}}) { |
|
495
|
|
|
|
|
|
|
$options{$k} = $args{defaults}{$k}; |
|
496
|
|
|
|
|
|
|
} |
|
497
|
|
|
|
|
|
|
my $ret = GetOptions(%{$options_spec{$tool}}, %options_spec_all); |
|
498
|
|
|
|
|
|
|
|
|
499
|
|
|
|
|
|
|
set_verbosity(); |
|
500
|
|
|
|
|
|
|
|
|
501
|
|
|
|
|
|
|
$urpm->{tune_rpm} and urpm::tune_rpm($urpm); |
|
502
|
|
|
|
|
|
|
|
|
503
|
|
|
|
|
|
|
if ($tool ne 'urpmi.addmedia' && $tool ne 'urpmi.update' && |
|
504
|
|
|
|
|
|
|
$options{probe_with} && !$options{usedistrib}) { |
|
505
|
|
|
|
|
|
|
die N("Can't use %s without %s", "--probe-$options{probe_with}", "--use-distrib"); |
|
506
|
|
|
|
|
|
|
} |
|
507
|
|
|
|
|
|
|
if ($options{probe_with} && $options{probe_with} eq 'rpms' && $options{virtual}) { |
|
508
|
|
|
|
|
|
|
die N("Can't use %s with %s", "--probe-rpms", "--virtual"); |
|
509
|
|
|
|
|
|
|
} |
|
510
|
|
|
|
|
|
|
if ($options{nolock} && $options{wait_lock}) { |
|
511
|
|
|
|
|
|
|
warn N("Can't use %s with %s", "--wait-lock", "--nolock") . "\n"; |
|
512
|
|
|
|
|
|
|
} |
|
513
|
|
|
|
|
|
|
if ($tool eq 'urpmf' && @ARGV && $ARGV[0] eq '--') { |
|
514
|
|
|
|
|
|
|
if (@ARGV == 2) { |
|
515
|
|
|
|
|
|
|
add_urpmf_parameter($ARGV[1]); |
|
516
|
|
|
|
|
|
|
$ret = 1; |
|
517
|
|
|
|
|
|
|
} |
|
518
|
|
|
|
|
|
|
else { |
|
519
|
|
|
|
|
|
|
die N("Too many arguments\n"); |
|
520
|
|
|
|
|
|
|
} |
|
521
|
|
|
|
|
|
|
} |
|
522
|
|
|
|
|
|
|
$ret; |
|
523
|
|
|
|
|
|
|
} |
|
524
|
|
|
|
|
|
|
|
|
525
|
|
|
|
|
|
|
sub copyright { |
|
526
|
|
|
|
|
|
|
my ($prog_name, @copyrights) = @_; |
|
527
|
|
|
|
|
|
|
N("%s version %s |
|
528
|
|
|
|
|
|
|
%s |
|
529
|
|
|
|
|
|
|
This is free software and may be redistributed under the terms of the GNU GPL. |
|
530
|
|
|
|
|
|
|
|
|
531
|
|
|
|
|
|
|
usage: |
|
532
|
|
|
|
|
|
|
", $prog_name, $urpm::VERSION, |
|
533
|
|
|
|
|
|
|
join("\n", map { N("Copyright (C) %s by %s", @$_) } @copyrights) |
|
534
|
|
|
|
|
|
|
); |
|
535
|
|
|
|
|
|
|
} |
|
536
|
|
|
|
|
|
|
|
|
537
|
|
|
|
|
|
|
1; |
|
538
|
|
|
|
|
|
|
|
|
539
|
|
|
|
|
|
|
|
|
540
|
|
|
|
|
|
|
=head1 NAME |
|
541
|
|
|
|
|
|
|
|
|
542
|
|
|
|
|
|
|
urpm::args - command-line argument parser for the urpm* tools |
|
543
|
|
|
|
|
|
|
|
|
544
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
545
|
|
|
|
|
|
|
|
|
546
|
|
|
|
|
|
|
urpm::args::parse_cmdline(); |
|
547
|
|
|
|
|
|
|
|
|
548
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
549
|
|
|
|
|
|
|
|
|
550
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
551
|
|
|
|
|
|
|
|
|
552
|
|
|
|
|
|
|
Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 MandrakeSoft SA |
|
553
|
|
|
|
|
|
|
|
|
554
|
|
|
|
|
|
|
Copyright (C) 2005-2010 Mandriva SA |
|
555
|
|
|
|
|
|
|
|
|
556
|
|
|
|
|
|
|
=for vim:ts=8:sts=4:sw=4 |
|
557
|
|
|
|
|
|
|
|
|
558
|
|
|
|
|
|
|
=cut |