]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - contrib/xz/src/liblzma/validate_map.sh
MFC: xz 5.2.2.
[FreeBSD/stable/10.git] / contrib / xz / src / liblzma / validate_map.sh
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
14 LC_ALL=C
15 export LC_ALL
16
17 STATUS=0
18
19 cd "$(dirname "$0")"
20
21 # Get the list of symbols that aren't defined in liblzma.map.
22 SYMS=$(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.
28 VER=$(cd ../.. && sh build-aux/version.sh)
29 NAMES=
30 case $VER in
31         *alpha | *beta)
32                 NAMES=$(sed -n 's/^.*XZ_\([^ ]*\)\(alpha\|beta\) .*$/\1\2/p' \
33                         liblzma.map | grep -Fv "$VER")
34                 ;;
35 esac
36
37 # Check for duplicate lines. It can catch missing dependencies.
38 DUPS=$(sort liblzma.map | sed '/^$/d;/^global:$/d' | uniq -d)
39
40 # Print error messages if needed.
41 if 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
65 fi
66
67 # Exit status is 1 if problems were found, 0 otherwise.
68 exit "$STATUS"