This commit is contained in:
Kovid Goyal 2008-02-21 20:57:28 +00:00
parent c8cce1e355
commit 3487147221
3 changed files with 131 additions and 78 deletions

View File

@ -18,7 +18,6 @@
import sys, re, os, shutil, subprocess, stat import sys, re, os, shutil, subprocess, stat
from setup import VERSION, APPNAME, scripts, main_modules, basenames, main_functions from setup import VERSION, APPNAME, scripts, main_modules, basenames, main_functions
from setuptools import setup from setuptools import setup
sys.argv[1:2] = ['py2app']
from py2app.build_app import py2app from py2app.build_app import py2app
from modulegraph.find_modules import find_modules from modulegraph.find_modules import find_modules
@ -222,6 +221,15 @@ sys.frameworks_dir = os.path.join(os.path.dirname(os.environ['RESOURCEPATH']), '
BuildAPP.makedmg(os.path.join(self.dist_dir, APPNAME+'.app'), APPNAME+'-'+VERSION) BuildAPP.makedmg(os.path.join(self.dist_dir, APPNAME+'.app'), APPNAME+'-'+VERSION)
def main():
auto = '--auto' in sys.argv
if auto:
sys.argv.remove('--auto')
if auto and not os.path.exists('dist/auto'):
print '%s does not exist'%os.path.abspath('dist/auto')
return 1
sys.argv[1:2] = ['py2app']
setup( setup(
name = APPNAME, name = APPNAME,
app = [scripts['gui'][0]], app = [scripts['gui'][0]],
@ -250,3 +258,9 @@ setup(
}, },
setup_requires = ['py2app'], setup_requires = ['py2app'],
) )
if auto:
subprocess.call(('sudo', 'shutdown', '-h', '+0'))
return 0
if __name__ == '__main__':
sys.exit(main())

View File

@ -1,6 +1,7 @@
#!/usr/bin/python #!/usr/bin/python
import sys, os, shutil import sys, os, shutil, time
sys.path.append('src') sys.path.append('src')
import subprocess
from subprocess import check_call as _check_call from subprocess import check_call as _check_call
from functools import partial from functools import partial
#from pyvix.vix import Host, VIX_SERVICEPROVIDER_VMWARE_WORKSTATION #from pyvix.vix import Host, VIX_SERVICEPROVIDER_VMWARE_WORKSTATION
@ -34,23 +35,49 @@ def tag_release():
client.callback_get_log_message = get_log_message client.callback_get_log_message = get_log_message
client.copy(base+'/trunk', tag) client.copy(base+'/trunk', tag)
def build_installer(installer, vm, timeout=25):
if os.path.exists(installer):
os.unlink(installer)
f = open('dist/auto', 'wb')
f.write('\n')
f.close()
print 'Building installer %s ...'%installer
vmware = ('vmware', '-q', '-x', '-n', vm)
try:
p = subprocess.Popen(vmware)
print 'Waiting...',
minutes = 0
sys.stdout.flush()
while p.returncode is None and minutes < timeout and not os.path.exists(installer):
p.poll()
time.sleep(60)
minutes += 1
print minutes,
sys.stdout.flush()
if not os.path.exists(installer):
raise Exception('Failed to build windows installer')
finally:
os.unlink('dist/auto')
return os.path.basename(installer)
def build_windows(): def build_windows():
from libprs500 import __version__ from libprs500 import __version__
installer = 'dist/libprs500-%s.exe'%__version__ installer = 'dist/libprs500-%s.exe'%__version__
if not os.path.exists(installer): vm = '/vmware/Windows XP/Windows XP Professional.vmx'
raise Exception('You must build the windows installer before running this script') return build_installer(installer, vm, 20)
return os.path.basename(installer)
def build_osx(): def build_osx():
from libprs500 import __version__ from libprs500 import __version__
installer = 'dist/libprs500-%s.dmg'%__version__ installer = 'dist/libprs500-%s.dmg'%__version__
if not os.path.exists(installer): vm = '/vmware/Mac OSX/Mac OSX.vmx'
raise Exception('You must build the OSX installer before running this script') return build_installer(installer, vm, 20)
return os.path.basename(installer)
def build_installers():
return build_windows(), build_osx()
def upload_demo(): def upload_demo():
check_call('''html2lrf --title='Demonstration of html2lrf' --author='Kovid Goyal' ''' check_call('''html2lrf --title='Demonstration of html2lrf' --author='Kovid Goyal' '''
@ -94,10 +121,7 @@ def main():
check_call('svn commit -m "Updated translations" src/libprs500/translations') check_call('svn commit -m "Updated translations" src/libprs500/translations')
tag_release() tag_release()
upload_demo() upload_demo()
print 'Building OSX installer...' exe, dmg = build_installers()
dmg = build_osx()
print 'Building Windows installer...'
exe = build_windows()
if upload: if upload:
print 'Uploading installers...' print 'Uploading installers...'
upload_installers(exe, dmg) upload_installers(exe, dmg)

View File

@ -15,9 +15,6 @@
''' Create a windows installer ''' ''' Create a windows installer '''
import sys, re, os, shutil, subprocess import sys, re, os, shutil, subprocess
from setup import VERSION, APPNAME, entry_points, scripts, basenames from setup import VERSION, APPNAME, entry_points, scripts, basenames
sys.argv[1:2] = ['py2exe']
if '--verbose' not in ' '.join(sys.argv):
sys.argv.append('--quiet') #py2exe produces too much output by default
from distutils.core import setup from distutils.core import setup
from distutils.filelist import FileList from distutils.filelist import FileList
import py2exe, glob import py2exe, glob
@ -432,6 +429,18 @@ class BuildEXE(build_exe):
return (24, cls.manifest_resource_id, return (24, cls.manifest_resource_id,
cls.MANIFEST_TEMPLATE % dict(prog=prog, version=VERSION+'.0')) cls.MANIFEST_TEMPLATE % dict(prog=prog, version=VERSION+'.0'))
def main():
auto = '--auto' in sys.argv
if auto:
sys.argv.remove('--auto')
sys.argv[1:2] = ['py2exe']
if '--verbose' not in sys.argv:
sys.argv.append('--quiet') #py2exe produces too much output by default
if auto and not os.path.exists('dist\\auto'):
print os.path.abspath('dist\\auto'), 'does not exist'
return 1
console = [dict(dest_base=basenames['console'][i], script=scripts['console'][i]) console = [dict(dest_base=basenames['console'][i], script=scripts['console'][i])
for i in range(len(scripts['console']))] for i in range(len(scripts['console']))]
@ -466,3 +475,9 @@ setup(
}, },
) )
if auto:
subprocess.call(('shutdown', '-s', '-f', '-t', '01'))
return 0
if __name__ == '__main__':
sys.exit(main())