1#!/bin/sh
2
3if [ $# = 1 ]; then
4    cd $1
5fi
6
7# Create a list of all the files in the source tree, excluding various things we
8# know don't belong.
9echo "Creating current directory contents list."
10find . | \
11    grep -v '^\./.gitignore' | \
12    grep -v '^\./dist' | \
13    grep -v '^\./utils' | \
14    grep -v '^\./venv' | \
15    grep -v '^\./notes.txt' | \
16    grep -v '^\./lit.egg-info' | \
17    grep -v '^\./lit/ExampleTests' | \
18    grep -v '/Output' | \
19    grep -v '__pycache__' | \
20    grep -v '.pyc$' | grep -v '~$' | \
21    sort > /tmp/lit_source_files.txt
22
23# Create the source distribution.
24echo "Creating source distribution."
25rm -rf lit.egg-info dist
26python setup.py sdist > /tmp/lit_sdist_log.txt
27
28# Creating list of files in source distribution.
29echo "Creating source distribution file list."
30tar zft dist/lit*.tar.gz | \
31    sed -e 's#lit-[0-9.dev]*/#./#' | \
32    sed -e 's#/$##' | \
33    grep -v '^\./PKG-INFO' | \
34    grep -v '^\./setup.cfg' | \
35    grep -v '^\./lit.egg-info' | \
36    sort > /tmp/lit_sdist_files.txt
37
38# Diff the files.
39echo "Running diff..."
40if (diff /tmp/lit_source_files.txt /tmp/lit_sdist_files.txt); then
41    echo "Diff is clean!"
42else
43    echo "error: there were differences in the source lists!"
44    exit 1
45fi
46