#!/bin/bash copynote=`mktemp` copynotepatch=`mktemp` oldfile=`mktemp` newfile=`mktemp` cat << EOT > $copynote This copyright note is auto-generated by ./scripts/Create-CopyPatch. Please add additional copyright information _after_ the line containing the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by the ./scripts/Create-CopyPatch script. Do not edit this copyright text! ROCK Linux: rock-src/@@FILENAME@@ ROCK Linux is Copyright (C) 1998 - `date +%Y` Clifford Wolf EOT cp $copynote $copynotepatch cat << EOT >> $copynote This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. A copy of the GNU General Public License can be found at Documentation/COPYING. Many people helped and are helping developing ROCK Linux. Please have a look at https://www.rocklinux.org/ and the Documentation/TEAM file for details. EOT cat << EOT >> $copynotepatch This patch file is dual-licensed. It is available under the license the patched project is licensed under, as long as it is an OpenSource license as defined at https://www.opensource.org/ (e.g. BSD, X11) or under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. EOT echo "Creating copy.patch (this may take a while) ..." >&2 if [ "$1" == -* ] ; then echo echo "Usage: ./scripts/Create-CopyPatch [ ]" echo echo " Update copyright notes in files that already contain such a note." echo " The first and last line of ROCK copyright notes are marked by the" echo " --- ROCK-COPYRIGHT-NOTE-BEGIN ---" echo " and" echo " --- ROCK-COPYRIGHT-NOTE-END ---" echo " respectively." echo " Files that contain the line" echo " --- NO-ROCK-COPYRIGHT-NOTE ---" echo " are not updated." echo " If no directories are given, process Documentation, architecture," echo " misc, package, scripts and target." echo exit fi [ $# = 0 ] && set Documentation/. architecture/. misc/. \ package/. scripts/. target/. bash scripts/xfind.sh $* -type f ! -name "*~" \ ! -name Create-CopyPatch | sed 's,/\./,/,g' | \ while read filename do grep -q -- '--- NO-ROCK-COPYRIGHT-NOTE ---' $filename && continue tag="`grep -- '--- ROCK-COPYRIGHT-NOTE-BEGIN ---' \ $filename | sed 's,---.*,,' | head -n 1`" cat $filename > $oldfile if [ -z "$tag" -a '(' \ "$filename" != "${filename%/*.init}" -o \ "$filename" != "${filename%/*.sh}" ')' ] && grep -n '^#!' $filename | grep -q ':1:' then sed '1 a\ # # --- ROCK-COPYRIGHT-NOTE-BEGIN ---\ # --- ROCK-COPYRIGHT-NOTE-END ---' < $filename > $oldfile tag="# " fi if [ -z "$tag" -a '(' \ "" != "$( expr $filename : \ 'package/.*/\(.*\)/\1\.conf' )" -o \ "$filename" != "${filename%/*.diff}" -o \ "$filename" != "${filename%/*.patch}" -o \ "$filename" != "${filename%/*.patch.*}" -o \ "$filename" != "${filename%/parse-config*}" -o \ "$filename" != "${filename%/*config*.in}" -o \ "$filename" != "${filename%/config*.hlp}" ')' ] then sed '1 i\ # --- ROCK-COPYRIGHT-NOTE-BEGIN ---\ # --- ROCK-COPYRIGHT-NOTE-END ---\ ' < $filename > $oldfile tag="# " fi if [ -z "$tag" -a '(' \ "$filename" != "${filename%/*.cache}" -o \ "$filename" != "${filename%/*.desc}" ')' ] then sed '1 i\ [COPY] --- ROCK-COPYRIGHT-NOTE-BEGIN ---\ [COPY] --- ROCK-COPYRIGHT-NOTE-END --- ' < $filename > $oldfile tag="[COPY] " fi if [ "$tag" ] ; then { grep -B 100000 -- '--- ROCK-COPYRIGHT-NOTE-BEGIN ---' $oldfile if [ "$filename" != "${filename%/*.diff}" -o \ "$filename" != "${filename%/*.patch}" -o \ "$filename" != "${filename%/*.patch.*}" ] ; then cat $copynotepatch | \ sed -e "s,@@FILENAME@@,$filename,; s,^,$tag," else cat $copynote | \ sed -e "s,@@FILENAME@@,$filename,; s,^,$tag," fi grep -A 100000 -- '--- ROCK-COPYRIGHT-NOTE-END ---' $oldfile } > $newfile if ! cmp -s $oldfile $newfile ; then echo "Creating patch for $filename." >&2 diff -u ./$filename $newfile | sed -e "2 s,$newfile,./$filename," fi else echo "WARNING: No Copyright tags in $filename found!" >&2 fi done rm -f $copynote $copynotepatch $newfile