Add a local perl module to get year last changed

This is used for generating a more-correct copyright statement
for the "build_generated" targets.

Fixes: #13765

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/13791)
This commit is contained in:
Rich Salz 2021-01-05 20:26:05 -05:00 committed by Tomas Mraz
parent c47a0803ce
commit c37b947957
9 changed files with 99 additions and 16 deletions

View File

@ -1,5 +1,5 @@
#! /usr/bin/env perl
# Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved.
# Copyright 2000-2021 The OpenSSL Project Authors. All Rights Reserved.
#
# Licensed under the Apache License 2.0 (the "License"). You may not use
# this file except in compliance with the License. You can obtain a copy
@ -7,6 +7,9 @@
# https://www.openssl.org/source/license.html
use strict;
use FindBin;
use lib "$FindBin::Bin/../../util/perl";
use OpenSSL::copyright;
my ($i, @arr);
@ -83,7 +86,8 @@ $arr[ord("?")] |= $PSTRING_CHAR;
# Now generate the C code
# Year the file was generated.
my $YEAR = [localtime()]->[5] + 1900;
my $YEAR = OpenSSL::copyright::year_of($0);
print <<EOF;
/*
* WARNING: do not edit!

View File

@ -1,13 +1,17 @@
#! /usr/bin/env perl
# Copyright 1998-2020 The OpenSSL Project Authors. All Rights Reserved.
# Copyright 1998-2021 The OpenSSL Project Authors. All Rights Reserved.
#
# Licensed under the Apache License 2.0 (the "License"). You may not use
# this file except in compliance with the License. You can obtain a copy
# in the file LICENSE in the source distribution or at
# https://www.openssl.org/source/license.html
use FindBin;
use lib "$FindBin::Bin/../../util/perl";
use OpenSSL::copyright;
# The year the output file is generated.
my $YEAR = [localtime()]->[5] + 1900;
my $YEAR = OpenSSL::copyright::year_of($0);
print <<"EOF";
/*
* WARNING: do not edit!

View File

@ -1,5 +1,5 @@
#! /usr/bin/env perl
# Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
# Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved.
#
# Licensed under the Apache License 2.0 (the "License"). You may not use
# this file except in compliance with the License. You can obtain a copy
@ -8,6 +8,9 @@
use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/../../util/perl";
use OpenSSL::copyright;
my $NUMBER = 0x0001;
my $UPPER = 0x0002;
@ -58,7 +61,7 @@ foreach (0 .. 127) {
}
# The year the output file is generated.
my $YEAR = [localtime()]->[5] + 1900;
my $YEAR = OpenSSL::copyright::year_of($0);
print <<"EOF";
/*
* WARNING: do not edit!

View File

@ -1,5 +1,5 @@
#! /usr/bin/env perl
# Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
# Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved.
#
# Licensed under the Apache License 2.0 (the "License"). You may not use
# this file except in compliance with the License. You can obtain a copy
@ -9,6 +9,9 @@
use integer;
use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/../../util/perl";
use OpenSSL::copyright;
# Generate the DER encoding for the given OID.
sub der_it
@ -37,7 +40,7 @@ sub der_it
}
# The year the output file is generated.
my $YEAR = [localtime()]->[5] + 1900;
my $YEAR = OpenSSL::copyright::latest(($0, $ARGV[0]));
# Read input, parse all #define's into OID name and value.
# Populate %ln and %sn with long and short names (%dupln and %dupsn)

View File

@ -7,12 +7,15 @@
# https://www.openssl.org/source/license.html
use Getopt::Std;
use FindBin;
use lib "$FindBin::Bin/../../util/perl";
use OpenSSL::copyright;
our($opt_n);
getopts('n');
# The year the output file is generated.
my $YEAR = [localtime()]->[5] + 1900;
my $YEAR = OpenSSL::copyright::latest(($0, $ARGV[1], $ARGV[0]));
open (NUMIN,"$ARGV[1]") || die "Can't open number file $ARGV[1]";
$max_nid=0;

View File

@ -1,13 +1,15 @@
#! /usr/bin/env perl
# Copyright 1998-2020 The OpenSSL Project Authors. All Rights Reserved.
# Copyright 1998-2021 The OpenSSL Project Authors. All Rights Reserved.
#
# Licensed under the Apache License 2.0 (the "License"). You may not use
# this file except in compliance with the License. You can obtain a copy
# in the file LICENSE in the source distribution or at
# https://www.openssl.org/source/license.html
use strict;
use FindBin;
use lib "$FindBin::Bin/../../util/perl";
use OpenSSL::copyright;
my %xref_tbl;
my %oid_tbl;
@ -15,7 +17,7 @@ my %oid_tbl;
my ($mac_file, $xref_file) = @ARGV;
# The year the output file is generated.
my $YEAR = [localtime()]->[5] + 1900;
my $YEAR = OpenSSL::copyright::latest(($0, $mac_file, $xref_file));
open(IN, $mac_file) || die "Can't open $mac_file, $!\n";

View File

@ -1,15 +1,27 @@
#! /usr/bin/env perl
# Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved.
# Copyright 1995-2021 The OpenSSL Project Authors. All Rights Reserved.
#
# Licensed under the Apache License 2.0 (the "License"). You may not use
# this file except in compliance with the License. You can obtain a copy
# in the file LICENSE in the source distribution or at
# https://www.openssl.org/source/license.html
use FindBin;
use lib "$FindBin::Bin/../util/perl";
use OpenSSL::copyright;
my $obj_dat_h = $ARGV[0];
# The year the output file is generated.
my $YEAR = [localtime()]->[5] + 1900;
my $YEAR = OpenSSL::copyright::latest(($0, $obj_dat_h));
print <<"EOF";
# WARNING: do not edit!
# Generated by fuzz/mkfuzzoids.pl
#
# Copyright 2020-$YEAR The OpenSSL Project Authors. All Rights Reserved.
#
# Licensed under the Apache License 2.0 (the "License"). You may not use
# this file except in compliance with the License. You can obtain a copy
# in the file LICENSE in the source distribution or at
# https://www.openssl.org/source/license.html
EOF
open IN, '<', $obj_dat_h
|| die "Couldn't open $obj_dat_h : $!\n";

View File

@ -1,3 +1,12 @@
# WARNING: do not edit!
# Generated by fuzz/mkfuzzoids.pl
#
# Copyright 2020-2021 The OpenSSL Project Authors. All Rights Reserved.
#
# Licensed under the Apache License 2.0 (the "License"). You may not use
# this file except in compliance with the License. You can obtain a copy
# in the file LICENSE in the source distribution or at
# https://www.openssl.org/source/license.html
OBJ_rsadsi="\x2A\x86\x48\x86\xF7\x0D"
OBJ_pkcs="\x2A\x86\x48\x86\xF7\x0D\x01"
OBJ_md2="\x2A\x86\x48\x86\xF7\x0D\x02\x02"

View File

@ -0,0 +1,43 @@
#! /usr/bin/env perl
# Copyright 2021 The OpenSSL Project Authors. All Rights Reserved.
#
# Licensed under the Apache License 2.0 (the "License"). You may not use
# this file except in compliance with the License. You can obtain a copy
# in the file LICENSE in the source distribution or at
# https://www.openssl.org/source/license.html
use strict;
use warnings;
package OpenSSL::copyright;
sub year_of {
my $file = shift;
return $ENV{'OSSL_COPYRIGHT_YEAR'} if defined $ENV{'OSSL_COPYRIGHT_YEAR'};
# Get the current year. We use that as the default because the other
# common case is that someone unpacked a tarfile and the file dates
# are't properly set on extract.
my $YEAR = [localtime()]->[5] + 1900;
# See if git's available
open my $FH,
"git log -1 --date=format:%Y --format=format:%ad $file 2>/dev/null|"
or return $YEAR;
my $LINE = <$FH>;
close $FH;
chomp($LINE);
$YEAR = $LINE if $LINE;
return $YEAR;
}
sub latest {
my $l = 0;
foreach my $f (@_ ) {
my $y = year_of($f);
$l = $y if $y > $l;
}
return $l
}
1;