-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathjava.req.sh
More file actions
67 lines (60 loc) · 1.16 KB
/
java.req.sh
File metadata and controls
67 lines (60 loc) · 1.16 KB
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
#!/bin/sh -e
JCFDUMP=${1:-jcf-dump}
JAR=${2:-jar}
dump=`mktemp ${TMPDIR:-/tmp}/classdepXXXXXX`
if test -z "$dump"; then
echo Error creating temporary file.
exit 1
fi
classdir=`mktemp -d ${TMPDIR:-/tmp}/classdepXXXXXX`
if test -z "$classdir"; then
echo Error creating temporary directory.
rm -f $dump
exit 1
fi
cleanup() {
rm -f $dump
rm -fr $classdir
}
trap cleanup EXIT
scandeps()
{
$JCFDUMP -c -v "$1" > $dump 2> /dev/null
awk '
/InterfaceMethodref class:/ {
gsub("^[0123456789]+=", "", $4);
print "java(" $4 ")"
}
/Methodref class:/ {
gsub("^[0123456789]+=", "", $4);
print "java(" $4 ")"
}
/InterfaceFieldref class:/ {
gsub("^[0123456789]+=", "", $4);
print "java(" $4 ")"
}
/Fieldref class:/ {
gsub("^[0123456789]+=", "", $4);
print "java(" $4 ")"
}
' $dump
}
while read filename ; do
case "$filename" in
*.class)
scandeps "$filename"
;;
*.jar)
if ! $JAR tf "$filename" | grep -q -e '(^..|^/|^\\)' ; then
PUSHDIR=`pwd`
cd $classdir > /dev/null
$JAR xf "$filename"
cd $PUSHDIR > /dev/null
$JAR tf "$filename" | sed "s|^|$classdir/|g" | $0 "$@"
rm -fr $classdir/*
fi
;;
*)
;;
esac
done