validate_map.sh revision 292588
1#!/bin/sh
2
3###############################################################################
4#
5# Check liblzma.map for certain types of errors
6#
7# Author: Lasse Collin
8#
9# This file has been put into the public domain.
10# You can do whatever you want with this file.
11#
12###############################################################################
13
14LC_ALL=C
15export LC_ALL
16
17STATUS=0
18
19cd "$(dirname "$0")"
20
21# Get the list of symbols that aren't defined in liblzma.map.
22SYMS=$(sed -n 's/^extern LZMA_API([^)]*) \([a-z0-9_]*\)(.*$/\1;/p' \
23		api/lzma/*.h \
24	| sort \
25	| grep -Fve "$(sed '/[{}:*]/d;/^$/d;s/^	//' liblzma.map)")
26
27# Check that there are no old alpha or beta versions listed.
28VER=$(cd ../.. && sh build-aux/version.sh)
29NAMES=
30case $VER in
31	*alpha | *beta)
32		NAMES=$(sed -n 's/^.*XZ_\([^ ]*\)\(alpha\|beta\) .*$/\1\2/p' \
33			liblzma.map | grep -Fv "$VER")
34		;;
35esac
36
37# Check for duplicate lines. It can catch missing dependencies.
38DUPS=$(sort liblzma.map | sed '/^$/d;/^global:$/d' | uniq -d)
39
40# Print error messages if needed.
41if test -n "$SYMS$NAMES$DUPS"; then
42	echo
43	echo 'validate_map.sh found problems from liblzma.map:'
44	echo
45
46	if test -n "$SYMS"; then
47		echo 'liblzma.map lacks the following symbols:'
48		echo "$SYMS"
49		echo
50	fi
51
52	if test -n "$NAMES"; then
53		echo 'Obsolete alpha or beta version names:'
54		echo "$NAMES"
55		echo
56	fi
57
58	if test -n "$DUPS"; then
59		echo 'Duplicate lines:'
60		echo "$DUPS"
61		echo
62	fi
63
64	STATUS=1
65fi
66
67# Exit status is 1 if problems were found, 0 otherwise.
68exit "$STATUS"
69