gen-emails.pl 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/usr/bin/perl
  2. # Copyright (C) 2010 Alexander Wirt <formorer@debian.org>
  3. #
  4. # This program is free software; you can redistribute it and/or modify it under
  5. # the terms of the GNU General Public License as published by the Free Software
  6. # Foundation; either version 2 of the License, or (at your option) any later
  7. # version.
  8. #
  9. # This program is distributed in the hope that it will be useful, but WITHOUT ANY
  10. # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  11. # PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License along with
  14. # this program; if not, see <http://www.gnu.org/licenses/>.
  15. use warnings;
  16. use strict;
  17. use DBI;
  18. my $outfile = shift;
  19. if (! $outfile) {
  20. print "Output Filename needed\n";
  21. exit 1;
  22. }
  23. my $dbh = DBI->connect("DBI:Pg:dbname=backports");
  24. my $sth = $dbh->prepare( "
  25. SELECT maintainer.name,
  26. source.source,
  27. max(source.version)
  28. FROM source,source_suite,
  29. maintainer
  30. WHERE source.id = source_suite.src
  31. AND source.changedby = maintainer.id
  32. AND ( suite_name = 'squeeze-backports' )
  33. GROUP BY source.source,maintainer.name;
  34. ");
  35. if ( !defined $sth ) {
  36. die "Cannot prepare statement: $DBI::errstr\n";
  37. }
  38. $sth->execute or die "Could not execute query: $DBI::errstr\n";
  39. open (my $fh, '>', $outfile) or die "Could not open File $outfile for writing: $!";
  40. while (my $row = $sth->fetchrow_hashref) {
  41. my $email;
  42. if ($row->{'name'} =~ /<([^>]+)>/) {
  43. $email = $1;
  44. } else {
  45. next;
  46. }
  47. printf($fh "%s: %s\n", $row->{'source'}, $email);
  48. }
  49. close($fh);