[mythtv] Ticket #7010: ./cpsvndir causes errors with checkinstall for themes

David Engel david at istwok.net
Tue Sep 8 16:19:51 UTC 2009


On Tue, Sep 08, 2009 at 12:07:57AM -0500, David Engel wrote:
> Actually, I think I might have a better way, but I'm not going to work
> on it anymore until tomorrow.

Would some people please try the attached version of cpsvndir.

Also, does anyone care about preserving the timestamps on installed
files?  If not, we could just do a plain cp and get rid of the chown
garbage.

David
-- 
David Engel
david at istwok.net
-------------- next part --------------
#!/bin/sh
#
# cpsvndir: recursive directory copy excluding .svn sub dirs.

if [ -z "$1" -o -z "$2" ]; then
    echo "Usage: $0 source-dir destination-dir"
    exit -1
fi

# Some shells don't set EUID
if [ -z "$EUID" ]; then
    if [ -x /usr/bin/id ]; then EUID=`id -u` ;fi
    if [ -z "$EUID" ];     then EUID=$USER   ;fi
    if [ -z "$EUID" ];     then EUID=0       ;fi  # Will fail if not root
fi

# Do similarly for EGID
if [ -z "$EGID" ]; then
    if [ -x /usr/bin/id ]; then EGID=`id -g` ;fi
    if [ -z "$EGID" ];     then EGID=0       ;fi  # Will fail if not root
fi

BASE=$(basename "$1")
case "$BASE" in
    .|..|/)  BASE="" ;;
    *)       BASE="/$BASE" ;;
esac

SRC="$1"

case "$2" in
    /*) DEST="$2$BASE" ;;
    *)  DEST="$(pwd)/$2$BASE" ;;
esac

#echo "BASE=$BASE SRC=$SRC DEST=$DEST"

IFS='
'

# Copy all files and directories except .svn
cd "$SRC"
for file in $(find . -name .svn -prune -or -print); do
    #echo "processing $file"
    if [ -d "$file" ]; then
	mkdir -p "$DEST/$file"
    else
	cp -p "$file" "$DEST/$file"
	chown $EUID:$EGID "$DEST/$file"
	chmod +r "$DEST/$file" &> /dev/null
    fi
done

exit 0



More information about the mythtv-dev mailing list