]> git.pld-linux.org Git - packages/rpm.git/blame - rpm-find-spec-bcond
- fixed
[packages/rpm.git] / rpm-find-spec-bcond
CommitLineData
867baf24 1#!/bin/sh
35a6f2f9 2# Display bcond (_with_*, _without_*) macros from given spec
867baf24 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: rpm --bcond SPEC"
14 exit 1
15 fi
16 SPEC=$2
17fi
18
19if [ ! -f $SPEC ]; then
20 echo "rpm: $SPEC: no such file"
21 exit 1
22fi
23
305e70e6 24bconds=`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 {
b30e79c0 31 match($0, /bcond_with(out)?[ \t]+[_a-zA-Z0-9]+/);
bc17cac9 32 bcond = substr($0, RSTART +5 , RLENGTH -5);
b30e79c0 33 gsub(/[ \t]+/,"_",bcond);
bc17cac9
AF
34 print bcond
35 }' $SPEC | sort -u`
867baf24 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 {
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
63done
64
This page took 0.055402 seconds and 4 git commands to generate.