#!/usr/bin/env perl
use strict;
use warnings;

use File::Spec::Functions qw(updir catfile abs2rel canonpath);
use File::Basename qw(dirname);
use Cwd qw(abs_path);
use POSIX qw(strftime);

my $dir = dirname(__FILE__);
my $root = abs2rel(abs_path(catfile($dir, updir)));

my $CACERT_PEM_FILE = canonpath("$root/lib/Mozilla/CA/cacert.pem");

system($^X, "$dir/mk-ca-bundle.pl", '-u', $CACERT_PEM_FILE) == 0
    or exit $?;

if (system(qw( git diff --exit-code --quiet ), $CACERT_PEM_FILE) == 0) {
    print "No changes to certificate bundle.\n";
}
