~ubuntu-branches/ubuntu/utopic/devscripts/utopic-security

« back to all changes in this revision

Viewing changes to scripts/rc-alert.pl

  • Committer: Package Import Robot
  • Author(s): Benjamin Drung
  • Date: 2013-02-18 22:27:33 UTC
  • mfrom: (10.9.22 experimental)
  • Revision ID: package-import@ubuntu.com-20130218222733-7krtkqzko32xte0z
Tags: 2.13.0ubuntu1
* Merge from Debian experimental. Remaining changes:
  - Convert python scripts to python3. (Closes: #680313)
    Debian bug #695259 needs to be fixed to get the change into Debian.

Show diffs side-by-side

added added

removed removed

Lines of Context:
158
158
 
159
159
## First download the RC bugs page
160
160
 
161
 
unless (system("command -v wget >/dev/null 2>&1") == 0) {
162
 
    die "$progname: this program requires the wget package to be installed\n";
 
161
my $curl_or_wget;
 
162
my $getcommand;
 
163
if (system("command -v wget >/dev/null 2>&1") == 0) {
 
164
    $curl_or_wget = "wget";
 
165
    $getcommand = "wget -q -O -";
 
166
} elsif (system("command -v curl >/dev/null 2>&1") == 0) {
 
167
    $curl_or_wget = "curl";
 
168
    $getcommand = "curl -qs";
 
169
} else {
 
170
    die "$progname: this program requires either the wget or curl package to be installed\n";
163
171
}
164
172
 
165
173
 
171
179
if (-d $cachedir) {
172
180
    chdir $cachedir or die "$progname: can't cd $cachedir: $!\n";
173
181
 
174
 
    # Either use the cached version because the remote hasn't been updated
175
 
    # (-N) or download a complete new copy (--no-continue)
176
 
    if (system('wget', '-qN', '--no-continue', $url) != 0) {
177
 
        die "$progname: wget failed!\n";
 
182
    if ("$curl_or_wget" eq "wget") {
 
183
        # Either use the cached version because the remote hasn't been
 
184
        # updated (-N) or download a complete new copy (--no-continue)
 
185
        if (system('wget', '-qN', '--no-continue', $url) != 0) {
 
186
            die "$progname: wget failed!\n";
 
187
        }
 
188
    } elsif ("$curl_or_wget" eq "curl") {
 
189
        if (system('curl', '-qsR', $url) != 0) {
 
190
            die "$progname: curl failed!\n";
 
191
        }
 
192
    } else {
 
193
        die "$progname: Unknown download program $curl_or_wget!\n";
178
194
    }
179
195
    open BUGS, $cachefile or die "$progname: could not read $cachefile: $!\n";
180
196
}
181
197
else {
182
 
    open BUGS, "wget -q -O - $url |" or
183
 
        die "$progname: could not run wget: $!\n";
 
198
    open BUGS, "$getcommand $url |" or
 
199
        die "$progname: could not run $curl_or_wget: $!\n";
184
200
}
185
201
 
186
202
## Get list of installed packages (not source packages)
204
220
            or die "$progname: Unable to access popcon data: $!";
205
221
        $pc_regex = '(\d+)\s\d+\s(\S+)';
206
222
    } else {
207
 
        open POPCON, "wget -q -O - http://popcon.debian.org/by_$pc_by.gz | gunzip -c |"
 
223
        open POPCON, "$getcommand http://popcon.debian.org/by_$pc_by.gz | gunzip -c |"
208
224
            or die "$progname: Not able to receive remote popcon data!";
209
225
        $pc_regex = '(\d+)\s+(\S+)\s+(\d+\s+){5}\(.*\)';
210
226
    }