Ticket #6772: cpsvndir_mythtv3.patch

File cpsvndir_mythtv3.patch, 1.2 KB (added by mythtv@…, 13 years ago)
  • themes/cpsvndir

     
    22#
    33# cpsvndir: recursive directory copy excluding .svn sub dirs.
    44
    5 DESTDIR=$2
    6 SOURCE=$(basename "$1")
    75
    86if [ -z "$1" -o -z "$2" ]; then
    97    echo "Usage: $0 source-dir destination-dir"
     
    2321    if [ -z "$EGID" ];     then EGID=0       ;fi  # Will fail if not root
    2422fi
    2523
    26 mkdir -p $DESTDIR/$SOURCE || exit 1
     24# Build directory structure
     25IFS=$'\012'
     26for directory in $(find "$1" -path '*/.svn' -prune -or -type d -print); do
     27    mkdir -p "$2/${1##*/}/${directory/#$1}"
     28done
    2729
    28 find $SOURCE -path '*/.svn' -prune -or -type d -exec mkdir -p $DESTDIR/{} \;
    29 find $SOURCE -path '*/.svn' -prune -or ! -type d \
    30              -exec cp -p {}    $DESTDIR/{} \; \
    31              -exec chown $EUID $DESTDIR/{} \; \
    32              -exec chgrp $EGID $DESTDIR/{} \; \
    33              -exec chmod +r    $DESTDIR/{} \;
     30# Copy files
     31for file in $(find "$1" -path '*/.svn' -prune -or ! -type d -print); do
     32    cp -pR "$file" "$2/${1##*/}/${file/#$1}"
     33    chown $EUID:$EGID "$2/${1##*/}/${file/#$1}" &> /dev/null
     34    chmod +r "$2/${1##*/}/${file/#$1}" &> /dev/null
     35done
    3436
    3537exit 0