-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslim_classes.sh
92 lines (79 loc) · 2 KB
/
slim_classes.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
#!/bin/bash
# run the client with -verbose:class like this:
# (with the server running, of course)
#
# cp classes/Envelope.java .
# java -verbose:class -cp . Envelope > loaded.txt
#
# then click around and cause classes to get loaded.
# that will print all the classes loaded to loaded.txt.
# then, run this file from the same directory as build.xml.
listfile=classes.txt
dir=slim_class_dir
outjar=slim-client
# parse the loaded text file to get a list of class files
grep http:// loaded.txt \
| egrep -v net.lump.envelope.client.Main\|net.lump.envelope.client.ui.defs.Strings\|net.lump.client.ui.MainFrame \
| perl -lne '/.*?\s(.*?)\s+.*$/;$a=$1;$a=~s/\./\//g; print $a' > $listfile
rm -rf $dir
mkdir $dir
cd $dir
# get the bootstrap envelope class
cp ../classes/Envelope.class .
# step through list, copying or extracting class files
for i in `cat ../classes.txt` ; do
found=0
if [[ -e ../classes/$i.class ]] ; then
found=1
cwd=`pwd`
cd ../classes
tar -cf - $i.class | tar -xv -C $cwd -f -
cd $cwd
else
for j in ../lib/*.jar ; do
echo trying $j
unzip $j $i.class 2>/dev/null 1>/dev/null
if [[ $? == 0 ]] ; then
found=1
echo "found $i in $j"
break
fi
done
fi
if [[ $found == 0 ]] ; then
echo "couldn't find $i"
break
fi
done
set -o errexit
# compress the classes into jar
rm -f ../lib/$outjar-*
jar cvf ../lib/$outjar-unsigned.jar *
cd ..
$JAVA_HOME/bin/pack200 \
--repack \
--strip-debug \
--no-keep-file-order \
--effort=5 \
--deflate-hint=true \
--modification-time=latest \
--verbose \
lib/$outjar-repacked.jar \
lib/$outjar-unsigned.jar
jarsigner \
-keystore security/keystore \
-storepass OS.32sf \
-verbose \
lib/$outjar-repacked.jar \
envelope
mv lib/$outjar-repacked.jar lib/$outjar.jar
$JAVA_HOME/bin/pack200 \
--gzip \
--strip-debug \
--no-keep-file-order \
--effort=5 \
--deflate-hint=true \
--modification-time=latest \
--verbose \
lib/$outjar.jar.pack.gz \
lib/$outjar.jar