Good evening developers,
I'm a novice contributor and I have done some work on your scripts,
which I would like to submit to you.
I didn't found any library that can produce d/changelog files, so I
decided to invoke dch with the right options, besides it can manage
multi-maintainer releases, and since this feature is hardcoded, I
thought there was no library supporting it at all. I needed to create
entries with specific timestamps, so I started hacking dch to implement
an option for that.
Since there seems to be no way to feed a "%s" value to date, I decided
to use strftime(), and thus get rid of the date -R invocation. It seems
to me that globally setting the locale to "C" doesn't cause trouble
("dch Ìnîtíãl release." is fine) but I may be wrong. However, there
could be a better solution with the Email::Date::Format package ; it
takes care of formatting time according to RFC 2822 and doesn't touch
the locale. It does exactly what we want in a clean way, so it's
probably worth depending on it.
Please take time to judge the attached patches. If you ask, I can
rearrange them, removing the intermediate step `date` -> strftime() ->
email_date, for example. I didn't update the changelog (no joke
intended) to keep patches light.
Greetings,
Louis
--
When I grow up,
I will run a Tor node around the clock,
To help threatened protesters 'round the world.
>From 3855f74c27cf79a230d3c89c0d2e211fe43c2d1c Mon Sep 17 00:00:00 2001
From: Louis Bettens <lo...@bettens.info>
Date: Sat, 30 Nov 2013 20:12:00 +0100
Subject: [PATCH 1/5] debchange: replace call to date -R with strftime()
---
scripts/debchange.pl | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/scripts/debchange.pl b/scripts/debchange.pl
index 82875d6..3ec288d 100755
--- a/scripts/debchange.pl
+++ b/scripts/debchange.pl
@@ -43,6 +43,9 @@ use Dpkg::Compression;
use Dpkg::Vendor qw(get_current_vendor);
use lib '/usr/share/devscripts';
use Devscripts::Debbugs;
+use POSIX qw(locale_h strftime);
+
+setlocale(LC_TIME, "C"); # so that strftime is locale independent
# Predeclare functions
sub fatal($);
@@ -989,8 +992,7 @@ if (@ARGV and ! $TEXT) {
}
# Get the date
-my $date_cmd = ($opt_tz ? "TZ=$opt_tz " : "") . "date -R";
-chomp(my $DATE=`$date_cmd`);
+my $DATE=strftime "%a, %d %b %Y %T %z", localtime();
if ($opt_news && !$opt_i && !$opt_a) {
if ($VERSION eq $changelog{'Version'} && !$opt_v && !$opt_l) {
--
1.8.4.3
>From e5a0712e721fa3d2ba01a83b33035ad83f88c967 Mon Sep 17 00:00:00 2001
From: Louis Bettens <lo...@bettens.info>
Date: Sat, 30 Nov 2013 19:58:10 +0100
Subject: [PATCH 2/5] add --timestamp
---
scripts/debchange.pl | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/scripts/debchange.pl b/scripts/debchange.pl
index 3ec288d..b6ce458 100755
--- a/scripts/debchange.pl
+++ b/scripts/debchange.pl
@@ -129,6 +129,9 @@ Options:
Increase the Debian release number, adding a new changelog entry
-v <version>, --newversion=<version>
Add a new changelog entry with version number specified
+ --timestamp=<timestamp>
+ When generating a trailer line, use the specified time as a number of
+ seconds after january 1st, 1970 instead of the current time
-e, --edit
Don't change version number or add a new changelog entry, just
update the changelog's stamp and open up an editor
@@ -363,7 +366,7 @@ if (@ARGV and $ARGV[0] =~ /^--no-?conf$/) {
# We use bundling so that the short option behaviour is the same as
# with older debchange versions.
my ($opt_help, $opt_version);
-my ($opt_i, $opt_a, $opt_e, $opt_r, $opt_v, $opt_b, $opt_d, $opt_D, $opt_u, $opt_force_dist);
+my ($opt_i, $opt_a, $opt_timestamp, $opt_e, $opt_r, $opt_v, $opt_b, $opt_d, $opt_D, $opt_u, $opt_force_dist);
my ($opt_n, $opt_bn, $opt_qa, $opt_R, $opt_s, $opt_team, $opt_U, $opt_bpo, $opt_l, $opt_c, $opt_m, $opt_M, $opt_create, $opt_package, @closes);
my ($opt_news);
my ($opt_level, $opt_regex, $opt_noconf, $opt_empty);
@@ -371,6 +374,7 @@ my ($opt_level, $opt_regex, $opt_noconf, $opt_empty);
Getopt::Long::Configure('bundling');
GetOptions("help|h" => \$opt_help,
"version" => \$opt_version,
+ "timestamp=s" => \$opt_timestamp,
"i|increment" => \$opt_i,
"a|append" => \$opt_a,
"e|edit" => \$opt_e,
@@ -992,7 +996,8 @@ if (@ARGV and ! $TEXT) {
}
# Get the date
-my $DATE=strftime "%a, %d %b %Y %T %z", localtime();
+$opt_timestamp = defined $opt_timestamp ? $opt_timestamp : time;
+my $DATE=strftime "%a, %d %b %Y %T %z", localtime($opt_timestamp);
if ($opt_news && !$opt_i && !$opt_a) {
if ($VERSION eq $changelog{'Version'} && !$opt_v && !$opt_l) {
--
1.8.4.3
>From dad123b835d99a012c29e908026b4ccf1b259910 Mon Sep 17 00:00:00 2001
From: Louis Bettens <lo...@bettens.info>
Date: Sat, 30 Nov 2013 20:52:49 +0100
Subject: [PATCH 3/5] bts: replace call to date -R with strftime()
---
scripts/bts.pl | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/scripts/bts.pl b/scripts/bts.pl
index ba4929f..80003df 100755
--- a/scripts/bts.pl
+++ b/scripts/bts.pl
@@ -61,6 +61,9 @@ use Getopt::Long;
use Encode;
use Scalar::Util qw(looks_like_number);
+use POSIX qw(locale_h strftime);
+
+setlocale(LC_TIME, "C"); # so that strftime is locale independent
# Funny UTF-8 warning messages from HTML::Parse should be ignorable (#292671)
$SIG{'__WARN__'} = sub { warn $_[0] unless $_[0] =~ /^Parsing of undecoded UTF-8 will give garbage when decoding entities/; };
@@ -2521,8 +2524,7 @@ sub send_mail {
my $fromaddress = $fromaddresses[0];
# Message-ID algorithm from git-send-email
my $msgid = sprintf("%s-%s", time(), int(rand(4200)))."-bts-$fromaddress";
- my $date = `date -R`;
- chomp $date;
+ my $date = strftime "%a, %d %b %Y %T %z", localtime;
my $message = fold_from_header("From: $from") . "\n";
$message .= "To: $to\n" if length $to;
--
1.8.4.3
>From 63df78d9870382d892909a94fa3c3534c533676b Mon Sep 17 00:00:00 2001
From: Louis Bettens <lo...@bettens.info>
Date: Sat, 30 Nov 2013 20:55:09 +0100
Subject: [PATCH 4/5] mass-bug: replace call to date -R with strftime()
---
scripts/mass-bug.pl | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/scripts/mass-bug.pl b/scripts/mass-bug.pl
index ad0fa20..247de52 100755
--- a/scripts/mass-bug.pl
+++ b/scripts/mass-bug.pl
@@ -152,6 +152,9 @@ use strict;
use Getopt::Long qw(:config gnu_getopt);
use Text::Wrap;
use File::Basename;
+use POSIX qw(locale_h strftime);
+
+setlocale(LC_TIME, "C"); # so that strftime is locale independent
my $progname = basename($0);
$Text::Wrap::columns=70;
@@ -322,8 +325,7 @@ sub mailbts {
my ($subject, $body, $to, $from) = @_;
if (defined $from) {
- my $date = `date -R`;
- chomp $date;
+ my $date = strftime "%a, %d %b %Y %T %z", localtime;
my $pid = open(MAIL, "|-");
if (! defined $pid) {
--
1.8.4.3
>From e6234f839fadb3db05e733ce9b9caf08da64aad7 Mon Sep 17 00:00:00 2001
From: Louis Bettens <lo...@bettens.info>
Date: Sat, 30 Nov 2013 21:28:40 +0100
Subject: [PATCH 5/5] use Email::Date::Format instead of strftime
---
debian/control | 1 +
scripts/bts.pl | 6 ++----
scripts/debchange.pl | 6 ++----
scripts/mass-bug.pl | 6 ++----
4 files changed, 7 insertions(+), 12 deletions(-)
diff --git a/debian/control b/debian/control
index d48f7f2..cdbc576 100644
--- a/debian/control
+++ b/debian/control
@@ -11,6 +11,7 @@ Standards-Version: 3.9.4
Build-Depends: debhelper (>= 9),
docbook-xsl,
libdistro-info-perl,
+ libemail-date-format-perl,
libfile-desktopentry-perl,
libjson-perl,
libparse-debcontrol-perl,
diff --git a/scripts/bts.pl b/scripts/bts.pl
index 80003df..0822216 100755
--- a/scripts/bts.pl
+++ b/scripts/bts.pl
@@ -61,9 +61,7 @@ use Getopt::Long;
use Encode;
use Scalar::Util qw(looks_like_number);
-use POSIX qw(locale_h strftime);
-
-setlocale(LC_TIME, "C"); # so that strftime is locale independent
+use Email::Date::Format qw(email_date);
# Funny UTF-8 warning messages from HTML::Parse should be ignorable (#292671)
$SIG{'__WARN__'} = sub { warn $_[0] unless $_[0] =~ /^Parsing of undecoded UTF-8 will give garbage when decoding entities/; };
@@ -2524,7 +2522,7 @@ sub send_mail {
my $fromaddress = $fromaddresses[0];
# Message-ID algorithm from git-send-email
my $msgid = sprintf("%s-%s", time(), int(rand(4200)))."-bts-$fromaddress";
- my $date = strftime "%a, %d %b %Y %T %z", localtime;
+ my $date = email_date;
my $message = fold_from_header("From: $from") . "\n";
$message .= "To: $to\n" if length $to;
diff --git a/scripts/debchange.pl b/scripts/debchange.pl
index b6ce458..bf787cf 100755
--- a/scripts/debchange.pl
+++ b/scripts/debchange.pl
@@ -43,9 +43,7 @@ use Dpkg::Compression;
use Dpkg::Vendor qw(get_current_vendor);
use lib '/usr/share/devscripts';
use Devscripts::Debbugs;
-use POSIX qw(locale_h strftime);
-
-setlocale(LC_TIME, "C"); # so that strftime is locale independent
+use Email::Date::Format qw(email_date);
# Predeclare functions
sub fatal($);
@@ -997,7 +995,7 @@ if (@ARGV and ! $TEXT) {
# Get the date
$opt_timestamp = defined $opt_timestamp ? $opt_timestamp : time;
-my $DATE=strftime "%a, %d %b %Y %T %z", localtime($opt_timestamp);
+my $DATE=email_date($opt_timestamp);
if ($opt_news && !$opt_i && !$opt_a) {
if ($VERSION eq $changelog{'Version'} && !$opt_v && !$opt_l) {
diff --git a/scripts/mass-bug.pl b/scripts/mass-bug.pl
index 247de52..b8b9b05 100755
--- a/scripts/mass-bug.pl
+++ b/scripts/mass-bug.pl
@@ -152,9 +152,7 @@ use strict;
use Getopt::Long qw(:config gnu_getopt);
use Text::Wrap;
use File::Basename;
-use POSIX qw(locale_h strftime);
-
-setlocale(LC_TIME, "C"); # so that strftime is locale independent
+use Email::Date::Format qw(email_date);
my $progname = basename($0);
$Text::Wrap::columns=70;
@@ -325,7 +323,7 @@ sub mailbts {
my ($subject, $body, $to, $from) = @_;
if (defined $from) {
- my $date = strftime "%a, %d %b %Y %T %z", localtime;
+ my $date = email_date;
my $pid = open(MAIL, "|-");
if (! defined $pid) {
--
1.8.4.3