Samuel Mendoza-Jonas | 52bd75b | 2018-02-28 10:59:02 +1100 | [diff] [blame] | 1 | #!/usr/bin/env perl |
Stewart Smith | f76e7f9 | 2017-05-19 10:42:01 +1000 | [diff] [blame] | 2 | |
Patrick Williams | 37567b7 | 2015-06-08 15:25:40 -0500 | [diff] [blame] | 3 | use strict; |
| 4 | |
Stewart Smith | f76e7f9 | 2017-05-19 10:42:01 +1000 | [diff] [blame] | 5 | use Getopt::Long; |
| 6 | use 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. |
| 10 | my $db = "dbi:SQLite:dbname=release-notes.sqlite"; |
| 11 | #my $dbh = DBI->connect("dbi:SQLite:dbname=:memory:","",""); |
| 12 | my $dbh = DBI->connect($db,undef,undef, {AutoCommit => 1, RaiseError=>1}); |
| 13 | |
Patrick Williams | 37567b7 | 2015-06-08 15:25:40 -0500 | [diff] [blame] | 14 | my $repos = |
| 15 | { |
Samuel Mendoza-Jonas | a6262a0 | 2017-08-17 14:46:02 +1000 | [diff] [blame] | 16 | 'op-build' => { REPO => "https://github.com/open-power/op-build" }, |
Stewart Smith | b7cab66 | 2018-05-09 16:38:43 -0500 | [diff] [blame] | 17 | 'hcode' => { REPO => "https://github.com/open-power/hcode" , |
| 18 | DIR => "openpower/package/hcode" }, |
Samuel Mendoza-Jonas | a6262a0 | 2017-08-17 14:46:02 +1000 | [diff] [blame] | 19 | 'hostboot' => { REPO => "https://github.com/open-power/hostboot" , |
Stewart Smith | f76e7f9 | 2017-05-19 10:42:01 +1000 | [diff] [blame] | 20 | DIR => "openpower/package/hostboot" }, |
Samuel Mendoza-Jonas | a6262a0 | 2017-08-17 14:46:02 +1000 | [diff] [blame] | 21 | 'sbe' => { REPO => "https://github.com/open-power/sbe" , |
Stewart Smith | f76e7f9 | 2017-05-19 10:42:01 +1000 | [diff] [blame] | 22 | DIR => "openpower/package/sbe"}, |
Samuel Mendoza-Jonas | a6262a0 | 2017-08-17 14:46:02 +1000 | [diff] [blame] | 23 | 'skiboot' => { REPO => "https://github.com/open-power/skiboot" , |
Stewart Smith | f76e7f9 | 2017-05-19 10:42:01 +1000 | [diff] [blame] | 24 | DIR => "openpower/package/skiboot"}, |
Samuel Mendoza-Jonas | a6262a0 | 2017-08-17 14:46:02 +1000 | [diff] [blame] | 25 | 'occ' => { REPO => "https://github.com/open-power/occ" , |
Stewart Smith | f76e7f9 | 2017-05-19 10:42:01 +1000 | [diff] [blame] | 26 | DIR => "openpower/package/occ"}, |
Samuel Mendoza-Jonas | a6262a0 | 2017-08-17 14:46:02 +1000 | [diff] [blame] | 27 | 'pnor' => { REPO => "https://github.com/open-power/pnor" , |
Stewart Smith | f76e7f9 | 2017-05-19 10:42:01 +1000 | [diff] [blame] | 28 | DIR => "openpower/package/openpower-pnor"}, |
Samuel Mendoza-Jonas | a6262a0 | 2017-08-17 14:46:02 +1000 | [diff] [blame] | 29 | 'petitboot' => { REPO => "https://github.com/open-power/petitboot" , |
Stewart Smith | f76e7f9 | 2017-05-19 10:42:01 +1000 | [diff] [blame] | 30 | DIR => "openpower/package/petitboot"}, |
Patrick Williams | 37567b7 | 2015-06-08 15:25:40 -0500 | [diff] [blame] | 31 | }; |
| 32 | |
Stewart Smith | f76e7f9 | 2017-05-19 10:42:01 +1000 | [diff] [blame] | 33 | my $begin_release; |
| 34 | my $end_release; |
| 35 | my $begin_worktree; |
| 36 | my $end_worktree; |
| 37 | my $platform; |
| 38 | |
| 39 | GetOptions("begin-release=s" => \$begin_release, |
| 40 | "end-release=s" => \$end_release, |
| 41 | "begin-worktree=s" => \$begin_worktree, |
| 42 | "platform=s" => \$platform, |
| 43 | "end-worktree=s" => \$end_worktree) |
| 44 | or die("Error in command line arguments"); |
| 45 | |
| 46 | die "Required argument missing" unless ($begin_release and $end_release and $begin_worktree and $end_worktree); |
| 47 | |
| 48 | open(OUTPUT, "> RELEASE.md") || die "Failed to open RELEASE.md"; |
| 49 | |
Samuel Mendoza-Jonas | f017527 | 2018-10-10 11:00:08 +1100 | [diff] [blame] | 50 | print OUTPUT "# Release Notes for OpenPower Firmware $end_release \n"; |
Stewart Smith | f76e7f9 | 2017-05-19 10:42:01 +1000 | [diff] [blame] | 51 | |
| 52 | if (-e $begin_worktree) { |
| 53 | system("cd $begin_worktree && git checkout $begin_release && git submodule update --reference ../buildroot && git submodule update") and die "Could not update $begin_worktree"; |
| 54 | } else { |
| 55 | 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"; |
| 56 | } |
| 57 | |
| 58 | if (-e $end_worktree) { |
| 59 | system("cd $end_worktree && git checkout $end_release && git submodule update --reference ../buildroot && git submodule update") and die "Could not update $end_worktree"; |
| 60 | } else { |
| 61 | 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"; |
| 62 | } |
| 63 | |
| 64 | opendir (my $dh, "$begin_worktree/openpower/configs") |
| 65 | or die "can't scan $begin_worktree defconfigs"; |
| 66 | my @begin_platforms = grep { /.*_defconfig/ } readdir($dh); |
| 67 | closedir $dh; |
| 68 | |
| 69 | opendir (my $dh, "$end_worktree/openpower/configs") |
| 70 | or die "can't scan $end_worktree defconfigs"; |
| 71 | my @end_platforms = grep { /.*_defconfig/ } readdir($dh); |
| 72 | closedir $dh; |
| 73 | |
| 74 | s/_defconfig// foreach (@begin_platforms); |
| 75 | s/_defconfig// foreach (@end_platforms); |
| 76 | |
Stewart Smith | 24f8255 | 2017-07-14 15:53:22 +1000 | [diff] [blame] | 77 | my $witherspoon_insanity; |
| 78 | |
Samuel Mendoza-Jonas | 93c5a54 | 2017-09-21 13:55:00 +1000 | [diff] [blame] | 79 | # If both witherspoon and witherspoon-sequoia exist we've switched back |
| 80 | # to a single witherspoon platform and the -sequoia platform is just to |
| 81 | # keep Jenkins happy - ignore it. |
| 82 | if ("witherspoon" ~~ @begin_platforms |
| 83 | && "witherspoon-sequoia" ~~ @begin_platforms) { |
| 84 | my $index = 0; |
| 85 | $index++ until @begin_platforms[$index] eq "witherspoon-sequoia"; |
| 86 | splice(@begin_platforms, $index, 1); |
| 87 | } |
| 88 | |
| 89 | if ("witherspoon" ~~ @end_platforms |
| 90 | && "witherspoon-sequoia" ~~ @end_platforms) { |
| 91 | my $index = 0; |
| 92 | $index++ until @end_platforms[$index] eq "witherspoon-sequoia"; |
| 93 | splice(@end_platforms, $index, 1); |
| 94 | } |
| 95 | |
Stewart Smith | 88c7e35 | 2017-07-14 15:12:36 +1000 | [diff] [blame] | 96 | if (($platform && $platform eq 'witherspoon') |
| 97 | && -f "$end_worktree/openpower/configs/witherspoon-sequoia_defconfig") { |
| 98 | @begin_platforms = ('witherspoon'); |
| 99 | @end_platforms = ('witherspoon-sequoia', 'witherspoon-redbud'); |
Stewart Smith | 24f8255 | 2017-07-14 15:53:22 +1000 | [diff] [blame] | 100 | $witherspoon_insanity = 1; |
Stewart Smith | 88c7e35 | 2017-07-14 15:12:36 +1000 | [diff] [blame] | 101 | } elsif ($platform) { |
Stewart Smith | f76e7f9 | 2017-05-19 10:42:01 +1000 | [diff] [blame] | 102 | @begin_platforms = ($platform); |
| 103 | @end_platforms = ($platform); |
| 104 | } |
| 105 | |
| 106 | $dbh->do("CREATE TABLE platforms (platform TEXT, version TEXT);") or die "$!"; |
| 107 | { |
| 108 | my $q = "INSERT INTO platforms (platform,version) VALUES (?,?)"; |
| 109 | my $sth = $dbh->prepare($q) or die "$!"; |
| 110 | $sth->execute($_, $begin_release) foreach (@begin_platforms); |
| 111 | $sth->execute($_, $end_release) foreach (@end_platforms); |
| 112 | } |
| 113 | |
| 114 | { |
Stewart Smith | 88c7e35 | 2017-07-14 15:12:36 +1000 | [diff] [blame] | 115 | 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 Smith | f76e7f9 | 2017-05-19 10:42:01 +1000 | [diff] [blame] | 116 | my $sth = $dbh->prepare($q) or die $!; |
| 117 | $sth->execute($begin_release, $end_release); |
| 118 | my $r; |
Stewart Smith | 59d3cb4 | 2018-02-12 11:52:12 +1100 | [diff] [blame] | 119 | print OUTPUT "\n## Removed platforms\n\n- ".$r->{p}."\n" if $r = $sth->fetchrow_hashref; |
Samuel Mendoza-Jonas | f017527 | 2018-10-10 11:00:08 +1100 | [diff] [blame] | 120 | print OUTPUT "- ".$r->{p}." \n" while ($r = $sth->fetchrow_hashref); |
Stewart Smith | f76e7f9 | 2017-05-19 10:42:01 +1000 | [diff] [blame] | 121 | |
| 122 | $sth->execute($end_release, $begin_release); |
Stewart Smith | 59d3cb4 | 2018-02-12 11:52:12 +1100 | [diff] [blame] | 123 | print OUTPUT "\n## New platforms\n\n- ".$r->{p}."\n" if $r = $sth->fetchrow_hashref; |
Samuel Mendoza-Jonas | f017527 | 2018-10-10 11:00:08 +1100 | [diff] [blame] | 124 | print OUTPUT "- ".$r->{p}." \n" while($r = $sth->fetchrow_hashref); |
Stewart Smith | f76e7f9 | 2017-05-19 10:42:01 +1000 | [diff] [blame] | 125 | } |
| 126 | |
| 127 | my @common_platforms; |
| 128 | { |
Stewart Smith | 88c7e35 | 2017-07-14 15:12:36 +1000 | [diff] [blame] | 129 | my $q = "SELECT platform as p FROM platforms WHERE version is ? AND EXISTS (select platform from platforms where version is ? and platform=p)"; |
Stewart Smith | f76e7f9 | 2017-05-19 10:42:01 +1000 | [diff] [blame] | 130 | my $sth = $dbh->prepare($q) or die $!; |
| 131 | $sth->execute($begin_release, $end_release); |
| 132 | my $r; |
Stewart Smith | 88c7e35 | 2017-07-14 15:12:36 +1000 | [diff] [blame] | 133 | push @common_platforms, $r->{p} while ($r = $sth->fetchrow_hashref); |
Stewart Smith | f76e7f9 | 2017-05-19 10:42:01 +1000 | [diff] [blame] | 134 | } |
| 135 | |
Stewart Smith | 88c7e35 | 2017-07-14 15:12:36 +1000 | [diff] [blame] | 136 | use Data::Dumper; |
| 137 | |
| 138 | print "# COMMON PLATFORMS\n"; |
| 139 | print Dumper(\@common_platforms); |
| 140 | |
Stewart Smith | f76e7f9 | 2017-05-19 10:42:01 +1000 | [diff] [blame] | 141 | foreach my $p (@common_platforms) { |
| 142 | next if $p =~ /firenze/; |
| 143 | next if $p =~ /^zz$/; |
| 144 | next if $p =~ /mambo/; |
Stewart Smith | 2343264 | 2019-04-05 16:40:43 +1100 | [diff] [blame] | 145 | next if $p =~ /opal/; |
Samuel Mendoza-Jonas | 84f3d25 | 2017-07-12 13:26:55 +1000 | [diff] [blame] | 146 | next if $p =~ /redbud/; |
Samuel Mendoza-Jonas | 264a6cd | 2017-08-04 11:42:41 +1000 | [diff] [blame] | 147 | next if $p =~ /pseries/; |
| 148 | next if $p =~ /witherspoon-redbud/; |
| 149 | if ($p =~ /witherspoon-sequoia/) { |
| 150 | $p = "witherspoon"; |
| 151 | $witherspoon_insanity = 1; |
| 152 | } |
Samuel Mendoza-Jonas | 3ae961a | 2018-10-10 11:00:12 +1100 | [diff] [blame] | 153 | next if ($p =~ /witherspoon_dev/); |
Samuel Mendoza-Jonas | a6262a0 | 2017-08-17 14:46:02 +1000 | [diff] [blame] | 154 | $repos->{"$p-xml"} = { REPO => "https://github.com/open-power/$p-xml" , |
Stewart Smith | f76e7f9 | 2017-05-19 10:42:01 +1000 | [diff] [blame] | 155 | DIR => "openpower/package/$p-xml" }; |
| 156 | } |
| 157 | |
| 158 | foreach my $p (@begin_platforms) { |
| 159 | system("bash -c '(cd $begin_worktree && . op-build-env && op-build ".$p."_defconfig && op-build legal-info)'"); |
Stewart Smith | 88c7e35 | 2017-07-14 15:12:36 +1000 | [diff] [blame] | 160 | # Work-around bug in op-build v1.17, fixed 2 commits later |
| 161 | system('sed -e \'s/,""\([^",]\)/,"\1/; s/\([^,]\)"",/\1",/; s/machine-xml-"\(.*\)".tar/machine-xml-\1.tar/\' -i '. $begin_worktree .'/output/legal-info/manifest.csv'); |
Stewart Smith | f76e7f9 | 2017-05-19 10:42:01 +1000 | [diff] [blame] | 162 | # Forgive me for this.... |
Stewart Smith | cd96a99 | 2017-07-14 15:40:19 +1000 | [diff] [blame] | 163 | system("sqlite3 release-notes.sqlite \".mode csv\" \".import $begin_worktree/output/legal-info/manifest.csv i\""); |
| 164 | $dbh->do("ALTER TABLE i RENAME to 'begin_".$p."_manifest'") or die $!; |
Stewart Smith | f76e7f9 | 2017-05-19 10:42:01 +1000 | [diff] [blame] | 165 | } |
| 166 | |
| 167 | foreach my $p (@end_platforms) { |
Stewart Smith | 88c7e35 | 2017-07-14 15:12:36 +1000 | [diff] [blame] | 168 | print "# END PLATFORMS LEGAL-INFO $p\n"; |
Stewart Smith | f76e7f9 | 2017-05-19 10:42:01 +1000 | [diff] [blame] | 169 | system("bash -c '(cd $end_worktree && . op-build-env && op-build ".$p."_defconfig && op-build legal-info)'"); |
| 170 | # Forgive me for this.... |
Stewart Smith | cd96a99 | 2017-07-14 15:40:19 +1000 | [diff] [blame] | 171 | print "# loading manifest\n"; |
| 172 | system("sqlite3 release-notes.sqlite \".mode csv\" \".import $end_worktree/output/legal-info/manifest.csv i\""); |
| 173 | $dbh->do("ALTER TABLE i RENAME to 'end_".$p."_manifest'") or die $!; |
Stewart Smith | f76e7f9 | 2017-05-19 10:42:01 +1000 | [diff] [blame] | 174 | } |
| 175 | |
Stewart Smith | 24f8255 | 2017-07-14 15:53:22 +1000 | [diff] [blame] | 176 | if ($witherspoon_insanity) { |
| 177 | $dbh->do("ALTER TABLE 'end_witherspoon-sequoia_manifest' RENAME to end_witherspoon_manifest"); |
Samuel Mendoza-Jonas | 264a6cd | 2017-08-04 11:42:41 +1000 | [diff] [blame] | 178 | $dbh->do("ALTER TABLE 'begin_witherspoon-sequoia_manifest' RENAME to begin_witherspoon_manifest"); |
Stewart Smith | 24f8255 | 2017-07-14 15:53:22 +1000 | [diff] [blame] | 179 | @end_platforms = grep { $_ != 'witherspoon-sequoia' } @end_platforms; |
Samuel Mendoza-Jonas | 264a6cd | 2017-08-04 11:42:41 +1000 | [diff] [blame] | 180 | @begin_platforms = grep { $_ != 'witherspoon-sequoia' } @begin_platforms; |
Stewart Smith | 24f8255 | 2017-07-14 15:53:22 +1000 | [diff] [blame] | 181 | push @end_platforms, 'witherspoon'; |
Samuel Mendoza-Jonas | 264a6cd | 2017-08-04 11:42:41 +1000 | [diff] [blame] | 182 | push @begin_platforms, 'witherspoon'; |
Stewart Smith | 24f8255 | 2017-07-14 15:53:22 +1000 | [diff] [blame] | 183 | push @common_platforms, 'witherspoon'; |
| 184 | } |
| 185 | |
Stewart Smith | f76e7f9 | 2017-05-19 10:42:01 +1000 | [diff] [blame] | 186 | $dbh->do(<<'SQL') or die "$!"; |
| 187 | CREATE TABLE package_upgrades ( |
| 188 | PACKAGE TEXT, |
| 189 | OLDVERSION TEXT, |
| 190 | NEWVERSION TEXT, |
| 191 | PLATFORM TEXT |
| 192 | ) |
| 193 | SQL |
| 194 | |
| 195 | foreach my $p (@common_platforms) { |
Stewart Smith | 88c7e35 | 2017-07-14 15:12:36 +1000 | [diff] [blame] | 196 | $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 Smith | f76e7f9 | 2017-05-19 10:42:01 +1000 | [diff] [blame] | 197 | } |
| 198 | |
| 199 | $dbh->do(<<'SQL') or die "$!"; |
| 200 | CREATE TABLE new_package ( |
| 201 | PACKAGE TEXT, |
| 202 | VERSION TEXT, |
| 203 | PLATFORM TEXT |
| 204 | ) |
| 205 | SQL |
| 206 | |
| 207 | foreach my $p (@common_platforms) { |
Stewart Smith | 88c7e35 | 2017-07-14 15:12:36 +1000 | [diff] [blame] | 208 | $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 Smith | f76e7f9 | 2017-05-19 10:42:01 +1000 | [diff] [blame] | 209 | } |
| 210 | |
| 211 | $dbh->do(<<'SQL') or die "$!"; |
| 212 | CREATE TABLE removed_package ( |
| 213 | PACKAGE TEXT, |
| 214 | VERSION TEXT, |
| 215 | PLATFORM TEXT |
| 216 | ) |
| 217 | SQL |
| 218 | |
| 219 | foreach my $p (@common_platforms) { |
Stewart Smith | 88c7e35 | 2017-07-14 15:12:36 +1000 | [diff] [blame] | 220 | $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 Smith | f76e7f9 | 2017-05-19 10:42:01 +1000 | [diff] [blame] | 221 | } |
| 222 | |
| 223 | my $old_level = {}; |
| 224 | my $new_level = {}; |
| 225 | |
| 226 | { |
| 227 | my $q = <<'SQL'; |
| 228 | select package as pk ,oldversion as o ,newversion as n, |
Stewart Smith | 59d3cb4 | 2018-02-12 11:52:12 +1100 | [diff] [blame] | 229 | GROUP_CONCAT(platform,', ') as ps |
Stewart Smith | f76e7f9 | 2017-05-19 10:42:01 +1000 | [diff] [blame] | 230 | FROM package_upgrades |
| 231 | GROUP BY package,oldversion,newversion |
| 232 | ORDER BY package,platform |
| 233 | SQL |
| 234 | my $sth = $dbh->prepare($q) or die $!; |
| 235 | $sth->execute(); |
| 236 | |
Stewart Smith | 59d3cb4 | 2018-02-12 11:52:12 +1100 | [diff] [blame] | 237 | print OUTPUT "\n## Updated Packages\n\n"; |
Samuel Mendoza-Jonas | f017527 | 2018-10-10 11:00:08 +1100 | [diff] [blame] | 238 | print OUTPUT "Package | Old Version | New Version | Platforms \n"; |
Stewart Smith | 59d3cb4 | 2018-02-12 11:52:12 +1100 | [diff] [blame] | 239 | my $t; |
| 240 | my ($plen,$olen,$nlen,$platlen) = (3,3,3,3); |
Stewart Smith | f76e7f9 | 2017-05-19 10:42:01 +1000 | [diff] [blame] | 241 | while (my $r = $sth->fetchrow_hashref) { |
Samuel Mendoza-Jonas | f017527 | 2018-10-10 11:00:08 +1100 | [diff] [blame] | 242 | $t.= join(' | ',($r->{pk}, $r->{o}, $r->{n}, $r->{ps}))." \n" ; |
Stewart Smith | 59d3cb4 | 2018-02-12 11:52:12 +1100 | [diff] [blame] | 243 | $plen = length($r->{pk}) if $plen < length($r->{pk}); |
| 244 | $olen = length($r->{o}) if $olen < length($r->{o}); |
| 245 | $nlen = length($r->{n}) if $nlen < length($r->{n}); |
| 246 | $platlen = length($r->{ps}) if $platlen < length($r->{ps}); |
| 247 | |
Stewart Smith | f76e7f9 | 2017-05-19 10:42:01 +1000 | [diff] [blame] | 248 | if ($r->{pk} eq 'machine-xml') { |
| 249 | $old_level->{$r->{ps}."-xml"} = $r->{o}; |
| 250 | $new_level->{$r->{ps}."-xml"} = $r->{n}; |
| 251 | } else { |
| 252 | $old_level->{$r->{pk}} = $r->{o}; |
| 253 | $new_level->{$r->{pk}} = $r->{n}; |
| 254 | } |
| 255 | } |
Stewart Smith | 59d3cb4 | 2018-02-12 11:52:12 +1100 | [diff] [blame] | 256 | print OUTPUT "-"x$plen." | "."-"x$olen." | "."-"x$nlen." | ". |
Samuel Mendoza-Jonas | f017527 | 2018-10-10 11:00:08 +1100 | [diff] [blame] | 257 | "-"x$platlen." \n"; |
Stewart Smith | 59d3cb4 | 2018-02-12 11:52:12 +1100 | [diff] [blame] | 258 | print OUTPUT $t; |
Stewart Smith | f76e7f9 | 2017-05-19 10:42:01 +1000 | [diff] [blame] | 259 | } |
| 260 | |
| 261 | { |
| 262 | my $q = <<'SQL'; |
| 263 | select package as pk ,version as v, |
| 264 | GROUP_CONCAT(platform) as ps |
| 265 | FROM new_package |
| 266 | GROUP BY package,version |
| 267 | ORDER BY package,platform |
| 268 | SQL |
| 269 | my $sth = $dbh->prepare($q) or die $!; |
| 270 | $sth->execute(); |
| 271 | |
| 272 | print OUTPUT "\n\n## New Packages\n\n"; |
Samuel Mendoza-Jonas | f017527 | 2018-10-10 11:00:08 +1100 | [diff] [blame] | 273 | print OUTPUT "Package | Version | Platforms \n"; |
| 274 | print OUTPUT "--- | --- | --- \n"; |
Stewart Smith | f76e7f9 | 2017-05-19 10:42:01 +1000 | [diff] [blame] | 275 | while (my $r = $sth->fetchrow_hashref) { |
Samuel Mendoza-Jonas | f017527 | 2018-10-10 11:00:08 +1100 | [diff] [blame] | 276 | print OUTPUT join(' | ',($r->{pk}, $r->{v}, $r->{ps}))." \n" ; |
Stewart Smith | f76e7f9 | 2017-05-19 10:42:01 +1000 | [diff] [blame] | 277 | if ($r->{pk} eq 'machine-xml') { |
| 278 | $new_level->{$r->{ps}."-xml"} = $r->{v}; |
| 279 | } |
| 280 | } |
| 281 | } |
| 282 | |
| 283 | { |
| 284 | my $q = <<'SQL'; |
| 285 | select package as pk ,version as v, |
| 286 | GROUP_CONCAT(platform) as ps |
| 287 | FROM removed_package |
| 288 | GROUP BY package,version |
| 289 | ORDER BY package,platform |
| 290 | SQL |
| 291 | my $sth = $dbh->prepare($q) or die $!; |
| 292 | $sth->execute(); |
| 293 | |
| 294 | print OUTPUT "\n\n## Removed Packages\n\n"; |
Samuel Mendoza-Jonas | f017527 | 2018-10-10 11:00:08 +1100 | [diff] [blame] | 295 | print OUTPUT "Package | Version | Platforms \n"; |
| 296 | print OUTPUT "--- | --- | --- \n"; |
Stewart Smith | f76e7f9 | 2017-05-19 10:42:01 +1000 | [diff] [blame] | 297 | while (my $r = $sth->fetchrow_hashref) { |
Samuel Mendoza-Jonas | f017527 | 2018-10-10 11:00:08 +1100 | [diff] [blame] | 298 | print OUTPUT join(' | ',($r->{pk}, $r->{v}, $r->{ps}))." \n" ; |
Stewart Smith | f76e7f9 | 2017-05-19 10:42:01 +1000 | [diff] [blame] | 299 | if ($r->{pk} eq $r->{ps}."-xml") { |
| 300 | $old_level->{$r->{ps}."-xml"} = $r->{v}; |
| 301 | } |
| 302 | } |
| 303 | print OUTPUT "\n\n"; |
| 304 | } |
Patrick Williams | 37567b7 | 2015-06-08 15:25:40 -0500 | [diff] [blame] | 305 | |
| 306 | foreach my $repo (keys %{$repos}) |
| 307 | { |
| 308 | if (-e $repo) |
| 309 | { |
| 310 | system("cd $repo; git fetch") && die "Could not fetch $repo"; |
| 311 | } |
| 312 | else |
| 313 | { |
| 314 | system("git clone $repos->{$repo}->{REPO} $repo") && |
| 315 | die "Could not clone $repo"; |
| 316 | } |
| 317 | } |
| 318 | |
| 319 | system("cd op-build; git checkout $end_release --force; git reset HEAD --hard"); |
| 320 | |
| 321 | |
Patrick Williams | 37567b7 | 2015-06-08 15:25:40 -0500 | [diff] [blame] | 322 | my $op_url = $repos->{'op-build'}->{REPO}; |
| 323 | |
| 324 | foreach my $repo (sort keys %{$repos}) |
| 325 | { |
Stewart Smith | f76e7f9 | 2017-05-19 10:42:01 +1000 | [diff] [blame] | 326 | my $package = $repo; |
Patrick Williams | 37567b7 | 2015-06-08 15:25:40 -0500 | [diff] [blame] | 327 | my $url = $repos->{$repo}->{REPO}; |
| 328 | my $dir = $repos->{$repo}->{DIR}; |
| 329 | |
Samuel Mendoza-Jonas | f017527 | 2018-10-10 11:00:08 +1100 | [diff] [blame] | 330 | print OUTPUT "\n## Package: $repo \n"; |
| 331 | print OUTPUT "[Repository]($url) \n"; |
Patrick Williams | 37567b7 | 2015-06-08 15:25:40 -0500 | [diff] [blame] | 332 | print OUTPUT "\n"; |
| 333 | |
Patrick Williams | 37567b7 | 2015-06-08 15:25:40 -0500 | [diff] [blame] | 334 | # Display patches. |
| 335 | if (open(LSLOG, "ls op-build/$dir/*.patch | ". |
| 336 | "xargs -n1 --no-run-if-empty basename |")) |
| 337 | { |
Samuel Mendoza-Jonas | f017527 | 2018-10-10 11:00:08 +1100 | [diff] [blame] | 338 | print OUTPUT "### Patches \n"; |
Patrick Williams | 37567b7 | 2015-06-08 15:25:40 -0500 | [diff] [blame] | 339 | while (my $logline = <LSLOG>) |
| 340 | { |
| 341 | chomp $logline; |
| 342 | print OUTPUT "* [$logline]". |
Samuel Mendoza-Jonas | f017527 | 2018-10-10 11:00:08 +1100 | [diff] [blame] | 343 | "($op_url/tree/$end_release/$dir/$logline) \n"; |
Patrick Williams | 37567b7 | 2015-06-08 15:25:40 -0500 | [diff] [blame] | 344 | } |
| 345 | close LSLOG; |
| 346 | print OUTPUT "\n"; |
| 347 | } |
| 348 | else |
| 349 | { |
Samuel Mendoza-Jonas | f017527 | 2018-10-10 11:00:08 +1100 | [diff] [blame] | 350 | print OUTPUT "None. \n"; |
Patrick Williams | 37567b7 | 2015-06-08 15:25:40 -0500 | [diff] [blame] | 351 | } |
| 352 | |
| 353 | # Display changes. |
Samuel Mendoza-Jonas | f017527 | 2018-10-10 11:00:08 +1100 | [diff] [blame] | 354 | print OUTPUT "### Commits \n"; |
Patrick Williams | 37567b7 | 2015-06-08 15:25:40 -0500 | [diff] [blame] | 355 | if ((not exists $old_level->{$package}) && |
| 356 | (not exists $new_level->{$package})) |
| 357 | { |
| 358 | # No change identified. |
Samuel Mendoza-Jonas | f017527 | 2018-10-10 11:00:08 +1100 | [diff] [blame] | 359 | print "No changes: $repo \n"; |
Stewart Smith | 59d3cb4 | 2018-02-12 11:52:12 +1100 | [diff] [blame] | 360 | print OUTPUT "No changes.\n\n"; |
Patrick Williams | 37567b7 | 2015-06-08 15:25:40 -0500 | [diff] [blame] | 361 | next; |
| 362 | } |
| 363 | |
| 364 | if ((exists $old_level->{$package}) && |
| 365 | (exists $new_level->{$package})) |
| 366 | { |
Samuel Mendoza-Jonas | f017527 | 2018-10-10 11:00:08 +1100 | [diff] [blame] | 367 | print "Changes in $repo... \n"; |
Patrick Williams | 37567b7 | 2015-06-08 15:25:40 -0500 | [diff] [blame] | 368 | open(GITLOG, "cd $repo; git shortlog $old_level->{$package}...". |
| 369 | "$new_level->{$package} --no-merges --format=". |
Stewart Smith | 59d3cb4 | 2018-02-12 11:52:12 +1100 | [diff] [blame] | 370 | "\"- [%h]($url/commit/%h) %s\" |"); |
Patrick Williams | 37567b7 | 2015-06-08 15:25:40 -0500 | [diff] [blame] | 371 | |
| 372 | while (my $logline = <GITLOG>) |
| 373 | { |
| 374 | chomp $logline; |
| 375 | $logline =~ s/^[[:space:]]*//; |
Stewart Smith | 59d3cb4 | 2018-02-12 11:52:12 +1100 | [diff] [blame] | 376 | $logline =~ s/:$/:\n/; |
Samuel Mendoza-Jonas | f017527 | 2018-10-10 11:00:08 +1100 | [diff] [blame] | 377 | print OUTPUT "$logline \n"; |
Patrick Williams | 37567b7 | 2015-06-08 15:25:40 -0500 | [diff] [blame] | 378 | } |
| 379 | close GITLOG; |
Samuel Mendoza-Jonas | f017527 | 2018-10-10 11:00:08 +1100 | [diff] [blame] | 380 | print OUTPUT " \n"; |
Patrick Williams | 37567b7 | 2015-06-08 15:25:40 -0500 | [diff] [blame] | 381 | next; |
| 382 | } |
| 383 | |
| 384 | if (not exists $old_level->{$package}) |
| 385 | { |
| 386 | print "New package $repo.\n"; |
Samuel Mendoza-Jonas | f017527 | 2018-10-10 11:00:08 +1100 | [diff] [blame] | 387 | print OUTPUT "New package. \n"; |
Patrick Williams | 37567b7 | 2015-06-08 15:25:40 -0500 | [diff] [blame] | 388 | next; |
| 389 | } |
| 390 | |
| 391 | if (not exists $new_level->{$package}) |
| 392 | { |
| 393 | print "Deleted package $repo.\n"; |
Samuel Mendoza-Jonas | f017527 | 2018-10-10 11:00:08 +1100 | [diff] [blame] | 394 | print OUTPUT "Package removed. \n"; |
Patrick Williams | 37567b7 | 2015-06-08 15:25:40 -0500 | [diff] [blame] | 395 | next; |
| 396 | } |
| 397 | } |