-
Notifications
You must be signed in to change notification settings - Fork 0
/
MakeTarBall.py
executable file
·118 lines (102 loc) · 3.7 KB
/
MakeTarBall.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2006-2008 Stas Zykiewicz <[email protected]>
#
# MakeTarBall.py
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 3 of the GNU General Public License
# as published by the Free Software Foundation. A copy of this license should
# be included in the file GPL-3.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Library General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# make tarball!
import glob
from SPVersion import version
import os,sys
ans = raw_input("Are the mo files up to date? [y/n]")
if ans != 'y':
sys.exit(0)
distdir = 'childsplay-%s' % version
print "looking for old packages"
if os.path.exists(distdir):
print "Removing %s" % distdir
os.system('rm -rf %s' % distdir)
if os.path.exists('%s.tgz' % distdir):
print "Removing %s.tgz" % distdir
os.system('rm %s.tgz' % distdir)
if os.path.exists('%s.zip' % distdir):
print "Removing %s.zip" % distdir
os.system('rm %s.zip' % distdir)
if os.path.exists('%s.tgz.sig' % distdir):
print "Removing %s.tgz.sig" % distdir
os.system('rm %s.tgz.sig' % distdir)
print "Looking for pyc files and remove them"
os.system('find ./ -name "*.pyc" -exec rm -v {} \;')
filelist = open('filelist', 'r')
folderlist = open('folderlist', 'r')
excludelist = open('excludelist','r')
myFiles = filelist.readlines()
myFolders = folderlist.readlines()
myExclude = excludelist.readlines()
os.system('mkdir %s' % distdir)
for file in myFiles:
file = file[:-1]
if not file or file in myExclude:
print 'not copying {0}'.format(file)
continue
os.system('cp %s %s' % (file, distdir))
for folder in myFolders:
folder = folder[:-1]
if not folder or folder in myExclude:
print 'not copying {0}'.format(folder)
continue
os.system('mkdir -vp %s/%s' % (distdir, folder))
os.system('cp -r %s %s' % (folder, distdir))
# add alphabet sounds
os.system('mkdir -vp %s/%s' % (distdir, 'alphabet-sounds'))
for folder in glob.glob('alphabet-sounds/*-*_*'):
print "copying", folder
lang = folder.split('_', 1)[1]
os.system('cp -r %s %s' % (os.path.join(folder, 'AlphabetSounds', lang),
os.path.join(distdir, 'alphabet-sounds', lang)))
# remove the files mentioned in the exclude list
for item in myExclude:
print item
try:
item = os.path.join(distdir,item)
print "Exclude -> ",item,
v = os.system('rm -r %s' % item)
if not v:
print "Removed file/dir ->",item
except OSError,info:
print "####### ERROR ######\n",info
sys.exit(1)
# Now the dir tree is clean and ready to be packaged.
# remember we do everything in a copy, 'distdir'
print "\nCreate a GNU/Linux tarball..."
try:
execString = 'tar -czf %s.tgz %s/' % (distdir, distdir)
print execString
os.system(execString)
except Exception,info:
print info,"\nYou must have the tar package installed"
else:
print "Done.\n"
os.system("gpg -b --use-agent %s.tgz" % distdir)
#print "Create a Windows compatible zipfile..."
#try:
# execString = 'zip -rq %s.zip ./%s' % (distdir, distdir)
# print execString
# os.system(execString)
#except Exception,info:
# print info,"\nYou must have the zip package installed."
#else:
# print "Done\n"
#os.system('rm -rf %s' % distdir)