]> git.pld-linux.org Git - packages/rpm.git/blob - rpm-find-spec-bcond
- typo
[packages/rpm.git] / rpm-find-spec-bcond
1 #!/bin/sh
2 # Display bcond (_with_*, _without_*) 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: rpmbuild --bcond SPEC"
14         exit 1
15     fi
16     SPEC=$2
17 fi
18
19 if [ ! -f $SPEC ]; then
20     echo "rpmbuild: $SPEC: no such file"
21     exit 1
22 fi
23
24 bconds=`awk -F"\n" 'BEGIN { chlog=0 }
25                 /^%changelog/ { chlog=1 }
26                 /_with(out)?_[_a-zA-Z0-9]+/ && chlog == 0 {
27                         match($0, /_with(out)?_[_a-zA-Z0-9]+/);
28                         print substr($0, RSTART, RLENGTH)                       
29                 }
30                 /^%bcond_with/ && chlog == 0 {
31                         match($0, /bcond_with(out)?[ \t]+[_a-zA-Z0-9]+/);
32                                  bcond = substr($0, RSTART +5 , RLENGTH -5);
33                                  gsub(/[ \t]+/,"_",bcond);
34                                  print bcond
35                         }' $SPEC | sort -u`
36
37 for c in $bconds; do
38     echo -n "$c"
39
40     if ! echo `rpm --eval "%$c"` | grep $c >/dev/null; then
41         echo " (on)"
42     else 
43         echo ""
44     fi
45 done
46
47
48 for bcond in $bconds; do
49     isset=`awk -F"\n" "BEGIN { val=0 }
50                    /^%define[\t ]+$bcond/ {
51                      if (match(\\$0, /$bcond[\t ]+0[\t ]*$/)) {
52                         val = 0
53                      } else if (match(\\$0, /$bcond[\t ]+1[\t ]*$/)) {
54                         val = 1
55                      } else {
56                         print \"couldn't determine $bcond value from \", \\$0
57                      }
58                   } END { print val }" $SPEC`;
59
60     if [ x"$isset" = x"1" ]; then
61         echo "WARN: $bcond defined in spec";
62     fi
63 done
64          
This page took 0.062627 seconds and 3 git commands to generate.