"Fossies" - the Fresh Open Source Software Archive

Member "core-22.7.1/Scripts/license" (8 Aug 2022, 4461 Bytes) of package /linux/misc/opnsense-core-22.7.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/usr/bin/env perl
    2 
    3 # Copyright (c) 2017 Franco Fichtner <franco@opnsense.org>
    4 #
    5 # Redistribution and use in source and binary forms, with or without
    6 # modification, are permitted provided that the following conditions
    7 # are met:
    8 #
    9 # 1. Redistributions of source code must retain the above copyright
   10 #    notice, this list of conditions and the following disclaimer.
   11 #
   12 # 2. Redistributions in binary form must reproduce the above copyright
   13 #    notice, this list of conditions and the following disclaimer in the
   14 #    documentation and/or other materials provided with the distribution.
   15 #
   16 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   17 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   18 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   19 # ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   20 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   21 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   22 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   23 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   24 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   25 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   26 # SUCH DAMAGE.
   27 
   28 use strict;
   29 use warnings;
   30 use autodie;
   31 
   32 use Cwd;
   33 use File::Find;
   34 use File::Slurp;
   35 
   36 my $src = shift || 'src';
   37 my $cwd = getcwd;
   38 my $lic = << 'END_LIC';
   39 All rights reserved.
   40 
   41 Redistribution and use in source and binary forms, with or without
   42 modification, are permitted provided that the following conditions are met:
   43 
   44 1. Redistributions of source code must retain the above copyright notice, this
   45    list of conditions and the following disclaimer.
   46 
   47 2. Redistributions in binary form must reproduce the above copyright notice,
   48    this list of conditions and the following disclaimer in the documentation
   49    and/or other materials provided with the distribution.
   50 
   51 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
   52 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   53 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   54 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
   55 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   56 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
   57 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
   58 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   59 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
   60 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   61 END_LIC
   62 
   63 my %copyrights = ();
   64 
   65 sub process_file
   66 {
   67     my $filename = $File::Find::name;
   68 
   69     return if not -f "$cwd/$filename";
   70 
   71     my @lines = read_file( "$cwd/$filename" );
   72     my $possibly_bsd;
   73 
   74     for my $line ( @lines ) {
   75         $possibly_bsd = 1 if $line =~ /Redistribution and use in source and binary forms/i;
   76         if ( $line =~ /Apache License/i ) {
   77             $possibly_bsd = 0;
   78             last;
   79         }
   80     }
   81 
   82     return if not $possibly_bsd;
   83 
   84     for my $line ( @lines ) {
   85         my $copy = $line;
   86         next if $line !~ s/copyright\s+\(c\)\s+//i;
   87         $line =~ s/^[."\*\\#\s-]+//g;
   88         $line =~ s/\s+$//g;
   89         chomp $copy;
   90         $copy =~ s/^[\*\\#\s]+//g;
   91         my ( $start, $end ) = ( 0, 9999 );
   92         if ( $line =~ s/(\d\d\d\d\s*,?-?\s*)// ) {
   93             $start = $1;
   94             $start =~ s/[,\s\-]+//g;
   95         }
   96         if ( $line =~ s/(\d\d\d\d\s*,?\s+)// ) {
   97             $end = $1;
   98             $end =~ s/[,\s]+//g;
   99         }
  100         $end = $start if $end == 9999;
  101         say STDERR "Error in $filename: $copy" if $end == 0;
  102         if ( exists $copyrights{$line} ) {
  103             if ( $start > $copyrights{$line}[0] ) {
  104                 $start = $copyrights{$line}[0];
  105             }
  106             if ( $copyrights{$line}[1] == 9999 or $end < $copyrights{$line}[1] ) {
  107                 $end = $copyrights{$line}[1];
  108             }
  109         }
  110         $copyrights{$line} = [ $start, $end ];
  111     }
  112 }
  113 
  114 find( \&process_file, $src );
  115 
  116 for ( sort keys %copyrights ) {
  117     my $date = $copyrights{$_}[0];
  118     next if $date == 0;
  119     $date = join '-', @{ $copyrights{$_} } if $copyrights{$_}[1] != $date;
  120     print "Copyright (c) $date $_\n";
  121 }
  122 
  123 print $lic;