| 1 |
#!/bin/sh |
| 2 |
# links resources from one directory to another and sorts them there |
| 3 |
# usage: resources <source> <destination> <path to sortresources.py> |
| 4 |
|
| 5 |
# set -x |
| 6 |
|
| 7 |
source=$1 |
| 8 |
destination=$2 |
| 9 |
sortresources=$3 |
| 10 |
|
| 11 |
# globalize path |
| 12 |
#test -z `echo ${sortresources} | grep "^/"` && sortresources=`pwd`/${sortresources} |
| 13 |
|
| 14 |
# exit if source does not exist |
| 15 |
test -d $source || exit 0 |
| 16 |
|
| 17 |
# remake directory for included resources |
| 18 |
rm -rf ${destination} |
| 19 |
mkdir ${destination} |
| 20 |
|
| 21 |
# link/softlink/copy them over |
| 22 |
cp -Rlf ${source}/* ${destination}/ > /dev/null 2>&1 || cp -Rsf ${source}/* ${destination}/ > /dev/null 2>&1 || cp -Rf ${source}/* ${destination}/ || { echo Copying or linking resources failed. ; exit 1;} |
| 23 |
|
| 24 |
# remove CVS directories and backup files |
| 25 |
find ${destination}/ -depth -type d -name CVS -exec rm -rf \{\} \; |
| 26 |
find ${destination}/ -depth -type d -name .svn -exec rm -rf \{\} \; |
| 27 |
find ${destination}/ -name "*~" -exec rm -rf \{\} \; |
| 28 |
|
| 29 |
# rename them properly |
| 30 |
PYTHON=`which python3 python python2 2> /dev/null | head -n 1` |
| 31 |
echo python is ${PYTHON} |
| 32 |
${PYTHON} ${sortresources} -v ${destination} || exit 1 |
| 33 |
|
| 34 |
# silently remove empty directories |
| 35 |
find ${destination} -type d -depth -exec rmdir \{\} \; > /dev/null 2>&1 |
| 36 |
|
| 37 |
# copy map dtd file to one with correct version |
| 38 |
MAPVERSION=`grep "<!-- version=" < ${destination}/map.dtd | sed -e "s,.*=\",," -e "s,\".*,,"` |
| 39 |
test -r ${destination}/AATeam || mkdir ${destination}/AATeam |
| 40 |
cp ${destination}/map.dtd ${destination}/AATeam/map-$MAPVERSION.dtd |
| 41 |
echo $MAPVERSION > ${destination}/.mapversion |
| 42 |
|
| 43 |
# tag completion |
| 44 |
touch ${destination} || exit 1 |
| 45 |
chmod 755 ${destination} || exit 1 |