#!/bin/bash # Copyright generation script inspired and derived from the ROCK Linux # (http://www.rocklinux.org) equivalent. copynote=`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 GSMP-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by the ./scripts/Create-CopyPatch script. Do not edit this copyright text! GSMP: @@FILENAME@@ General Sound Manipulation Program is Copyright (C) 2000 - `date +%Y` Valentin Ziegler and René Rebe 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; version 2. A copy of the GNU General Public License can be found in the file LICENSE. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT- ABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. EOT echo "Creating copy.patch (this may take a while) ..." echo -n > copy.patch find -type f -a ! -path '*/.svn/*' -a ! -path "*/old-0.0.5-source/*" \ -a ! -name '*~' -a ! -name '*.d' -a ! -name '*#' -a ! -name '#*' \ | sed s,^\./,, | \ while read filename do case $filename in *.h*|*.c*|*.lex|*.y|*.spec|*.tcx|*.tmpl|*.tcc) mode=c ;; */Makefile|*.sh|*.pl) mode=sh ;; *) echo "Unknown type of $filename" continue ;; esac grep -q -- '--- NO-GSMP-COPYRIGHT-NOTE ---' $filename && continue tag="`grep -- '--- GSMP-COPYRIGHT-NOTE-BEGIN ---' \ $filename | sed 's,---.*,,' | head -n 1`" cat $filename > $oldfile if [ -z "$tag" -a "$mode" = "sh" ] ; then sed '1 a\ #\ # --- GSMP-COPYRIGHT-NOTE-BEGIN ---\ # --- GSMP-COPYRIGHT-NOTE-END ---' < $filename > $oldfile tag="# " fi if [ -z "$tag" -a "$mode" = "c" ] ; then sed '1 i\ /*\ * --- GSMP-COPYRIGHT-NOTE-BEGIN ---\ * --- GSMP-COPYRIGHT-NOTE-END ---\ */' < $filename > $oldfile tag=" \* " fi if [ -z "$tag" -a "$mode" = "asci" ] ; then sed '1 i\ [COPY] --- GSMP-COPYRIGHT-NOTE-BEGIN ---\ [COPY] --- GSMP-COPYRIGHT-NOTE-END --- ' < $filename > $oldfile tag="[COPY] " fi if [ "$tag" ] ; then { grep -B 100000 -- '--- GSMP-COPYRIGHT-NOTE-BEGIN ---' $oldfile cat $copynote | sed -e "s,@@FILENAME@@,$filename,; s,^,$tag," grep -A 100000 -- '--- GSMP-COPYRIGHT-NOTE-END ---' $oldfile } > $newfile if ! cmp -s $oldfile $newfile ; then echo "Creating patch for $filename." diff -u ./$filename $newfile | sed -e "2 s,$newfile,./$filename," >> copy.patch fi else echo "WARNING: No Copyright tags in $filename found!" fi done rm -f $copynote $copynotepatch $newfile