# -*- mode: python -*- # # Copyright (C) 2012-2016 Carl Hetherington # # This file is part of DCP-o-matic. # # DCP-o-matic is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # DCP-o-matic 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with DCP-o-matic. If not, see . # from __future__ import print_function import glob import shutil import os import copy deb_build_depends = {'debhelper', 'python', 'g++', 'pkg-config', 'libssh-dev', 'libsndfile1-dev', 'libgtk2.0-dev'} deb_depends = dict() deb_depends_base = ['libc6', 'libssh-4', 'libsndfile1', 'libsamplerate0', 'libxmlsec1', 'libxmlsec1-openssl', 'libcurl3', 'libgtk2.0-0'] deb_depends['12.04'] = copy.deepcopy(deb_depends_base) deb_depends['12.04'].extend(['libboost-filesystem1.48.0', 'libboost-thread1.48.0', 'libboost-regex1.48.0', 'libmagick++4', 'libxml++2.6-2', 'libboost-date-time1.48.0', 'libzip2', 'libicu48']) deb_depends['14.04'] = copy.deepcopy(deb_depends_base) deb_depends['14.04'].extend(['libboost-filesystem1.54.0', 'libboost-thread1.54.0', 'libboost-regex1.54.0', 'libmagick++5', 'libxml++2.6-2', 'libboost-date-time1.54.0', 'libzip2', 'libcairomm-1.0-1', 'libpangomm-1.4-1', 'libicu52']) deb_depends['15.10'] = copy.deepcopy(deb_depends_base) deb_depends['15.10'].extend(['libboost-filesystem1.58.0', 'libboost-thread1.58.0', 'libboost-regex1.58.0', 'libmagick++-6.q16-5v5', 'libxml++2.6-2v5', 'libboost-date-time1.58.0', 'libzip4', 'libwxgtk3.0-0v5', 'libicu55']) deb_depends['16.04'] = copy.deepcopy(deb_depends_base) deb_depends['16.04'].extend(['libboost-filesystem1.58.0', 'libboost-thread1.58.0', 'libboost-regex1.58.0', 'libmagick++-6.q16-5v5', 'libxml++2.6-2v5', 'libboost-date-time1.58.0', 'libzip4', 'libwxgtk3.0-0v5', 'libicu55']) deb_depends['7'] = copy.deepcopy(deb_depends_base) deb_depends['7'].extend(['libboost-filesystem1.49.0', 'libboost-thread1.49.0', 'libboost-regex1.49.0', 'libmagick++5', 'libxml++2.6-2', 'libboost-date-time1.49.0', 'libzip2', 'libcairomm-1.0-1', 'libpangomm-1.4-1', 'libicu48']) deb_depends['8'] = copy.deepcopy(deb_depends_base) deb_depends['8'].extend(['libboost-filesystem1.55.0', 'libboost-thread1.55.0', 'libboost-date-time1.55.0', 'libboost-regex1.55.0', 'libmagick++-6.q16-5', 'libxml++2.6-2', 'libzip2', 'libwxgtk3.0-0', 'libxcb-xfixes0', 'libxcb-shape0', 'libicu52']) deb_depends['unstable'] = copy.deepcopy(deb_depends_base) deb_depends['unstable'].extend(['libboost-filesystem1.58.0', 'libboost-thread1.58.0', 'libboost-regex1.58.0', 'libmagick++-6.q16-5v5', 'libxml++2.6-2v5', 'libgtk2.0-0', 'libboost-date-time1.58.0', 'libzip2', 'libicu52']) def packages(name, packages, f): s = '%s: ' % name for p in packages: s += str(p) + ', ' print(s[:-2], file=f) def make_control(debian_version, bits, filename, debug): f = open(filename, 'w') print('Source: dcpomatic', file=f) print('Section: video', file=f) print('Priority: extra', file=f) print('Maintainer: Carl Hetherington ', file=f) packages('Build-Depends', deb_build_depends, f) print('Standards-Version: 3.9.3', file=f) print('Homepage: http://dcpomatic.com/', file=f) print('', file=f) print('Package: dcpomatic', file=f) if bits == 32: print('Architecture: i386', file=f) else: print('Architecture: amd64', file=f) packages('Depends', deb_depends[debian_version], f) print('Description: Generator of Digital Cinema Packages (DCPs)', file=f) print(' DCP-o-matic generates Digital Cinema Packages (DCPs) from video and audio', file=f) print(' files (such as those from DVDs or Blu-Rays) for presentation on DCI-compliant', file=f) print(' digital projectors.', file=f) if debug: print('', file=f) print('Package: dcpomatic-dbg', file=f) if bits == 32: print('Architecture: i386', file=f) else: print('Architecture: amd64', file=f) print('Section: debug', file=f) print('Priority: extra', file=f) packages('Depends', deb_depends[debian_version], f) print('Description: debugging symbols for dcpomatic', file=f) print(' This package contains the debugging symbols for dcpomatic.', file=f) print('', file=f) def make_spec(filename, version, target): """Make a .spec file for a RPM build""" f = open(filename, 'w') print('Summary:A program that generates Digital Cinema Packages (DCPs) from video and audio files', file=f) print('Name:dcpomatic2', file=f) print('Version:%s' % version, file=f) print('Release:1%{?dist}', file=f) print('License:GPL', file=f) print('Group:Applications/Multimedia', file=f) print('URL:http://dcpomatic.com/', file=f) print('Requires: ImageMagick-c++, glibmm24, libzip', file=f) print('', file=f) print('%description', file=f) print('DCP-o-matic generates Digital Cinema Packages (DCPs) from video and audio ', file=f) print('files (such as those from DVDs or Blu-Rays) for presentation on DCI-compliant ', file=f) print('digital projectors.', file=f) print('', file=f) print('%files', file=f) print('%{_bindir}/dcpomatic2', file=f) print('%{_bindir}/dcpomatic2_batch', file=f) print('%{_bindir}/dcpomatic2_cli', file=f) print('%{_bindir}/dcpomatic2_create', file=f) print('%{_bindir}/dcpomatic2_kdm', file=f) print('%{_bindir}/dcpomatic2_server', file=f) print('%{_bindir}/dcpomatic2_server_cli', file=f) print('%{_bindir}/dcpomatic2_kdm_cli', file=f) print('%{_datadir}/applications/dcpomatic2.desktop', file=f) print('%{_datadir}/applications/dcpomatic2_batch.desktop', file=f) print('%{_datadir}/applications/dcpomatic2_server.desktop', file=f) print('%{_datadir}/applications/dcpomatic2_kdm.desktop', file=f) print('%{_datadir}/dcpomatic2/dcpomatic2_server_small.png', file=f) print('%{_datadir}/dcpomatic2/LiberationSans-Regular.ttf', file=f) print('%{_datadir}/dcpomatic2/LiberationSans-Italic.ttf', file=f) print('%{_datadir}/dcpomatic2/LiberationSans-Bold.ttf', file=f) print('%{_datadir}/dcpomatic2/splash.png', file=f) for r in ['128x128', '16x16', '22x22', '256x256', '32x32', '48x48', '512x512', '64x64']: print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2.png' % r, file=f) print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_batch.png' % r, file=f) print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_kdm.png' % r, file=f) print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_server.png' % r, file=f) for l in ['de_DE', 'es_ES', 'fr_FR', 'it_IT', 'sv_SE', 'nl_NL', 'ru_RU', 'pl_PL', 'da_DK', 'pt_PT', 'pt_BR', 'sk_SK', 'cs_CZ', 'uk_UA', 'zh_CN']: print('%%{_datadir}/locale/%s/LC_MESSAGES/dcpomatic2.mo' % l, file=f) print('%%{_datadir}/locale/%s/LC_MESSAGES/libdcpomatic2-wx.mo' % l, file=f) print('%%{_datadir}/locale/%s/LC_MESSAGES/libdcpomatic2.mo' % l, file=f) print('', file=f) print('%prep', file=f) print('rm -rf $RPM_BUILD_DIR/dcpomatic-%s' % version, file=f) print('tar xjf $RPM_SOURCE_DIR/dcpomatic-%s.tar.bz2' % version, file=f) print('%build', file=f) print('cd dcpomatic-%s' % version, file=f) print('export PKG_CONFIG_PATH=%s/lib/pkgconfig:%s/lib64/pkgconfig:/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig' % (target.directory, target.directory), file=f) if target.distro == 'centos' and target.version == '5': prefix = 'BUILDROOT/usr' else: prefix = '%{buildroot}/usr' print('CXXFLAGS="-I%s/include" LDFLAGS="-L%s/lib" ./waf configure --prefix=%s --install-prefix=/usr %s' % (target.directory, target.directory, prefix, configure_options(target)), file=f) print('./waf', file=f) print('%install', file=f) print('cd dcpomatic-%s' % version, file=f) print('./waf install', file=f) print('', file=f) print('%post', file=f) print('/bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :', file=f) print('', file=f) print('%postun', file=f) print('if [ $1 -eq 0 ] ; then', file=f) print(' /bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null', file=f) print(' /usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :', file=f) print('fi', file=f) print('', file=f) print('%posttrans', file=f) print('/usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :', file=f) def dependencies(target): if target.platform == 'linux': ffmpeg_options = { 'shared': False } else: ffmpeg_options = {} return (('ffmpeg-cdist', 'aab2fb1', ffmpeg_options), ('libdcp', '89d5fe1'), ('libsub', '96ea6d2')) def configure_options(target): opt = '' if target.debug: opt += ' --enable-debug' if target.platform == 'windows': opt += ' --target-windows' elif target.platform == 'linux': opt += ' --static-dcpomatic --static-wxwidgets --static-ffmpeg --static-dcp --static-sub --static-cxml' if target.distro == 'centos': opt += ' --static-xmlsec --static-ssh --disable-tests' if target.version == '6.5': opt += ' --static-boost --static-xmlpp' elif target.version == '7': opt += ' --workaround-gssapi --static-xmlpp' return opt def build(target, options): target.command('./waf configure --prefix=%s %s' % (target.directory, configure_options(target))) target.command('./waf') if target.platform == 'linux' or target.platform == 'osx': target.command('./waf install') def package_windows(target): identifier = '' if target.version is not None: identifier = '%s.' % target.version identifier += '%d' % target.bits shutil.copyfile('build/platform/windows/installer.%s.nsi' % identifier, 'build/platform/windows/installer2.%s.nsi' % identifier) target.command('sed -i "s~%%resources%%~%s/platform/windows~g" build/platform/windows/installer2.%s.nsi' % (os.getcwd(), identifier)) target.command('sed -i "s~%%graphics%%~%s/graphics~g" build/platform/windows/installer2.%s.nsi' % (os.getcwd(), identifier)) target.command('sed -i "s~%%static_deps%%~%s~g" build/platform/windows/installer2.%s.nsi' % (target.windows_prefix, identifier)) target.command('sed -i "s~%%cdist_deps%%~%s~g" build/platform/windows/installer2.%s.nsi' % (target.directory, identifier)) target.command('sed -i "s~%%mingw%%~%s~g" build/platform/windows/installer2.%s.nsi' % (target.mingw_path, identifier)) target.command('sed -i "s~%%binaries%%~%s/build~g" build/platform/windows/installer2.%s.nsi' % (os.getcwd(), identifier)) target.command('sed -i "s~%%bits%%~32~g" build/platform/windows/installer2.%s.nsi' % identifier) target.command('makensis build/platform/windows/installer2.%s.nsi' % identifier) return os.path.abspath(glob.glob('build/platform/windows/*%s*.exe' % target.bits)[0]) def package_debian(target, cpu, version): make_control(target.version, target.bits, 'debian/control', target.debug) target.command('./waf dist') f = open('debian/files', 'w') print('dcpomatic_%s-1_%s.deb video extra' % (version, cpu), file=f) shutil.rmtree('build/deb', ignore_errors=True) os.makedirs('build/deb') os.chdir('build/deb') shutil.move('../../dcpomatic-%s.tar.bz2' % version, 'dcpomatic_%s.orig.tar.bz2' % version) target.command('tar xjf dcpomatic_%s.orig.tar.bz2' % version) os.chdir('dcpomatic-%s' % version) target.command('dch -b -v %s-1 "New upstream release."' % version) target.set('CDIST_LINKFLAGS', target.get('LINKFLAGS')) target.set('CDIST_CXXFLAGS', target.get('CXXFLAGS')) target.set('CDIST_PKG_CONFIG_PATH', target.get('PKG_CONFIG_PATH')) target.set('CDIST_CONFIGURE', '"' + configure_options(target) + '"') if target.debug: target.set('CDIST_DEBUG_PACKAGE', '--dbg-package=dcpomatic-dbg') if target.version in ['15.04', '15.10', '16.04', '8']: target.set('CDIST_LOCALE_PREFIX', '/usr/share/locale') else: target.set('CDIST_LOCALE_PREFIX', '/usr/local/share/locale') target.command('dpkg-buildpackage -uc -us') debs = [] for p in glob.glob('../*.deb'): debs.append(os.path.abspath(p)) return debs def package_rpm(target, cpu, version): topdir = os.path.realpath('build/rpmbuild') os.makedirs('%s/BUILD' % topdir) os.makedirs('%s/RPMS' % topdir) os.makedirs('%s/SOURCES' % topdir) os.makedirs('%s/SPECS' % topdir) os.makedirs('%s/SRPMS' % topdir) target.command('./waf dist') shutil.copyfile( "%s/src/dcpomatic/dcpomatic-%s.tar.bz2" % (target.directory, version), "%s/SOURCES/dcpomatic-%s.tar.bz2" % (topdir, version) ) make_spec('build/platform/linux/dcpomatic2.spec', version, target) cmd = 'rpmbuild --define \'_topdir %s\' -bb build/platform/linux/dcpomatic2.spec' % topdir if target.distro == 'centos' and target.version == '5': cmd += ' --buildroot %s/BUILD/dcpomatic-%s/BUILDROOT' % (topdir, version) target.command(cmd) rpms = [] if cpu == "amd64": cpu = "x86_64" else: if target.distro == 'centos' and target.version == '5': cpu = "i386" else: cpu = "i686" print('Looking in %s/RPMS/%s/*.rpm' % (topdir, cpu)) for p in glob.glob('%s/RPMS/%s/*.rpm' % (topdir, cpu)): print('found %s' % p) rpms.append(os.path.abspath(p)) return rpms def package(target, version): if target.platform == 'windows': return package_windows(target) elif target.platform == 'linux': if target.bits == 32: cpu = 'i386' else: cpu = 'amd64' if target.distro == 'debian' or target.distro == 'ubuntu': return package_debian(target, cpu, version) elif target.distro == 'centos' or target.distro == 'fedora': return package_rpm(target, cpu, version) elif target.platform == 'osx': target.command('bash platform/osx/make_dmg.sh %s' % target.directory) return os.path.abspath(glob.glob('build/platform/osx/DCP-o-matic*.dmg')[0]) def make_pot(target): target.command('./waf pot') return [os.path.abspath('build/src/lib/libdcpomatic.pot'), os.path.abspath('build/src/wx/libdcpomatic-wx.pot'), os.path.abspath('build/src/tools/dcpomatic.pot')] def make_manual(target): os.chdir('doc/manual') target.command('make') target.command('pdflatex colour.tex') return [os.path.abspath('pdf'), os.path.abspath('html'), os.path.abspath('colour.pdf')] def test(target, test): if target.platform != 'windows': target.set('LC_ALL', 'C') if test is None: target.command('run/tests') else: target.command('run/tests --run_test=%s' % test)