2 # Display bcond (_with_*, _without_*) macros from given spec
3 # $Id: rpm-find-spec-bcond,v 1.10 2008/02/23 17:33:34 glen Exp $
11 if [ $SPEC = "--" ]; then
12 if [ "$#" -lt 2 ]; then
13 echo "Usage: rpmbuikd --bcond SPEC"
19 if [ ! -f $SPEC ]; then
20 echo "rpmbuild: $SPEC: no such file"
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)
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);
40 if ! echo `rpm --eval "%$c"` | grep $c >/dev/null; then
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 ]*$/)) {
53 } else if (match(\\$0, /$bcond[\t ]+1[\t ]*$/)) {
56 print \"couldn't determine $bcond value from \", \\$0
58 } END { print val }" $SPEC`;
60 if [ x"$isset" = x"1" ]; then
61 echo "WARN: $bcond defined in spec";