medit/makewin

195 lines
6.5 KiB
Plaintext
Raw Normal View History

2006-05-04 01:26:38 -07:00
#!/usr/bin/env python
import os
import sys
import getopt
2006-12-23 16:13:09 -08:00
def get_version():
sys.path.insert(0, moo_builddir)
import config
return config.version
2006-05-04 01:26:38 -07:00
dir = os.getcwd()
builddir = dir
2006-12-10 14:46:22 -08:00
thisscript = os.path.abspath(sys.argv[0])
2006-05-04 01:26:38 -07:00
moo_windir = "/usr/local/win/medit"
2007-01-06 02:18:50 -08:00
strip = "i586-mingw32msvc-strip --strip-unneeded"
do_strip = True
2006-11-26 19:41:25 -08:00
do_zip = False
2006-12-23 16:13:09 -08:00
pida = False
2006-11-12 11:10:12 -08:00
bin_only = False
2006-12-08 00:23:33 -08:00
no_python = False
installer = None
2006-12-10 14:46:22 -08:00
release = False
name = None
dry_run = False
2006-11-16 02:25:59 -08:00
data_dirs = []
2006-05-04 01:26:38 -07:00
def usage():
2006-12-23 16:13:09 -08:00
print "Usage: %s [--dry-run] [--no-strip] [--bin-only] [--zip] [--pida] [--no-python] [build_dir] [additional_dir1] ..." % (sys.argv[0],)
2006-12-10 14:46:22 -08:00
print " %s [--dry-run] --release build_dir gtk_dir python_dir" % (sys.argv[0],)
2006-05-04 01:26:38 -07:00
sys.exit(2)
try:
2006-12-23 16:13:09 -08:00
opts, args = getopt.getopt(sys.argv[1:], "", ["dry-run", "no-strip", "no-python", "bin-only", "zip", "pida", "release", "name="])
except getopt.GetoptError:
usage()
for o, a in opts:
if o == "--no-strip":
do_strip = False
2006-11-12 11:10:12 -08:00
if o == "--bin-only":
bin_only = True
2006-12-08 00:23:33 -08:00
if o == "--no-python":
no_python = True
2006-11-26 19:41:25 -08:00
if o == "--zip":
do_zip = True
2006-12-23 16:13:09 -08:00
if o == "--pida":
pida = True
2006-12-10 14:46:22 -08:00
if o == "--release":
release = True
if o == "--name":
name = a
if o == "--dry-run":
dry_run = True
if args:
moo_builddir = os.path.abspath(args[0])
2006-05-04 01:26:38 -07:00
else:
moo_builddir = builddir
if args[1:]:
2006-11-16 02:25:59 -08:00
data_dirs = [os.path.abspath(d) for d in args[1:]]
2006-05-04 01:26:38 -07:00
2006-12-23 16:13:09 -08:00
if pida:
do_zip = True
name = "medit-pida-%s.zip" % (get_version(),)
2006-12-10 14:46:22 -08:00
if release:
if len(data_dirs) != 2:
usage()
installdir = dir + "/inst_"
2006-05-04 01:26:38 -07:00
issdir = "Z:%s/medit" % (moo_builddir,)
2006-05-04 01:26:38 -07:00
iss = issdir + "/medit.iss"
class Error(Exception):
def __init__(self, status):
Exception.__init__(self)
self.status = status
2006-12-10 14:46:22 -08:00
def do_cmd(cmd, force=False):
2006-05-04 01:26:38 -07:00
print cmd
2006-12-10 14:46:22 -08:00
if force or not dry_run:
status = os.system(cmd)
if status:
raise Error(status)
2006-05-04 01:26:38 -07:00
def copy_mime():
do_cmd("mkdir -p %s/mime/packages" % (installdir,))
2008-01-10 03:04:23 -08:00
do_cmd("cp %s/usr/local/win/gtk-dist/share/mime/packages/moo.xml %s/mime/packages" % (installdir, installdir))
do_cmd("cp /usr/share/mime/packages/freedesktop.org.xml %s/mime/packages" % (installdir,))
do_cmd("update-mime-database %s/mime" % (installdir,))
do_cmd("mkdir -p %s/share/mime/" % (moo_windir,))
do_cmd("cp %s/mime/mime.cache %s/share/mime/" % (installdir, moo_windir))
do_cmd("rm -fr %s/mime/" % (installdir,))
2006-05-04 01:26:38 -07:00
def copy_files():
2006-11-16 02:25:59 -08:00
if data_dirs:
for d in data_dirs:
do_cmd("cp -r %s/* %s/" % (d, moo_windir))
2006-11-12 11:10:12 -08:00
do_cmd("mkdir -p %s/bin" % (moo_windir,))
2008-01-10 03:04:23 -08:00
do_cmd("cp -r %s/usr/local/win/gtk-dist/bin/libmoo.dll %s/bin/" % (installdir, moo_windir))
2006-12-23 16:13:09 -08:00
if not pida:
2008-01-10 03:04:23 -08:00
do_cmd("cp -r %s/usr/local/win/gtk-dist/bin/medit.exe %s/bin/" % (installdir, moo_windir))
2006-12-23 16:13:09 -08:00
2006-11-12 11:10:12 -08:00
if not bin_only:
2008-01-10 03:04:23 -08:00
do_cmd("mkdir -p %s/share/doc" % (moo_windir,))
2007-01-10 02:15:52 -08:00
do_cmd("mkdir -p %s/share/mime" % (moo_windir,))
2006-11-12 11:10:12 -08:00
do_cmd("mkdir -p %s/lib/moo" % (moo_windir,))
2008-01-10 03:04:23 -08:00
do_cmd("cp -r %s/usr/local/win/gtk-dist/share/doc/medit %s/share/doc/" % (installdir, moo_windir))
do_cmd("cp -r %s/usr/local/win/gtk-dist/share/moo %s/share/" % (installdir, moo_windir))
do_cmd("rm -fr %s/share/moo/scripts" % (moo_windir,))
do_cmd("cp -r %s/usr/local/win/gtk-dist/share/locale %s/lib/" % (installdir, moo_windir))
copy_mime()
2006-12-08 00:23:33 -08:00
if not no_python:
2008-01-10 03:04:23 -08:00
do_cmd("cp -r %s/usr/local/win/gtk-dist/lib/moo/plugins %s/lib/moo/" % (installdir, moo_windir))
if os.path.exists("%s/usr/local/win/gtk-dist/lib/moo/projects" % (installdir,)):
do_cmd("cp -r %s/usr/local/win/gtk-dist/lib/moo/projects %s/lib/moo/" % (installdir, moo_windir))
2006-11-12 11:10:12 -08:00
2006-12-23 16:13:09 -08:00
if pida:
do_cmd("mkdir -p %s/lib/site-packages" % (moo_windir,))
2008-01-10 03:04:23 -08:00
do_cmd("cp %s/usr/local/win/gtk-dist/lib/moo/plugins/lib/moo.pyd %s/lib/site-packages/moo.pyd" % (installdir, moo_windir))
2006-12-23 16:13:09 -08:00
else:
do_cmd("mkdir -p %s/lib/moo/plugins" % (moo_windir,))
2008-01-10 03:04:23 -08:00
do_cmd("cp %s/usr/local/win/gtk-dist/lib/moo/plugins/pymoo.dll %s/lib/moo/plugins/" % (installdir, moo_windir))
do_cmd("cp %s/usr/local/win/gtk-dist/lib/moo/plugins/lib/moo.pyd %s/lib/moo/plugins/" % (installdir, moo_windir))
if do_strip:
2006-12-08 00:23:33 -08:00
if not bin_only and not no_python:
2007-01-06 02:18:50 -08:00
if pida:
2007-01-10 02:15:52 -08:00
do_cmd("%s %s/lib/site-packages/*.pyd" % (strip, moo_windir))
2006-12-23 16:13:09 -08:00
else:
do_cmd("%s %s/lib/moo/plugins/*.dll" % (strip, moo_windir))
2007-01-10 02:15:52 -08:00
do_cmd("%s %s/lib/moo/plugins/*/*.pyd" % (strip, moo_windir))
do_cmd("%s %s/bin/medit.exe %s/bin/libmoo.dll" % (strip, moo_windir, moo_windir))
2006-05-04 01:26:38 -07:00
def build():
global installer
2006-12-10 14:46:22 -08:00
if release:
script = thisscript
if dry_run:
script += " --dry-run"
installer_no_gtk = "medit-no-gtk-%s.exe" % (get_version(),)
installer_no_python = "medit-%s.exe" % (get_version(),)
installer_python = "medit-python-%s.exe" % (get_version(),)
do_cmd('%s --name=%s "%s"' % (script, installer_no_gtk, moo_builddir), True)
do_cmd('%s --name=%s "%s" "%s"' % (script, installer_no_python, moo_builddir, data_dirs[0]), True)
do_cmd('%s --name=%s "%s" "%s" "%s"' % (script, installer_python, moo_builddir, data_dirs[0], data_dirs[1]), True)
print ""
print "+++ Success +++"
print "Installers: %s, %s, %s" % (installer_no_gtk, installer_no_python, installer_python)
sys.exit(0)
2006-05-04 01:26:38 -07:00
do_cmd("mkdir " + moo_windir)
do_cmd("mkdir " + installdir)
os.chdir(moo_builddir)
do_cmd("make install DESTDIR=" + installdir)
2006-05-04 01:26:38 -07:00
copy_files()
if do_strip:
2006-11-26 19:41:25 -08:00
dbg = ""
else:
2006-11-26 19:41:25 -08:00
dbg = "dbg-"
if do_zip:
zipdir = "medit-" + dbg + get_version()
2006-12-10 14:46:22 -08:00
installer = name or (zipdir + ".zip")
2006-11-26 19:41:25 -08:00
do_cmd("rm -fr %s %s" % (zipdir, installer))
do_cmd("mv %s ./%s" % (moo_windir, zipdir))
do_cmd("zip -r9 %s %s" % (installer, zipdir))
do_cmd("rm -fr %s" % (zipdir,))
else:
2006-12-10 14:46:22 -08:00
installer = name or ("medit-" + dbg + get_version() + ".exe")
2006-11-26 19:41:25 -08:00
do_cmd("wine /usr/local/win/InnoSetup5/ISCC.exe " + iss)
do_cmd("mv %s/medit/Output/setup.exe %s/%s" % (moo_builddir, dir, installer))
2006-05-04 01:26:38 -07:00
def clean():
do_cmd("rm -rf %s %s %s" % (moo_windir, installdir,
moo_builddir + "/medit/Output"))
2006-05-04 01:26:38 -07:00
try:
build()
except Error, e:
clean()
sys.exit(e.status)
clean()
print "*** Success ***"
print "Installer: ", installer