2 # This script reads filenames from STDIN and outputs any relevant requires
3 # information that needs to be included in the package.
5 # Based on rpm-4.4.2/scripts/find-req.pl
6 # Authors: Elan Ruusamäe <glen@pld-linux.org>
8 export PATH="/sbin:/usr/sbin:/bin:/usr/bin"
10 # Set the prefix, unless it is overriden
11 : ${RPM_LIBDIR=/usr/lib/rpm}
13 # Enable debug: JAVADEPS_DEBUG=true
14 : ${JAVADEPS_DEBUG=false}
16 # xsltproc for eclipse feature.xml
17 : ${xsltproc=/usr/bin/xsltproc}
19 # save $- state, to enable in functions
25 [ $# -gt 0 ] || return 1
26 $JAVADEPS_DEBUG && echo >&2 ">> javaclassversion($mode): $*"
28 # process only requires
29 [ "$mode" = requires ] || return $ret
31 local classver=$(echo "$@" | xargs -r file | grep -o 'compiled Java class data, version [0-9.]*' | awk '{print $NF}' | sort -u)
32 if [ -z "$classver" ]; then
37 for v in $classver; do
38 echo "java(ClassDataVersion) >= $v"
48 $JAVADEPS_DEBUG && echo >&2 ">> javajarversion($mode): $jar"
50 # check only files, symlinks could point outside buildroot
51 [ -f "$jar" -a ! -L "$jar" ] || return $ret
54 unzip -q -d $tmp $jar >&2
55 # workaround for .jar files with stupid permissions
58 # find .jar and .class files
59 find_javadeps $mode $(find $tmp -type f -regextype posix-extended -regex '^.+\.(class|jar)$') || ret=1
70 $JAVADEPS_DEBUG && echo >&2 ">> eclipse_feature($mode): $file"
72 if [ ! -x $xsltproc ]; then
76 $xsltproc --stringparam mode $mode ${RPM_LIBDIR}/eclipse-feature.xslt $file
84 $JAVADEPS_DEBUG && echo >&2 ">> find_javadeps($mode): $*"
88 javajarversion $mode "$file" || ret=1
91 javaclassversion $mode "$file" || {
92 echo >&2 "ERROR: Class version could not be extracted from $file"
97 eclipse_feature $mode "$file" || ret=1
100 $JAVADEPS_DEBUG && echo >&2 ">> find_javadeps($mode): no handle: $file"
108 # default mode to requires for backward compat
122 find_javadeps $mode $(cat -) > $t || ret=1