]>
Commit | Line | Data |
---|---|---|
867baf24 | 1 | #!/bin/sh |
35a6f2f9 | 2 | # Display bcond (_with_*, _without_*) macros from given spec |
867baf24 | 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 | ||
305e70e6 | 24 | bconds=`awk -F"\n" 'BEGIN { chlog=0 } |
25 | /^%changelog/ { chlog=1 } | |
f481ae19 JB |
26 | /_with(out)?_[_a-zA-Z0-9]+/ && chlog == 0 { |
27 | match($0, /_with(out)?_[_a-zA-Z0-9]+/); | |
305e70e6 | 28 | print substr($0, RSTART, RLENGTH) |
bc17cac9 AF |
29 | } |
30 | /^%bcond_with/ && chlog == 0 { | |
f481ae19 | 31 | match($0, /bcond_with(out)?[ ]+[_a-zA-Z0-9]+/); |
bc17cac9 AF |
32 | bcond = substr($0, RSTART +5 , RLENGTH -5); |
33 | gsub(/ /,"_",bcond); | |
34 | print bcond | |
35 | }' $SPEC | sort -u` | |
867baf24 | 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 { | |
305e70e6 | 56 | print \"couldn't determine $bcond value from \", \\$0 |
867baf24 | 57 | } |
58 | } END { print val }" $SPEC`; | |
59 | ||
2a129ee0 | 60 | if [ x"$isset" = x"1" ]; then |
867baf24 | 61 | echo "WARN: $bcond defined in spec"; |
62 | fi | |
63 | done | |
64 |