-
Notifications
You must be signed in to change notification settings - Fork 0
/
makesrcdist.sh
92 lines (78 loc) · 1.98 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
#!/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}"
else
echo "`pwd`/${SUBFILE}"
rm "${SUBFILE}"
fi
elif [ "${RETVAL}" -eq 1 ]; then
if [ -d "${SUBFILE}" ]; then
recursiveRmdir "${DIRNAME}" "${SUBFILE}"
fi
fi
}
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}"
fi
done
for SUBFILE in *; do
if [ ! "${SUBFILE}" = "*" ]; then
match "${SUBFILE}" "${DIRNAME}"
fi
done
popd > /dev/null
else
match "${FILE}" "${DIRNAME}"
fi
done
}
TEMPDIR=srcdisttemp.~
echo "Cleaning temp dir..."
rm -r $TEMPDIR
mkdir $TEMPDIR
echo "Copying files..."
cp * $TEMPDIR
cp -r dist $TEMPDIR
cp -r lib $TEMPDIR
cp -r resource $TEMPDIR
cp -r src $TEMPDIR
cp -r src.META-INF $TEMPDIR
cp -r src.win32 $TEMPDIR
echo "Removing CVS directories..."
recursiveRmdir "^CVS$" "$TEMPDIR"
echo "Removing emacs backup files (*~)..."
recursiveRmdir ".*~$" "$TEMPDIR"
echo "Removing emacs temporary files (#*#)..."
recursiveRmdir "^#.*#$" "$TEMPDIR"
echo "Removing Thumbs.db files..."
recursiveRmdir "^Thumbs\.db$" "$TEMPDIR"
echo "Removing .DS_Store files..."
recursiveRmdir "^\.DS_Store$" "$TEMPDIR"
echo "Removing .cvsignore files..."
recursiveRmdir "^\.cvsignore$" "$TEMPDIR"
echo "Setting execute permissions for shell scripts..."
chmod a+x $TEMPDIR/*.sh
chmod a+x $TEMPDIR/dist/*.sh
echo "Building zip file..."
cd $TEMPDIR
rm ../releases/current-src.zip
zip -9 -r ../releases/current-src.zip *
cd ..
echo "Done! Zip file generated in releases/current-src.zip"