#!/usr/bin/perl 

use Readonly;
use File::Temp qw();
use Software::License;
use Data::Dumper;
require UNIVERSAL::require;

Readonly my @LICENSES => qw(
    Apache_2_0
    FreeBSD
    GPL_1
    GPL_2
    GPL_3
    LGPL_2
    LGPL_2_1
    LGPL_3_0
    MIT
    Mozilla_2_0
    QPL_1_0
    Zlib
    CC0_1_0
    GFDL_1_3
    Artistic_1_0
    Artistic_2_0
    Mozilla_1_0
    None
    PostgreSQL
    AGPL_3
    SSLeay
    Apache_1_1
    Mozilla_1_1
    GFDL_1_2
    Sun
    BSD
    OpenSSL
    Perl_5
);


my $dir = File::Temp->newdir('/tmp/slgenXXXXX');
my $year = 2000;
foreach my $license (@LICENSES) {
	my $slfile = $dir->dirname . "/$license";
	my $module = "Software::License::$license";
	$module->require;
	my $slobj = $module->new({
		holder => 'Testophilus Testownik <tester@testity.org>',
		year=>$year,
	});
	open my $fh, '>', $slfile;
	print $fh $slobj->notice;
	print $fh $slobj->debian_text;
	close $fh;
	++$year;
    system("licensecheck --no-conf $slfile");
}

