2009-12-30 16:34:41 +00:00
|
|
|
# Created By: Virgil Dupras
|
|
|
|
# Created On: 2009-12-30
|
2012-03-15 18:28:40 +00:00
|
|
|
# Copyright 2012 Hardcoded Software (http://www.hardcoded.net)
|
2009-12-30 16:34:41 +00:00
|
|
|
#
|
2010-09-30 10:17:41 +00:00
|
|
|
# This software is licensed under the "BSD" License as described in the "LICENSE" file,
|
2009-12-30 16:34:41 +00:00
|
|
|
# which should be included with this package. The terms are also available at
|
2010-09-30 10:17:41 +00:00
|
|
|
# http://www.hardcoded.net/licenses/bsd_license
|
2009-12-30 16:34:41 +00:00
|
|
|
|
|
|
|
import os
|
|
|
|
import os.path as op
|
2010-04-07 10:56:43 +00:00
|
|
|
import compileall
|
2010-02-09 14:52:09 +00:00
|
|
|
import shutil
|
2011-01-11 15:21:36 +00:00
|
|
|
import json
|
2012-04-07 15:21:38 +00:00
|
|
|
from argparse import ArgumentParser
|
2009-12-30 16:34:41 +00:00
|
|
|
|
2011-09-22 13:32:09 +00:00
|
|
|
from hscommon.plat import ISWINDOWS, ISLINUX
|
2012-06-20 17:09:42 +00:00
|
|
|
from hscommon.build import (add_to_pythonpath, print_and_do, copy_packages, build_debian_changelog,
|
|
|
|
copy_qt_plugins, get_module_version, filereplace, copy, setup_package_argparser,
|
2012-07-11 16:22:00 +00:00
|
|
|
package_cocoa_app_in_dmg, copy_all)
|
2010-02-09 14:42:48 +00:00
|
|
|
|
2012-04-07 15:21:38 +00:00
|
|
|
def parse_args():
|
|
|
|
parser = ArgumentParser()
|
2012-06-20 17:09:42 +00:00
|
|
|
setup_package_argparser(parser)
|
2012-07-11 20:21:40 +00:00
|
|
|
parser.add_argument('--source', action='store_true', dest='source_pkg',
|
|
|
|
help="Build only a source debian package (Linux only).")
|
2012-06-20 17:09:42 +00:00
|
|
|
return parser.parse_args()
|
2012-04-07 15:21:38 +00:00
|
|
|
|
2012-06-20 17:09:42 +00:00
|
|
|
def package_cocoa(edition, args):
|
2010-02-09 14:42:48 +00:00
|
|
|
app_path = {
|
2011-12-02 15:48:59 +00:00
|
|
|
'se': 'cocoa/se/dupeGuru.app',
|
|
|
|
'me': 'cocoa/me/dupeGuru ME.app',
|
|
|
|
'pe': 'cocoa/pe/dupeGuru PE.app',
|
2010-02-09 14:42:48 +00:00
|
|
|
}[edition]
|
2012-06-20 17:09:42 +00:00
|
|
|
package_cocoa_app_in_dmg(app_path, '.', args)
|
2010-02-09 14:42:48 +00:00
|
|
|
|
2010-04-08 10:17:03 +00:00
|
|
|
def package_windows(edition, dev):
|
2011-09-22 13:32:09 +00:00
|
|
|
if not ISWINDOWS:
|
2010-08-11 14:39:06 +00:00
|
|
|
print("Qt packaging only works under Windows.")
|
2010-02-09 14:42:48 +00:00
|
|
|
return
|
|
|
|
add_to_pythonpath('.')
|
2011-01-13 10:56:46 +00:00
|
|
|
app_version = get_module_version('core_{}'.format(edition))
|
2010-10-05 08:48:07 +00:00
|
|
|
distdir = 'dist'
|
2010-02-09 14:42:48 +00:00
|
|
|
|
2010-10-05 08:48:07 +00:00
|
|
|
if op.exists(distdir):
|
|
|
|
shutil.rmtree(distdir)
|
2010-04-07 15:30:04 +00:00
|
|
|
|
2011-03-20 11:28:53 +00:00
|
|
|
# Since v4.2.3, cx_freeze started to falsely include tkinter in the package. We exclude it explicitly because of that.
|
|
|
|
cmd = 'cxfreeze --base-name Win32GUI --target-dir "{0}" --target-name "{1}.exe" --icon {2} --exclude-modules tkinter run.py'
|
2010-04-07 15:30:04 +00:00
|
|
|
target_name = {'se': 'dupeGuru', 'me': 'dupeGuru ME', 'pe': 'dupeGuru PE'}[edition]
|
2010-10-05 08:48:07 +00:00
|
|
|
icon_path = 'images\\dg{0}_logo.ico'.format(edition)
|
|
|
|
print_and_do(cmd.format(distdir, target_name, icon_path))
|
2010-04-07 15:30:04 +00:00
|
|
|
|
2010-04-08 10:17:03 +00:00
|
|
|
if not dev:
|
|
|
|
# Copy qt plugins
|
2010-10-05 08:48:07 +00:00
|
|
|
plugin_dest = op.join(distdir, 'qt4_plugins')
|
2010-04-08 10:17:03 +00:00
|
|
|
plugin_names = ['accessible', 'codecs', 'iconengines', 'imageformats']
|
|
|
|
copy_qt_plugins(plugin_names, plugin_dest)
|
|
|
|
|
|
|
|
# Compress with UPX
|
2010-10-05 08:48:07 +00:00
|
|
|
libs = [name for name in os.listdir(distdir) if op.splitext(name)[1] in ('.pyd', '.dll', '.exe')]
|
2010-04-07 15:30:04 +00:00
|
|
|
for lib in libs:
|
2010-10-05 08:48:07 +00:00
|
|
|
print_and_do("upx --best \"{0}\"".format(op.join(distdir, lib)))
|
2010-04-13 13:04:15 +00:00
|
|
|
|
2011-01-13 10:56:46 +00:00
|
|
|
help_path = op.join('build', 'help')
|
2011-11-30 16:06:08 +00:00
|
|
|
print("Copying {} to dist\\help".format(help_path))
|
2010-10-05 08:48:07 +00:00
|
|
|
shutil.copytree(help_path, op.join(distdir, 'help'))
|
2011-11-30 16:06:08 +00:00
|
|
|
locale_path = op.join('build', 'locale')
|
|
|
|
print("Copying {} to dist\\locale".format(locale_path))
|
|
|
|
shutil.copytree(locale_path, op.join(distdir, 'locale'))
|
2010-02-09 14:42:48 +00:00
|
|
|
|
|
|
|
# AdvancedInstaller.com has to be in your PATH
|
|
|
|
# this is so we don'a have to re-commit installer.aip at every version change
|
2010-10-05 08:48:07 +00:00
|
|
|
installer_path = op.join('qt', edition, 'installer.aip')
|
|
|
|
shutil.copy(installer_path, 'installer_tmp.aip')
|
2011-01-13 10:56:46 +00:00
|
|
|
print_and_do('AdvancedInstaller.com /edit installer_tmp.aip /SetVersion %s' % app_version)
|
2010-02-09 14:42:48 +00:00
|
|
|
print_and_do('AdvancedInstaller.com /build installer_tmp.aip -force')
|
|
|
|
os.remove('installer_tmp.aip')
|
2010-10-05 08:48:07 +00:00
|
|
|
if op.exists('installer_tmp.back.aip'):
|
|
|
|
os.remove('installer_tmp.back.aip')
|
2009-12-30 16:34:41 +00:00
|
|
|
|
2012-07-11 20:21:40 +00:00
|
|
|
def package_debian(edition, source_pkg):
|
2011-01-13 10:56:46 +00:00
|
|
|
app_version = get_module_version('core_{}'.format(edition))
|
2010-04-07 10:56:43 +00:00
|
|
|
ed = lambda s: s.format(edition)
|
2011-01-13 10:56:46 +00:00
|
|
|
destpath = op.join('build', 'dupeguru-{0}-{1}'.format(edition, app_version))
|
2011-01-13 11:23:21 +00:00
|
|
|
if op.exists(destpath):
|
|
|
|
shutil.rmtree(destpath)
|
2010-04-07 10:56:43 +00:00
|
|
|
srcpath = op.join(destpath, 'src')
|
|
|
|
os.makedirs(destpath)
|
2010-10-05 09:02:02 +00:00
|
|
|
os.makedirs(srcpath)
|
|
|
|
shutil.copy('run.py', op.join(srcpath, 'run.py'))
|
2011-01-11 12:36:05 +00:00
|
|
|
packages = ['hscommon', 'core', ed('core_{0}'), 'qtlib', 'qt', 'send2trash', 'jobprogress']
|
2010-07-14 09:40:46 +00:00
|
|
|
if edition == 'me':
|
|
|
|
packages.append('hsaudiotag')
|
2010-04-07 10:56:43 +00:00
|
|
|
copy_packages(packages, srcpath)
|
2012-07-11 16:22:00 +00:00
|
|
|
if edition == 'pe':
|
|
|
|
os.mkdir(op.join(destpath, 'modules'))
|
|
|
|
copy_all(op.join('core_pe', 'modules', '*.*'), op.join(destpath, 'modules'))
|
|
|
|
copy(op.join('qt', 'pe', 'modules', 'block.c'), op.join(destpath, 'modules', 'block_qt.c'))
|
|
|
|
copy(op.join('debian', 'build_pe_modules.py'), op.join(destpath, 'build_pe_modules.py'))
|
2012-06-16 14:35:23 +00:00
|
|
|
debdest = op.join(destpath, 'debian')
|
|
|
|
os.makedirs(debdest)
|
|
|
|
debopts = json.load(open(op.join('debian', ed('{}.json'))))
|
2012-07-11 19:07:29 +00:00
|
|
|
for fn in ['compat', 'copyright', 'dirs', 'rules']:
|
2012-06-16 14:35:23 +00:00
|
|
|
copy(op.join('debian', fn), op.join(debdest, fn))
|
2012-07-11 19:07:29 +00:00
|
|
|
filereplace(op.join('debian', 'control'), op.join(debdest, 'control'), **debopts)
|
|
|
|
filereplace(op.join('debian', 'Makefile'), op.join(destpath, 'Makefile'), **debopts)
|
2012-06-16 14:35:23 +00:00
|
|
|
filereplace(op.join('debian', 'dupeguru.desktop'), op.join(debdest, ed('dupeguru_{}.desktop')), **debopts)
|
2011-01-13 11:23:21 +00:00
|
|
|
changelogpath = op.join('help', ed('changelog_{}'))
|
2012-06-16 14:35:23 +00:00
|
|
|
changelog_dest = op.join(debdest, 'changelog')
|
|
|
|
project_name = debopts['pkgname']
|
2010-04-07 10:56:43 +00:00
|
|
|
from_version = {'se': '2.9.2', 'me': '5.7.2', 'pe': '1.8.5'}[edition]
|
2011-01-11 15:21:36 +00:00
|
|
|
build_debian_changelog(changelogpath, changelog_dest, project_name, from_version=from_version)
|
2011-01-13 11:23:21 +00:00
|
|
|
shutil.copytree(op.join('build', 'help'), op.join(srcpath, 'help'))
|
2011-11-30 17:13:02 +00:00
|
|
|
shutil.copytree(op.join('build', 'locale'), op.join(srcpath, 'locale'))
|
2010-04-07 10:56:43 +00:00
|
|
|
shutil.copy(op.join('images', ed('dg{0}_logo_128.png')), srcpath)
|
|
|
|
compileall.compile_dir(srcpath)
|
|
|
|
os.chdir(destpath)
|
2012-07-11 20:21:40 +00:00
|
|
|
cmd = "dpkg-buildpackage"
|
|
|
|
if source_pkg:
|
|
|
|
cmd += " -S"
|
|
|
|
os.system(cmd)
|
2010-04-07 10:56:43 +00:00
|
|
|
|
2009-12-30 16:34:41 +00:00
|
|
|
def main():
|
2012-04-07 15:21:38 +00:00
|
|
|
args = parse_args()
|
2011-01-11 15:21:36 +00:00
|
|
|
conf = json.load(open('conf.json'))
|
2009-12-30 16:34:41 +00:00
|
|
|
edition = conf['edition']
|
|
|
|
ui = conf['ui']
|
|
|
|
dev = conf['dev']
|
2010-08-11 14:39:06 +00:00
|
|
|
print("Packaging dupeGuru {0} with UI {1}".format(edition.upper(), ui))
|
2009-12-30 16:34:41 +00:00
|
|
|
if ui == 'cocoa':
|
2012-06-20 17:09:42 +00:00
|
|
|
package_cocoa(edition, args)
|
2009-12-30 16:34:41 +00:00
|
|
|
elif ui == 'qt':
|
2011-09-22 13:32:09 +00:00
|
|
|
if ISWINDOWS:
|
2010-04-08 10:17:03 +00:00
|
|
|
package_windows(edition, dev)
|
2011-09-22 13:32:09 +00:00
|
|
|
elif ISLINUX:
|
2012-07-11 20:21:40 +00:00
|
|
|
package_debian(edition, source_pkg=args.source_pkg)
|
2010-04-07 10:56:43 +00:00
|
|
|
else:
|
2010-08-11 14:39:06 +00:00
|
|
|
print("Qt packaging only works under Windows or Linux.")
|
2009-12-30 16:34:41 +00:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2010-04-07 10:56:43 +00:00
|
|
|
main()
|