aboutsummaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/rpm/rpm/perfile_rpmdeps.sh
blob: b72c9f0265b489d6270bf08204bb25d4169c3ed5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash

: ${RPMDEPS:=rpmdeps}

process() {
	while read file_name ; do
		printf "%s\t" ${file_name}
		if [ ! -d $file_name ]; then
			printf "%s " $($RPMDEPS $1 $file_name | sed -e 's,rpmlib(.*,,' -e 's,\([<>\=]\+ \+[^ ]*\),(\1),g')
		fi
		printf "\n"
	done
}

usage() {
	echo "$0 {-P|--provides} {-R|--requires} FILE ..."
}

while [ $# -gt 0 ]; do
   case "$1" in
	--rpmdeps)
		RPMDEPS=$2
		shift
		shift
		;;
	-R|--requires)
		process_type=--requires
		shift
		;;
	-P|--provides)
		process_type=--provides
		shift
		;;
	*)
		break;
		;;
   esac
done

if [ -z "$process_type" ]; then
	usage
	exit 1
fi

if [ $# -gt 0 ]; then
	find "$@" | process $process_type
	exit $?
fi

process $process_type