blob: a0f322f8c3ed82a043231805dea440e0b24d0855 [file] [log] [blame]
Patrick Williams37567b72015-06-08 15:25:40 -05001#!/bin/env perl
Stewart Smithf76e7f92017-05-19 10:42:01 +10002
Patrick Williams37567b72015-06-08 15:25:40 -05003use strict;
4
Stewart Smithf76e7f92017-05-19 10:42:01 +10005use Getopt::Long;
6use DBI;
7
8# We use an in-memory SQLite database as SQL is good for doing queries
9# of differences between data sets, and doing that in perl is annoying.
10my $db = "dbi:SQLite:dbname=release-notes.sqlite";
11#my $dbh = DBI->connect("dbi:SQLite:dbname=:memory:","","");
12my $dbh = DBI->connect($db,undef,undef, {AutoCommit => 1, RaiseError=>1});
13
Patrick Williams37567b72015-06-08 15:25:40 -050014my $repos =
15{
Samuel Mendoza-Jonasa6262a02017-08-17 14:46:02 +100016 'op-build' => { REPO => "https://github.com/open-power/op-build" },
17 'hostboot' => { REPO => "https://github.com/open-power/hostboot" ,
Stewart Smithf76e7f92017-05-19 10:42:01 +100018 DIR => "openpower/package/hostboot" },
Samuel Mendoza-Jonasa6262a02017-08-17 14:46:02 +100019 'sbe' => { REPO => "https://github.com/open-power/sbe" ,
Stewart Smithf76e7f92017-05-19 10:42:01 +100020 DIR => "openpower/package/sbe"},
Samuel Mendoza-Jonasa6262a02017-08-17 14:46:02 +100021 'skiboot' => { REPO => "https://github.com/open-power/skiboot" ,
Stewart Smithf76e7f92017-05-19 10:42:01 +100022 DIR => "openpower/package/skiboot"},
Samuel Mendoza-Jonasa6262a02017-08-17 14:46:02 +100023 'occ' => { REPO => "https://github.com/open-power/occ" ,
Stewart Smithf76e7f92017-05-19 10:42:01 +100024 DIR => "openpower/package/occ"},
Samuel Mendoza-Jonasa6262a02017-08-17 14:46:02 +100025 'pnor' => { REPO => "https://github.com/open-power/pnor" ,
Stewart Smithf76e7f92017-05-19 10:42:01 +100026 DIR => "openpower/package/openpower-pnor"},
Samuel Mendoza-Jonasa6262a02017-08-17 14:46:02 +100027 'petitboot' => { REPO => "https://github.com/open-power/petitboot" ,
Stewart Smithf76e7f92017-05-19 10:42:01 +100028 DIR => "openpower/package/petitboot"},
Patrick Williams37567b72015-06-08 15:25:40 -050029};
30
Stewart Smithf76e7f92017-05-19 10:42:01 +100031my $begin_release;
32my $end_release;
33my $begin_worktree;
34my $end_worktree;
35my $platform;
36
37GetOptions("begin-release=s" => \$begin_release,
38 "end-release=s" => \$end_release,
39 "begin-worktree=s" => \$begin_worktree,
40 "platform=s" => \$platform,
41 "end-worktree=s" => \$end_worktree)
42 or die("Error in command line arguments");
43
44die "Required argument missing" unless ($begin_release and $end_release and $begin_worktree and $end_worktree);
45
46open(OUTPUT, "> RELEASE.md") || die "Failed to open RELEASE.md";
47
48print OUTPUT "# Release Notes for OpenPower Firmware $end_release\n";
49
50if (-e $begin_worktree) {
51 system("cd $begin_worktree && git checkout $begin_release && git submodule update --reference ../buildroot && git submodule update") and die "Could not update $begin_worktree";
52} else {
53 system("git worktree add $begin_worktree $begin_release && cd $begin_worktree&& git submodule update --reference ../buildroot && git submodule update && rm -rf dl && ln -s ../dl dl") and die "Couldn't init $begin_worktree";
54}
55
56if (-e $end_worktree) {
57 system("cd $end_worktree && git checkout $end_release && git submodule update --reference ../buildroot && git submodule update") and die "Could not update $end_worktree";
58} else {
59 system("git worktree add $end_worktree $end_release && cd $end_worktree && git submodule update --reference ../buildroot && git submodule update && rm -rf dl && ln -s ../dl dl") and die "Couldn't init $end_worktree";
60}
61
62opendir (my $dh, "$begin_worktree/openpower/configs")
63 or die "can't scan $begin_worktree defconfigs";
64my @begin_platforms = grep { /.*_defconfig/ } readdir($dh);
65closedir $dh;
66
67opendir (my $dh, "$end_worktree/openpower/configs")
68 or die "can't scan $end_worktree defconfigs";
69my @end_platforms = grep { /.*_defconfig/ } readdir($dh);
70closedir $dh;
71
72s/_defconfig// foreach (@begin_platforms);
73s/_defconfig// foreach (@end_platforms);
74
Stewart Smith24f82552017-07-14 15:53:22 +100075my $witherspoon_insanity;
76
Stewart Smith88c7e352017-07-14 15:12:36 +100077if (($platform && $platform eq 'witherspoon')
78 && -f "$end_worktree/openpower/configs/witherspoon-sequoia_defconfig") {
79 @begin_platforms = ('witherspoon');
80 @end_platforms = ('witherspoon-sequoia', 'witherspoon-redbud');
Stewart Smith24f82552017-07-14 15:53:22 +100081 $witherspoon_insanity = 1;
Stewart Smith88c7e352017-07-14 15:12:36 +100082} elsif ($platform) {
Stewart Smithf76e7f92017-05-19 10:42:01 +100083 @begin_platforms = ($platform);
84 @end_platforms = ($platform);
85}
86
87$dbh->do("CREATE TABLE platforms (platform TEXT, version TEXT);") or die "$!";
88{
89 my $q = "INSERT INTO platforms (platform,version) VALUES (?,?)";
90 my $sth = $dbh->prepare($q) or die "$!";
91 $sth->execute($_, $begin_release) foreach (@begin_platforms);
92 $sth->execute($_, $end_release) foreach (@end_platforms);
93}
94
95{
Stewart Smith88c7e352017-07-14 15:12:36 +100096 my $q = "SELECT platform as p FROM platforms WHERE version is ? AND platform NOT IN (SELECT platform FROM platforms WHERE version is ? and platform=p)";
Stewart Smithf76e7f92017-05-19 10:42:01 +100097 my $sth = $dbh->prepare($q) or die $!;
98 $sth->execute($begin_release, $end_release);
99 my $r;
Stewart Smith88c7e352017-07-14 15:12:36 +1000100 print OUTPUT "## Removed platforms\n\n- ".$r->{p}."\n" if $r = $sth->fetchrow_hashref;
101 print OUTPUT "- ".$r->{p}."\n" while ($r = $sth->fetchrow_hashref);
Stewart Smithf76e7f92017-05-19 10:42:01 +1000102
103 $sth->execute($end_release, $begin_release);
Stewart Smith88c7e352017-07-14 15:12:36 +1000104 print OUTPUT "## New platforms\n\n- ".$r->{p}."\n" if $r = $sth->fetchrow_hashref;
105 print OUTPUT "- ".$r->{p}."\n" while($r = $sth->fetchrow_hashref);
Stewart Smithf76e7f92017-05-19 10:42:01 +1000106}
107
108my @common_platforms;
109{
Stewart Smith88c7e352017-07-14 15:12:36 +1000110 my $q = "SELECT platform as p FROM platforms WHERE version is ? AND EXISTS (select platform from platforms where version is ? and platform=p)";
Stewart Smithf76e7f92017-05-19 10:42:01 +1000111 my $sth = $dbh->prepare($q) or die $!;
112 $sth->execute($begin_release, $end_release);
113 my $r;
Stewart Smith88c7e352017-07-14 15:12:36 +1000114 push @common_platforms, $r->{p} while ($r = $sth->fetchrow_hashref);
Stewart Smithf76e7f92017-05-19 10:42:01 +1000115}
116
Stewart Smith88c7e352017-07-14 15:12:36 +1000117use Data::Dumper;
118
119print "# COMMON PLATFORMS\n";
120print Dumper(\@common_platforms);
121
Stewart Smithf76e7f92017-05-19 10:42:01 +1000122foreach my $p (@common_platforms) {
123 next if $p =~ /firenze/;
124 next if $p =~ /^zz$/;
125 next if $p =~ /mambo/;
Samuel Mendoza-Jonas84f3d252017-07-12 13:26:55 +1000126 next if $p =~ /redbud/;
Samuel Mendoza-Jonas264a6cd2017-08-04 11:42:41 +1000127 next if $p =~ /pseries/;
128 next if $p =~ /witherspoon-redbud/;
129 if ($p =~ /witherspoon-sequoia/) {
130 $p = "witherspoon";
131 $witherspoon_insanity = 1;
132 }
Samuel Mendoza-Jonasa6262a02017-08-17 14:46:02 +1000133 $repos->{"$p-xml"} = { REPO => "https://github.com/open-power/$p-xml" ,
Stewart Smithf76e7f92017-05-19 10:42:01 +1000134 DIR => "openpower/package/$p-xml" };
135}
136
137foreach my $p (@begin_platforms) {
138 system("bash -c '(cd $begin_worktree && . op-build-env && op-build ".$p."_defconfig && op-build legal-info)'");
Stewart Smith88c7e352017-07-14 15:12:36 +1000139 # Work-around bug in op-build v1.17, fixed 2 commits later
140 system('sed -e \'s/,""\([^",]\)/,"\1/; s/\([^,]\)"",/\1",/; s/machine-xml-"\(.*\)".tar/machine-xml-\1.tar/\' -i '. $begin_worktree .'/output/legal-info/manifest.csv');
Stewart Smithf76e7f92017-05-19 10:42:01 +1000141 # Forgive me for this....
Stewart Smithcd96a992017-07-14 15:40:19 +1000142 system("sqlite3 release-notes.sqlite \".mode csv\" \".import $begin_worktree/output/legal-info/manifest.csv i\"");
143 $dbh->do("ALTER TABLE i RENAME to 'begin_".$p."_manifest'") or die $!;
Stewart Smithf76e7f92017-05-19 10:42:01 +1000144}
145
146foreach my $p (@end_platforms) {
Stewart Smith88c7e352017-07-14 15:12:36 +1000147 print "# END PLATFORMS LEGAL-INFO $p\n";
Stewart Smithf76e7f92017-05-19 10:42:01 +1000148 system("bash -c '(cd $end_worktree && . op-build-env && op-build ".$p."_defconfig && op-build legal-info)'");
149 # Forgive me for this....
Stewart Smithcd96a992017-07-14 15:40:19 +1000150 print "# loading manifest\n";
151 system("sqlite3 release-notes.sqlite \".mode csv\" \".import $end_worktree/output/legal-info/manifest.csv i\"");
152 $dbh->do("ALTER TABLE i RENAME to 'end_".$p."_manifest'") or die $!;
Stewart Smithf76e7f92017-05-19 10:42:01 +1000153}
154
Stewart Smith24f82552017-07-14 15:53:22 +1000155if ($witherspoon_insanity) {
156 $dbh->do("ALTER TABLE 'end_witherspoon-sequoia_manifest' RENAME to end_witherspoon_manifest");
Samuel Mendoza-Jonas264a6cd2017-08-04 11:42:41 +1000157 $dbh->do("ALTER TABLE 'begin_witherspoon-sequoia_manifest' RENAME to begin_witherspoon_manifest");
Stewart Smith24f82552017-07-14 15:53:22 +1000158 @end_platforms = grep { $_ != 'witherspoon-sequoia' } @end_platforms;
Samuel Mendoza-Jonas264a6cd2017-08-04 11:42:41 +1000159 @begin_platforms = grep { $_ != 'witherspoon-sequoia' } @begin_platforms;
Stewart Smith24f82552017-07-14 15:53:22 +1000160 push @end_platforms, 'witherspoon';
Samuel Mendoza-Jonas264a6cd2017-08-04 11:42:41 +1000161 push @begin_platforms, 'witherspoon';
Stewart Smith24f82552017-07-14 15:53:22 +1000162 push @common_platforms, 'witherspoon';
163}
164
Stewart Smithf76e7f92017-05-19 10:42:01 +1000165$dbh->do(<<'SQL') or die "$!";
166CREATE TABLE package_upgrades (
167 PACKAGE TEXT,
168 OLDVERSION TEXT,
169 NEWVERSION TEXT,
170 PLATFORM TEXT
171)
172SQL
173
174foreach my $p (@common_platforms) {
Stewart Smith88c7e352017-07-14 15:12:36 +1000175 $dbh->do("INSERT INTO package_upgrades select b.package,b.version,e.version,'$p' from 'begin_".$p."_manifest' as b LEFT JOIN 'end_".$p."_manifest' AS e ON b.package=e.package WHERE b.version != e.version") or die $!;
Stewart Smithf76e7f92017-05-19 10:42:01 +1000176}
177
178$dbh->do(<<'SQL') or die "$!";
179CREATE TABLE new_package (
180 PACKAGE TEXT,
181 VERSION TEXT,
182 PLATFORM TEXT
183)
184SQL
185
186foreach my $p (@common_platforms) {
Stewart Smith88c7e352017-07-14 15:12:36 +1000187 $dbh->do("INSERT INTO new_package select b.package,b.version,'$p' from 'end_".$p."_manifest' as b WHERE NOT EXISTS(SELECT package FROM 'begin_".$p."_manifest' AS e WHERE b.package=e.package)") or die $!;
Stewart Smithf76e7f92017-05-19 10:42:01 +1000188}
189
190$dbh->do(<<'SQL') or die "$!";
191CREATE TABLE removed_package (
192 PACKAGE TEXT,
193 VERSION TEXT,
194 PLATFORM TEXT
195)
196SQL
197
198foreach my $p (@common_platforms) {
Stewart Smith88c7e352017-07-14 15:12:36 +1000199 $dbh->do("INSERT INTO removed_package select b.package,b.version,'$p' from 'begin_".$p."_manifest' as b WHERE NOT EXISTS(SELECT package FROM 'end_".$p."_manifest' AS e WHERE b.package=e.package)") or die $!;
Stewart Smithf76e7f92017-05-19 10:42:01 +1000200}
201
202my $old_level = {};
203my $new_level = {};
204
205{
206 my $q = <<'SQL';
207select package as pk ,oldversion as o ,newversion as n,
208 GROUP_CONCAT(platform) as ps
209FROM package_upgrades
210 GROUP BY package,oldversion,newversion
211ORDER BY package,platform
212SQL
213 my $sth = $dbh->prepare($q) or die $!;
214 $sth->execute();
215
216 print OUTPUT "## Updated Packages\n\n";
217 print OUTPUT "Package | Old Version | New Version | Platforms\n";
218 print OUTPUT "--- | --- | --- | ---\n";
219 while (my $r = $sth->fetchrow_hashref) {
220 print OUTPUT join(' | ',($r->{pk}, $r->{o}, $r->{n}, $r->{ps}))."\n" ;
221 if ($r->{pk} eq 'machine-xml') {
222 $old_level->{$r->{ps}."-xml"} = $r->{o};
223 $new_level->{$r->{ps}."-xml"} = $r->{n};
224 } else {
225 $old_level->{$r->{pk}} = $r->{o};
226 $new_level->{$r->{pk}} = $r->{n};
227 }
228 }
229}
230
231{
232 my $q = <<'SQL';
233select package as pk ,version as v,
234 GROUP_CONCAT(platform) as ps
235FROM new_package
236 GROUP BY package,version
237ORDER BY package,platform
238SQL
239 my $sth = $dbh->prepare($q) or die $!;
240 $sth->execute();
241
242 print OUTPUT "\n\n## New Packages\n\n";
243 print OUTPUT "Package | Version | Platforms\n";
244 print OUTPUT "--- | --- | ---\n";
245 while (my $r = $sth->fetchrow_hashref) {
246 print OUTPUT join(' | ',($r->{pk}, $r->{v}, $r->{ps}))."\n" ;
247 if ($r->{pk} eq 'machine-xml') {
248 $new_level->{$r->{ps}."-xml"} = $r->{v};
249 }
250 }
251}
252
253{
254 my $q = <<'SQL';
255select package as pk ,version as v,
256 GROUP_CONCAT(platform) as ps
257FROM removed_package
258 GROUP BY package,version
259ORDER BY package,platform
260SQL
261 my $sth = $dbh->prepare($q) or die $!;
262 $sth->execute();
263
264 print OUTPUT "\n\n## Removed Packages\n\n";
265 print OUTPUT "Package | Version | Platforms\n";
266 print OUTPUT "--- | --- | ---\n";
267 while (my $r = $sth->fetchrow_hashref) {
268 print OUTPUT join(' | ',($r->{pk}, $r->{v}, $r->{ps}))."\n" ;
269 if ($r->{pk} eq $r->{ps}."-xml") {
270 $old_level->{$r->{ps}."-xml"} = $r->{v};
271 }
272 }
273 print OUTPUT "\n\n";
274}
Patrick Williams37567b72015-06-08 15:25:40 -0500275
276foreach my $repo (keys %{$repos})
277{
278 if (-e $repo)
279 {
280 system("cd $repo; git fetch") && die "Could not fetch $repo";
281 }
282 else
283 {
284 system("git clone $repos->{$repo}->{REPO} $repo") &&
285 die "Could not clone $repo";
286 }
287}
288
289system("cd op-build; git checkout $end_release --force; git reset HEAD --hard");
290
291
Patrick Williams37567b72015-06-08 15:25:40 -0500292my $op_url = $repos->{'op-build'}->{REPO};
293
294foreach my $repo (sort keys %{$repos})
295{
Stewart Smithf76e7f92017-05-19 10:42:01 +1000296 my $package = $repo;
Patrick Williams37567b72015-06-08 15:25:40 -0500297 my $url = $repos->{$repo}->{REPO};
298 my $dir = $repos->{$repo}->{DIR};
299
300 print OUTPUT "## Package: $repo\n";
301 print OUTPUT "[Repository]($url)\n";
302 print OUTPUT "\n";
303
Patrick Williams37567b72015-06-08 15:25:40 -0500304 # Display patches.
305 if (open(LSLOG, "ls op-build/$dir/*.patch | ".
306 "xargs -n1 --no-run-if-empty basename |"))
307 {
308 print OUTPUT "### Patches\n";
309 while (my $logline = <LSLOG>)
310 {
311 chomp $logline;
312 print OUTPUT "* [$logline]".
313 "($op_url/tree/$end_release/$dir/$logline)\n";
314 }
315 close LSLOG;
316 print OUTPUT "\n";
317 }
318 else
319 {
320 print OUTPUT "None.\n";
321 }
322
323 # Display changes.
324 print OUTPUT "### Commits\n";
325 if ((not exists $old_level->{$package}) &&
326 (not exists $new_level->{$package}))
327 {
328 # No change identified.
329 print "No changes: $repo\n";
330 print OUTPUT "No changes.\n";
331 next;
332 }
333
334 if ((exists $old_level->{$package}) &&
335 (exists $new_level->{$package}))
336 {
337 print "Changes in $repo...\n";
Patrick Williams37567b72015-06-08 15:25:40 -0500338 open(GITLOG, "cd $repo; git shortlog $old_level->{$package}...".
339 "$new_level->{$package} --no-merges --format=".
340 "\"* [%h]($url/commit/%h) %s\" |");
341
342 while (my $logline = <GITLOG>)
343 {
344 chomp $logline;
345 $logline =~ s/^[[:space:]]*//;
346 print OUTPUT "$logline\n";
347 }
348 close GITLOG;
349 print OUTPUT "\n";
350 next;
351 }
352
353 if (not exists $old_level->{$package})
354 {
355 print "New package $repo.\n";
356 print OUTPUT "New package.\n";
357 next;
358 }
359
360 if (not exists $new_level->{$package})
361 {
362 print "Deleted package $repo.\n";
363 print OUTPUT "Package removed.\n";
364 next;
365 }
366}