Bug#690024: devscripts:rc-alert: A patch for on the fly selection of curl or wget

Regid Ichira regid23 at nt1.in
Mon Oct 8 23:40:03 UTC 2012


package: devscripts
Version: 2.12.4
Tags:    patch
Files:   /usr/bin/rc-alert 
         /usr/share/doc/devscripts/README.gz

  Many devscripts choose on the fly whether to use curl or wget,
depending on what is installed.  So far rc-alert was using solely
wget.  The following patches tries to rectify this.  

1. rc-alert is a Perl script.  Can you verify that the patch is
   correct, and reasonbly written, As far as Perl is concerned? 
2. Are the following pairs equivalent?
  2.1    curl -qsR -C - $url
         wget -qN --no-continue $url
  2.2    curl -qs $url
         wget -q -O - $url


--- a/usr/bin/rc-alert	2012-09-25 01:45:59.000000000 +0200
+++ n/usr/bin/rc-alert	2012-10-09 01:26:26.000000000 +0200
@@ -158,8 +158,13 @@ $excludedists = remove_duplicate_values(
 
 ## First download the RC bugs page
 
-unless (system("command -v wget >/dev/null 2>&1") == 0) {
-    die "$progname: this program requires the wget package to be installed\n";
+my $curl_or_wget;
+if (system("command -v curl >/dev/null 2>&1") == 0) {
+    $curl_or_wget = "curl";
+} elsif (system("command -v wget >/dev/null 2>&1") == 0) {
+    $curl_or_wget = "wget";
+} else {
+    die "$progname: this program requires either the curl or the wget package to be installed\n";
 }
 
 
@@ -171,16 +176,33 @@ if (! -d $cachedir and $forcecache) {
 if (-d $cachedir) {
     chdir $cachedir or die "$progname: can't cd $cachedir: $!\n";
 
-    # Either use the cached version because the remote hasn't been updated
-    # (-N) or download a complete new copy (--no-continue)
-    if (system('wget', '-qN', '--no-continue', $url) != 0) {
+    # Is
+    #     curl -qsR -C - $url
+    # equivalent to 
+    #     wget -qN --no-continue $url
+    # ?
+    if ("$curl_or_wget" eq "curl") {
+        if (system('curl', '-qsR', '-C', '-', $url) != 0) {
+	    die "$progname: curl failed!\n";
+        }
+    } elsif (system('wget', '-qN', '--no-continue', $url) != 0) {
+        # $curl_or_wget" eq "wget" 
+        # Either use the cached version because the remote hasn't
+        # been updated (-N) or download a complete new copy
+        # (--no-continue)
 	die "$progname: wget failed!\n";
     }
     open BUGS, $cachefile or die "$progname: could not read $cachefile: $!\n";
 }
 else {
-    open BUGS, "wget -q -O - $url |" or
-	die "$progname: could not run wget: $!\n";
+    if ("$curl_or_wget" eq "curl") {
+        open BUGS, "curl -qs $url |" or
+	    die "$progname: could not run curl: $!\n";
+    } else {
+        # $curl_or_wget" eq "wget" 
+        open BUGS, "wget -q -O - $url |" or
+	    die "$progname: could not run wget: $!\n";
+    }
 }
 
 ## Get list of installed packages (not source packages)
@@ -204,8 +226,13 @@ if ($popcon) {
 	    or die "$progname: Unable to access popcon data: $!";
 	$pc_regex = '(\d+)\s\d+\s(\S+)';
     } else {
-	open POPCON, "wget -q -O - http://popcon.debian.org/by_$pc_by.gz | gunzip -c |"
-	    or die "$progname: Not able to receive remote popcon data!";
+        if ("$curl_or_wget" eq "curl") {
+	    open POPCON, "curl -qs http://popcon.debian.org/by_$pc_by.gz | gunzip -c |"
+        } else {
+            # $curl_or_wget" eq "wget" 
+	    open POPCON, "wget -q -O - http://popcon.debian.org/by_$pc_by.gz | gunzip -c |"
+        }
+        or die "$progname: Not able to receive remote popcon data!";
 	$pc_regex = '(\d+)\s+(\S+)\s+(\d+\s+){5}\(.*\)';
     }
 

--- a/README	2012-10-09 00:35:19.512134230 +0200
+++ b/README	2012-10-09 00:34:37.000000000 +0200
@@ -197,7 +197,8 @@ And now, in mostly alphabetical order, t
 - pts-subscribe: subscribe to the PTS (Package Tracking System) for a
   limited period of time. [bsd-mailx | mailx, at]
 
-- rc-alert: list installed packages which have release-critical bugs [wget]
+- rc-alert: list installed packages which have release-critical bugs
+  [curl | wget]
 
 - rmadison: Remotely query the Debian archive database about packages.
   [liburi-perl, wget | curl]


-- 
To UNSUBSCRIBE, email to debian-user-REQUEST at lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmaster at lists.debian.org
Archive: http://lists.debian.org/20121008234003.GB2461@nt1.in



More information about the devscripts-devel mailing list