[Xcb] [PATCH 1/2] Validate .pc file Requires lines

Keith Packard keithp at keithp.com
Wed Feb 12 12:14:00 PST 2014


This walks through the .pc.in files and makes sure all of the Requires
lines express sufficient dependency information.

Signed-off-by: Keith Packard <keithp at keithp.com>
---
 Makefile.am       |  5 ++++-
 check-pc-requires | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 64 insertions(+), 1 deletion(-)
 create mode 100755 check-pc-requires

diff --git a/Makefile.am b/Makefile.am
index 387c2f2..29ef372 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -86,8 +86,11 @@ pkgconfig_DATA += xcb-xvmc.pc
 endif
 
 
+TESTS=check-pc-requires
+
 EXTRA_DIST = \
 tools/README \
 tools/api_conv.pl \
 tools/constants \
-autogen.sh
+autogen.sh \
+$(TESTS)
diff --git a/check-pc-requires b/check-pc-requires
new file mode 100755
index 0000000..68750b6
--- /dev/null
+++ b/check-pc-requires
@@ -0,0 +1,60 @@
+#!/bin/sh
+fix=n
+status=0
+case "$1" in
+"-fix")
+	fix=y
+	;;
+esac
+
+for inc in src/*.h; do
+	package=xcb-`basename $inc .h`
+	pcin=$package.pc.in
+	if [ -f $pcin ]; then
+		included=`grep '# *include' $inc |
+			sed -e 's/[^<"]*[<"]//' -e 's/[>"]//' |
+			grep -v 'xcb.h\|xproto.h'`
+		requires=`grep '^Requires:' $pcin`
+		missing=""
+		for i in $included; do
+			ibase=`basename $i .h`
+			r="xcb-$ibase"
+			if [ -f $r.pc.in ]; then
+				m="$r"
+				for has in $requires; do
+					if [ $has = $r ]; then
+						m=""
+					fi
+				done
+				case "$m" in
+				"")
+					;;
+				*)
+					case "$missing" in
+					"")
+						missing=$m
+						;;
+					*)
+						missing="$missing $m"
+						;;
+					esac
+					;;
+				esac
+			fi
+		done
+		case "$missing" in
+		"")
+			;;
+		*)
+			if [ "$fix" = "y" ]; then
+			    echo $package adding dependency on $missing
+			    sed -i '/^Requires:/s/$/ '"$missing"'/' $pcin
+			else
+			    echo $package missing $missing
+			    status=1
+			fi
+			;;
+		esac
+	fi
+done
+exit $status
-- 
1.9.rc1



More information about the Xcb mailing list