#!/usr/bin/env perl # # $FreeBSD$ # use strict; use warnings; use locale; use Getopt::Std; use File::Basename; my $prog = basename($0); our $opt_h; our $builddate; our $svnrev; our $junk = ""; our $arch = ""; our $kernel = ""; our $branch = ""; our $revision = 0; our $branchname = ""; our $version = 0; our $hasarmv6 = 0; our $hasarm64 = 0; our $hasbranch = 0; sub usage() { print("Usage: ./get-checksums.sh -c ./builds-NN.conf | $prog > outfile\n"); exit(0); } sub main() { getopts('h'); my @lines = (); my @builds = (); my @amis = (); my @vmimages = (); my $endisos = 0; $builddate = 0; $svnrev = 0; $junk = ""; $arch = ""; $kernel = ""; $branch = ""; $branchname = ""; $revision = 0; $version = 0; $hasbranch = 0; if ($opt_h) { &usage(); } while() { chomp($_); push(@lines, $_); if ($_ =~ m/^== VM IMAGE CHECKSUMS ==/) { $endisos = 1; } if ($_ =~ m/^BUILDDATE/) { $builddate = $_; $builddate =~ s/^BUILDDATE=//; pop(@lines); next; } if ($_ =~ m/^SVNREV/) { $svnrev = $_; $svnrev =~ s/^SVNREV=//; pop(@lines); next; } if ($_ =~ m/^o /) { $_ =~ s/:$//; if ($_ =~ m/^o .* armv6 .*/) { $hasarmv6 = 1; } if ($_ =~ m/^o .* aarch64 .*/) { $hasarm64 = 1; } if ($hasbranch eq 0) { ($junk, $branch, $arch, $kernel) = split(" ", $_); $revision = $branch; $revision =~ s/-\w+.*//; $version = $revision; $version =~ s/\.\d.*//; $branchname = $branch; $branchname =~ s/\d+\.\d-//; $branchname =~ s/ .*$//; if ($branchname =~ m/(ALPHA|CURRENT)/) { $branch = "head"; } elsif ($branchname =~ m/(BETA|PRERELEASE|RC|STABLE)/) { $branch = "stable/$version"; } else { $branch = "unknown"; } $hasbranch = 1; } if ($endisos == 0) { push(@builds, $_); } else { push(@vmimages, $_); } } if ($_ =~ m/^Created AMI in /) { $_ =~ s/^Created AMI in //; # Exclude ca-central-1 eu-west-2 for now #if ($_ !~ m/(ca-central-1|eu-west-2)/) { push(@amis, $_); pop(@lines); #} } } print <