]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Add a local perl module to get year last changed
authorRich Salz <rsalz@akamai.com>
Wed, 6 Jan 2021 01:26:05 +0000 (20:26 -0500)
committerTomas Mraz <tomas@openssl.org>
Wed, 31 Mar 2021 11:59:53 +0000 (13:59 +0200)
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)

crypto/asn1/charmap.pl
crypto/bn/bn_prime.pl
crypto/conf/keysets.pl
crypto/objects/obj_dat.pl
crypto/objects/objects.pl
crypto/objects/objxref.pl
fuzz/mkfuzzoids.pl
fuzz/oids.txt
util/perl/OpenSSL/copyright.pm [new file with mode: 0644]

index 43102a136a58f859f4fe8ddde27c8b90bd493a1c..78053dee15fb2437286b72f6797d298d157505e7 100644 (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!
index a808c3c9ce10994e0fcc059d915b6af95d861dc0..a7a764627b94f69f3d3578657628a25579334873 100644 (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!
index f4c4b807c661d3ce30ea0be01ef7f5145a3efc89..7e83d800501bfae3064d52076dfa441004e1422c 100644 (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!
index ea77b9d24217dc386805f7bd2c1294e13fc659f6..60a5e5a6833e34375cb8c96e05bf4ccd4d079afb 100644 (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)
index 8c80b2f83f935b7722a002a16db37612dc5d2fd9..51bc248b3f003c6755162d0526d8554b1ef0f16f 100644 (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;
index bf45d6604645fc22997911054c35d57ac91c5eea..a6748f00f45ad4ee0e87c62a42553e43792902eb 100644 (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";
 
index 8fff764b9667899b721df427c9e2148438b9cb26..56021717a8d49b32d8dacbfc0f38df6125b432bf 100755 (executable)
@@ -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";
index cec6a7015159b7df5547baa060af48d6b0dcb596..8ca5291a016193dd8c90b9957d3da9c92f74de58 100644 (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"
diff --git a/util/perl/OpenSSL/copyright.pm b/util/perl/OpenSSL/copyright.pm
new file mode 100644 (file)
index 0000000..1fd9f35
--- /dev/null
@@ -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;