10 while read fop fspec fperm
; do
11 local fop
=`echo "$fop" | tr -d ' \t\n'`
12 if [ "$fop" = "+" ]; then
13 if [ ! -e "${src_dir}${fspec}" ]; then
14 echo "File not found '${src_dir}${fspec}'"
17 dpath
=`dirname "$fspec"`
18 if [ -z "$fperm" ]; then
19 dperm
=`stat -c "%a" ${src_dir}${dpath}`
21 mkdir
-p -m$dperm ${dst_dir}${dpath}
22 echo "copying: '$fspec'"
23 cp -fpR ${src_dir}${fspec} ${dst_dir}${dpath}/
24 if [ -n "$fperm" ]; then
25 chmod -R $fperm ${dst_dir}${fspec}
27 elif [ "$fop" = "-" ]; then
28 echo "removing: '$fspec'"
29 rm -fR ${dst_dir}${fspec}
30 elif [ "$fop" = "=" ]; then
31 echo "setting permissions: '$fperm' on '$fspec'"
32 chmod -R $fperm ${dst_dir}${fspec}
44 process_filespec
"$src_dir" "$dst_dir" "$filespec" ||
{
45 echo "process filespec error-ed"
49 # delete egg-info directories
50 find "$dst_dir" -name "*.egg-info" |
xargs rm -rf
52 if [ "$mode" == "sources" ] ; then
53 # Copy only python source files
54 find $dst_dir -not -type d
-not -name "*\.py" |
xargs rm -f
56 # Delete empty folders (if the case)
57 if [ -d "$dst_dir/usr" ] ; then
58 find $dst_dir/usr
-type d |
xargs rmdir --ignore-fail-on-non-empty
59 rmdir --ignore-fail-on-non-empty $dst_dir/usr
64 # XXX [So that you won't goof as I did]
65 # Note: Yes, I tried to use the -O & -OO flags here.
66 # However the generated byte-codes were not portable.
67 # So, we just stuck to un-optimized byte-codes,
68 # which is still way better/faster than running
69 # Python sources all the time.
70 $python -m compileall
-b -d '/' $dst_dir ||
{
71 echo "python -m compileall err-ed"
75 # Delete source files and pyc [ un-optimized bytecode files ]
76 # We may want to make this optimization thing configurable later, but not sure atm
77 find $dst_dir -type f
-name "*\.py" |
xargs rm -f
79 # Delete empty folders (if the case)
80 if [ -d "$dst_dir/usr" ] ; then
81 find $dst_dir/usr
-type d |
xargs rmdir --ignore-fail-on-non-empty
82 rmdir --ignore-fail-on-non-empty $dst_dir/usr