]> git.pld-linux.org Git - packages/rpm-build-macros.git/blame - rpm-find-spec-bcond
- move more scripts from main rpm package
[packages/rpm-build-macros.git] / rpm-find-spec-bcond
CommitLineData
d5b72096
JR
1#!/bin/sh
2# Display bcond (_with_*, _without_*) 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: rpmbuild --bcond SPEC"
14 exit 1
15 fi
16 SPEC=$2
17fi
18
19if [ ! -f $SPEC ]; then
20 echo "rpmbuild: $SPEC: no such file"
21 exit 1
22fi
23
24bconds=`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
37for 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
45done
46
47
48for 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
63done
64
This page took 0.04959 seconds and 4 git commands to generate.