|
In preparation for changing tests over to use SPDX tags, add the
initial licenses needed for the common/ and tests/ changeover to
the LICENSES/ directory. For this initial patch set, only the GPLv2
license text is required.
The tests and other common scripts will be converted to tags via a
script and, if necessary touched up to fix any warts the script
can't handle. The script is run on a target via:
for f in `git grep -l "GNU General" <target>` ; do
echo $f
cat $f | awk -f hdr.awk > $f.new
mv -f $f.new $f
done
This, unfortunately, changes the permissions of the files, so each
patch was post processed to remove the mode change fields from
the patches before they were committed. This preserves the file
modes, even though the files were replaced.
The awk script that dos all the substitution work is as follows:
$ cat hdr.awk
BEGIN {
hdr = 1
tag = "GPL-2.0"
ignore = 0
str = ""
cstr = ""
}
/^#[\!#][ ]*\/bin\/bash/ {
print $0
next
}
/^#[\!#][ ]*.*\/perl/ {
print $0
next
}
/any later version./ {
tag = "GPL-2.0+"
next
}
/^#[\-]{65}/ {
if (hdr == 1 && ignore == 0) {
ignore = 1
hdr = 0
} else if (ignore == 1) {
# use this to ignore empty comment line after license
ignore = 2
}
next
}
/This program is free software/ {
if (hdr == 1 && ignore == 0) {
ignore = 1
hdr = 0
}
next
}
/02110-1301[, ] *USA/ {
# use this to ignore empty comment line after license
if (ignore = 1) {
ignore = 2
}
next
}
/^#[ ]*Copyright/ {
if (cstr != "")
cstr = cstr "\n"
cstr = cstr $0
next
}
// {
if (ignore == 2) {
print "# SPDX-License-Identifier: " tag
print cstr "\n#"
print str
str=""
ignore = 3
}
if (ignore == 1) {
next
} else if (ignore == 3) {
# ignore trailing empty comment lines
if ($0 == "#")
next
ignore = 0
}
if (str != "")
str = str "\n"
str = str $0
}
END {
print str
}
$
Signed-off-by: Dave Chinner <dchinner@redhat.com>
|