summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-10-25 09:45:16 +0200
committerThomas Haller <thaller@redhat.com>2018-10-25 09:49:32 +0200
commita0157f86281d6519a7e3e246e35941c4d5d70cba (patch)
tree02a08c4d441b79d0d1e00a17b03c662f1b500cfb
parenta9f907bfa7233cb77f44c7929f6eb428a9299780 (diff)
parent679fa18e34fddbf7517a101edbb36cab0610e738 (diff)
downloadNetworkManager-a0157f86281d6519a7e3e246e35941c4d5d70cba.tar.gz
build: merge branch 'fix-bashism-in-tools-check-docs-sh'
https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/35 (cherry picked from commit cacd3be1a9dc335b429e21253ef27e2db0ef4e3f)
-rwxr-xr-xtools/check-docs.sh54
1 files changed, 40 insertions, 14 deletions
diff --git a/tools/check-docs.sh b/tools/check-docs.sh
index 9dcdb1ef3b..b7623fed88 100755
--- a/tools/check-docs.sh
+++ b/tools/check-docs.sh
@@ -1,22 +1,48 @@
-#!/bin/sh
+#!/bin/bash
-SOURCEDIR=$1
+set -e
+
+die() {
+ printf '%s\n' "$@" >&2
+ exit 1
+}
+
+word_regex() {
+ tr '\n|<>\\' ' ' \
+ | sed -e 's, *$,\\>,' \
+ -e 's,^ *,\\<,' \
+ -e 's, \+,\\>\\|\\<,g'
+}
+
+same_lines() {
+ diff <(printf "%s\n" "$1" | sed '/^$/d' | sort) \
+ <(printf "%s\n%s\n" "$2" "$3" | sed '/^$/d' | sort) >&2
+}
+
+SOURCEDIR="$1"
[ -n "$SOURCEDIR" ] && SOURCEDIR="$SOURCEDIR/"
# Check that the D-Bus API docs contain all known interfaces
-if (sed -n 's/.*<xi:include href="dbus-\(.*\.xml\)".*/\1\n\1/p' $SOURCEDIR''docs/api/network-manager-docs.xml;
- cd $SOURCEDIR''introspection; ls *.xml) |sort |uniq -u| grep . >&2; then
- echo "*** Error: D-Bus interfaces not included in docs/api/network-manager-docs.xml ***" >&2
- exit 1
+F1="$(sed -n 's,^ <xi:include href="dbus-\([^"]*\.xml\)"/>$,\1,p' "$SOURCEDIR"docs/api/network-manager-docs.xml)"
+F2="$(cd "$SOURCEDIR"introspection; ls -1 *.xml)"
+if ! same_lines "$F1" "$F2" ; then
+ die "*** Error: D-Bus interfaces not included in docs/api/network-manager-docs.xml ***"
fi
# Check that files that define types that are in public libnm API are included in libnm documentation.
-# Don't complain about readability or I'll rewrite this in Perl.
-if (sed -n 's/.*<xi:include href="\(xml\/.*\.xml\)".*/\1\n\1/p' $SOURCEDIR''docs/libnm/libnm-docs.xml;
- grep -lE "$(sed -n 's/^[\t ]*\(.*_get_type\);/\1/p' $SOURCEDIR''libnm/libnm.ver |xargs echo |sed 's/ /|/g')" $SOURCEDIR''libnm{,-core}/*.h |
- sed 's,.*/,xml/,;s/\.h$/.xml/') |sort |uniq -u| grep . >&2; then
- echo "*** Error: libnm classes not included in docs/libnm/libnm-docs.xml ***" >&2
- exit 1
+F1="$(sed -n 's/.*<xi:include href="xml\/\([^"]*\)\.xml".*/\1/p' "$SOURCEDIR"docs/libnm/libnm-docs.xml)"
+F2="$(grep -l "$(sed -n 's/^[\t ]*\(.*_get_type\);/\1/p' "$SOURCEDIR"libnm/libnm.ver | word_regex)" \
+ "$SOURCEDIR"libnm/*.h \
+ "$SOURCEDIR"libnm-core/*.h \
+ | sed 's,.*/\([^/]\+\)\.h$,\1,')"
+F2_EXTRA="
+annotation-glossary
+api-index-full
+nm-dbus-interface
+nm-errors
+nm-utils
+nm-version
+"
+if ! same_lines "$F1" "$F2" "$F2_EXTRA"; then
+ die "*** Error: libnm classes not included in docs/libnm/libnm-docs.xml ***"
fi
-
-exit 0