/[soft]/rpm/urpmi/branches/1/urpmi.update
ViewVC logotype

Contents of /rpm/urpmi/branches/1/urpmi.update

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3132 - (show annotations) (download)
Wed Feb 29 23:59:36 2012 UTC (8 years, 4 months ago) by tv
File size: 4297 byte(s)
branch

1 #!/usr/bin/perl
2
3 #- Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 MandrakeSoft SA
4 #- Copyright (C) 2005-2010 Mandriva SA
5 #-
6 #- This program is free software; you can redistribute it and/or modify
7 #- it under the terms of the GNU General Public License as published by
8 #- the Free Software Foundation; either version 2, or (at your option)
9 #- any later version.
10 #-
11 #- This program is distributed in the hope that it will be useful,
12 #- but WITHOUT ANY WARRANTY; without even the implied warranty of
13 #- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 #- GNU General Public License for more details.
15 #-
16 #- You should have received a copy of the GNU General Public License
17 #- along with this program; if not, write to the Free Software
18 #- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
20 #- this program is based upon old urpmi.addmedia
21
22 use strict;
23 use urpm;
24 use urpm::args;
25 use urpm::msg;
26 use urpm::download ();
27 use urpm::media;
28
29 sub usage() {
30 print N("usage: urpmi.update [options] <name> ...
31 where <name> is a medium name to update.
32 ") . N(" --help - print this help message.
33 ") . N(" --wget - use wget to retrieve distant files.
34 ") . N(" --curl - use curl to retrieve distant files.
35 ") . N(" --prozilla - use prozilla to retrieve distant files.
36 ") . N(" --aria2 - use aria2 to retrieve distant files.
37 ") . N(" --metalink - generate and use a local metalink.
38 ") . N(" --limit-rate - limit the download speed.
39 ") . N(" --proxy - use specified HTTP proxy, the port number is assumed
40 to be 1080 by default (format is <proxyhost[:port]>).
41 ") . N(" --proxy-user - specify user and password to use for proxy
42 authentication (format is <user:password>).
43 ") . N(" --update - update only update media.
44 ") . N(" --no-md5sum - disable MD5SUM file checking.
45 ") . N(" --force-key - force update of gpg key.
46 ") . N(" --ignore - don't update, mark the media as ignored.
47 ") . N(" --no-ignore - don't update, mark the media as enabled.
48 ") . N(" --urpmi-root - use another root for urpmi db & rpm installation.
49 ") . N(" --probe-rpms - do not use synthesis, use rpm files directly
50 ") . N(" -a - select all non-removable media.
51 ") . N(" -f - force updating synthesis
52 ") . N(" -ff - really force updating synthesis
53 ") . N(" -q - quiet mode.
54 ") . N(" -v - verbose mode.
55 ");
56 exit 1;
57 }
58
59 $ENV{PATH} = "/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin";
60 delete @ENV{qw(ENV BASH_ENV IFS CDPATH)};
61
62 our @cmdline; #- set by urpm::args
63
64 $options{force} = 0;
65
66 my $urpm = urpm->new_parse_cmdline or exit(1);
67
68 if ($< != 0) {
69 $urpm->{fatal}(1, N("Only superuser is allowed to update media"));
70 }
71 my $_urpmi_lock = urpm::lock::urpmi_db($urpm, 'exclusive', wait => $options{wait_lock});
72 urpm::media::read_config($urpm, 'nocheck');
73
74 my @chosen_media;
75
76 if ($options{all} || $options{update}) {
77 $options{allow_failures} = 1;
78 }
79
80 if ($options{all} || $options{update}) {
81 @chosen_media = urpm::media::all_media_to_update($urpm, $options{update});
82 }
83 push @chosen_media, urpm::media::select_media_by_name($urpm, \@cmdline);
84
85 @chosen_media or die $options{all} ?
86 N("nothing to update (use urpmi.addmedia to add a media)\n")
87 : N("the entry to update is missing\n(one of %s)\n", join(", ", map { $_->{name} } @{$urpm->{media}}));
88
89 if (defined $options{ignore}) {
90 foreach (@chosen_media) {
91 if ($options{ignore}) {
92 $_->{ignore} = 1;
93 } else {
94 #- force ignored media to be returned alive.
95 delete $_->{ignore};
96 }
97 }
98 my $str = join(", ", map { N("\"%s\"", $_->{name}) } @chosen_media);
99 $urpm->{log}($options{ignore} ? N("ignoring media %s", $str) : N("enabling media %s", $str));
100 urpm::media::write_config($urpm);
101 } else {
102 # this is unneeded afaik, keeping just in case it helps
103 $_->{modified} = 1 foreach @chosen_media;
104
105 my $ok = urpm::media::update_those_media($urpm, \@chosen_media, %options,
106 quiet => $options{verbose} < 0,
107 callback => \&urpm::download::sync_logger);
108 #- try to umount removable device which may have been mounted.
109 urpm::removable::try_umounting_removables($urpm);
110 exit($ok ? 0 : 1);
111 }

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.28