2006-05-04 01:26:38 -07:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import getopt
|
|
|
|
|
|
|
|
dir = os.getcwd()
|
|
|
|
builddir = "/home/muntyan/projects/moo/build"
|
|
|
|
moo_windir = "/usr/local/win/medit"
|
|
|
|
|
|
|
|
|
|
|
|
def usage():
|
|
|
|
print "Usage:", sys.argv[0], "[build_dir]"
|
|
|
|
sys.exit(2)
|
|
|
|
|
|
|
|
if sys.argv[1:]:
|
|
|
|
if sys.argv[2:]: usage()
|
|
|
|
moo_builddir = os.path.abspath(sys.argv[1])
|
|
|
|
else:
|
|
|
|
moo_builddir = builddir + "/mingw"
|
|
|
|
|
|
|
|
config = os.path.basename(moo_builddir)
|
|
|
|
installdir = "%s/%s-inst" % (dir, config)
|
|
|
|
|
|
|
|
issdir = "Z:%s/wininstaller" % (moo_builddir,)
|
|
|
|
iss = issdir + "/medit.iss"
|
|
|
|
|
|
|
|
|
|
|
|
class Error(Exception):
|
|
|
|
def __init__(self, status):
|
|
|
|
Exception.__init__(self)
|
|
|
|
self.status = status
|
|
|
|
|
|
|
|
def do_cmd(cmd):
|
|
|
|
print cmd
|
|
|
|
status = os.system(cmd)
|
|
|
|
if status:
|
|
|
|
raise Error(status)
|
|
|
|
|
|
|
|
def copy_files():
|
|
|
|
files = ["bin/medit.exe", "share/moo/syntax",
|
|
|
|
"share/moo/tools.cfg", "share/moo/menu.cfg", "share/moo/as.cfg",
|
|
|
|
"share/moo/completion", "lib/moo/plugins"]
|
|
|
|
for f in files:
|
|
|
|
do_cmd("cp -r %s/usr/local/%s %s/" % (installdir, f, moo_windir))
|
|
|
|
|
|
|
|
config_template = """
|
|
|
|
version = @MOO_VERSION@
|
|
|
|
"""
|
|
|
|
|
|
|
|
def get_version():
|
|
|
|
sys.path.insert(0, moo_builddir)
|
|
|
|
if not os.path.exists('config.py.in'):
|
|
|
|
file = open('config.py.in', 'w+')
|
|
|
|
file.write(config_template)
|
|
|
|
file.close()
|
|
|
|
do_cmd('./config.status --file config.py:config.py.in')
|
|
|
|
import config
|
|
|
|
return config.version
|
|
|
|
|
|
|
|
def build():
|
|
|
|
do_cmd("mkdir " + moo_windir)
|
|
|
|
do_cmd("mkdir " + installdir)
|
|
|
|
os.chdir(moo_builddir)
|
|
|
|
do_cmd("make install-strip DESTDIR=" + installdir)
|
|
|
|
copy_files()
|
|
|
|
do_cmd("wine /usr/local/win/InnoSetup5/ISCC.exe " + iss)
|
|
|
|
installer = "meditsetup-" + get_version() + config.replace("mingw", "") + ".exe"
|
|
|
|
do_cmd("mv %s/wininstaller/Output/setup.exe %s/%s" % (moo_builddir, dir, installer))
|
|
|
|
|
|
|
|
def clean():
|
|
|
|
do_cmd("rm -rf %s %s %s" % (moo_windir, installdir,
|
|
|
|
moo_builddir + "/wininstaller/Output"))
|
|
|
|
|
|
|
|
try:
|
|
|
|
build()
|
|
|
|
except Error, e:
|
|
|
|
clean()
|
|
|
|
sys.exit(e.status)
|
|
|
|
|
|
|
|
clean()
|
|
|
|
print "*** Success ***"
|