[devscripts] 01/02: uscan: Add --log option

Osamu Aoki osamu at moszumanska.debian.org
Sun Feb 7 13:28:09 UTC 2016


This is an automated email from the git hooks/post-receive script.

osamu pushed a commit to branch master
in repository devscripts.

commit e00d12a80d28ec394bf3fc9a5b8a8fec3fc33814
Author: Osamu Aoki <osamu at debian.org>
Date:   Sun Feb 7 21:36:31 2016 +0900

    uscan: Add --log option
    
    Now uscan only writes *.uscan.log when requested by --log and honors ${destdir}
    Closes: #809806
---
 debian/changelog |  1 +
 scripts/uscan.pl | 72 ++++++++++++++++++++++++++++++--------------------------
 2 files changed, 39 insertions(+), 34 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index c287bd3..7b50a0e 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -54,6 +54,7 @@ devscripts (2.16.1) UNRELEASED; urgency=medium
     - Fix regressions of the verbosety. (Closes: #809541, #809554)
     - Keep the original compressed file when decompressing it for the
       signature verification. (Closes: #812860)
+    - Write *.uscan.log only when requested by --log. (Closes: #809806)
 
   [ Dominique Dumont ]
   * licensecheck:
diff --git a/scripts/uscan.pl b/scripts/uscan.pl
index d23c86e..427ec65 100755
--- a/scripts/uscan.pl
+++ b/scripts/uscan.pl
@@ -1821,6 +1821,7 @@ Options:
                    servers to respond (default 20 seconds)
     --user-agent, --useragent
                    Override the default user agent string
+    --log          Record md5sum changes of repackaging
     --help         Show this message
     --version      Show version information
 
@@ -1980,7 +1981,7 @@ if (@ARGV and $ARGV[0] =~ /^--no-?conf$/) {
 
 # Now read the command line arguments
 my ($opt_h, $opt_v, $opt_destdir, $opt_safe, $opt_download,
-    $opt_signature, $opt_passive, $opt_symlink, $opt_repack,
+    $opt_signature, $opt_passive, $opt_symlink, $opt_repack, $opt_log,
     $opt_compression, $opt_exclusion, $opt_copyright_file);
 my ($opt_verbose, $opt_level, $opt_regex, $opt_noconf);
 my ($opt_package, $opt_uversion, $opt_watchfile, $opt_dehs, $opt_timeout);
@@ -2007,6 +2008,7 @@ GetOptions("help" => \$opt_h,
 	   "symlink!" => sub { $opt_symlink = $_[1] ? 'symlink' : 'no'; },
 	   "rename" => sub { $opt_symlink = 'rename'; },
 	   "repack" => sub { $opt_repack = 1; },
+	   "log" => \$opt_log,
 	   "compression=s" => \$opt_compression,
 	   "package=s" => \$opt_package,
 	   "uversion|upstream-version=s" => \$opt_uversion,
@@ -3686,42 +3688,44 @@ EOF
 	uscan_verbose "New orig.tar.* tarball version (after mk-origtargz): $common_mangled_newversion\n";
     }
 
-    # Check pkg-ver.tar.gz and pkg_ver.orig.tar.gz
-    if (! defined $uscanlog) {
-	$uscanlog = "../${pkg}_${common_mangled_newversion}.uscan.log";
-	if (-e "$uscanlog.old") {
-	    unlink "$uscanlog.old" or uscan_die "Can\'t remove old backup log $uscanlog.old: $!";
-	    uscan_warn "Old backup uscan log found.  Remove: $uscanlog.old\n";
+    if ($opt_log) {
+	# Check pkg-ver.tar.gz and pkg_ver.orig.tar.gz
+	if (! defined $uscanlog) {
+	    $uscanlog = "${destdir}/${pkg}_${common_mangled_newversion}.uscan.log";
+	    if (-e "$uscanlog.old") {
+		unlink "$uscanlog.old" or uscan_die "Can\'t remove old backup log $uscanlog.old: $!";
+		uscan_warn "Old backup uscan log found.  Remove: $uscanlog.old\n";
+	    }
+	    if (-e $uscanlog) {
+		move($uscanlog, "$uscanlog.old");
+		uscan_warn "Old uscan log found.  Moved to: $uscanlog.old\n";
+	    }
+	    open(USCANLOG, ">> $uscanlog") or uscan_die "$progname: could not open $uscanlog for append: $!\n";
+	    print USCANLOG "# uscan log\n";
+	} else {
+	    open(USCANLOG, ">> $uscanlog") or uscan_die "$progname: could not open $uscanlog for append: $!\n";
 	}
-	if (-e $uscanlog) {
-	    move($uscanlog, "$uscanlog.old");
-	    uscan_warn "Old uscan log found.  Moved to: $uscanlog.old\n";
+	if ($symlink ne "rename") {
+	    my $umd5sum = Digest::MD5->new;
+	    my $omd5sum = Digest::MD5->new;
+	    open (my $ufh, '<', "${destdir}/${newfile_base}") or die "Can't open '${destdir}/${newfile_base}': $!";
+	    open (my $ofh, '<', "${destdir}/${target}") or die "Can't open '${destdir}/${target}': $!";
+	    $umd5sum->addfile($ufh);
+	    $omd5sum->addfile($ofh);
+	    close($ufh);
+	    close($ofh);
+	    my $umd5hex = $umd5sum->hexdigest;
+	    my $omd5hex = $omd5sum->hexdigest;
+	    if ($umd5hex eq $omd5hex) {
+		print USCANLOG "# == ${newfile_base}\t-->\t${target}\t(same)\n";
+	    } else {
+		print USCANLOG "# !! ${newfile_base}\t-->\t${target}\t(changed)\n";
+	    }
+	    print USCANLOG "$umd5hex  ${newfile_base}\n";
+	    print USCANLOG "$omd5hex  ${target}\n";
 	}
-	open(USCANLOG, ">> $uscanlog") or uscan_die "$progname: could not open $uscanlog for append: $!\n";
-	print USCANLOG "# uscan log\n";
-    } else {
-	open(USCANLOG, ">> $uscanlog") or uscan_die "$progname: could not open $uscanlog for append: $!\n";
-    }
-    if ($symlink ne "rename") {
-      my $umd5sum = Digest::MD5->new;
-      my $omd5sum = Digest::MD5->new;
-      open (my $ufh, '<', "${destdir}/${newfile_base}") or die "Can't open '${destdir}/${newfile_base}': $!";
-      open (my $ofh, '<', "${destdir}/${target}") or die "Can't open '${destdir}/${target}': $!";
-      $umd5sum->addfile($ufh);
-      $omd5sum->addfile($ofh);
-      close($ufh);
-      close($ofh);
-      my $umd5hex = $umd5sum->hexdigest;
-      my $omd5hex = $omd5sum->hexdigest;
-      if ($umd5hex eq $omd5hex) {
-	print USCANLOG "# == ${newfile_base}\t-->\t${target}\t(same)\n";
-      } else {
-	print USCANLOG "# !! ${newfile_base}\t-->\t${target}\t(changed)\n";
-      }
-      print USCANLOG "$umd5hex  ${newfile_base}\n";
-      print USCANLOG "$omd5hex  ${target}\n";
+	close USCANLOG or uscan_die "$progname: could not close $uscanlog: $!\n";
     }
-    close USCANLOG or uscan_die "$progname: could not close $uscanlog: $!\n";
 
     dehs_verbose "$mk_origtargz_out\n" if defined $mk_origtargz_out;
     $dehs_tags{target} = $target;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/devscripts.git



More information about the devscripts-devel mailing list