1 | #!/usr/bin/perl |
---|
2 | # -*- Mode: cperl -*- |
---|
3 | # Send a changelog to $list |
---|
4 | |
---|
5 | use strict; |
---|
6 | use MIME::Words qw(encode_mimewords); |
---|
7 | use vars qw($version $contrib $debug $club); |
---|
8 | use URPM; |
---|
9 | |
---|
10 | if ($ARGV[0] =~ /^-c/) { |
---|
11 | $contrib++; |
---|
12 | shift; |
---|
13 | } |
---|
14 | |
---|
15 | if ($ARGV[0] =~ /^-C/) { |
---|
16 | $club++; |
---|
17 | shift; |
---|
18 | } |
---|
19 | |
---|
20 | if ($ARGV[0] =~ /^-d/) { |
---|
21 | $debug++; |
---|
22 | shift; |
---|
23 | } |
---|
24 | |
---|
25 | if ($ARGV[0] =~ /^-f/) { |
---|
26 | shift; |
---|
27 | $version = shift; |
---|
28 | } |
---|
29 | |
---|
30 | my $rpm = shift or die "Give me a fuel for my aeroplane\n"; |
---|
31 | my $list = "Changelog List <changelog\@mandrivalinux.org>"; |
---|
32 | local *M; |
---|
33 | |
---|
34 | #my $changelog = `~/robot/ch $rpm`;# die "Can't ~/robot/ch $rpm: $!" if $?;chomp $changelog; |
---|
35 | #my $maintain = `~/robot/ch -m $rpm`;# die "Can't ~/robot/ch -m $rpm: $!" if $?;chomp $maintain; |
---|
36 | my $official_maintainer = `~/robot/rpmmon -p $rpm`; |
---|
37 | |
---|
38 | my $URPM = URPM->new(); |
---|
39 | my $description = `rpm --nosignature -qpi $rpm`;die "Can't ~/robot/ch -m $rpm: $!" if $?; |
---|
40 | my ($id) = $URPM->parse_rpm($rpm, keep_all_tags => 1); |
---|
41 | my $pkg = $URPM->{depslist}[$id]; |
---|
42 | |
---|
43 | my $name = $pkg->name . "-" . $pkg->version . "-" . $pkg->release; |
---|
44 | |
---|
45 | my $changelog = ($pkg->changelog_name)[0] . "\n\n" . ($pkg->changelog_text)[0]; |
---|
46 | my $maintain = ($pkg->changelog_name)[0]; |
---|
47 | $maintain =~ s/<.*\@.*>.*//; |
---|
48 | |
---|
49 | $description .= "\n"; |
---|
50 | $description .= "Buildarchs: ". join(' ',$pkg->buildarchs). "\n" if $pkg->buildarchs; |
---|
51 | $description .= "Exclusivearch: ". join(' ',$pkg->exclusivearchs). "\n" if $pkg->exclusivearchs; |
---|
52 | $description .= "Excludearch: ". join(' ',$pkg->exclusivearchs). "\n" if $pkg->excludearchs; |
---|
53 | |
---|
54 | unless ($debug) { |
---|
55 | open M, "|/usr/sbin/sendmail -B8BITMIME -oi -t " or die "Can't fork for sendmail: $!\n";select M; |
---|
56 | } |
---|
57 | |
---|
58 | if ($club) { |
---|
59 | print "From: ", encode_mimewords($maintain), "<devel\@mandriva.com>\nTo: webmaster\@mandrivaclub.com\n"; |
---|
60 | } else { |
---|
61 | print "From: ", encode_mimewords($maintain), "<devel\@mandriva.com>\nTo: $list\nReply-To: cooker\@mandrivalinux.org\nSender: devel\@mandriva.com\n"; |
---|
62 | } |
---|
63 | |
---|
64 | my $srpms; |
---|
65 | |
---|
66 | my $tag; |
---|
67 | if ($contrib) { |
---|
68 | if ($version) { |
---|
69 | $tag = "$version-"; |
---|
70 | if ($club) { $tag = "Club-$tag" } |
---|
71 | $srpms = "/community/$version/SRPMS/contrib" |
---|
72 | } else { |
---|
73 | $srpms = '/SRPMS/contrib/release/' |
---|
74 | } |
---|
75 | print "Subject: [${tag}Contrib-Rpm] " . $name . "\n\n[Contrib-RPM]\n\n"; |
---|
76 | } else { |
---|
77 | if ($version) { |
---|
78 | $tag = "$version-"; |
---|
79 | if ($club) { $tag = "Club-$tag" } |
---|
80 | $srpms = "/community/$version/SRPMS/main"; |
---|
81 | } else { |
---|
82 | $srpms = '/SRPMS/main/release/'; |
---|
83 | } |
---|
84 | print "Subject: [${tag}CHRPM] " . $name . "\n\n"; |
---|
85 | } |
---|
86 | |
---|
87 | my $diff = `~/robot/diffsrcrpm $rpm $srpms`; |
---|
88 | my $rpmlint = `rpmlint $rpm`; |
---|
89 | |
---|
90 | print "-=-=-=-\n$description\n\n"; |
---|
91 | $official_maintainer ? print "-=-=-=-\nOfficial maintainer: $official_maintainer\n" : print "-=-=-=-\nUnmaintained......\n"; |
---|
92 | $changelog ? print "-=-=-=-\n$changelog\n\n" : print "-=-=-=-\nNothing :-( ......\n\n"; |
---|
93 | $rpmlint ? print "-=-=-=-\n$rpmlint\n" : print "-=-=-=-\nNo rpmlint error, happy (wo)man :-)\n\n"; |
---|
94 | print "-=-=-=-\nhttp://cvs.mandriva.com/cgi-bin/viewvc.cgi/" . ( $contrib ? "contrib-" : "" ) . "SPECS/" . $pkg->name . "/\n"; |
---|
95 | print "\n", "$diff" || "No diff from old package", "\n\n" ; |
---|
96 | print "-- \nhttp://www.mandrivalinux.com/en/cookerdevel.php3\n"; |
---|
97 | |
---|
98 | |
---|
99 | close M unless $debug; |
---|
100 | |
---|