3 # Copyright (C) 2012-2020 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
29 headline = "DCP-o-matic is a suite of tools to allow the creation, manipulation and playback of Digital Cinema Packages (DCPs)."
30 description = "DCP-o-matic can create DCPs from videos, images, sound and subtitle files. You can use it to make content for playback on DCI-compliant cinema projectors, as used in most of the world's digital cinemas. It also includes a DCP player and tools to verify DCPs and write them to distribution drives."
31 maintainer_name = "Carl Hetherington"
32 maintainer_email = "carl@dcpomatic.com"
33 homepage = "https://dcpomatic.com"
35 deb_build_depends = dict()
37 deb_build_depends_base = ['debhelper', 'python', 'g++', 'pkg-config', 'libsndfile1-dev', 'libgtk2.0-dev', 'libx264-dev']
39 deb_build_depends['16.04'] = copy.deepcopy(deb_build_depends_base)
40 deb_build_depends['16.04'].extend(['libssh-dev'])
41 deb_build_depends['18.04'] = copy.deepcopy(deb_build_depends_base)
42 deb_build_depends['18.04'].extend(['libssh-dev'])
43 deb_build_depends['19.10'] = copy.deepcopy(deb_build_depends_base)
44 deb_build_depends['19.10'].extend(['libssh-dev'])
45 deb_build_depends['20.04'] = copy.deepcopy(deb_build_depends_base)
46 deb_build_depends['20.04'].extend(['libssh-dev'])
47 deb_build_depends['9'] = copy.deepcopy(deb_build_depends_base)
48 deb_build_depends['9'].extend(['libssh-gcrypt-dev'])
49 deb_build_depends['10'] = copy.deepcopy(deb_build_depends_base)
50 deb_build_depends['10'].extend(['libssh-gcrypt-dev'])
51 deb_build_depends['unstable'] = copy.deepcopy(deb_build_depends_base)
54 deb_depends_gui = dict()
56 deb_depends_base = ['libc6', 'libsndfile1', 'libsamplerate0', 'libxmlsec1', 'libxmlsec1-openssl', 'libgtk2.0-0']
58 deb_depends['16.04'] = copy.deepcopy(deb_depends_base)
59 deb_depends['16.04'].extend(['libboost-filesystem1.58.0',
60 'libboost-thread1.58.0',
61 'libboost-regex1.58.0',
63 'libboost-date-time1.58.0',
75 deb_depends['18.04'] = copy.deepcopy(deb_depends_base)
76 deb_depends['18.04'].extend(['libboost-filesystem1.65.1',
77 'libboost-thread1.65.1',
78 'libboost-regex1.65.1',
79 'libboost-date-time1.65.1',
94 deb_depends['19.10'] = copy.deepcopy(deb_depends_base)
95 deb_depends['19.10'].extend(['libboost-filesystem1.67.0',
96 'libboost-thread1.67.0',
97 'libboost-regex1.67.0',
98 'libboost-date-time1.67.0',
100 'libpangomm-1.4-1v5',
113 deb_depends['20.04'] = copy.deepcopy(deb_depends_base)
114 deb_depends['20.04'].extend(['libboost-filesystem1.71.0',
115 'libboost-thread1.71.0',
116 'libboost-regex1.71.0',
117 'libboost-date-time1.71.0',
118 'libcairomm-1.0-1v5',
119 'libpangomm-1.4-1v5',
122 'libwxgtk3.0-gtk3-0v5',
132 deb_depends['9'] = copy.deepcopy(deb_depends_base)
133 deb_depends['9'].extend(['libboost-filesystem1.62.0',
134 'libboost-thread1.62.0',
135 'libboost-regex1.62.0',
136 'libboost-date-time1.62.0',
140 'libcairomm-1.0-1v5',
141 'libpangomm-1.4-1v5',
150 deb_depends_gui['9'] = [ 'libwxgtk3.0-0v5',
156 deb_depends['10'] = copy.deepcopy(deb_depends_base)
157 deb_depends['10'].extend(['libboost-filesystem1.67.0',
158 'libboost-thread1.67.0',
159 'libboost-regex1.67.0',
160 'libboost-date-time1.67.0',
164 'libcairomm-1.0-1v5',
165 'libpangomm-1.4-1v5',
175 deb_depends_gui['10'] = [ 'libwxgtk3.0-0v5',
181 deb_depends['unstable'] = copy.deepcopy(deb_depends_base)
182 deb_depends['unstable'].extend(['libboost-filesystem1.67.0',
183 'libboost-thread1.67.0',
184 'libboost-regex1.67.0',
185 'libboost-date-time1.67.0',
195 def can_build_disk(target):
196 # We can build dcpomatic2_disk on platforms that have Boost process and can build the lwext4
197 # library. For now, just whitelist good ones here.
199 # - Lots of Linux distros (including Ubuntu 16.04) don't have a new enough boost (1.64 or above)
200 # - On Centos 6 we can't build lwext4 because it needs a new CMake which Centos 6's g++ is not new enough to build.
201 # - On Centos 7 there is a build error in lwext4 related to __unused
202 if target.platform == 'windows':
204 if target.platform == 'osx':
206 if target.platform == 'linux':
207 if target.distro == 'ubuntu' and target.version in ['18.04', '19.10', '20.04']:
209 if target.distro == 'debian' and target.version == '10':
211 if target.detail == 'appimage':
213 if target.distro == 'fedora' and target.version == '31':
215 if target.distro == 'centos' and target.version == '8':
219 def packages(name, packages, f):
223 print(s[:-2], file=f)
225 def make_control(debian_version, bits, filename, debug, gui):
226 f = open(filename, 'w')
227 print('Source: dcpomatic', file=f)
228 print('Section: video', file=f)
229 print('Priority: extra', file=f)
230 print('Maintainer: %s <%s>' % (maintainer_name, maintainer_email), file=f)
231 packages('Build-Depends', deb_build_depends[debian_version], f)
232 print('Standards-Version: 3.9.3', file=f)
233 print('Homepage: %s' % homepage, file=f)
235 print('Package: dcpomatic', file=f)
237 print('Architecture: i386', file=f)
239 print('Architecture: amd64', file=f)
241 pkg = deb_depends[debian_version]
242 if gui and debian_version in deb_depends_gui:
243 pkg.extend(deb_depends_gui[debian_version])
245 packages('Depends', pkg, f)
247 print('Description: %s' % headline, file=f)
248 print(' %s' % description, file=f)
252 print('Package: dcpomatic-dbg', file=f)
254 print('Architecture: i386', file=f)
256 print('Architecture: amd64', file=f)
257 print('Section: debug', file=f)
258 print('Priority: extra', file=f)
259 packages('Depends', pkg, f)
260 print('Description: debugging symbols for dcpomatic', file=f)
261 print(' This package contains the debugging symbols for dcpomatic.', file=f)
264 def make_spec(filename, version, target, options, requires=None):
265 """Make a .spec file for a RPM build"""
266 tools = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(filename))), "src/tools")
267 f = open(filename, 'w')
268 print('Summary:%s' % headline, file=f)
269 print('Name:dcpomatic2', file=f)
270 print('Version:%s' % version, file=f)
271 print('Release:1%{?dist}', file=f)
272 print('License:GPL', file=f)
273 print('Group:Applications/Multimedia', file=f)
274 print('URL:%s' % homepage, file=f)
275 if requires is not None:
276 print('Requires:%s' % requires, file=f)
278 print('%description', file=f)
279 for line in textwrap.wrap(description, 50):
282 print('%files', file=f)
283 print('%{_bindir}/dcpomatic2', file=f)
284 print('%{_bindir}/dcpomatic2_batch', file=f)
285 print('%{_bindir}/dcpomatic2_cli', file=f)
286 print('%{_bindir}/dcpomatic2_create', file=f)
287 print('%{_bindir}/dcpomatic2_kdm', file=f)
288 print('%{_bindir}/dcpomatic2_server', file=f)
289 print('%{_bindir}/dcpomatic2_server_cli', file=f)
290 print('%{_bindir}/dcpomatic2_kdm_cli', file=f)
291 print('%{_bindir}/dcpomatic2_player', file=f)
292 print('%{_bindir}/dcpomatic2_playlist', file=f)
293 print('%{_bindir}/dcpomatic2_openssl', file=f)
294 if options['variant'] == 'swaroop-studio':
295 print('%{_bindir}/dcpomatic2_ecinema', file=f)
296 print('%{_bindir}/dcpomatic2_uuid', file=f)
297 if os.path.exists(os.path.join(tools, "dcpomatic2_disk")):
298 print('%{_bindir}/dcpomatic2_disk', file=f)
299 print('%{_bindir}/dcpomatic2_disk_writer', file=f)
300 print('%{_datadir}/applications/dcpomatic2.desktop', file=f)
301 print('%{_datadir}/applications/dcpomatic2_batch.desktop', file=f)
302 print('%{_datadir}/applications/dcpomatic2_server.desktop', file=f)
303 print('%{_datadir}/applications/dcpomatic2_kdm.desktop', file=f)
304 print('%{_datadir}/applications/dcpomatic2_player.desktop', file=f)
305 print('%{_datadir}/applications/dcpomatic2_playlist.desktop', file=f)
306 print('%{_datadir}/applications/dcpomatic2_playlist.desktop', file=f)
307 if os.path.exists(os.path.join(tools, "dcpomatic2_disk")):
308 print('%{_datadir}/applications/dcpomatic2_disk.desktop', file=f)
309 print('%{_datadir}/dcpomatic2/dcpomatic2_server_small.png', file=f)
310 print('%{_datadir}/dcpomatic2/select.png', file=f)
311 print('%{_datadir}/dcpomatic2/sequence.png', file=f)
312 print('%{_datadir}/dcpomatic2/snap.png', file=f)
313 print('%{_datadir}/dcpomatic2/zoom.png', file=f)
314 print('%{_datadir}/dcpomatic2/zoom_all.png', file=f)
315 print('%{_datadir}/dcpomatic2/tick.png', file=f)
316 print('%{_datadir}/dcpomatic2/no_tick.png', file=f)
317 print('%{_datadir}/dcpomatic2/link.png', file=f)
318 print('%{_datadir}/dcpomatic2/me.jpg', file=f)
319 print('%{_datadir}/dcpomatic2/LiberationSans-Regular.ttf', file=f)
320 print('%{_datadir}/dcpomatic2/LiberationSans-Italic.ttf', file=f)
321 print('%{_datadir}/dcpomatic2/LiberationSans-Bold.ttf', file=f)
322 print('%{_datadir}/dcpomatic2/splash.png', file=f)
323 for r in ['128x128', '16x16', '22x22', '256x256', '32x32', '48x48', '512x512', '64x64']:
324 print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2.png' % r, file=f)
325 print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_batch.png' % r, file=f)
326 print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_kdm.png' % r, file=f)
327 print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_server.png' % r, file=f)
328 print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_player.png' % r, file=f)
329 print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_playlist.png' % r, file=f)
330 print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_disk.png' % r, file=f)
331 for l in ['de_DE', 'es_ES', 'fr_FR', 'it_IT', 'sv_SE', 'nl_NL', 'ru_RU', 'pl_PL', 'da_DK',
332 'pt_PT', 'pt_BR', 'sk_SK', 'cs_CZ', 'uk_UA', 'zh_CN', 'tr_TR', 'ko_KR']:
333 print('%%{_datadir}/locale/%s/LC_MESSAGES/dcpomatic2.mo' % l, file=f)
334 print('%%{_datadir}/locale/%s/LC_MESSAGES/libdcpomatic2-wx.mo' % l, file=f)
335 print('%%{_datadir}/locale/%s/LC_MESSAGES/libdcpomatic2.mo' % l, file=f)
337 print('%prep', file=f)
338 print('rm -rf $RPM_BUILD_DIR/dcpomatic-%s' % version, file=f)
339 print('tar xjf $RPM_SOURCE_DIR/dcpomatic-%s.tar.bz2' % version, file=f)
340 print('%build', file=f)
341 print('cd dcpomatic-%s' % version, file=f)
342 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)
343 print('CXXFLAGS="-I%s/include" LDFLAGS="-L%s/lib" ./waf configure --prefix=%%{buildroot}/usr --install-prefix=/usr %s' %
344 (target.directory, target.directory, configure_options(target, options)), file=f)
345 print('./waf', file=f)
346 print('%install', file=f)
347 print('cd dcpomatic-%s' % version, file=f)
348 print('./waf install', file=f)
349 print('/bin/cp %s/src/openssl/apps/openssl %%{buildroot}/usr/bin/dcpomatic2_openssl' % target.directory, file=f)
351 print('%post', file=f)
352 print('/bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :', file=f)
354 print('%postun', file=f)
355 print('if [ $1 -eq 0 ] ; then', file=f)
356 print(' /bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null', file=f)
357 print(' /usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :', file=f)
360 print('%posttrans', file=f)
361 print('/usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :', file=f)
363 def dependencies(target, options):
365 if target.platform == 'linux':
366 ffmpeg_options = { 'shared': False }
370 if target.platform == 'windows' and target.version == 'xp':
371 deps = [('ffmpeg-cdist', '5783efa', ffmpeg_options)]
372 elif target.platform != 'linux' or target.distro != 'arch':
373 deps = [('ffmpeg-cdist', '7427ffe', ffmpeg_options)]
375 # Use distro-provided FFmpeg on Arch
378 # Let's use C++11 mode if we can
379 cpp_lib_options = {'force-cpp11': True} if (
380 (target.platform == 'osx' and target.bits == 64) or
381 (target.platform == 'windows')) else {}
383 deps.append(('libdcp', None, cpp_lib_options))
384 deps.append(('libsub', None, cpp_lib_options))
385 deps.append(('leqm-nrt', 'carl'))
386 deps.append(('rtaudio', 'carl'))
387 # We get our OpenSSL libraries from the environment, but we
388 # also need a patched openssl binary to make certificates.
389 # This dependency is to get that binary, which is added into
390 # the appropriate place later
391 deps.append(('openssl', 'carl'))
392 if can_build_disk(target):
393 deps.append(('lwext4', '370b3de6'))
397 option_defaults = { "gui": True, "variant": None }
399 def configure_options(target, options):
402 if not (target.platform == 'linux' and target.distro == 'ubuntu' and target.version == '18.04'):
403 # Currently we only build tests on Ubuntu 18.04
404 opt += ' --disable-tests'
407 opt += ' --enable-debug'
408 if target.platform == 'windows':
409 opt += ' --target-windows'
410 elif target.platform == 'linux':
411 opt += ' --static-dcpomatic --static-wxwidgets --static-ffmpeg --static-dcp --static-sub --static-cxml'
412 if target.distro == 'centos':
413 if target.version == '6.5':
414 opt += ' --static-boost --static-xmlpp'
415 elif target.version == '7':
416 opt += ' --workaround-gssapi'
417 # Centos 7 ships with glibmm 2.50.0 which requires C++11
418 # but its compiler (gcc 4.8.5) defaults to C++97. Go figure.
419 # I worry that this will cause ABI problems but I don't have
421 opt += ' --force-cpp11'
422 elif target.platform == 'osx' and target.bits == 64:
423 opt += ' --force-cpp11'
425 if not options['gui']:
426 opt += ' --disable-gui'
428 if options['variant'] is not None:
429 opt += ' --variant=%s' % options['variant']
431 # Build Windows debug versions with static linking as I think gdb works better then
432 if target.debug and target.platform == 'windows':
433 opt += ' --static-dcpomatic'
435 if can_build_disk(target):
436 opt += ' --enable-disk'
440 def build(target, options):
441 if target.platform == 'flatpak':
442 target.checkout_dependencies()
443 prefix = 'https://dcpomatic.com/deps'
445 modules.append({'name': 'libzip',
446 'buildsystem': 'cmake',
447 'sources': [{'type': 'archive',
448 'url': '%s/libzip-1.4.0.tar.xz' % prefix,
449 'sha256': 'e508aba025f5f94b267d5120fc33761bcd98440ebe49dbfe2ed3df3afeacc7b1'}]})
450 modules.append({'name': 'libsigc++',
451 'sources': [{'type': 'archive',
452 'url': '%s/libsigc++-2.10.0.tar.xz' % prefix,
453 'sha256': 'f843d6346260bfcb4426259e314512b99e296e8ca241d771d21ac64f28298d81'}]})
454 modules.append({'name': 'glibmm',
455 'sources': [{'type': 'archive',
456 'url': '%s/glibmm-2.48.1.tar.xz' % prefix,
457 'sha256': 'dc225f7d2f466479766332483ea78f82dc349d59399d30c00de50e5073157cdf'}]})
458 modules.append({'name': 'cairomm',
459 'sources': [{'type': 'archive',
460 'url': '%s/cairomm-1.12.2.tar.gz' % prefix,
461 'sha256': '45c47fd4d0aa77464a75cdca011143fea3ef795c4753f6e860057da5fb8bd599'}]})
462 modules.append({'name': 'pangomm',
463 'sources': [{'type': 'archive',
464 'url': '%s/pangomm-2.40.1.tar.xz' % prefix,
465 'sha256': '9762ee2a2d5781be6797448d4dd2383ce14907159b30bc12bf6b08e7227be3af'}]})
466 modules.append({'name': 'libxml++',
467 'sources': [{'type': 'archive',
468 'url': '%s/libxml++-2.40.1.tar.xz' % prefix,
469 'sha256': '4ad4abdd3258874f61c2e2a41d08e9930677976d303653cd1670d3e9f35463e9'}]})
470 modules.append({'name': 'xmlsec1',
471 'sources': [{'type': 'archive',
472 'url': '%s/xmlsec1-1.2.25.tar.gz' % prefix,
473 'sha256': '967ca83edf25ccb5b48a3c4a09ad3405a63365576503bf34290a42de1b92fcd2'}]})
474 modules.append({'name': 'openjpeg2',
475 'buildsystem': 'cmake',
476 'sources': [{'type': 'dir', 'path': os.path.abspath('../openjpeg2-cdist')}]})
477 modules.append({'name': 'boost',
478 'buildsystem': 'simple',
480 './bootstrap.sh --prefix=/app',
483 'sources': [{'type': 'archive',
484 'url': '%s/boost_1_66_0.tar.bz2' % prefix,
485 'sha256': '5721818253e6a0989583192f96782c4a98eb6204965316df9f5ad75819225ca9'}]})
486 modules.append({'name': 'asdcplib',
487 'buildsystem': 'simple',
489 './waf configure --prefix=/app --libdir=/app/lib build install'
491 'sources': [{'type': 'dir', 'path': os.path.abspath('../asdcplib-carl')}]})
492 modules.append({'name': 'locked_sstream',
493 'buildsystem': 'simple',
495 './waf configure --prefix=/app build install'
497 'sources': [{'type': 'dir', 'path': os.path.abspath('../locked_sstream')}]})
498 modules.append({'name': 'libcxml',
499 'buildsystem': 'simple',
501 './waf configure --prefix=/app --libdir=/app/lib build install'
503 'sources': [{'type': 'dir', 'path': os.path.abspath('../libcxml')}]})
504 modules.append({'name': 'libdcp',
505 'buildsystem': 'simple',
507 './waf configure --prefix=/app --libdir=/app/lib build install'
509 'sources': [{'type': 'dir', 'path': os.path.abspath('../libdcp')}]})
510 modules.append({'name': 'libsub',
511 'buildsystem': 'simple',
513 './waf configure --prefix=/app --libdir=/app/lib build install'
515 'sources': [{'type': 'dir', 'path': os.path.abspath('../libsub')}]})
516 modules.append({'name': 'rtaudio',
524 'sources': [{'type': 'dir', 'path': os.path.abspath('../rtaudio-cdist')}]})
525 modules.append({'name': 'wxwidgets',
526 'sources': [{'type': 'archive',
527 'url': '%s/wxWidgets-3.0.3.tar.bz2' % prefix,
528 'sha256': '08c8033f48ec1b23520f036cde37b5ae925a6a65f137ded665633ca159b9307b'}]})
529 modules.append({'name': 'libssh',
530 'buildsystem': 'cmake',
532 'sources': [{'type': 'archive',
533 'url': '%s/libssh-0.7.5.tar.xz' % prefix,
534 'sha256': '54e86dd5dc20e5367e58f3caab337ce37675f863f80df85b6b1614966a337095'}]})
535 modules.append({'name': 'dcpomatic',
536 'buildsystem': 'simple',
538 './waf configure --prefix=/app build install'
541 'build-args': ['--share=network']
543 'sources': [{'type': 'dir', 'path': os.path.abspath('.')}]})
544 desc = {'app-id': 'com.dcpomatic.DCP-o-matic',
545 'runtime': 'org.gnome.Sdk',
546 'runtime-version': '3.26',
547 'sdk': 'org.gnome.Sdk',
548 'command': 'dcpomatic2',
549 'finish-args': ['--socket=x11', '--share=ipc', '--share=network', '--socket=pulseaudio', '--filesystem=host'],
551 os.makedirs('build/platform')
552 with open('build/com.dcpomatic.DCP-o-matic.json', 'w') as outfile:
553 json.dump(desc, outfile)
554 target.command('%s --repo=build/platform/repo build/platform/flatpak build/com.dcpomatic.DCP-o-matic.json' % target.flatpak_builder())
556 target.command('./waf configure --prefix=%s %s' % (target.directory, configure_options(target, options)))
557 target.command('./waf')
559 if target.platform == 'linux' or target.platform == 'osx':
560 target.command('./waf install')
562 def package_windows(target):
564 if target.version is not None:
565 identifier = '%s.' % target.version
566 identifier += '%d' % target.bits
567 shutil.copyfile('build/platform/windows/installer.%s.nsi' % identifier, 'build/platform/windows/installer2.%s.nsi' % identifier)
568 target.command('sed -i "s~%%resources%%~%s/platform/windows~g" build/platform/windows/installer2.%s.nsi' % (os.getcwd(), identifier))
569 target.command('sed -i "s~%%graphics%%~%s/graphics~g" build/platform/windows/installer2.%s.nsi' % (os.getcwd(), identifier))
570 target.command('sed -i "s~%%static_deps%%~%s~g" build/platform/windows/installer2.%s.nsi' % (target.windows_prefix, identifier))
571 target.command('sed -i "s~%%cdist_deps%%~%s~g" build/platform/windows/installer2.%s.nsi' % (target.directory, identifier))
572 target.command('sed -i "s~%%mingw%%~%s~g" build/platform/windows/installer2.%s.nsi' % (target.environment_prefix, identifier))
573 target.command('sed -i "s~%%binaries%%~%s/build~g" build/platform/windows/installer2.%s.nsi' % (os.getcwd(), identifier))
574 target.command('sed -i "s~%%bits%%~32~g" build/platform/windows/installer2.%s.nsi' % identifier)
575 target.command('makensis build/platform/windows/installer2.%s.nsi' % identifier)
576 return os.path.abspath(glob.glob('build/platform/windows/*%s*.exe' % target.bits)[0])
578 def package_debian(target, cpu, version, options):
579 make_control(target.version, target.bits, 'debian/control', target.debug, options['gui'])
580 target.command('./waf dist')
581 f = open('debian/files', 'w')
582 print('dcpomatic_%s-1_%s.deb video extra' % (version, cpu), file=f)
583 shutil.rmtree('build/deb', ignore_errors=True)
585 os.makedirs('build/deb')
586 os.chdir('build/deb')
587 shutil.move('../../dcpomatic-%s.tar.bz2' % version, 'dcpomatic_%s.orig.tar.bz2' % version)
588 target.command('tar xjf dcpomatic_%s.orig.tar.bz2' % version)
589 os.chdir('dcpomatic-%s' % version)
590 target.command('dch -b -v %s-1 "New upstream release."' % version)
591 target.set('CDIST_LINKFLAGS', target.get('LINKFLAGS'))
592 target.set('CDIST_CXXFLAGS', target.get('CXXFLAGS'))
593 target.set('CDIST_PKG_CONFIG_PATH', target.get('PKG_CONFIG_PATH'))
594 target.set('CDIST_DIRECTORY', target.directory)
596 target.set('CDIST_CONFIGURE', '"' + configure_options(target, options) + '"')
598 target.set('CDIST_DEBUG_PACKAGE', '--dbg-package=dcpomatic-dbg')
600 target.command('dpkg-buildpackage -uc -us')
603 for p in glob.glob('../*.deb'):
604 debs.append(os.path.abspath(p))
608 def package_rpm(target, cpu, version, options):
609 topdir = os.path.realpath('build/rpmbuild')
610 os.makedirs('%s/BUILD' % topdir)
611 os.makedirs('%s/RPMS' % topdir)
612 os.makedirs('%s/SOURCES' % topdir)
613 os.makedirs('%s/SPECS' % topdir)
614 os.makedirs('%s/SRPMS' % topdir)
616 target.command('./waf dist')
618 "%s/src/dcpomatic/dcpomatic-%s.tar.bz2" % (target.directory, version),
619 "%s/SOURCES/dcpomatic-%s.tar.bz2" % (topdir, version)
623 if target.distro == 'mageia':
624 requires = "lib64xmlsec1-devel"
626 make_spec('build/platform/linux/dcpomatic2.spec', version, target, options, requires)
627 cmd = 'rpmbuild --define "_topdir %s" -bb build/platform/linux/dcpomatic2.spec' % topdir
636 for p in glob.glob('%s/RPMS/%s/*.rpm' % (topdir, cpu)):
637 rpms.append(os.path.abspath(p))
641 def make_appimage(target, nice_name, internal_name, version):
642 nice_filename = nice_name.replace(' ', '_')
643 os.makedirs('build/%s.AppDir/usr/bin' % nice_filename)
644 target.command('cp %s/bin/%s build/%s.AppDir/usr/bin' % (target.directory, internal_name, nice_filename))
645 target.command('cp %s/src/openssl/apps/openssl build/%s.AppDir/usr/bin/dcpomatic2_openssl' % (target.directory, nice_filename))
646 target.command('mkdir -p build/%s.AppDir/usr/share/libdcp' % nice_filename)
647 target.command('cp -r %s/share/libdcp/xsd build/%s.AppDir/usr/share/libdcp/' % (target.directory, nice_filename))
648 with open('build/%s.AppDir/AppRun' % nice_filename, 'w') as f:
649 print('#!/bin/bash', file=f)
650 print('export APPDIR="$(dirname "$(readlink -f "$0")")"', file=f)
651 print('export PATH=$APPDIR/usr/bin:$PATH', file=f)
652 print('export XDG_DATA_DIRS="$APPDIR/usr/share/:/usr/share/:$XDG_DATA_DIRS"', file=f)
653 print('"$APPDIR"/usr/bin/%s $@' % internal_name, file=f)
654 target.command('chmod a+rx build/%s.AppDir/AppRun' % nice_filename)
655 with open('build/%s.AppDir/%s.desktop' % (nice_filename, internal_name), 'w') as f:
656 print('[Desktop Entry]', file=f)
657 print('Type=Application', file=f)
658 print('Categories=AudioVideo;', file=f)
659 print('Name=%s' % nice_name, file=f)
660 print('Icon=%s' % internal_name, file=f)
661 target.command('cp graphics/linux/256/%s.png build/%s.AppDir' % (internal_name, nice_filename))
662 target.command('linuxdeploy-x86_64.AppImage --appdir build/%s.AppDir' % nice_filename)
663 target.command('appimagetool-x86_64.AppImage build/%s.AppDir' % nice_filename)
664 target.command('mv %s-x86_64.AppImage build/%s-%s-x86_64.AppImage' % (nice_filename, nice_filename, version))
665 return os.path.abspath('build/%s-%s-x86_64.AppImage' % (nice_filename, version))
667 def package(target, version, options):
668 """version: DCP-o-matic version string"""
669 if target.platform == 'windows':
670 return package_windows(target)
671 elif target.platform == 'linux':
672 if target.detail == 'appimage':
674 out.append(make_appimage(target, 'DCP-o-matic', 'dcpomatic2', version))
675 out.append(make_appimage(target, 'DCP-o-matic Player', 'dcpomatic2_player', version))
676 out.append(make_appimage(target, 'DCP-o-matic Playlist Editor', 'dcpomatic2_playlist', version))
677 out.append(make_appimage(target, 'DCP-o-matic KDM Creator', 'dcpomatic2_kdm', version))
678 out.append(make_appimage(target, 'DCP-o-matic Batch Converter', 'dcpomatic2_batch', version))
679 out.append(make_appimage(target, 'DCP-o-matic Encode Server', 'dcpomatic2_server', version))
680 out.append(make_appimage(target, 'DCP-o-matic Disk Writer', 'dcpomatic2_disk', version))
683 if target.bits == 32:
688 if target.distro == 'debian' or target.distro == 'ubuntu':
689 return package_debian(target, cpu, version, options)
690 elif target.distro == 'centos' or target.distro == 'fedora' or target.distro == 'mageia':
691 return package_rpm(target, cpu, version, options)
692 elif target.platform == 'osx' and target.bits is None:
693 target.command('bash platform/osx/make_dmg.sh %s %s universal no %s %s' % (target.environment_prefix, target.directory, target.apple_id, target.apple_password))
694 return [os.path.abspath(x) for x in glob.glob('build/platform/osx/DCP-o-matic*.dmg')]
695 elif target.platform == 'osx' and target.bits == 64:
696 target.command('bash platform/osx/make_dmg.sh %s %s thin %s %s' % (target.environment_prefix, target.directory, target.apple_id, target.apple_password))
697 return [os.path.abspath(x) for x in glob.glob('build/platform/osx/DCP-o-matic*.dmg')]
698 elif target.platform == 'docker':
699 shutil.copyfile(target.deb, 'build/platform/docker')
700 f = open('build/platform/docker/Dockerfile', 'w')
701 print('FROM debian:jessie', file=f)
702 print('MAINTAINER %s' % maintainer_email, file=f)
703 print('ADD build/platform/docker/dcpomatic_%s-1_amd64.deb /tmp' % (version, version), file=f)
704 print('RUN apt-get -o Acquire:http::Timeout="5" update; exit 0', file=f)
705 print('RUN dpkg -i /tmp/dcpomatic_*.deb; exit 0', file=f)
706 print('RUN apt-get -y -f install', file=f)
707 print('RUN apt-get clean', file=f)
708 print('EXPOSE 6192', file=f)
709 print('CMD ["/usr/bin/dcpomatic2_server_cli", "--verbose"]', file=f)
711 target.command('docker build build/platform/docker -t dcpomatic-server:%s' % version)
712 target.command('docker save dcpomatic-server:%s -o dcpomatic-server-%s-docker.tar' % (version, version))
713 elif target.platform == 'flatpak':
714 target.command('%s build-bundle build/platform/repo build/dcpomatic_%s.flatpak com.dcpomatic.DCP-o-matic' % (target.flatpak(), version))
715 return os.path.abspath('build/dcpomatic_%s.flatpak' % version)
717 def make_pot(target):
718 target.command('./waf pot')
719 return [os.path.abspath('build/src/lib/libdcpomatic.pot'),
720 os.path.abspath('build/src/wx/libdcpomatic-wx.pot'),
721 os.path.abspath('build/src/tools/dcpomatic.pot')]
723 def make_manual(target):
724 os.chdir('doc/manual')
725 target.command('make')
726 target.command('pdflatex colour.tex')
727 return [os.path.abspath('pdf'), os.path.abspath('html'), os.path.abspath('colour.pdf')]
729 def test(target, test):
730 if target.platform != 'windows':
731 target.set('LC_ALL', 'C')
734 cmd += '--backtrace '
736 cmd += '--run_test=%s' % test