Convert the check-for-missing files check to a python script

'git ls-files --exclude=<pattern>' was changed (intentionally!)
not to exclude anything files that are actually in the index.
Since git ls-files by default simply lists the files in the
index, this is a problem. Emulating this in shell went past
the limits of what made sense, so move it to a simple external
python script.
This commit is contained in:
Owen W. Taylor 2010-02-22 19:21:42 -05:00
parent 09df6a3818
commit e7066d12cf
2 changed files with 28 additions and 12 deletions

View File

@ -6,7 +6,8 @@ SUBDIRS = data js src tests po man
EXTRA_DIST = \ EXTRA_DIST = \
.project \ .project \
.settings \ .settings \
autogen.sh autogen.sh \
tools/check-for-missing.py
# These are files checked into Git that we don't want to distribute # These are files checked into Git that we don't want to distribute
DIST_EXCLUDE = \ DIST_EXCLUDE = \
@ -17,14 +18,4 @@ DIST_EXCLUDE = \
distcheck-hook: distcheck-hook:
@echo "Checking disted files against files in git" @echo "Checking disted files against files in git"
@failed=false; \ @$(srcdir)/tools/check-for-missing.py $(srcdir) $(distdir) $(DIST_EXCLUDE)
exclude=`(for p in $(DIST_EXCLUDE) ; do echo --exclude=$$p ; done)`; \
for f in `cd $(srcdir) && git ls-files $$exclude` ; do \
if ! test -e $(distdir)/$$f ; then \
echo File missing from distribution: $$f ; \
failed=true ; \
fi \
done ; \
if $$failed ; then \
exit 1 ; \
fi

25
tools/check-for-missing.py Executable file
View File

@ -0,0 +1,25 @@
#!/usr/bin/python
#
# This is a simple script that we use to check for files in git
# and not in the distribution. It was previously written in shell
# and inlined in the Makefile.am, but 'git ls-files --exclude=<pattern>'
# was changed to no longer due anything useful, which made that
# too challenging to be worthwhile.
import fnmatch, os, subprocess, sys
srcdir=sys.argv[1]
distdir=sys.argv[2]
excludes=sys.argv[3:]
os.chdir(srcdir)
status=0
for f in subprocess.Popen(["git", "ls-files"], stdout=subprocess.PIPE).stdout:
f = f.strip()
if (not os.path.exists(os.path.join(distdir, f)) and
not any((fnmatch.fnmatch(f, p) for p in excludes))):
print "File missing from distribution:", f
status=1
sys.exit(status)