1#!/bin/sh
2set -o xtrace   # Write all commands first to stderr
3set -o errexit  # Exit the script with error if any of the commands fail
4
5# Check that a CLion user didn't accidentally convert NEWS from UTF-8 to ASCII
6news_type=`file NEWS`
7echo "NEWS file type is $news_type"
8case "$news_type" in
9  *ASCII*) exit 1 ;;
10esac
11
12# Use modern sphinx-build from venv.
13. venv/bin/activate
14which sphinx-build
15sphinx-build --version
16
17./autogen.sh --enable-html-docs --enable-man-pages --with-snappy=bundled --with-zlib=bundled --with-libbson=bundled
18make distcheck
19
20# Check that docs were included, but sphinx temp files weren't.
21tarfile=mongo-c-driver-*.tar.gz
22docs='mongo-c-driver-*/doc/html/index.html mongo-c-driver-*/doc/man/mongoc_client_t.3'
23tmpfiles='mongo-c-driver-*/doc/html/.doctrees \
24   mongo-c-driver-*/doc/html/.buildinfo \
25   mongo-c-driver-*/doc/man/.doctrees \
26   mongo-c-driver-*/doc/man/.buildinfo'
27
28echo "Checking for built docs"
29for doc in $docs; do
30   # Check this doc is in the archive.
31   tar --wildcards -tzf $tarfile $doc
32done
33
34echo "Checking that temp files are not included in tarball"
35for tmpfile in $tmpfiles; do
36   # Check this temp file doesn't exist.
37   if tar --wildcards -tzf $tarfile $tmpfile > /dev/null 2>&1; then
38      echo "Found temp file in archive: $tmpfile"
39      exit 1
40   fi
41done
42
43echo "Checking that index.3 wasn't built"
44if tar --wildcards -tzf $tarfile 'mongo-c-driver-*/doc/man/index.3' > /dev/null 2>&1; then
45   echo "Found index.3 in archive"
46   exit 1
47fi
48
49echo "Checking that all C files are included in tarball"
50# Check that all C files were included.
51TAR_CFILES=`tar --wildcards -tf mongo-c-driver-*.tar.gz 'mongo-c-driver-*/src/mongoc/*.c' | cut -d / -f 4 | sort`
52SRC_CFILES=`echo src/mongoc/*.c | xargs -n 1 | cut -d / -f 3 | sort`
53if [ "$TAR_CFILES" != "$SRC_CFILES" ]; then
54   echo "Not all C files are in the release archive"
55   echo $TAR_CFILES > tar_cfiles.txt
56   echo $SRC_CFILES | diff -y - tar_cfiles.txt
57fi
58
59