]> git.pld-linux.org Git - packages/rpm.git/blob - rpm-find-spec-bcond
- --bcond popt alias (shows b(uild)cond_* macros from given spec)
[packages/rpm.git] / rpm-find-spec-bcond
1 #!/bin/sh
2 # Display bcond_* macros from given spec 
3 # $Id$
4
5 if [ "$#" = 0 ]; then
6     echo "Usage: $0 SPEC"
7     exit 1
8 fi
9
10 SPEC=$1
11 if [ $SPEC = "--" ]; then
12     if [ "$#" -lt 2 ]; then
13         echo "Usage: rpm --bcond SPEC"
14         exit 1
15     fi
16     SPEC=$2
17 fi
18
19 if [ ! -f $SPEC ]; then
20     echo "rpm: $SPEC: no such file"
21     exit 1
22 fi
23
24 bconds=`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
29 for 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
37 done
38
39
40 for 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
55 done
56          
This page took 0.032794 seconds and 4 git commands to generate.