]> git.pld-linux.org Git - packages/rpm.git/blame - rpm-find-spec-bcond
- rebuild with latest rpm.macros
[packages/rpm.git] / rpm-find-spec-bcond
CommitLineData
867baf24 1#!/bin/sh
2# Display bcond_* 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: 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 }
26 /bcond_[_a-z0-9]+/ && chlog == 0 {
27 match($0, /bcond_[_a-z0-9]+/);
28 print substr($0, RSTART, RLENGTH)
29 }' $SPEC | sort -u`
867baf24 30
31for c in $bconds; do
32 echo -n "$c"
33
34 if ! echo `rpm --eval "%$c"` | grep $c >/dev/null; then
35 echo " (on)"
36 else
37 echo ""
38 fi
39done
40
41
42for bcond in $bconds; do
43 isset=`awk -F"\n" "BEGIN { val=0 }
44 /^%define[\t ]+$bcond/ {
45 if (match(\\$0, /$bcond[\t ]+0[\t ]*$/)) {
46 val = 0
47 } else if (match(\\$0, /$bcond[\t ]+1[\t ]*$/)) {
48 val = 1
49 } else {
305e70e6 50 print \"couldn't determine $bcond value from \", \\$0
867baf24 51 }
52 } END { print val }" $SPEC`;
53
54 if [ $isset -eq 1 ]; then
55 echo "WARN: $bcond defined in spec";
56 fi
57done
58
This page took 0.033807 seconds and 4 git commands to generate.