The following commit has been merged in the master branch:
commit be72de2b9ba8c8e7be782f5c2c259341d1a6e235
Author: James McCoy <[email protected]>
Date: Sun Nov 6 21:46:12 2011 -0500
Reformat dep3changelog and add it to the list in README
Signed-off-by: James McCoy <[email protected]>
diff --git a/README b/README
index d8212f7..a29ee2f 100644
--- a/README
+++ b/README
@@ -136,6 +136,8 @@ And now, in mostly alphabetical order, the scripts:
- deb-reversion: Increases a binary package version number and repacks
the package, useful for porters and the like.
+- dep3changelog: generate a changelog entry from a DEP3-style patch header
+
- desktop2menu: given a freedesktop.org desktop file, generate a skeleton
for a menu file [libfile-desktopentry-perl]
diff --git a/scripts/dep3changelog.pl b/scripts/dep3changelog.pl
index a88eef7..8f1fe5a 100755
--- a/scripts/dep3changelog.pl
+++ b/scripts/dep3changelog.pl
@@ -1,4 +1,4 @@
-#! /usr/bin/perl -w
+#! /usr/bin/perl
# dep3changelog: extract a DEP3 patch header from the named file and
# automatically update debian/changelog with a suitable entry
@@ -22,6 +22,7 @@
use 5.008; # We're using PerlIO layers
use strict;
+use warnings;
use open ':utf8'; # patch headers are required to be UTF-8
# for checking whether user names are valid and making format() behave
@@ -29,9 +30,6 @@ use Encode qw/decode_utf8 encode_utf8/;
use Getopt::Long;
use File::Basename;
-# Predeclare functions
-my $warnings = 0;
-
# And global variables
my $progname = basename($0);
my %env;
@@ -60,7 +58,7 @@ EOF
my ($opt_help, $opt_version);
GetOptions("help|h" => \$opt_help,
- "version" => \$opt_version,
+ "version" => \$opt_version,
)
or die "Usage: $progname patch [... patch] [-- [dch options]]\nRun $progname
--help for more details\n";
@@ -70,7 +68,7 @@ if ($opt_version) { version; exit 0; }
my @patches;
while (@ARGV && $ARGV[0] !~ /^-/) {
- push(@patches,shift(@ARGV));
+ push(@patches,shift(@ARGV));
}
# Check, sanitise and decode these environment variables
@@ -80,96 +78,95 @@ check_env_utf8('DEBEMAIL');
check_env_utf8('EMAIL');
if (exists $env{'DEBEMAIL'} and $env{'DEBEMAIL'} =~ /^(.*)\s+<(.*)>$/) {
- $env{'DEBFULLNAME'} = $1 unless exists $env{'DEBFULLNAME'};
- $env{'DEBEMAIL'} = $2;
+ $env{'DEBFULLNAME'} = $1 unless exists $env{'DEBFULLNAME'};
+ $env{'DEBEMAIL'} = $2;
}
if (! exists $env{'DEBEMAIL'} or ! exists $env{'DEBFULLNAME'}) {
- if (exists $env{'EMAIL'} and $env{'EMAIL'} =~ /^(.*)\s+<(.*)>$/) {
- $env{'DEBFULLNAME'} = $1 unless exists $env{'DEBFULLNAME'};
- $env{'EMAIL'} = $2;
- }
+ if (exists $env{'EMAIL'} and $env{'EMAIL'} =~ /^(.*)\s+<(.*)>$/) {
+ $env{'DEBFULLNAME'} = $1 unless exists $env{'DEBFULLNAME'};
+ $env{'EMAIL'} = $2;
+ }
}
my $fullname = '';
my $email = '';
if (exists $env{'DEBFULLNAME'}) {
- $fullname = $env{'DEBFULLNAME'};
+ $fullname = $env{'DEBFULLNAME'};
} elsif (exists $env{'NAME'}) {
- $fullname = $env{'NAME'};
+ $fullname = $env{'NAME'};
} else {
- my @pw = getpwuid $<;
- if ($pw[6]) {
- if (my $pw = decode_utf8($pw[6])) {
- $pw =~ s/,.*//;
- $fullname = $pw;
- } else {
- warn "$progname warning: passwd full name field for uid
$<\nis not UTF-8 encoded; ignoring\n";
- $warnings++;
- }
+ my @pw = getpwuid $<;
+ if ($pw[6]) {
+ if (my $pw = decode_utf8($pw[6])) {
+ $pw =~ s/,.*//;
+ $fullname = $pw;
+ } else {
+ warn "$progname warning: passwd full name field for uid $<\nis not
UTF-8 encoded; ignoring\n";
}
+ }
}
if (exists $env{'DEBEMAIL'}) {
- $email = $env{'DEBEMAIL'};
+ $email = $env{'DEBEMAIL'};
} elsif (exists $env{'EMAIL'}) {
- $email = $env{'EMAIL'};
+ $email = $env{'EMAIL'};
}
for my $patch (@patches) {
- my $shebang = 0;
- my $dpatch = 0;
- # TODO: more than one debian or launchpad bug in a patch?
- my ($description,$author,$debbug,$lpbug,$origin);
-
- next unless (open PATCH, $patch);
- while (<PATCH>) {
- # first line only
- if (!$shebang) {
- $shebang = 1;
- if (/^#!/) {
- $dpatch = $shebang = 1;
- next;
- }
- }
- last if (/^---/ || /^\s*$/);
- chomp;
- # only if there was a shebang do we strip comment chars
- s/^# // if ($dpatch);
- # fixme: this should only apply to the description field.
- next if (/^ /);
-
- if (/^(Description|Subject):\s+(.*)\s*/) {
- $description = $2;
- } elsif (/^(Author|From):\s+(.*)\s*/) {
- $author = $2;
- } elsif (/^Origin:\s+(.*)\s*/) {
- $origin = $1;
- } elsif
(/^bug-debian:\s+http:\/\/bugs\.debian\.org\/([0-9]+)\s*/i) {
- $debbug = $1;
- } elsif
(/^bug-ubuntu:\s+https:\/\/.*launchpad\.net\/.*\/([0-9]+)\s*/i) {
- $lpbug = $1;
- }
- }
- close PATCH;
- if (!$description || (!$origin && !$author)) {
- print STDERR "$patch: Invalid DEP3 header\n";
+ my $shebang = 0;
+ my $dpatch = 0;
+ # TODO: more than one debian or launchpad bug in a patch?
+ my ($description,$author,$debbug,$lpbug,$origin);
+
+ next unless (open PATCH, $patch);
+ while (<PATCH>) {
+ # first line only
+ if (!$shebang) {
+ $shebang = 1;
+ if (/^#!/) {
+ $dpatch = $shebang = 1;
next;
+ }
}
- my $changelog = "$patch: $description";
- $changelog .= '.' unless ($changelog =~ /\.$/);
- if ($author && $author ne $fullname && $author ne "$fullname <$email>")
- {
- $changelog .= " Thanks to $author.";
- }
- if ($debbug || $lpbug) {
- $changelog .= ' Closes';
- $changelog .= ": #$debbug" if ($debbug);
- $changelog .= "," if ($debbug && $lpbug);
- $changelog .= " LP: #$lpbug" if ($lpbug);
- $changelog .= '.';
+ last if (/^---/ || /^\s*$/);
+ chomp;
+ # only if there was a shebang do we strip comment chars
+ s/^# // if ($dpatch);
+ # fixme: this should only apply to the description field.
+ next if (/^ /);
+
+ if (/^(Description|Subject):\s+(.*)\s*/) {
+ $description = $2;
+ } elsif (/^(Author|From):\s+(.*)\s*/) {
+ $author = $2;
+ } elsif (/^Origin:\s+(.*)\s*/) {
+ $origin = $1;
+ } elsif (/^bug-debian:\s+http:\/\/bugs\.debian\.org\/([0-9]+)\s*/i) {
+ $debbug = $1;
+ } elsif (/^bug-ubuntu:\s+https:\/\/.*launchpad\.net\/.*\/([0-9]+)\s*/i)
{
+ $lpbug = $1;
}
- system('dch',$changelog,@ARGV);
+ }
+ close PATCH;
+ if (!$description || (!$origin && !$author)) {
+ warn "$patch: Invalid DEP3 header\n";
+ next;
+ }
+ my $changelog = "$patch: $description";
+ $changelog .= '.' unless ($changelog =~ /\.$/);
+ if ($author && $author ne $fullname && $author ne "$fullname <$email>")
+ {
+ $changelog .= " Thanks to $author.";
+ }
+ if ($debbug || $lpbug) {
+ $changelog .= ' Closes';
+ $changelog .= ": #$debbug" if ($debbug);
+ $changelog .= "," if ($debbug && $lpbug);
+ $changelog .= " LP: #$lpbug" if ($lpbug);
+ $changelog .= '.';
+ }
+ system('dch',$changelog,@ARGV);
}
# Is the environment variable valid or not?
--
Git repository for devscripts
--
To unsubscribe, send mail to [email protected].