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:/usr/X11R6/bin"
12 classver=$(file "$@" | grep -o 'compiled Java class data, version [0-9.]*' | awk '{print $NF}' | sort -u)
13 [ "$classver" ] || return
14 for v in $classver; do
15 echo "java(ClassDataVersion) >= $v"
22 # check only files, symlinks could point outside buildroot
23 [ -f "$jar" -a ! -L "$jar" ] || return
26 unzip -q -d $tmp $jar >&2
27 javaclassversion $(find $tmp -type f -name '*.class')
34 for file in $FILES; do
37 javajarversion "$file"
38 unzip -p $file | javadeps --requires --rpmformat --keywords -
41 javaclassversion "$file"
42 javadeps --requires --rpmformat --keywords $file
49 for file in $FILES; do
52 unzip -p $file | javadeps --provides --rpmformat --keywords --starprov -
55 javadeps --provides --rpmformat --keywords --starprov $file
61 # This is a little magic trick to get all REQUIRES that are not
62 # in PROVIDES. While RPM functions correctly when such deps exist,
63 # they make the metadata a bit bloated.
65 # Filter out dups from both lists
66 REQUIRES=$(echo "$REQUIRES" | sort | uniq)
67 PROVIDES=$(echo "$PROVIDES" | sort | uniq)
70 # Get a list of elements that exist in exactly one of PROVIDES or REQUIRES
72 UNIQ=$(echo "$PROVIDES
73 $REQUIRES" | sort | uniq -u)
76 # Of those, only choose the ones that are in REQUIRES
79 $REQUIRES" | sort | uniq -d