Home | History | Annotate | Line # | Download | only in OpenSSL
      1  1.1  christos #! /usr/bin/env perl
      2  1.1  christos # Copyright 2021-2022 The OpenSSL Project Authors. All Rights Reserved.
      3  1.1  christos #
      4  1.1  christos # Licensed under the Apache License 2.0 (the "License").  You may not use
      5  1.1  christos # this file except in compliance with the License.  You can obtain a copy
      6  1.1  christos # in the file LICENSE in the source distribution or at
      7  1.1  christos # https://www.openssl.org/source/license.html
      8  1.1  christos 
      9  1.1  christos use strict;
     10  1.1  christos use warnings;
     11  1.1  christos 
     12  1.1  christos package OpenSSL::copyright;
     13  1.1  christos 
     14  1.1  christos sub year_of {
     15  1.1  christos     my $file = shift;
     16  1.1  christos 
     17  1.1  christos     return $ENV{'OSSL_COPYRIGHT_YEAR'} if defined $ENV{'OSSL_COPYRIGHT_YEAR'};
     18  1.1  christos 
     19  1.1  christos     # Get the current year.  We use that as the default because the other
     20  1.1  christos     # common case is that someone unpacked a tarfile and the file dates
     21  1.1  christos     # are't properly set on extract.
     22  1.1  christos     my $YEAR = [localtime()]->[5] + 1900;
     23  1.1  christos 
     24  1.1  christos     # See if git's available
     25  1.1  christos     open my $FH,
     26  1.1  christos        "git log -1 --date=short --format=format:%cd $file 2>/dev/null|"
     27  1.1  christos            or return $YEAR;
     28  1.1  christos     my $LINE = <$FH>;
     29  1.1  christos     close $FH;
     30  1.1  christos     $LINE =~ s/^([0-9]*)-.*/$1/;
     31  1.1  christos     $YEAR = $LINE if $LINE;
     32  1.1  christos     return $YEAR;
     33  1.1  christos }
     34  1.1  christos 
     35  1.1  christos sub latest {
     36  1.1  christos     my $l = 0;
     37  1.1  christos     foreach my $f (@_ ) {
     38  1.1  christos         my $y = year_of($f);
     39  1.1  christos         $l = $y if $y > $l;
     40  1.1  christos     }
     41  1.1  christos     return $l
     42  1.1  christos }
     43  1.1  christos 1;
     44