3 # Copyright (C) 2012-2022 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 def dmg_prefix(variant):
32 def debian_name(variant):
35 deb_build_depends = dict()
37 deb_build_depends_base = ['debhelper', 'g++', 'pkg-config', 'libsndfile1-dev', 'libgtk2.0-dev', 'libx264-dev']
39 for v in ['16.04', '18.04', '20.04']:
40 deb_build_depends[v] = copy.deepcopy(deb_build_depends_base)
41 deb_build_depends[v].extend(['libssh-dev', 'python'])
43 deb_build_depends[v] = copy.deepcopy(deb_build_depends_base)
44 deb_build_depends[v].extend(['libssh-dev', 'python3.10'])
45 for v in ['23.04', '23.10']:
46 deb_build_depends[v] = copy.deepcopy(deb_build_depends_base)
47 deb_build_depends[v].extend(['libssh-dev', 'python3.11'])
49 deb_build_depends[v] = copy.deepcopy(deb_build_depends_base)
50 deb_build_depends[v].extend(['libssh-dev', 'python3.12'])
52 deb_build_depends[v] = copy.deepcopy(deb_build_depends_base)
53 deb_build_depends[v].extend(['libssh-gcrypt-dev', 'python'])
55 deb_build_depends[v] = copy.deepcopy(deb_build_depends_base)
56 deb_build_depends[v].extend(['libssh-gcrypt-dev', 'python3.9'])
58 deb_build_depends[v] = copy.deepcopy(deb_build_depends_base)
59 deb_build_depends[v].extend(['libssh-gcrypt-dev', 'python3.11'])
60 deb_build_depends['unstable'] = copy.deepcopy(deb_build_depends_base)
61 deb_build_depends['unstable'].extend(['python3'])
64 deb_depends_gui = dict()
66 deb_depends_base = ['libc6', 'libsndfile1', 'libsamplerate0', 'libxmlsec1', 'libxmlsec1-openssl', 'libgtk2.0-0']
68 deb_depends['16.04'] = copy.deepcopy(deb_depends_base)
69 deb_depends['16.04'].extend(['libboost-filesystem1.58.0',
70 'libboost-thread1.58.0',
71 'libboost-regex1.58.0',
73 'libboost-date-time1.58.0',
84 deb_depends['18.04'] = copy.deepcopy(deb_depends_base)
85 deb_depends['18.04'].extend(['libboost-filesystem1.65.1',
86 'libboost-thread1.65.1',
87 'libboost-regex1.65.1',
88 'libboost-date-time1.65.1',
102 deb_depends['20.04'] = copy.deepcopy(deb_depends_base)
103 deb_depends['20.04'].extend(['libboost-filesystem1.71.0',
104 'libboost-thread1.71.0',
105 'libboost-regex1.71.0',
106 'libboost-date-time1.71.0',
107 'libcairomm-1.0-1v5',
108 'libpangomm-1.4-1v5',
120 deb_depends['21.10'] = copy.deepcopy(deb_depends_base)
121 deb_depends['21.10'].extend(['libboost-filesystem1.74.0',
122 'libboost-thread1.74.0',
123 'libboost-regex1.74.0',
124 'libboost-date-time1.74.0',
125 'libcairomm-1.0-1v5',
126 'libpangomm-1.4-1v5',
139 deb_depends['22.04'] = copy.deepcopy(deb_depends_base)
140 deb_depends['22.04'].extend(['libboost-filesystem1.74.0',
141 'libboost-thread1.74.0',
142 'libboost-regex1.74.0',
143 'libboost-date-time1.74.0',
144 'libcairomm-1.0-1v5',
145 'libpangomm-1.4-1v5',
158 deb_depends['23.04'] = copy.deepcopy(deb_depends_base)
159 deb_depends['23.04'].extend(['libboost-filesystem1.74.0',
160 'libboost-thread1.74.0',
161 'libboost-regex1.74.0',
162 'libboost-date-time1.74.0',
163 'libcairomm-1.0-1v5',
164 'libpangomm-1.4-1v5',
178 deb_depends['23.10'] = copy.deepcopy(deb_depends_base)
179 deb_depends['23.10'].extend(['libboost-filesystem1.74.0',
180 'libboost-thread1.74.0',
181 'libboost-regex1.74.0',
182 'libboost-date-time1.74.0',
183 'libcairomm-1.0-1v5',
184 'libpangomm-1.4-1v5',
198 def debs(boost, icu, x264):
199 output = copy.deepcopy(deb_depends_base)
200 output.extend(['libboost-filesystem' + boost,
201 'libboost-thread' + boost,
202 'libboost-regex' + boost,
203 'libboost-date-time' + boost,
204 'libcairomm-1.0-1v5',
205 'libpangomm-1.4-1v5',
220 deb_depends['24.04'] = debs(boost='1.83.0', icu='74', x264='164')
222 deb_depends['9'] = copy.deepcopy(deb_depends_base)
223 deb_depends['9'].extend(['libboost-filesystem1.62.0',
224 'libboost-thread1.62.0',
225 'libboost-regex1.62.0',
226 'libboost-date-time1.62.0',
230 'libcairomm-1.0-1v5',
231 'libpangomm-1.4-1v5',
240 deb_depends_gui['9'] = [ 'libxcb-xfixes0',
245 deb_depends['10'] = copy.deepcopy(deb_depends_base)
246 deb_depends['10'].extend(['libboost-filesystem1.67.0',
247 'libboost-thread1.67.0',
248 'libboost-regex1.67.0',
249 'libboost-date-time1.67.0',
253 'libcairomm-1.0-1v5',
254 'libpangomm-1.4-1v5',
264 deb_depends_gui['10'] = [ 'libxcb-xfixes0',
269 deb_depends['11'] = copy.deepcopy(deb_depends_base)
270 deb_depends['11'].extend(['libboost-filesystem1.74.0',
271 'libboost-thread1.74.0',
272 'libboost-regex1.74.0',
273 'libboost-date-time1.74.0',
276 'libcairomm-1.0-1v5',
277 'libpangomm-1.4-1v5',
288 deb_depends_gui['11'] = [ 'libxcb-xfixes0',
293 deb_depends['12'] = copy.deepcopy(deb_depends_base)
294 deb_depends['12'].extend(['libboost-filesystem1.74.0',
295 'libboost-thread1.74.0',
296 'libboost-regex1.74.0',
297 'libboost-date-time1.74.0',
300 'libcairomm-1.0-1v5',
301 'libpangomm-1.4-1v5',
311 deb_depends_gui['12'] = [ 'libxcb-xfixes0',
316 deb_depends['unstable'] = copy.deepcopy(deb_depends_base)
317 deb_depends['unstable'].extend(['libboost-filesystem1.67.0',
318 'libboost-thread1.67.0',
319 'libboost-regex1.67.0',
320 'libboost-date-time1.67.0',
331 def can_build_disk(target):
332 # We can build dcpomatic2_disk on platforms that have Boost process and can build the lwext4
333 # library. For now, just whitelist good ones here.
335 # - Lots of Linux distros (including Ubuntu 16.04) don't have a new enough boost (1.64 or above)
336 # - 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.
337 # - On Centos 7 there is a build error in lwext4 related to __unused
338 if target.platform == 'windows':
340 if target.platform == 'osx':
342 if target.platform == 'linux':
343 if target.distro == 'ubuntu' and target.version != '16.04':
345 if target.distro == 'debian' and target.version != '9':
347 if target.detail == 'appimage':
349 if target.distro == 'fedora' and int(target.version) >= 31:
351 if target.distro == 'centos' and target.version != '7':
353 if target.distro == 'mageia':
357 def packages(name, packages, f):
361 print(s[:-2], file=f)
363 def make_control(debian_version, bits, filename, debug, gui, name):
364 f = open(filename, 'w')
365 print(f'Source: {name}', file=f)
366 print('Section: video', file=f)
367 print('Priority: extra', file=f)
368 print('Maintainer: Carl Hetherington <carl@dcpomatic.com>', file=f)
369 packages('Build-Depends', deb_build_depends[debian_version], f)
370 print('Standards-Version: 3.9.3', file=f)
371 print('Homepage: https://dcpomatic.com/', file=f)
373 suffix = '' if gui else '-cli'
374 print(f'Package: {name}{suffix}', file=f)
376 print(f'Replaces: {name}-cli', file=f)
378 print('Architecture: i386', file=f)
380 print('Architecture: amd64', file=f)
382 pkg = deb_depends[debian_version]
383 if gui and debian_version in deb_depends_gui:
384 pkg.extend(deb_depends_gui[debian_version])
386 packages('Depends', pkg, f)
388 print('Description: Generator of Digital Cinema Packages (DCPs)', file=f)
389 print(' DCP-o-matic generates Digital Cinema Packages (DCPs) from videos, images,', file=f)
390 print(' sound and subtitle files. You can use it to make content for playback on DCI-compliant', file=f)
391 print(' cinema projectors.', file=f)
393 print(' This package contains the command-line tools only.', file=f)
397 print(f'Package: {name}{suffix}-dbg', file=f)
399 print('Architecture: i386', file=f)
401 print('Architecture: amd64', file=f)
402 print('Section: debug', file=f)
403 print('Priority: extra', file=f)
404 packages('Depends', pkg, f)
405 print(f'Description: debugging symbols for {name}', file=f)
406 print(f' This package contains the debugging symbols for {name}.', file=f)
409 def make_spec(filename, version, target, options, requires=None):
410 """Make a .spec file for a RPM build"""
411 f = open(filename, 'w')
412 print('Summary:A program that generates Digital Cinema Packages (DCPs) from video and audio files', file=f)
413 print('Name:dcpomatic2', file=f)
414 print('Version:%s' % version, file=f)
415 print('Release:1%{?dist}', file=f)
416 print('License:GPL', file=f)
417 print('Group:Applications/Multimedia', file=f)
418 print('URL:https://dcpomatic.com/', file=f)
419 if requires is not None:
420 print('Requires:%s' % requires, file=f)
422 print('%description', file=f)
423 print('DCP-o-matic generates Digital Cinema Packages (DCPs) from video and audio ', file=f)
424 print('files for presentation on DCI-compliant digital projectors.', file=f)
426 print('%files', file=f)
427 print('%{_bindir}/dcpomatic2', file=f)
428 print('%{_bindir}/dcpomatic2_batch', file=f)
429 print('%{_bindir}/dcpomatic2_cli', file=f)
430 print('%{_bindir}/dcpomatic2_create', file=f)
431 print('%{_bindir}/dcpomatic2_editor', file=f)
432 print('%{_bindir}/dcpomatic2_kdm', file=f)
433 print('%{_bindir}/dcpomatic2_server', file=f)
434 print('%{_bindir}/dcpomatic2_server_cli', file=f)
435 print('%{_bindir}/dcpomatic2_kdm_cli', file=f)
436 print('%{_bindir}/dcpomatic2_player', file=f)
437 print('%{_bindir}/dcpomatic2_playlist', file=f)
438 print('%{_bindir}/dcpomatic2_openssl', file=f)
439 print('%{_bindir}/dcpomatic2_combiner', file=f)
440 print('%{_bindir}/dcpomatic2_verify_cli', file=f)
441 print('%{_bindir}/dcpomatic2_verifier', file=f)
442 print('%{_bindir}/dcpomatic2_kdm_inspect', file=f)
443 print('%{_bindir}/dcpomatic2_map', file=f)
444 if can_build_disk(target):
445 print('%{_bindir}/dcpomatic2_disk', file=f)
446 print('%caps(cap_dac_override=ep) %{_bindir}/dcpomatic2_disk_writer', file=f)
447 print('%{_datadir}/applications/dcpomatic2.desktop', file=f)
448 print('%{_datadir}/applications/dcpomatic2_batch.desktop', file=f)
449 print('%{_datadir}/applications/dcpomatic2_editor.desktop', file=f)
450 print('%{_datadir}/applications/dcpomatic2_verifier.desktop', file=f)
451 print('%{_datadir}/applications/dcpomatic2_server.desktop', file=f)
452 print('%{_datadir}/applications/dcpomatic2_kdm.desktop', file=f)
453 print('%{_datadir}/applications/dcpomatic2_player.desktop', file=f)
454 print('%{_datadir}/applications/dcpomatic2_playlist.desktop', file=f)
455 print('%{_datadir}/applications/dcpomatic2_combiner.desktop', file=f)
456 if can_build_disk(target):
457 print('%{_datadir}/applications/dcpomatic2_disk.desktop', file=f)
458 print('%{_datadir}/dcpomatic2/dcpomatic2_server_small.png', file=f)
459 print('%{_datadir}/dcpomatic2/select_white.png', file=f)
460 print('%{_datadir}/dcpomatic2/select_black.png', file=f)
461 print('%{_datadir}/dcpomatic2/sequence_white.png', file=f)
462 print('%{_datadir}/dcpomatic2/sequence_black.png', file=f)
463 print('%{_datadir}/dcpomatic2/snap_white.png', file=f)
464 print('%{_datadir}/dcpomatic2/snap_black.png', file=f)
465 print('%{_datadir}/dcpomatic2/zoom_white.png', file=f)
466 print('%{_datadir}/dcpomatic2/zoom_black.png', file=f)
467 print('%{_datadir}/dcpomatic2/zoom_all_white.png', file=f)
468 print('%{_datadir}/dcpomatic2/zoom_all_black.png', file=f)
469 print('%{_datadir}/dcpomatic2/link_black.png', file=f)
470 print('%{_datadir}/dcpomatic2/link_white.png', file=f)
471 print('%{_datadir}/dcpomatic2/me.jpg', file=f)
472 print('%{_datadir}/dcpomatic2/add_black.png', file=f)
473 print('%{_datadir}/dcpomatic2/add_white.png', file=f)
474 print('%{_datadir}/dcpomatic2/pause_black.png', file=f)
475 print('%{_datadir}/dcpomatic2/pause_white.png', file=f)
476 print('%{_datadir}/dcpomatic2/LiberationSans-Regular.ttf', file=f)
477 print('%{_datadir}/dcpomatic2/LiberationSans-Italic.ttf', file=f)
478 print('%{_datadir}/dcpomatic2/LiberationSans-Bold.ttf', file=f)
479 print('%{_datadir}/dcpomatic2/splash.png', file=f)
480 for r in ['128x128', '16x16', '22x22', '256x256', '32x32', '48x48', '512x512', '64x64']:
481 print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2.png' % r, file=f)
482 print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_batch.png' % r, file=f)
483 print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_editor.png' % r, file=f)
484 print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_verifier.png' % r, file=f)
485 print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_kdm.png' % r, file=f)
486 print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_server.png' % r, file=f)
487 print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_player.png' % r, file=f)
488 print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_playlist.png' % r, file=f)
489 print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_disk.png' % r, file=f)
490 print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_combiner.png' % r, file=f)
491 for l in ['de_DE', 'es_ES', 'fr_FR', 'it_IT', 'sv_SE', 'nl_NL', 'ru_RU', 'pl_PL', 'da_DK',
492 'pt_PT', 'pt_BR', 'sk_SK', 'cs_CZ', 'uk_UA', 'zh_CN', 'tr_TR', 'sl_SI', 'hu_HU',
494 print('%%{_datadir}/locale/%s/LC_MESSAGES/dcpomatic2.mo' % l, file=f)
495 print('%%{_datadir}/locale/%s/LC_MESSAGES/libdcpomatic2-wx.mo' % l, file=f)
496 print('%%{_datadir}/locale/%s/LC_MESSAGES/libdcpomatic2.mo' % l, file=f)
497 print('%{_datadir}/libdcp/tags/*', file=f)
498 print('%{_datadir}/libdcp/xsd/*', file=f)
499 print('%{_datadir}/libdcp/ratings', file=f)
500 print('%{_datadir}/polkit-1/actions/com.dcpomatic.write-drive.policy', file=f)
502 print('%prep', file=f)
503 print('rm -rf $RPM_BUILD_DIR/dcpomatic-%s' % version, file=f)
504 print('tar xjf $RPM_SOURCE_DIR/dcpomatic-%s.tar.bz2' % version, file=f)
505 print('%build', file=f)
506 print('cd dcpomatic-%s' % version, file=f)
507 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)
508 print('CXXFLAGS="-I%s/include" LDFLAGS="-L%s/lib" ./waf configure --prefix=%%{buildroot}/usr --destdir=/usr %s' %
509 (target.directory, target.directory, configure_options(target, options, for_package=True)), file=f)
510 print('./waf', file=f)
511 print('%install', file=f)
512 print('cd dcpomatic-%s' % version, file=f)
513 print('./waf install', file=f)
514 print('/bin/cp %s/src/openssl/apps/openssl %%{buildroot}/usr/bin/dcpomatic2_openssl' % target.directory, file=f)
515 print('/bin/mkdir -p %{buildroot}/usr/share/libdcp', file=f)
516 print('/bin/cp -r %s/src/libdcp/tags %%{buildroot}/usr/share/libdcp' % target.directory, file=f)
517 print('/bin/cp -r %s/src/libdcp/xsd %%{buildroot}/usr/share/libdcp' % target.directory, file=f)
518 print('/bin/cp %s/src/libdcp/ratings %%{buildroot}/usr/share/libdcp' % target.directory, file=f)
519 print('/bin/mv %s/bin/dcpverify %%{buildroot}/usr/bin/dcpomatic2_verify_cli' % target.directory, file=f)
520 print('/bin/mv %s/bin/dcpkdm %%{buildroot}/usr/bin/dcpomatic2_kdm_inspect' % target.directory, file=f)
522 print('%post', file=f)
523 print('/bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :', file=f)
524 print('setcap "cap_dac_override+ep cap_sys_admin+ep" /usr/bin/dcpomatic2_disk_writer', file=f)
526 print('%postun', file=f)
527 print('if [ $1 -eq 0 ] ; then', file=f)
528 print(' /bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null', file=f)
529 print(' /usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :', file=f)
532 print('%posttrans', file=f)
533 print('/usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :', file=f)
535 def dependencies(target, options):
536 deps = [('libdcp', '9b9af8a80860210c6a29446f7a24795eeda9e7bc', {'c++17': target.platform == 'osx'})]
537 deps.append(('libsub', 'v1.6.47'))
538 deps.append(('leqm-nrt', '30dcaea1373ac62fba050e02ce5b0c1085797a23'))
539 deps.append(('rtaudio', 'f619b76'))
540 # We get our OpenSSL libraries from the environment, but we
541 # also need a patched openssl binary to make certificates.
542 # This dependency is to get that binary, which is added into
543 # the appropriate place later
544 deps.append(('openssl', '54298369cacfe0ae01c5aa42ace8a463fd2e7a2e'))
545 if can_build_disk(target):
546 deps.append(('lwext4', 'ab082923a791b58478d1d9939d65a0583566ac1f'))
547 deps.append(('ffcmp', '5ab6ed3b75d8ca7cf1f66bb9fb08792b92f4b419'))
551 option_defaults = { "gui": True, "variant": None }
553 def configure_options(target, options, for_package=False):
554 opt = ' --warnings-are-errors'
556 if for_package or not (
557 (target.platform == 'linux' and target.distro == 'ubuntu' and target.version in ['18.04', '22.04']) or
558 (target.platform == 'osx') or
559 (target.platform == 'windows')
561 # Currently we only build tests on macOS, Windows, and some Ubuntu versions
562 opt += ' --disable-tests'
565 opt += ' --enable-debug'
566 if target.platform == 'windows':
567 opt += f' --target-windows-{target.bits}'
568 elif target.platform == 'linux':
569 opt += ' --static-dcpomatic --static-wxwidgets --static-ffmpeg --static-dcp --static-sub --static-cxml'
570 if target.distro == 'centos':
571 if target.version == '6.5':
572 opt += ' --static-boost --static-xmlpp'
573 elif target.version == '7':
574 opt += ' --workaround-gssapi'
576 if not options['gui']:
577 opt += ' --disable-gui'
579 if options['variant']:
580 opt += ' --variant=%s' % options['variant']
582 # Build Windows debug versions with static linking as I think gdb works better then
583 if target.debug and target.platform == 'windows':
584 opt += ' --static-dcpomatic'
586 if can_build_disk(target):
587 opt += ' --enable-disk'
589 if target.platform == 'osx':
591 if target.arch == 'arm64':
592 opt += ' --wx-config=%s/wx-config' % target.bin
594 if target.platform == 'linux' and target.distro == 'ubuntu' and target.version in ['22.04']:
595 opt += ' --enable-grok'
599 def build(target, options, for_package):
600 if target.platform == 'flatpak':
601 target.checkout_dependencies()
602 prefix = 'https://dcpomatic.com/deps'
604 modules.append({'name': 'libzip',
605 'buildsystem': 'cmake',
606 'sources': [{'type': 'archive',
607 'url': '%s/libzip-1.4.0.tar.xz' % prefix,
608 'sha256': 'e508aba025f5f94b267d5120fc33761bcd98440ebe49dbfe2ed3df3afeacc7b1'}]})
609 modules.append({'name': 'libsigc++',
610 'sources': [{'type': 'archive',
611 'url': '%s/libsigc++-2.10.0.tar.xz' % prefix,
612 'sha256': 'f843d6346260bfcb4426259e314512b99e296e8ca241d771d21ac64f28298d81'}]})
613 modules.append({'name': 'glibmm',
614 'sources': [{'type': 'archive',
615 'url': '%s/glibmm-2.48.1.tar.xz' % prefix,
616 'sha256': 'dc225f7d2f466479766332483ea78f82dc349d59399d30c00de50e5073157cdf'}]})
617 modules.append({'name': 'cairomm',
618 'sources': [{'type': 'archive',
619 'url': '%s/cairomm-1.12.2.tar.gz' % prefix,
620 'sha256': '45c47fd4d0aa77464a75cdca011143fea3ef795c4753f6e860057da5fb8bd599'}]})
621 modules.append({'name': 'pangomm',
622 'sources': [{'type': 'archive',
623 'url': '%s/pangomm-2.40.1.tar.xz' % prefix,
624 'sha256': '9762ee2a2d5781be6797448d4dd2383ce14907159b30bc12bf6b08e7227be3af'}]})
625 modules.append({'name': 'libxml++',
626 'sources': [{'type': 'archive',
627 'url': '%s/libxml++-2.40.1.tar.xz' % prefix,
628 'sha256': '4ad4abdd3258874f61c2e2a41d08e9930677976d303653cd1670d3e9f35463e9'}]})
629 modules.append({'name': 'xmlsec1',
630 'sources': [{'type': 'archive',
631 'url': '%s/xmlsec1-1.2.25.tar.gz' % prefix,
632 'sha256': '967ca83edf25ccb5b48a3c4a09ad3405a63365576503bf34290a42de1b92fcd2'}]})
633 modules.append({'name': 'openjpeg2',
634 'buildsystem': 'cmake',
635 'sources': [{'type': 'dir', 'path': os.path.abspath('../openjpeg2-cdist')}]})
636 modules.append({'name': 'boost',
637 'buildsystem': 'simple',
639 './bootstrap.sh --prefix=/app',
642 'sources': [{'type': 'archive',
643 'url': '%s/boost_1_66_0.tar.bz2' % prefix,
644 'sha256': '5721818253e6a0989583192f96782c4a98eb6204965316df9f5ad75819225ca9'}]})
645 modules.append({'name': 'asdcplib',
646 'buildsystem': 'simple',
648 './waf configure --prefix=/app --libdir=/app/lib build install'
650 'sources': [{'type': 'dir', 'path': os.path.abspath('../asdcplib-carl')}]})
651 modules.append({'name': 'locked_sstream',
652 'buildsystem': 'simple',
654 './waf configure --prefix=/app build install'
656 'sources': [{'type': 'dir', 'path': os.path.abspath('../locked_sstream')}]})
657 modules.append({'name': 'libcxml',
658 'buildsystem': 'simple',
660 './waf configure --prefix=/app --libdir=/app/lib build install'
662 'sources': [{'type': 'dir', 'path': os.path.abspath('../libcxml')}]})
663 modules.append({'name': 'libdcp',
664 'buildsystem': 'simple',
666 './waf configure --prefix=/app --libdir=/app/lib build install'
668 'sources': [{'type': 'dir', 'path': os.path.abspath('../libdcp')}]})
669 modules.append({'name': 'libsub',
670 'buildsystem': 'simple',
672 './waf configure --prefix=/app --libdir=/app/lib build install'
674 'sources': [{'type': 'dir', 'path': os.path.abspath('../libsub')}]})
675 modules.append({'name': 'rtaudio',
683 'sources': [{'type': 'dir', 'path': os.path.abspath('../rtaudio-cdist')}]})
684 modules.append({'name': 'wxwidgets',
685 'sources': [{'type': 'archive',
686 'url': '%s/wxWidgets-3.0.3.tar.bz2' % prefix,
687 'sha256': '08c8033f48ec1b23520f036cde37b5ae925a6a65f137ded665633ca159b9307b'}]})
688 modules.append({'name': 'libssh',
689 'buildsystem': 'cmake',
691 'sources': [{'type': 'archive',
692 'url': '%s/libssh-0.7.5.tar.xz' % prefix,
693 'sha256': '54e86dd5dc20e5367e58f3caab337ce37675f863f80df85b6b1614966a337095'}]})
694 modules.append({'name': 'dcpomatic',
695 'buildsystem': 'simple',
697 './waf configure --prefix=/app build install'
700 'build-args': ['--share=network']
702 'sources': [{'type': 'dir', 'path': os.path.abspath('.')}]})
703 desc = {'app-id': 'com.dcpomatic.DCP-o-matic',
704 'runtime': 'org.gnome.Sdk',
705 'runtime-version': '3.26',
706 'sdk': 'org.gnome.Sdk',
707 'command': 'dcpomatic2',
708 'finish-args': ['--socket=x11', '--share=ipc', '--share=network', '--socket=pulseaudio', '--filesystem=host'],
710 os.makedirs('build/platform')
711 with open('build/com.dcpomatic.DCP-o-matic.json', 'w') as outfile:
712 json.dump(desc, outfile)
713 target.command('%s --repo=build/platform/repo build/platform/flatpak build/com.dcpomatic.DCP-o-matic.json' % target.flatpak_builder())
714 elif target.platform != 'linux' or target.detail == 'appimage' or not for_package:
715 target.command('./waf configure --prefix=%s %s' % (target.directory, configure_options(target, options, for_package)))
716 target.command('./waf')
717 target.command('./waf install')
719 def package_windows(target):
720 identifier = '%d' % target.bits
721 shutil.copyfile('build/platform/windows/installer.%s.nsi' % identifier, 'build/platform/windows/installer2.%s.nsi' % identifier)
722 target.command('sed -i "s~%%resources%%~%s/platform/windows~g" build/platform/windows/installer2.%s.nsi' % (os.getcwd(), identifier))
723 target.command('sed -i "s~%%graphics%%~%s/graphics~g" build/platform/windows/installer2.%s.nsi' % (os.getcwd(), identifier))
724 target.command('sed -i "s~%%static_deps%%~%s~g" build/platform/windows/installer2.%s.nsi' % (target.windows_prefix, identifier))
725 target.command('sed -i "s~%%cdist_deps%%~%s~g" build/platform/windows/installer2.%s.nsi' % (target.directory, identifier))
726 target.command('sed -i "s~%%mingw%%~%s~g" build/platform/windows/installer2.%s.nsi' % (target.environment_prefix, identifier))
727 target.command('sed -i "s~%%binaries%%~%s/build~g" build/platform/windows/installer2.%s.nsi' % (os.getcwd(), identifier))
728 target.command('sed -i "s~%%bits%%~32~g" build/platform/windows/installer2.%s.nsi' % identifier)
729 target.command('makensis build/platform/windows/installer2.%s.nsi' % identifier)
730 return os.path.abspath(glob.glob('build/platform/windows/*%s*.exe' % target.bits)[0])
732 def package_debian(target, cpu, version, options):
733 name = debian_name(options['variant'])
734 make_control(target.version, target.bits, 'debian/control', target.debug, options['gui'], name)
735 if target.version != '9' and target.version != '16.04' and options['gui']:
736 with open('debian/postinst', 'w') as f:
737 print('#!/bin/sh', file=f)
738 # Get the required capability to write to disks
739 print('setcap "cap_dac_override+ep cap_sys_admin+ep" /usr/bin/dcpomatic2_disk_writer', file=f)
740 target.command('./waf dist')
741 f = open('debian/files', 'w')
742 suffix = '' if options['gui'] else '-cli'
743 print(f'{name}{suffix}_{version}-1_{cpu}.deb video extra', file=f)
744 shutil.rmtree('build/deb', ignore_errors=True)
746 os.makedirs('build/deb')
747 os.chdir('build/deb')
748 shutil.move(f'../../dcpomatic-{version}.tar.bz2', f'{name}_{version}.orig.tar.bz2')
749 target.command(f'tar xjf {name}_{version}.orig.tar.bz2')
750 os.chdir(f'dcpomatic-{version}')
752 with open('debian/changelog', 'w') as f:
753 print(f'{name} ({version}-1) unstable; urgency=medium', file=f)
755 print(' * New upstream release.', file=f)
757 print(f" -- Carl Hetherington <carl@dcpomatic.com> {datetime.datetime.now().astimezone().strftime('%a, %d %b %Y %H:%M:%S %z')}", file=f)
759 target.set('CDIST_LINKFLAGS', target.get('LINKFLAGS'))
760 target.set('CDIST_CXXFLAGS', target.get('CXXFLAGS'))
761 target.set('CDIST_PKG_CONFIG_PATH', target.get('PKG_CONFIG_PATH'))
762 target.set('CDIST_DIRECTORY', target.directory)
764 target.set('CDIST_CONFIGURE', '"' + configure_options(target, options, for_package=True) + '"')
765 target.set('CDIST_PACKAGE', f'{name}{suffix}')
766 target.set('CDIST_WX_VERSION', "3.2" if target.version in ("23.04", "23.10", "24.04") else "3.1")
768 target.set('CDIST_DEBUG_PACKAGE_FLAG', '--no-ddebs')
770 target.command('dpkg-buildpackage -uc -us')
773 for p in glob.glob('../*.deb'):
774 debs.append(os.path.abspath(p))
778 def package_rpm(target, cpu, version, options):
779 topdir = os.path.realpath('build/rpmbuild')
780 os.makedirs('%s/BUILD' % topdir)
781 os.makedirs('%s/RPMS' % topdir)
782 os.makedirs('%s/SOURCES' % topdir)
783 os.makedirs('%s/SPECS' % topdir)
784 os.makedirs('%s/SRPMS' % topdir)
786 target.command('./waf dist')
788 "%s/src/dcpomatic/dcpomatic-%s.tar.bz2" % (target.directory, version),
789 "%s/SOURCES/dcpomatic-%s.tar.bz2" % (topdir, version)
793 if target.distro == 'mageia':
794 requires = "lib64xmlsec1-devel lib64canberra-gtk0 libcap-utils"
796 make_spec('dcpomatic2.spec', version, target, options, requires)
797 cmd = 'rpmbuild --define "_topdir %s" -bb dcpomatic2.spec' % topdir
806 for p in glob.glob('%s/RPMS/%s/*.rpm' % (topdir, cpu)):
807 rpms.append(os.path.abspath(p))
811 def make_appimage(target, nice_name, internal_name, version, extra_binaries=None):
812 nice_filename = nice_name.replace(' ', '_')
813 appdir = f'build/{nice_filename}.AppDir'
814 os.makedirs(f'{appdir}/usr/bin')
815 target.command(f'cp {target.directory}/bin/{internal_name} {appdir}/usr/bin')
816 target.command(f'cp {target.directory}/src/openssl/apps/openssl {appdir}/usr/bin/dcpomatic2_openssl')
817 target.command(f'cp {target.directory}/bin/dcpverify {appdir}/usr/bin/dcpomatic2_verify_cli')
818 target.command(f'cp {target.directory}/bin/dcpkdm {appdir}/usr/bin/dcpomatic2_kdm_inspect')
820 for bin in extra_binaries:
821 target.command(f'cp {target.directory}/bin/{bin} {appdir}/usr/bin')
822 target.command(f'mkdir -p {appdir}/usr/share/libdcp')
823 target.command(f'cp -r {target.directory}/share/dcpomatic2 {appdir}/usr/share/')
824 target.command(f'cp -r {target.directory}/share/libdcp/xsd {appdir}/usr/share/libdcp/')
825 target.command(f'cp -r {target.directory}/share/libdcp/tags {appdir}/usr/share/libdcp/')
826 target.command(f'cp {target.directory}/share/libdcp/ratings {appdir}/usr/share/libdcp/')
827 lib = 'usr/lib/x86_64-linux-gnu'
828 target.command(f'mkdir -p build/{nice_filename}.AppDir/{lib}/gdk-pixbuf-2.0/2.10.0')
829 target.command(f'cp -a /{lib}/gdk-pixbuf-2.0 build/{nice_filename}.AppDir/usr/lib/x86_64-linux-gnu/')
830 target.command('sudo apt update')
831 for package in ['libc6', 'libglib2.0-0', 'gnome-settings-daemon-schemas', 'librsvg2-common', 'libgdk-pixbuf2.0-0', 'libpango-1.0-0', 'libpangoft2-1.0-0', 'libpangocairo-1.0-0', 'libthai0']:
832 target.command(f'apt download {package}')
833 target.command(f'dpkg-deb -x {package}*.deb {appdir}')
834 target.command(f'glib-compile-schemas {appdir}/usr/share/glib-2.0/schemas')
835 target.command(f'sed -i -e "s|/usr/lib/x86_64-linux-gnu/gdk-pixbuf-.*/.*/loaders/||g" {appdir}/usr/lib/x86_64-linux-gnu/gdk-pixbuf-*/*/loaders.cache')
836 # Stop anything loading from outside the AppImage
837 target.command(f'sed -i -e "s|/usr|/xxx|g" {appdir}/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2')
839 if internal_name == 'dcpomatic2_disk':
840 target.command(f'mkdir -p {appdir}/usr/share/polkit-1/actions')
841 target.command(f'cp {target.directory}/share/polkit-1/actions/com.dcpomatic.write-drive.policy {appdir}/usr/share/polkit-1/actions')
843 with open(f'{appdir}/AppRun', 'w') as f:
844 print('#!/bin/bash', file=f)
845 print('export PATH=$APPDIR/usr/bin:$PATH', file=f)
846 print('export XDG_DATA_DIRS="$APPDIR/usr/share/:/usr/share/:$XDG_DATA_DIRS"', file=f)
847 print('export GDK_PIXBUF_MODULEDIR=$(readlink -f "$APPDIR"/usr/lib/x86_64-linux-gnu/gdk-pixbuf-*/*/loaders/ )', file=f)
848 print('export GDK_PIXBUF_MODULE_FILE=$(readlink -f "$APPDIR"/usr/lib/x86_64-linux-gnu/gdk-pixbuf-*/*/loaders.cache )', file=f)
849 print('export LD_LIBRARY_PATH=$GDK_PIXBUF_MODULEDIR:$APPDIR/usr/lib:$APPDIR/usr/lib/x86_64-linux-gnu', file=f)
850 print(f'"$APPDIR"/usr/bin/{internal_name} $@', file=f)
851 target.command(f'chmod a+rx {appdir}/AppRun')
852 with open(f'{appdir}/{internal_name}.desktop', 'w') as f:
853 print('[Desktop Entry]', file=f)
854 print('Type=Application', file=f)
855 print('Categories=AudioVideo;', file=f)
856 print(f'Name={nice_name}', file=f)
857 print(f'Icon={internal_name}', file=f)
858 target.command(f'cp graphics/linux/256/{internal_name}.png {appdir}')
859 target.command(f'linuxdeploy-x86_64.AppImage --appdir {appdir}')
860 target.command(f'appimagetool-x86_64.AppImage {appdir}')
861 target.command(f'mv {nice_filename}-x86_64.AppImage build/{nice_filename}-{version}-x86_64.AppImage')
862 return os.path.abspath(f'build/{nice_filename}-{version}-x86_64.AppImage')
864 def package(target, version, options):
865 """version: DCP-o-matic version string"""
866 if target.platform == 'windows':
867 return package_windows(target)
868 elif target.platform == 'linux':
869 if target.detail == 'appimage':
871 out.append(make_appimage(target, 'DCP-o-matic', 'dcpomatic2', version, ('dcpomatic2_map', 'dcpomatic2_cli')))
872 out.append(make_appimage(target, 'DCP-o-matic Player', 'dcpomatic2_player', version))
873 out.append(make_appimage(target, 'DCP-o-matic Playlist Editor', 'dcpomatic2_playlist', version))
874 out.append(make_appimage(target, 'DCP-o-matic KDM Creator', 'dcpomatic2_kdm', version))
875 out.append(make_appimage(target, 'DCP-o-matic Batch Converter', 'dcpomatic2_batch', version))
876 out.append(make_appimage(target, 'DCP-o-matic Encode Server', 'dcpomatic2_server', version))
877 out.append(make_appimage(target, 'DCP-o-matic Combiner', 'dcpomatic2_combiner', version))
878 out.append(make_appimage(target, 'DCP-o-matic Editor', 'dcpomatic2_editor', version))
879 out.append(make_appimage(target, 'DCP-o-matic Verifier', 'dcpomatic2_verifier', version))
882 if target.bits == 32:
887 if target.distro == 'debian' or target.distro == 'ubuntu':
888 return package_debian(target, cpu, version, options)
889 elif target.distro == 'centos' or target.distro == 'fedora' or target.distro == 'mageia':
890 return package_rpm(target, cpu, version, options)
891 elif target.platform == 'osx':
892 archs = '-a ' + ' -a '.join(f'{t.arch}/{t.deployment}' for t in target.sub_targets)
893 cmd = 'bash platform/osx/make_dmg.sh -e %s -r %s -i %s -p %s %s' % (target.environment_prefix, target.directory, target.apple_id, target.apple_password, archs)
894 if 'part' in options:
895 cmd += ' -b ' + options['part']
896 if options['variant']:
897 cmd += ' -v ' + options['variant']
899 return glob.glob('build/platform/osx/' + dmg_prefix(options['variant']) + '*.dmg')
900 elif target.platform == 'docker':
901 shutil.copyfile(target.deb, 'build/platform/docker')
902 f = open('build/platform/docker/Dockerfile', 'w')
903 print('FROM debian:jessie', file=f)
904 print('MAINTAINER carl@dcpomatic.com', file=f)
905 print('ADD build/platform/docker/dcpomatic_%s-1_amd64.deb /tmp' % (version, version), file=f)
906 print('RUN apt-get -o Acquire:http::Timeout="5" update; exit 0', file=f)
907 print('RUN dpkg -i /tmp/dcpomatic_*.deb; exit 0', file=f)
908 print('RUN apt-get -y -f install', file=f)
909 print('RUN apt-get clean', file=f)
910 print('EXPOSE 6192', file=f)
911 print('CMD ["/usr/bin/dcpomatic2_server_cli", "--verbose"]', file=f)
913 target.command('docker build build/platform/docker -t dcpomatic-server:%s' % version)
914 target.command('docker save dcpomatic-server:%s -o dcpomatic-server-%s-docker.tar' % (version, version))
915 elif target.platform == 'flatpak':
916 target.command('%s build-bundle build/platform/repo build/dcpomatic_%s.flatpak com.dcpomatic.DCP-o-matic' % (target.flatpak(), version))
917 return os.path.abspath('build/dcpomatic_%s.flatpak' % version)
919 def make_pot(target):
920 target.command('./waf pot')
921 return [os.path.abspath('build/src/lib/libdcpomatic.pot'),
922 os.path.abspath('build/src/wx/libdcpomatic-wx.pot'),
923 os.path.abspath('build/src/tools/dcpomatic.pot')]
925 def make_manual(target):
926 target.command('make -C doc/manual LIBDCP=../../../libdcp')
927 os.chdir('doc/manual')
928 target.command('pdflatex colour.tex')
929 return [os.path.abspath('pdf'), os.path.abspath('html'), os.path.abspath('colour.pdf')]
931 def test(target, options, test):
932 target.set('LC_ALL', 'C')
933 if target.platform == 'windows':
936 cmd = 'run/tests --check --log_level=test_suite '
938 cmd += '--backtrace '
940 cmd += '-t %s' % test