Bug#697923: devscripts: debchange and debcommit sometimes fail to notice editor modifications

Colin Watson cjwatson at ubuntu.com
Fri Jan 11 12:09:27 UTC 2013


Package: devscripts
Version: 2.12.6
Severity: normal
Tags: patch
User: ubuntu-devel at lists.ubuntu.com
Usertags: origin-ubuntu ubuntu-patch raring

When preparing to release a package, I run 'dch -r' and often manage to
type save-and-exit in my editor before a second has elapsed.  I don't
know off the top of my head whether this is a property of Perl or of my
filesystem (ext3), but stat only returns mtime at a one-second
granularity, so this means that dch often fails to notice that I've
saved the file.  This is an irritation because I often myself fail to
notice the warning message from dch - the finger-patterns involved in
releasing a package are thoroughly ingrained by now - and only realise
when I'm doing my final pre-upload .changes file check.

dch could avoid this problem by setting the timestamp of the temporary
editor file back one second before starting the editor, which would
guarantee that any change would update the timestamp.  debcommit has a
similar problem.  Here's a patch.

  * debchange, debcommit: Set the timestamp of temporary editor files back
    one second, to make modification detection more reliable in the absence
    of subsecond granularity.

diff --git a/scripts/debchange.pl b/scripts/debchange.pl
index a5c3936..923ef99 100755
--- a/scripts/debchange.pl
+++ b/scripts/debchange.pl
@@ -1563,6 +1563,8 @@ if ((!$TEXT and !$EMPTY_TEXT and ! ($opt_create and $opt_empty)) or @closes_text
     my $mtime = (stat("$changelog_path.dch"))[9];
     defined $mtime or fatal
 	"Error getting modification time of temporary $changelog_path: $!";
+    $mtime--;
+    utime $mtime, $mtime, "$changelog_path.dch";
 
     system("sensible-editor +$line $changelog_path.dch") == 0 or
 	fatal "Error editing $changelog_path";
diff --git a/scripts/debcommit.pl b/scripts/debcommit.pl
index 52a88fb..8f8f88b 100755
--- a/scripts/debcommit.pl
+++ b/scripts/debcommit.pl
@@ -830,6 +830,8 @@ sub edit {
     $fh->close();
     my $mtime = (stat("$fh"))[9];
     defined $mtime || die "$progname: unable to retrieve modification time for temporary file: $!\n";
+    $mtime--;
+    utime $mtime, $mtime, $fh->filename;
     system("sensible-editor $fh");
     open(FH, '<', "$fh") || die "$progname: unable to open temporary file for reading\n";
     $message = "";

Thanks,

-- 
Colin Watson                                       [cjwatson at ubuntu.com]



More information about the devscripts-devel mailing list