forked from unsound/dmgextractor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makesrcdist.sh
executable file
·130 lines (112 loc) · 2.63 KB
/
makesrcdist.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/bin/bash
match () {
local SUBFILE="$1"
local DIRNAME="$2"
CMPRES=`expr "${SUBFILE}" : "${DIRNAME}"`
RETVAL="$?"
if [ "${RETVAL}" -eq 0 ]; then
if [ -d "${SUBFILE}" ]; then
echo "`pwd`/${SUBFILE}/"
rm -r "${SUBFILE}"
if [ ! $? -eq 0 ]; then return 1; fi
else
echo "`pwd`/${SUBFILE}"
rm "${SUBFILE}"
if [ ! $? -eq 0 ]; then return 1; fi
fi
elif [ "${RETVAL}" -eq 1 ]; then
if [ -d "${SUBFILE}" ]; then
recursiveRmdir "${DIRNAME}" "${SUBFILE}"
if [ ! $? -eq 0 ]; then return 1; fi
fi
fi
return 0
}
recursiveRmdir () {
local DIRNAME="$1"
#local DIRNAMELEN="${#DIRNAME}"
shift 1
while [ ! $# -eq 0 ]; do
local FILE="$1"
shift 1
if [ -d "${FILE}" ]; then
pushd "${FILE}" > /dev/null
for SUBFILE in .*; do
if [ ! "${SUBFILE}" = ".." ] && [ ! "${SUBFILE}" = "." ]; then
match "${SUBFILE}" "${DIRNAME}"
if [ ! $? -eq 0 ]; then return 1; fi
fi
done
for SUBFILE in *; do
if [ ! "${SUBFILE}" = "*" ]; then
match "${SUBFILE}" "${DIRNAME}"
if [ ! $? -eq 0 ]; then return 1; fi
fi
done
popd > /dev/null
else
match "${FILE}" "${DIRNAME}"
if [ ! $? -eq 0 ]; then return 1; fi
fi
done
return 0
}
error () {
echo "There were errors..."
exit 1
}
checkerror () {
if [ ! $1 -eq 0 ]; then error; fi
}
TEMPDIR="srcdisttemp.~"
OUTFILE="releases/current-src.zip"
copydir () {
cp -r $1 "${TEMPDIR}"
checkerror $?
}
echo "Cleaning temp dir..."
rm -r "${TEMPDIR}"
mkdir "${TEMPDIR}"
checkerror $?
echo "Copying files..."
cp *.sh ${TEMPDIR}
checkerror $?
cp *.bat ${TEMPDIR}
checkerror $?
cp *.xml ${TEMPDIR}
checkerror $?
copydir lib
copydir src
copydir src.JNLP-INF
copydir src.META-INF
copydir targets
echo "Removing CVS directories..."
recursiveRmdir "^CVS$" "${TEMPDIR}"
checkerror $?
echo "Removing emacs backup files (*~)..."
recursiveRmdir ".*~$" "${TEMPDIR}"
checkerror $?
echo "Removing emacs temporary files (#*#)..."
recursiveRmdir "^#.*#$" "${TEMPDIR}"
checkerror $?
echo "Removing Thumbs.db files..."
recursiveRmdir "^Thumbs\.db$" "${TEMPDIR}"
checkerror $?
echo "Removing .DS_Store files..."
recursiveRmdir "^\.DS_Store$" "${TEMPDIR}"
checkerror $?
echo "Removing .cvsignore files..."
recursiveRmdir "^\.cvsignore$" "${TEMPDIR}"
checkerror $?
echo "Setting execute permissions for shell scripts..."
chmod a+x ${TEMPDIR}/*.sh
checkerror $?
chmod a+x ${TEMPDIR}/targets/application/bin/*.sh
checkerror $?
echo "Building zip file..."
cd "${TEMPDIR}"
rm "../${OUTFILE}"
zip -9 -r "../${OUTFILE}" *
checkerror $?
cd ..
echo "Done! Zip file generated in ${OUTFILE}"