3 # Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
5 # This file is part of DCP-o-matic.
7 # DCP-o-matic is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # DCP-o-matic is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
21 from __future__ import print_function
27 deb_build_depends = {'debhelper', 'python', 'g++', 'pkg-config', 'libssh-dev', 'libsndfile1-dev', 'libgtk2.0-dev'}
31 deb_depends_base = ['libc6', 'libssh-4', 'libsndfile1', 'libsamplerate0', 'libxmlsec1', 'libxmlsec1-openssl', 'libcurl3', 'libgtk2.0-0']
33 deb_depends['12.04'] = copy.deepcopy(deb_depends_base)
34 deb_depends['12.04'].extend(['libboost-filesystem1.48.0',
35 'libboost-thread1.48.0',
36 'libboost-regex1.48.0',
39 'libboost-date-time1.48.0',
43 deb_depends['14.04'] = copy.deepcopy(deb_depends_base)
44 deb_depends['14.04'].extend(['libboost-filesystem1.54.0',
45 'libboost-thread1.54.0',
46 'libboost-regex1.54.0',
49 'libboost-date-time1.54.0',
55 deb_depends['15.10'] = copy.deepcopy(deb_depends_base)
56 deb_depends['15.10'].extend(['libboost-filesystem1.58.0',
57 'libboost-thread1.58.0',
58 'libboost-regex1.58.0',
59 'libmagick++-6.q16-5v5',
61 'libboost-date-time1.58.0',
66 deb_depends['16.04'] = copy.deepcopy(deb_depends_base)
67 deb_depends['16.04'].extend(['libboost-filesystem1.58.0',
68 'libboost-thread1.58.0',
69 'libboost-regex1.58.0',
70 'libmagick++-6.q16-5v5',
72 'libboost-date-time1.58.0',
77 deb_depends['7'] = copy.deepcopy(deb_depends_base)
78 deb_depends['7'].extend(['libboost-filesystem1.49.0',
79 'libboost-thread1.49.0',
80 'libboost-regex1.49.0',
83 'libboost-date-time1.49.0',
89 deb_depends['8'] = copy.deepcopy(deb_depends_base)
90 deb_depends['8'].extend(['libboost-filesystem1.55.0',
91 'libboost-thread1.55.0',
92 'libboost-date-time1.55.0',
93 'libboost-regex1.55.0',
94 'libmagick++-6.q16-5',
102 deb_depends['unstable'] = copy.deepcopy(deb_depends_base)
103 deb_depends['unstable'].extend(['libboost-filesystem1.58.0',
104 'libboost-thread1.58.0',
105 'libboost-regex1.58.0',
106 'libmagick++-6.q16-5v5',
109 'libboost-date-time1.58.0',
113 def packages(name, packages, f):
117 print(s[:-2], file=f)
119 def make_control(debian_version, bits, filename, debug):
120 f = open(filename, 'w')
121 print('Source: dcpomatic', file=f)
122 print('Section: video', file=f)
123 print('Priority: extra', file=f)
124 print('Maintainer: Carl Hetherington <carl@dcpomatic.com>', file=f)
125 packages('Build-Depends', deb_build_depends, f)
126 print('Standards-Version: 3.9.3', file=f)
127 print('Homepage: http://dcpomatic.com/', file=f)
129 print('Package: dcpomatic', file=f)
131 print('Architecture: i386', file=f)
133 print('Architecture: amd64', file=f)
135 packages('Depends', deb_depends[debian_version], f)
137 print('Description: Generator of Digital Cinema Packages (DCPs)', file=f)
138 print(' DCP-o-matic generates Digital Cinema Packages (DCPs) from video and audio', file=f)
139 print(' files (such as those from DVDs or Blu-Rays) for presentation on DCI-compliant', file=f)
140 print(' digital projectors.', file=f)
144 print('Package: dcpomatic-dbg', file=f)
146 print('Architecture: i386', file=f)
148 print('Architecture: amd64', file=f)
149 print('Section: debug', file=f)
150 print('Priority: extra', file=f)
151 packages('Depends', deb_depends[debian_version], f)
152 print('Description: debugging symbols for dcpomatic', file=f)
153 print(' This package contains the debugging symbols for dcpomatic.', file=f)
156 def make_spec(filename, version, target):
157 """Make a .spec file for a RPM build"""
158 f = open(filename, 'w')
159 print('Summary:A program that generates Digital Cinema Packages (DCPs) from video and audio files', file=f)
160 print('Name:dcpomatic2', file=f)
161 print('Version:%s' % version, file=f)
162 print('Release:1%{?dist}', file=f)
163 print('License:GPL', file=f)
164 print('Group:Applications/Multimedia', file=f)
165 print('URL:http://dcpomatic.com/', file=f)
166 print('Requires: ImageMagick-c++, glibmm24, libzip', file=f)
168 print('%description', file=f)
169 print('DCP-o-matic generates Digital Cinema Packages (DCPs) from video and audio ', file=f)
170 print('files (such as those from DVDs or Blu-Rays) for presentation on DCI-compliant ', file=f)
171 print('digital projectors.', file=f)
173 print('%files', file=f)
174 print('%{_bindir}/dcpomatic2', file=f)
175 print('%{_bindir}/dcpomatic2_batch', file=f)
176 print('%{_bindir}/dcpomatic2_cli', file=f)
177 print('%{_bindir}/dcpomatic2_create', file=f)
178 print('%{_bindir}/dcpomatic2_kdm', file=f)
179 print('%{_bindir}/dcpomatic2_server', file=f)
180 print('%{_bindir}/dcpomatic2_server_cli', file=f)
181 print('%{_bindir}/dcpomatic2_kdm_cli', file=f)
182 print('%{_datadir}/applications/dcpomatic2.desktop', file=f)
183 print('%{_datadir}/applications/dcpomatic2_batch.desktop', file=f)
184 print('%{_datadir}/applications/dcpomatic2_server.desktop', file=f)
185 print('%{_datadir}/applications/dcpomatic2_kdm.desktop', file=f)
186 print('%{_datadir}/dcpomatic2/dcpomatic2_server_small.png', file=f)
187 print('%{_datadir}/dcpomatic2/LiberationSans-Regular.ttf', file=f)
188 print('%{_datadir}/dcpomatic2/LiberationSans-Italic.ttf', file=f)
189 print('%{_datadir}/dcpomatic2/LiberationSans-Bold.ttf', file=f)
190 print('%{_datadir}/dcpomatic2/splash.png', file=f)
191 for r in ['128x128', '16x16', '22x22', '256x256', '32x32', '48x48', '512x512', '64x64']:
192 print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2.png' % r, file=f)
193 print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_batch.png' % r, file=f)
194 print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_kdm.png' % r, file=f)
195 print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_server.png' % r, file=f)
196 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']:
197 print('%%{_datadir}/locale/%s/LC_MESSAGES/dcpomatic2.mo' % l, file=f)
198 print('%%{_datadir}/locale/%s/LC_MESSAGES/libdcpomatic2-wx.mo' % l, file=f)
199 print('%%{_datadir}/locale/%s/LC_MESSAGES/libdcpomatic2.mo' % l, file=f)
201 print('%prep', file=f)
202 print('rm -rf $RPM_BUILD_DIR/dcpomatic-%s' % version, file=f)
203 print('tar xjf $RPM_SOURCE_DIR/dcpomatic-%s.tar.bz2' % version, file=f)
204 print('%build', file=f)
205 print('cd dcpomatic-%s' % version, file=f)
206 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)
208 if target.distro == 'centos' and target.version == '5':
209 prefix = 'BUILDROOT/usr'
211 prefix = '%{buildroot}/usr'
213 print('CXXFLAGS="-I%s/include" LDFLAGS="-L%s/lib" ./waf configure --prefix=%s --install-prefix=/usr %s' %
214 (target.directory, target.directory, prefix, configure_options(target)), file=f)
215 print('./waf', file=f)
216 print('%install', file=f)
217 print('cd dcpomatic-%s' % version, file=f)
218 print('./waf install', file=f)
220 print('%post', file=f)
221 print('/bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :', file=f)
223 print('%postun', file=f)
224 print('if [ $1 -eq 0 ] ; then', file=f)
225 print(' /bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null', file=f)
226 print(' /usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :', file=f)
229 print('%posttrans', file=f)
230 print('/usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :', file=f)
232 def dependencies(target):
234 if target.platform == 'linux':
235 ffmpeg_options = { 'shared': False }
239 return (('ffmpeg-cdist', 'aab2fb1', ffmpeg_options),
240 ('libdcp', '89d5fe1'),
241 ('libsub', 'd848eed'))
243 def configure_options(target):
246 opt += ' --enable-debug'
247 if target.platform == 'windows':
248 opt += ' --target-windows'
249 elif target.platform == 'linux':
250 opt += ' --static-dcpomatic --static-wxwidgets --static-ffmpeg --static-dcp --static-sub --static-cxml'
251 if target.distro == 'centos':
252 opt += ' --static-xmlsec --static-ssh --disable-tests'
253 if target.version == '6.5':
254 opt += ' --static-boost --static-xmlpp'
255 elif target.version == '7':
256 opt += ' --workaround-gssapi --static-xmlpp'
260 def build(target, options):
261 target.command('./waf configure --prefix=%s %s' % (target.directory, configure_options(target)))
262 target.command('./waf')
264 if target.platform == 'linux' or target.platform == 'osx':
265 target.command('./waf install')
267 def package_windows(target):
269 if target.version is not None:
270 identifier = '%s.' % target.version
271 identifier += '%d' % target.bits
272 shutil.copyfile('build/platform/windows/installer.%s.nsi' % identifier, 'build/platform/windows/installer2.%s.nsi' % identifier)
273 target.command('sed -i "s~%%resources%%~%s/platform/windows~g" build/platform/windows/installer2.%s.nsi' % (os.getcwd(), identifier))
274 target.command('sed -i "s~%%graphics%%~%s/graphics~g" build/platform/windows/installer2.%s.nsi' % (os.getcwd(), identifier))
275 target.command('sed -i "s~%%static_deps%%~%s~g" build/platform/windows/installer2.%s.nsi' % (target.windows_prefix, identifier))
276 target.command('sed -i "s~%%cdist_deps%%~%s~g" build/platform/windows/installer2.%s.nsi' % (target.directory, identifier))
277 target.command('sed -i "s~%%mingw%%~%s~g" build/platform/windows/installer2.%s.nsi' % (target.mingw_path, identifier))
278 target.command('sed -i "s~%%binaries%%~%s/build~g" build/platform/windows/installer2.%s.nsi' % (os.getcwd(), identifier))
279 target.command('sed -i "s~%%bits%%~32~g" build/platform/windows/installer2.%s.nsi' % identifier)
280 target.command('makensis build/platform/windows/installer2.%s.nsi' % identifier)
281 return os.path.abspath(glob.glob('build/platform/windows/*%s*.exe' % target.bits)[0])
283 def package_debian(target, cpu, version):
284 make_control(target.version, target.bits, 'debian/control', target.debug)
285 target.command('./waf dist')
286 f = open('debian/files', 'w')
287 print('dcpomatic_%s-1_%s.deb video extra' % (version, cpu), file=f)
288 shutil.rmtree('build/deb', ignore_errors=True)
290 os.makedirs('build/deb')
291 os.chdir('build/deb')
292 shutil.move('../../dcpomatic-%s.tar.bz2' % version, 'dcpomatic_%s.orig.tar.bz2' % version)
293 target.command('tar xjf dcpomatic_%s.orig.tar.bz2' % version)
294 os.chdir('dcpomatic-%s' % version)
295 target.command('dch -b -v %s-1 "New upstream release."' % version)
296 target.set('CDIST_LINKFLAGS', target.get('LINKFLAGS'))
297 target.set('CDIST_CXXFLAGS', target.get('CXXFLAGS'))
298 target.set('CDIST_PKG_CONFIG_PATH', target.get('PKG_CONFIG_PATH'))
300 target.set('CDIST_CONFIGURE', '"' + configure_options(target) + '"')
302 target.set('CDIST_DEBUG_PACKAGE', '--dbg-package=dcpomatic-dbg')
303 if target.version in ['15.04', '15.10', '16.04', '8']:
304 target.set('CDIST_LOCALE_PREFIX', '/usr/share/locale')
306 target.set('CDIST_LOCALE_PREFIX', '/usr/local/share/locale')
308 target.command('dpkg-buildpackage -uc -us')
311 for p in glob.glob('../*.deb'):
312 debs.append(os.path.abspath(p))
316 def package_rpm(target, cpu, version):
317 topdir = os.path.realpath('build/rpmbuild')
318 os.makedirs('%s/BUILD' % topdir)
319 os.makedirs('%s/RPMS' % topdir)
320 os.makedirs('%s/SOURCES' % topdir)
321 os.makedirs('%s/SPECS' % topdir)
322 os.makedirs('%s/SRPMS' % topdir)
324 target.command('./waf dist')
326 "%s/src/dcpomatic/dcpomatic-%s.tar.bz2" % (target.directory, version),
327 "%s/SOURCES/dcpomatic-%s.tar.bz2" % (topdir, version)
330 make_spec('build/platform/linux/dcpomatic2.spec', version, target)
331 cmd = 'rpmbuild --define \'_topdir %s\' -bb build/platform/linux/dcpomatic2.spec' % topdir
332 if target.distro == 'centos' and target.version == '5':
333 cmd += ' --buildroot %s/BUILD/dcpomatic-%s/BUILDROOT' % (topdir, version)
342 print('Looking in %s/RPMS/%s/*.rpm' % (topdir, cpu))
343 for p in glob.glob('%s/RPMS/%s/*.rpm' % (topdir, cpu)):
344 print('found %s' % p)
345 rpms.append(os.path.abspath(p))
349 def package(target, version):
350 if target.platform == 'windows':
351 return package_windows(target)
352 elif target.platform == 'linux':
353 if target.bits == 32:
358 if target.distro == 'debian' or target.distro == 'ubuntu':
359 return package_debian(target, cpu, version)
360 elif target.distro == 'centos' or target.distro == 'fedora':
361 return package_rpm(target, cpu, version)
362 elif target.platform == 'osx':
363 target.command('bash platform/osx/make_dmg.sh %s' % target.directory)
364 return os.path.abspath(glob.glob('build/platform/osx/DCP-o-matic*.dmg')[0])
366 def make_pot(target):
367 target.command('./waf pot')
368 return [os.path.abspath('build/src/lib/libdcpomatic.pot'),
369 os.path.abspath('build/src/wx/libdcpomatic-wx.pot'),
370 os.path.abspath('build/src/tools/dcpomatic.pot')]
372 def make_manual(target):
373 os.chdir('doc/manual')
374 target.command('make')
375 target.command('pdflatex colour.tex')
376 return [os.path.abspath('pdf'), os.path.abspath('html'), os.path.abspath('colour.pdf')]
378 def test(target, test):
379 if target.platform != 'windows':
380 target.set('LC_ALL', 'C')
382 target.command('run/tests')
384 target.command('run/tests --run_test=%s' % test)