]> git.pld-linux.org Git - packages/rpm.git/blob - find-java-req.sh
- skip symlinks and inexistent 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 PATH=${PATH}:$(dirname $0)
7
8 javadeps_args='--requires --rpmformat --keywords'
9
10 IGNORE_DEPS="@"
11 BUILDROOT="/"
12
13 # Loop over all args
14 while :; do
15 # Break out if there are no more args
16         case $# in
17         0)
18                 break
19                 ;;
20         esac
21
22 # Get the first arg, and shuffle
23         option=$1
24         shift
25
26 # Make all options have two hyphens
27         orig_option=$option     # Save original for error messages
28         case $option in
29         --*) ;;
30         -*) option=-$option ;;
31         esac
32
33         case $option in
34         --buildroot)
35                 BUILDROOT=$1
36                 shift
37                 ;;
38         --ignore_deps)
39                 IGNORE_DEPS=$1
40                 shift
41                 ;;
42         --help)
43                 echo $usage
44                 exit 0
45                 ;;
46         *)
47                 echo "$0: Unrecognized option: \"$orig_option\"; use --help for usage." >&2
48                 exit 1
49                 ;;
50         esac
51 done
52
53 javaclassversion() {
54         local file="$1"
55
56         # check only files, symlinks could point outside buildroot
57         [ ! -f "$file" -o -L "$file" ] || return
58
59         tmp=$(mktemp -d)
60         unzip -q -d $tmp $file >&2
61         classver=$(find $tmp -type f -name '*.class' | xargs -r -d'\n' file | grep -o 'compiled Java class data, version [0-9.]*' | awk '{print $NF}' | sort -u)
62         rm -rf $tmp
63         [ "$classver" ] || return
64         for v in $classver; do
65                 echo "java(ClassDataVersion) >= $v"
66         done
67 }
68
69 for file in $(cat -); do
70         case $file in
71         *.jar)
72                 javaclassversion "$file"
73         ;;
74         esac
75 done | sort -u | egrep -v \'$IGNORE_DEPS\'
This page took 0.051449 seconds and 4 git commands to generate.