]> git.pld-linux.org Git - packages/rpm.git/blame - find-java-req.sh
- workaround for huge filelist
[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
95593bd3 27 tmp=$(mktemp -d)
b99bbf2b
ER
28 unzip -q -d $tmp $jar >&2
29 javaclassversion $(find $tmp -type f -name '*.class')
95593bd3 30 rm -rf $tmp
95593bd3
ER
31}
32
facae03a
ER
33FILES=$(cat -)
34
94b6a080 35find_requires() {
facae03a
ER
36 for file in $FILES; do
37 case $file in
38 *.jar)
39 javajarversion "$file"
40 unzip -p $file | javadeps --requires --rpmformat --keywords -
41 ;;
42 *.class)
43 javaclassversion "$file"
44 javadeps --requires --rpmformat --keywords $file
45 ;;
46 esac
47 done | sort -u
94b6a080 48}
facae03a 49
94b6a080 50find_provides() {
facae03a
ER
51 for file in $FILES; do
52 case $file in
53 *.jar)
54 unzip -p $file | javadeps --provides --rpmformat --keywords --starprov -
55 ;;
56 *.class)
57 javadeps --provides --rpmformat --keywords --starprov $file
58 ;;
59 esac
60 done | sort -u
94b6a080
ER
61}
62
63REQUIRES=$(find_requires)
64PROVIDES=$(find_provides)
facae03a
ER
65
66# This is a little magic trick to get all REQUIRES that are not
67# in PROVIDES. While RPM functions correctly when such deps exist,
68# they make the metadata a bit bloated.
69
70# Filter out dups from both lists
71REQUIRES=$(echo "$REQUIRES" | sort | uniq)
72PROVIDES=$(echo "$PROVIDES" | sort | uniq)
73
74#
75# Get a list of elements that exist in exactly one of PROVIDES or REQUIRES
76#
77UNIQ=$(echo "$PROVIDES
78$REQUIRES" | sort | uniq -u)
79
80#
81# Of those, only choose the ones that are in REQUIRES
82#
83echo "$UNIQ
84$REQUIRES" | sort | uniq -d
This page took 0.099781 seconds and 4 git commands to generate.