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