]> git.pld-linux.org Git - packages/rpm.git/blame - find-java-req.sh
- scan also .class files
[packages/rpm.git] / find-java-req.sh
CommitLineData
95593bd3
ER
1#!/bin/sh
2# This script reads filenames from STDIN and outputs any relevant provides
3# information that needs to be included in the package.
4
5export PATH="/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin"
95593bd3
ER
6
7IGNORE_DEPS="@"
4e1562b5 8BUILDROOT="/"
95593bd3
ER
9
10# Loop over all args
11while :; do
12# Break out if there are no more args
13 case $# in
14 0)
15 break
16 ;;
17 esac
18
19# Get the first arg, and shuffle
20 option=$1
21 shift
22
23# Make all options have two hyphens
24 orig_option=$option # Save original for error messages
25 case $option in
26 --*) ;;
27 -*) option=-$option ;;
28 esac
29
30 case $option in
31 --buildroot)
32 BUILDROOT=$1
33 shift
34 ;;
35 --ignore_deps)
36 IGNORE_DEPS=$1
37 shift
38 ;;
39 --help)
40 echo $usage
41 exit 0
42 ;;
43 *)
44 echo "$0: Unrecognized option: \"$orig_option\"; use --help for usage." >&2
45 exit 1
46 ;;
47 esac
48done
49
50javaclassversion() {
b99bbf2b
ER
51 local ver
52 classver=$(file "$@" | grep -o 'compiled Java class data, version [0-9.]*' | awk '{print $NF}' | sort -u)
53 [ "$classver" ] || return
54 for v in $classver; do
55 echo "java(ClassDataVersion) >= $v"
56 done
57}
58
59javajarversion() {
60 local jar="$1"
95593bd3 61
4e1562b5 62 # check only files, symlinks could point outside buildroot
b99bbf2b 63 [ -f "$jar" -a ! -L "$jar" ] || return
4e1562b5 64
95593bd3 65 tmp=$(mktemp -d)
b99bbf2b
ER
66 unzip -q -d $tmp $jar >&2
67 javaclassversion $(find $tmp -type f -name '*.class')
95593bd3 68 rm -rf $tmp
95593bd3
ER
69}
70
71for file in $(cat -); do
4e1562b5 72 case $file in
95593bd3 73 *.jar)
b99bbf2b
ER
74 javajarversion "$file"
75 unzip -p $file | javadeps --requires --rpmformat --keywords -
76 ;;
77 *.class)
4e1562b5 78 javaclassversion "$file"
b99bbf2b 79 javadeps --requires --rpmformat --keywords $file
95593bd3
ER
80 ;;
81 esac
82done | sort -u | egrep -v \'$IGNORE_DEPS\'
This page took 0.03902 seconds and 4 git commands to generate.