#!/bin/sh
# Copy a patch.
#

. patchfns 2>/dev/null ||
. /usr/lib/patch-scripts/patchfns 2>/dev/null ||
. $PATCHSCRIPTS_LIBDIR/patchfns 2>/dev/null ||
{
	echo "Impossible to find my library 'patchfns'."
	echo "Check your install, or go to the right directory"
	exit 1
}

usage()
{
	echo "Usage: cp-patch oldname newname"
	exit 1
}

do_cp()
{
    cp $P/pc/$1.pc $P/pc/$2.pc
    cp $P/txt/$1.txt $P/txt/$2.txt
    cp $P/patches/$1.patch $P/patches/$2.patch
}

src=$(stripit $1)
dest=$(stripit $2)

if [ $# != 2 ]
then
        usage
fi

if [ -e $P/pc/$dest.pc -o -e $P/txt/$dest.txt -o -e $P/patches/$dest.patch ]
then
    echo "$dest already exists";
    exit 1
fi

do_cp $src $dest
