~cando/gtg/zeitgeist-backend

« back to all changes in this revision

Viewing changes to scripts/tarball_integrity.py

  • Committer: Izidor Matušov
  • Date: 2012-03-17 00:53:39 UTC
  • Revision ID: izidor.matusov@gmail.com-20120317005339-d756csgmfzyexwal
Updated & cleaned scripts for building PPA + build_integrity.py

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
17
 
18
18
import os
 
19
import sys
19
20
import tarfile
20
21
from glob import glob
21
22
 
22
23
tarlist = list()
23
24
dirlist = list()
24
 
exclude_list = ('dist/', 'build/','.bzr', 'test', 'pyc', 'scripts/', 'tmp/', \
25
 
                'pot', 'HACKING', 'MANIFEST', 'Makefile', 'profile.py', '.swp')
 
25
exclude_list = ('dist/', 'build/', '.bzr', 'test', 'pyc', 'scripts/', 'tmp/', \
 
26
                'pot', 'HACKING', 'MANIFEST', 'Makefile', 'profile.py', '.swp')
26
27
 
27
28
for t in glob('dist/*.tar.gz'):
28
29
    tarball = tarfile.open(t, 'r')
29
30
    files = tarball.getnames()
30
31
    tarball.close()
31
32
    for f in [f for f in files if not f.endswith('/')]:
32
 
        # Skip the general directory
33
 
        if '/' not in f:
34
 
            continue
 
33
        # Skip the general directory
 
34
        if '/' not in f:
 
35
            continue
35
36
        tarlist.append(f.split('/', 1)[1])
36
37
 
37
38
for root, dirs, files in os.walk('.'):
38
 
    for f in [f for f in files if not f.endswith('/')]:
39
 
        dirlist.append(os.path.join(root, f).split('/', 1)[1])
40
 
 
41
 
if len(tarlist):
 
39
    for f in files:
 
40
        if f.endswith('/'):
 
41
            continue
 
42
 
 
43
        filename = os.path.join(root, f).split('/', 1)[1]
 
44
 
 
45
        exclude = False
 
46
        for ex in exclude_list:
 
47
            if filename.count(ex):
 
48
                exclude = True
 
49
                break
 
50
        if exclude:
 
51
            continue
 
52
 
 
53
        dirlist.append(filename)
 
54
 
 
55
missing = list(set(dirlist) - set(tarlist))
 
56
if len(missing) > 0:
 
57
    missing.sort()
42
58
    print 'Missing files in tarball:'
43
 
    for f in dirlist:
44
 
        if f and f not in tarlist:
45
 
            for ex in exclude_list:
46
 
                if f and f.count(ex):
47
 
                    f = None
48
 
                    continue
49
 
            if f:
50
 
                print f
 
59
    print '\n'.join("\t%s" % f for f in missing)
 
60
    sys.exit(1)