diff --git a/.gitattributes b/.gitattributes index 366a812d916..99167680573 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3491,6 +3491,7 @@ Scripts/developer_scripts/mirror_all_packages.rb -text Scripts/developer_scripts/mirror_package.rb -text Scripts/developer_scripts/mirror_package_files.rb -text Scripts/developer_scripts/mirror_package_impl.rb -text +Scripts/developer_scripts/qpl-to-gplv3.perl -text Scripts/developer_scripts/remove_package_files_from_build_tree.rb -text Scripts/developer_scripts/remove_package_files_from_build_tree_impl.rb -text Scripts/developer_scripts/replace_CGAL_NAMESPACE.py -text diff --git a/Scripts/developer_scripts/qpl-to-gplv3.perl b/Scripts/developer_scripts/qpl-to-gplv3.perl new file mode 100755 index 00000000000..25aee6d28e5 --- /dev/null +++ b/Scripts/developer_scripts/qpl-to-gplv3.perl @@ -0,0 +1,52 @@ +#!/usr/bin/env perl + +use warnings; + +sub print_gplv3 +{ + my $mark = shift; + my $software = shift; + print <<"EOF" +$mark This file is part of $software. +$mark You can redistribute it and/or modify it under the terms of the GNU +$mark General Public License as published by the Free Software Foundation, +$mark either version 3 of the License, or (at your option) any later version. +EOF +} + +unshift(@ARGV, '-') unless @ARGV; +while ($ARGV = shift) { + my $first_line=1; + + my $previous_line; + my $current_line; + + my $backup = $ARGV . ".bak"; + rename($ARGV, $backup); + open(my $fh, "<", $backup); + open(my $out, ">", $ARGV); + select($out); + while ($current_line = <$fh>) { + if($first_line) { + $first_line=0; + $previous_line = $current_line; + } else { + if( ((my $mark, $software) = $previous_line =~ /(\/\/|\#| \*|%+) *This file is part of (.*);/) && + ($current_line =~ /the terms of the Q Public License /) ) + { + print_gplv3($mark, $software); + $previous_line = <$fh>; + $previous_line = <$fh>; + } + else { + print $previous_line; + $previous_line = $current_line; + } + } + } + print $previous_line; + close($fh); + select(STDOUT); + close($out); + unlink($backup); +}