]> git.pld-linux.org Git - packages/rpm.git/blob - find-java-req.sh
- Th version, based on find-java-req.sh:AC-branch
[packages/rpm.git] / find-java-req.sh
1 #!/bin/sh
2 # This script reads filenames from STDIN and outputs any relevant requires
3 # information that needs to be included in the package.
4 #
5 # Based on rpm-4.4.2/scripts/find-req.pl
6 # Authors: Elan Ruusam√§e <glen@pld-linux.org>
7
8 export PATH="/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin"
9
10 javaclassversion() {
11         [ $# -gt 0 ] || return
12
13         local ver
14         classver=$(echo "$@" | xargs -r file | grep -o 'compiled Java class data, version [0-9.]*' | awk '{print $NF}' | sort -u)
15         [ "$classver" ] || return
16         for v in $classver; do
17                 echo "java(ClassDataVersion) >= $v"
18         done
19 }
20
21 javajarversion() {
22         local jar="$1"
23
24         # check only files, symlinks could point outside buildroot
25         [ -f "$jar" -a ! -L "$jar" ] || return
26
27 #       echo >&2 "find java requires: ${jar#$RPM_BUILD_ROOT}"
28
29         tmp=$(mktemp -d)
30         unzip -q -d $tmp $jar >&2
31         javaclassversion $(find $tmp -type f -name '*.class')
32         rm -rf $tmp
33 }
34
35 FILES=$(cat -)
36
37 find_requires() {
38         for file in $FILES; do
39                 case $file in
40                 *.jar)
41                         javajarversion "$file"
42                 ;;
43                 *.class)
44                         javaclassversion "$file"
45                 ;;
46                 esac
47         done
48 }
49
50 find_requires | sort -u
This page took 0.071235 seconds and 3 git commands to generate.