Ubuntu.pm 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. # Copyright © 2009 Raphaël Hertzog <hertzog@debian.org>
  2. # Copyright © 2008 Ian Jackson <ian@davenant.greenend.org.uk>, Colin Watson
  3. # <cjwatson@ubuntu.com>, James Westby <jw+debian@jameswestby.net>
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 2 of the License, or
  7. # (at your option) any later version.
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. # You should have received a copy of the GNU General Public License along
  13. # with this program; if not, write to the Free Software Foundation, Inc.,
  14. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  15. package Dpkg::Vendor::Ubuntu;
  16. use strict;
  17. use warnings;
  18. use Dpkg::Vendor::Default;
  19. use Dpkg::ErrorHandling;
  20. use Dpkg::Gettext;
  21. our @ISA = qw(Dpkg::Vendor::Default);
  22. =head1 NAME
  23. Dpkg::Vendor::Ubuntu - Ubuntu vendor object
  24. =head1 DESCRIPTION
  25. This vendor object customize the behaviour of dpkg-source
  26. to check that Maintainers have been modified if necessary.
  27. =cut
  28. sub run_hook {
  29. my ($self, $hook, @params) = @_;
  30. if ($hook eq "before-source-build") {
  31. my $src = shift @params;
  32. my $fields = $src->{'fields'};
  33. # check that Maintainer/XSBC-Original-Maintainer comply to
  34. # https://wiki.ubuntu.com/DebianMaintainerField
  35. if (defined($fields->{'Version'}) and defined($fields->{'Maintainer'}) and
  36. $fields->{'Version'} =~ /ubuntu/) {
  37. if ($fields->{'Maintainer'} !~ /ubuntu/i) {
  38. if (defined ($ENV{'DEBEMAIL'}) and $ENV{'DEBEMAIL'} =~ /\@ubuntu\.com/) {
  39. error(_g('Version number suggests Ubuntu changes, but Maintainer: does not have Ubuntu address'));
  40. } else {
  41. warning(_g('Version number suggests Ubuntu changes, but Maintainer: does not have Ubuntu address'));
  42. }
  43. }
  44. unless ($fields->{'Original-Maintainer'}) {
  45. warning(_g('Version number suggests Ubuntu changes, but there is no XSBC-Original-Maintainer field'));
  46. }
  47. }
  48. } elsif ($hook eq "before-changes-creation") {
  49. my $fields = shift @params;
  50. # Add Launchpad-Bugs-Fixed field
  51. my $bugs = find_launchpad_closes($fields->{"Changes"} || "");
  52. if (scalar(@{$bugs})) {
  53. $fields->{"Launchpad-Bugs-Fixed"} = join(" ", @{$bugs});
  54. }
  55. }
  56. }
  57. =head1 PUBLIC FUNCTIONS
  58. =over
  59. =item $bugs = Dpkg::Vendor::Ubuntu::find_launchpad_closes($changes)
  60. Takes one string as argument and finds "LP: #123456, #654321" statements,
  61. which are references to bugs on Launchpad. Returns all closed bug
  62. numbers in an array reference.
  63. =cut
  64. sub find_launchpad_closes {
  65. my ($changes) = @_;
  66. my @closes = ();
  67. while ($changes &&
  68. ($changes =~ /lp:\s+\#\d+(?:,\s*\#\d+)*/ig)) {
  69. push(@closes, $& =~ /\#?\s?(\d+)/g);
  70. }
  71. @closes = sort { $a <=> $b } @closes;
  72. return \@closes;
  73. }
  74. =back
  75. =cut
  76. 1;