]> git.pld-linux.org Git - packages/rpm.git/blame - rpm-find-spec-bcond
- --bcond popt alias (shows b(uild)cond_* macros from given spec)
[packages/rpm.git] / rpm-find-spec-bcond
CommitLineData
867baf24 1#!/bin/sh
2# Display bcond_* macros from given spec
3# $Id$
4
5if [ "$#" = 0 ]; then
6 echo "Usage: $0 SPEC"
7 exit 1
8fi
9
10SPEC=$1
11if [ $SPEC = "--" ]; then
12 if [ "$#" -lt 2 ]; then
13 echo "Usage: rpm --bcond SPEC"
14 exit 1
15 fi
16 SPEC=$2
17fi
18
19if [ ! -f $SPEC ]; then
20 echo "rpm: $SPEC: no such file"
21 exit 1
22fi
23
24bconds=`awk -F"\n" '/bcond_[_a-z0-9]+/ {
25 match($0, /bcond_[_a-z0-9]+/);
26 print substr($0, RSTART, RLENGTH)
27 }' $SPEC | sort -u`
28
29for c in $bconds; do
30 echo -n "$c"
31
32 if ! echo `rpm --eval "%$c"` | grep $c >/dev/null; then
33 echo " (on)"
34 else
35 echo ""
36 fi
37done
38
39
40for bcond in $bconds; do
41 isset=`awk -F"\n" "BEGIN { val=0 }
42 /^%define[\t ]+$bcond/ {
43 if (match(\\$0, /$bcond[\t ]+0[\t ]*$/)) {
44 val = 0
45 } else if (match(\\$0, /$bcond[\t ]+1[\t ]*$/)) {
46 val = 1
47 } else {
48 print \"could determine $bcond value from \", \\$0
49 }
50 } END { print val }" $SPEC`;
51
52 if [ $isset -eq 1 ]; then
53 echo "WARN: $bcond defined in spec";
54 fi
55done
56
This page took 0.035488 seconds and 4 git commands to generate.