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