]> git.pld-linux.org Git - packages/rpm.git/blob - find-java-req.sh
- scan also .class files
[packages/rpm.git] / find-java-req.sh
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
5 export PATH="/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin"
6
7 IGNORE_DEPS="@"
8 BUILDROOT="/"
9
10 # Loop over all args
11 while :; 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
48 done
49
50 javaclassversion() {
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
59 javajarversion() {
60         local jar="$1"
61
62         # check only files, symlinks could point outside buildroot
63         [ -f "$jar" -a ! -L "$jar" ] || return
64
65         tmp=$(mktemp -d)
66         unzip -q -d $tmp $jar >&2
67         javaclassversion $(find $tmp -type f -name '*.class')
68         rm -rf $tmp
69 }
70
71 for file in $(cat -); do
72         case $file in
73         *.jar)
74                 javajarversion "$file"
75                 unzip -p $file | javadeps --requires --rpmformat --keywords -
76         ;;
77         *.class)
78                 javaclassversion "$file"
79                 javadeps --requires --rpmformat --keywords $file
80         ;;
81         esac
82 done | sort -u | egrep -v \'$IGNORE_DEPS\'
This page took 0.054026 seconds and 4 git commands to generate.