~ubuntu-branches/ubuntu/lucid/mythplugins/lucid

« back to all changes in this revision

Viewing changes to cpsvndir

  • Committer: Bazaar Package Importer
  • Author(s): Mario Limonciello
  • Date: 2009-09-08 23:35:10 UTC
  • mfrom: (1.1.27 upstream)
  • Revision ID: james.westby@ubuntu.com-20090908233510-uvcvmvbn73khqark
Tags: 0.22.0~trunk21742-0ubuntu1
* New upstream checkout (r21742)
* debian/rules, debian/mythvideo.cron.daily:
  - Install jamu cron job
* debian/control:
  - Depends on python-imdbpy for mythvideo's new jamu cron job.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
#
 
3
# cpsvndir: recursive directory copy excluding .svn sub dirs.
 
4
 
 
5
if [ -z "$1" -o -z "$2" ]; then
 
6
    echo "Usage: $0 source-dir destination-dir"
 
7
    exit -1
 
8
fi
 
9
 
 
10
# Some shells don't set EUID
 
11
if [ -z "$EUID" ]; then
 
12
    if [ -x /usr/bin/id ]; then EUID=`id -u` ;fi
 
13
    if [ -z "$EUID" ];     then EUID=$USER   ;fi
 
14
    if [ -z "$EUID" ];     then EUID=0       ;fi  # Will fail if not root
 
15
fi
 
16
 
 
17
# Do similarly for EGID
 
18
if [ -z "$EGID" ]; then
 
19
    if [ -x /usr/bin/id ]; then EGID=`id -g` ;fi
 
20
    if [ -z "$EGID" ];     then EGID=0       ;fi  # Will fail if not root
 
21
fi
 
22
 
 
23
BASE=$(basename "$1")
 
24
case "$BASE" in
 
25
    .|..|/)  BASE="" ;;
 
26
    *)       BASE="/$BASE" ;;
 
27
esac
 
28
 
 
29
SRC="$1"
 
30
 
 
31
case "$2" in
 
32
    /*) DEST="$2$BASE" ;;
 
33
    *)  DEST="$(pwd)/$2$BASE" ;;
 
34
esac
 
35
 
 
36
#echo "BASE=$BASE SRC=$SRC DEST=$DEST"
 
37
 
 
38
IFS='
 
39
'
 
40
 
 
41
# Copy all files and directories except .svn
 
42
cd "$SRC"
 
43
for file in $(find . -name .svn -prune -or -print); do
 
44
    #echo "processing $file"
 
45
    if [ -d "$file" ]; then
 
46
        mkdir -p "$DEST/$file"
 
47
    else
 
48
        cp -p "$file" "$DEST/$file"
 
49
        chown $EUID:$EGID "$DEST/$file"
 
50
        chmod +r "$DEST/$file" &> /dev/null
 
51
    fi
 
52
done
 
53
 
 
54
exit 0
 
55