~ivantis/armagetronad/sty+ct+ivantis

« back to all changes in this revision

Viewing changes to batch/make/sortresources

  • Committer: ivantis
  • Date: 2008-09-09 21:33:18 UTC
  • Revision ID: ivantis@ivantis.net-20080909213318-k43y6yuq0zd6wbsa
first commit

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 ${sortresources} -v ${destination} || exit 1
 
31
 
 
32
# silently remove empty directories
 
33
find ${destination} -type d -depth -exec rmdir \{\} \; > /dev/null 2>&1 
 
34
 
 
35
# copy map dtd file to one with correct version
 
36
MAPVERSION=`grep "<!-- version=" < ${destination}/map.dtd | sed -e "s,.*=\",," -e "s,\".*,,"`
 
37
test -r ${destination}/AATeam || mkdir ${destination}/AATeam
 
38
cp ${destination}/map.dtd ${destination}/AATeam/map-$MAPVERSION.dtd
 
39
echo $MAPVERSION > ${destination}/.mapversion
 
40
 
 
41
# tag completion
 
42
touch ${destination} || exit 1
 
43
chmod 755 ${destination} || exit 1