Sfoglia il codice sorgente

Add Ubuntu vendor object

* scripts/Dpkg/Vendor/Ubuntu.pm: Ubuntu vendor object implementing
lookup of launchpad bugs in changelogs and a safety-check for
Maintainer fields of forked packages (launched during source
build).
Raphael Hertzog 17 anni fa
parent
commit
23f1bdb6db
5 ha cambiato i file con 117 aggiunte e 0 eliminazioni
  1. 10 0
      ChangeLog
  2. 3 0
      debian/changelog
  3. 102 0
      scripts/Dpkg/Vendor/Ubuntu.pm
  4. 1 0
      scripts/Makefile.am
  5. 1 0
      scripts/po/POTFILES.in

+ 10 - 0
ChangeLog

@@ -1,3 +1,13 @@
+2009-02-04  Raphael Hertzog  <hertzog@debian.org>
+
+	* scripts/Dpkg/Vendor/Ubuntu.pm: Ubuntu vendor object implementing
+	lookup of launchpad bugs in changelogs and a safety-check for
+	Maintainer fields of forked packages (launched during source
+	build).
+	* scripts/Makefile.am (EXTRA_DIST): Add
+	'scripts/Dpkg/Vendor/Ubuntu.pm'.
+	* scripts/po/POTFILES.in: Add 'scripts/Dpkg/Vendor/Ubuntu.pm'.
+
 2009-02-04  Raphael Hertzog  <hertzog@debian.org>
 
 	* scripts/Dpkg/Vendor/Default.pm: Generic vendor object that will

+ 3 - 0
debian/changelog

@@ -109,6 +109,9 @@ dpkg (1.15.0) UNRELEASED; urgency=low
     patch. Closes: #503954
   * Add new framework to hook vendor-specific logic (see
     module Dpkg::Vendor::Default).
+  * Add Ubuntu vendor object implementing lookup of launchpad bugs in
+    changelogs and a safety-check for Maintainer fields of forked packages
+    (launched during source build). Closes: #426752, #499924
 
   [ Pierre Habouzit ]
   * Add a --query option to update-alternatives. Closes: #336091, #441904

+ 102 - 0
scripts/Dpkg/Vendor/Ubuntu.pm

@@ -0,0 +1,102 @@
+# Copyright © 2009 Raphaël Hertzog <hertzog@debian.org>
+# Copyright © 2008 Ian Jackson <ian@davenant.greenend.org.uk>, Colin Watson
+# <cjwatson@ubuntu.com>, James Westby <jw+debian@jameswestby.net>
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+package Dpkg::Vendor::Ubuntu;
+
+use strict;
+use warnings;
+
+use Dpkg::Vendor::Default;
+use Dpkg::ErrorHandling;
+use Dpkg::Gettext;
+
+our @ISA = qw(Dpkg::Vendor::Default);
+
+=head1 NAME
+
+Dpkg::Vendor::Ubuntu - Ubuntu vendor object
+
+=head1 DESCRIPTION
+
+This vendor object customize the behaviour of dpkg-source
+to check that Maintainers have been modified if necessary.
+
+=cut
+sub run_hook {
+    my ($self, $hook, @params) = @_;
+
+    if ($hook eq "before-source-build") {
+        my $src = shift @params;
+        my $fields = $src->{'fields'};
+
+        # check that Maintainer/XSBC-Original-Maintainer comply to
+        # https://wiki.ubuntu.com/DebianMaintainerField
+        if (defined($fields->{'Version'}) and defined($fields->{'Maintainer'}) and
+           $fields->{'Version'} =~ /ubuntu/) {
+           if ($fields->{'Maintainer'} !~ /ubuntu/i) {
+               if (defined ($ENV{'DEBEMAIL'}) and $ENV{'DEBEMAIL'} =~ /\@ubuntu\.com/) {
+                   error(_g('Version number suggests Ubuntu changes, but Maintainer: does not have Ubuntu address'));
+               } else {
+                   warning(_g('Version number suggests Ubuntu changes, but Maintainer: does not have Ubuntu address'));
+               }
+           }
+           unless ($fields->{'Original-Maintainer'}) {
+               warning(_g('Version number suggests Ubuntu changes, but there is no XSBC-Original-Maintainer field'));
+           }
+        }
+
+    } elsif ($hook eq "before-changes-creation") {
+        my $fields = shift @params;
+
+        # Add Launchpad-Bugs-Fixed field
+        my $bugs = find_launchpad_closes($fields->{"Changes"} || "");
+        if (scalar(@{$bugs})) {
+            $fields->{"Launchpad-Bugs-Fixed"} = join(" ", @{$bugs});
+        }
+    }
+}
+
+=head1 PUBLIC FUNCTIONS
+
+=over
+
+=item $bugs = Dpkg::Vendor::Ubuntu::find_launchpad_closes($changes)
+
+Takes one string as argument and finds "LP: #123456, #654321" statements,
+which are references to bugs on Launchpad. Returns all closed bug
+numbers in an array reference.
+
+=cut
+sub find_launchpad_closes {
+    my ($changes) = @_;
+    my @closes = ();
+
+    while ($changes &&
+          ($changes =~ /lp:\s+\#\d+(?:,\s*\#\d+)*/ig)) {
+       push(@closes, $& =~ /\#?\s?(\d+)/g);
+    }
+
+    @closes = sort { $a <=> $b } @closes;
+
+    return \@closes;
+}
+
+=back
+
+=cut
+1;

+ 1 - 0
scripts/Makefile.am

@@ -122,6 +122,7 @@ nobase_dist_perllib_DATA = \
 	Dpkg/Vendor.pm \
 	Dpkg/Vendor/Debian.pm \
 	Dpkg/Vendor/Default.pm \
+	Dpkg/Vendor/Ubuntu.pm \
 	Dpkg/Version.pm \
 	Dpkg.pm
 

+ 1 - 0
scripts/po/POTFILES.in

@@ -43,4 +43,5 @@ scripts/Dpkg/Source/Package/V3/quilt.pm
 scripts/Dpkg/Substvars.pm
 scripts/Dpkg/Vars.pm
 scripts/Dpkg/Vendor.pm
+scripts/Dpkg/Vendor/Ubuntu.pm
 scripts/Dpkg/Version.pm