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
28 deb_build_depends = dict()
30 deb_build_depends_base = ['debhelper', 'g++', 'pkg-config', 'libsndfile1-dev', 'libgtk2.0-dev', 'libx264-dev']
32 for v in ['16.04', '18.04', '20.04', '20.10', '21.04', '21.10']:
33 deb_build_depends[v] = copy.deepcopy(deb_build_depends_base)
34 deb_build_depends[v].extend(['libssh-dev', 'python'])
36 deb_build_depends[v] = copy.deepcopy(deb_build_depends_base)
37 deb_build_depends[v].extend(['libssh-gcrypt-dev', 'python'])
39 deb_build_depends[v] = copy.deepcopy(deb_build_depends_base)
40 deb_build_depends[v].extend(['libssh-gcrypt-dev', 'python3.9'])
41 deb_build_depends['unstable'] = copy.deepcopy(deb_build_depends_base)
42 deb_build_depends['unstable'].extend(['python3'])
45 deb_depends_gui = dict()
47 deb_depends_base = ['libc6', 'libsndfile1', 'libsamplerate0', 'libxmlsec1', 'libxmlsec1-openssl', 'libgtk2.0-0']
49 deb_depends['16.04'] = copy.deepcopy(deb_depends_base)
50 deb_depends['16.04'].extend(['libboost-filesystem1.58.0',
51 'libboost-thread1.58.0',
52 'libboost-regex1.58.0',
54 'libboost-date-time1.58.0',
65 deb_depends['18.04'] = copy.deepcopy(deb_depends_base)
66 deb_depends['18.04'].extend(['libboost-filesystem1.65.1',
67 'libboost-thread1.65.1',
68 'libboost-regex1.65.1',
69 'libboost-date-time1.65.1',
83 deb_depends['20.04'] = copy.deepcopy(deb_depends_base)
84 deb_depends['20.04'].extend(['libboost-filesystem1.71.0',
85 'libboost-thread1.71.0',
86 'libboost-regex1.71.0',
87 'libboost-date-time1.71.0',
101 deb_depends['21.10'] = copy.deepcopy(deb_depends_base)
102 deb_depends['21.10'].extend(['libboost-filesystem1.74.0',
103 'libboost-thread1.74.0',
104 'libboost-regex1.74.0',
105 'libboost-date-time1.74.0',
106 'libcairomm-1.0-1v5',
107 'libpangomm-1.4-1v5',
120 deb_depends['9'] = copy.deepcopy(deb_depends_base)
121 deb_depends['9'].extend(['libboost-filesystem1.62.0',
122 'libboost-thread1.62.0',
123 'libboost-regex1.62.0',
124 'libboost-date-time1.62.0',
128 'libcairomm-1.0-1v5',
129 'libpangomm-1.4-1v5',
138 deb_depends_gui['9'] = [ 'libxcb-xfixes0',
143 deb_depends['10'] = copy.deepcopy(deb_depends_base)
144 deb_depends['10'].extend(['libboost-filesystem1.67.0',
145 'libboost-thread1.67.0',
146 'libboost-regex1.67.0',
147 'libboost-date-time1.67.0',
151 'libcairomm-1.0-1v5',
152 'libpangomm-1.4-1v5',
162 deb_depends_gui['10'] = [ 'libxcb-xfixes0',
167 deb_depends['11'] = copy.deepcopy(deb_depends_base)
168 deb_depends['11'].extend(['libboost-filesystem1.74.0',
169 'libboost-thread1.74.0',
170 'libboost-regex1.74.0',
171 'libboost-date-time1.74.0',
174 'libcairomm-1.0-1v5',
175 'libpangomm-1.4-1v5',
186 deb_depends_gui['11'] = [ 'libxcb-xfixes0',
191 deb_depends['unstable'] = copy.deepcopy(deb_depends_base)
192 deb_depends['unstable'].extend(['libboost-filesystem1.67.0',
193 'libboost-thread1.67.0',
194 'libboost-regex1.67.0',
195 'libboost-date-time1.67.0',
206 def can_build_disk(target):
207 # We can build dcpomatic2_disk on platforms that have Boost process and can build the lwext4
208 # library. For now, just whitelist good ones here.
210 # - Lots of Linux distros (including Ubuntu 16.04) don't have a new enough boost (1.64 or above)
211 # - 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.
212 # - On Centos 7 there is a build error in lwext4 related to __unused
213 if target.platform == 'windows':
215 if target.platform == 'osx':
217 if target.platform == 'linux':
218 if target.distro == 'ubuntu' and target.version != '16.04':
220 if target.distro == 'debian' and target.version != '9':
222 if target.detail == 'appimage':
224 if target.distro == 'fedora' and int(target.version) >= 31:
226 if target.distro == 'centos' and target.version != '7':
228 if target.distro == 'mageia':
232 def packages(name, packages, f):
236 print(s[:-2], file=f)
238 def make_control(debian_version, bits, filename, debug, gui):
239 f = open(filename, 'w')
240 print('Source: dcpomatic', file=f)
241 print('Section: video', file=f)
242 print('Priority: extra', file=f)
243 print('Maintainer: Carl Hetherington <carl@dcpomatic.com>', file=f)
244 packages('Build-Depends', deb_build_depends[debian_version], f)
245 print('Standards-Version: 3.9.3', file=f)
246 print('Homepage: https://dcpomatic.com/', file=f)
248 suffix = '' if gui else '-cli'
249 print(f'Package: dcpomatic{suffix}', file=f)
251 print('Architecture: i386', file=f)
253 print('Architecture: amd64', file=f)
255 pkg = deb_depends[debian_version]
256 if gui and debian_version in deb_depends_gui:
257 pkg.extend(deb_depends_gui[debian_version])
259 packages('Depends', pkg, f)
261 print('Description: Generator of Digital Cinema Packages (DCPs)', file=f)
262 print(' DCP-o-matic generates Digital Cinema Packages (DCPs) from videos, images,', file=f)
263 print(' sound and subtitle files. You can use it to make content for playback on DCI-compliant', file=f)
264 print(' cinema projectors.', file=f)
266 print(' This package contains the command-line tools only.', file=f)
270 print(f'Package: dcpomatic{suffix}-dbg', file=f)
272 print('Architecture: i386', file=f)
274 print('Architecture: amd64', file=f)
275 print('Section: debug', file=f)
276 print('Priority: extra', file=f)
277 packages('Depends', pkg, f)
278 print('Description: debugging symbols for dcpomatic', file=f)
279 print(' This package contains the debugging symbols for dcpomatic.', file=f)
282 def make_spec(filename, version, target, options, requires=None):
283 """Make a .spec file for a RPM build"""
284 f = open(filename, 'w')
285 print('Summary:A program that generates Digital Cinema Packages (DCPs) from video and audio files', file=f)
286 print('Name:dcpomatic2', file=f)
287 print('Version:%s' % version, file=f)
288 print('Release:1%{?dist}', file=f)
289 print('License:GPL', file=f)
290 print('Group:Applications/Multimedia', file=f)
291 print('URL:https://dcpomatic.com/', file=f)
292 if requires is not None:
293 print('Requires:%s' % requires, file=f)
295 print('%description', file=f)
296 print('DCP-o-matic generates Digital Cinema Packages (DCPs) from video and audio ', file=f)
297 print('files for presentation on DCI-compliant digital projectors.', file=f)
299 print('%files', file=f)
300 print('%{_bindir}/dcpomatic2', file=f)
301 print('%{_bindir}/dcpomatic2_batch', file=f)
302 print('%{_bindir}/dcpomatic2_cli', file=f)
303 print('%{_bindir}/dcpomatic2_create', file=f)
304 print('%{_bindir}/dcpomatic2_kdm', file=f)
305 print('%{_bindir}/dcpomatic2_server', file=f)
306 print('%{_bindir}/dcpomatic2_server_cli', file=f)
307 print('%{_bindir}/dcpomatic2_kdm_cli', file=f)
308 print('%{_bindir}/dcpomatic2_player', file=f)
309 print('%{_bindir}/dcpomatic2_playlist', file=f)
310 print('%{_bindir}/dcpomatic2_openssl', file=f)
311 print('%{_bindir}/dcpomatic2_combiner', file=f)
312 print('%{_bindir}/dcpomatic2_verify', file=f)
313 if can_build_disk(target):
314 print('%{_bindir}/dcpomatic2_disk', file=f)
315 print('%caps(cap_dac_override=ep) %{_bindir}/dcpomatic2_disk_writer', file=f)
316 print('%{_datadir}/applications/dcpomatic2.desktop', file=f)
317 print('%{_datadir}/applications/dcpomatic2_batch.desktop', file=f)
318 print('%{_datadir}/applications/dcpomatic2_server.desktop', file=f)
319 print('%{_datadir}/applications/dcpomatic2_kdm.desktop', file=f)
320 print('%{_datadir}/applications/dcpomatic2_player.desktop', file=f)
321 print('%{_datadir}/applications/dcpomatic2_playlist.desktop', file=f)
322 print('%{_datadir}/applications/dcpomatic2_combiner.desktop', file=f)
323 if can_build_disk(target):
324 print('%{_datadir}/applications/dcpomatic2_disk.desktop', file=f)
325 print('%{_datadir}/dcpomatic2/dcpomatic2_server_small.png', file=f)
326 print('%{_datadir}/dcpomatic2/select.png', file=f)
327 print('%{_datadir}/dcpomatic2/sequence.png', file=f)
328 print('%{_datadir}/dcpomatic2/snap.png', file=f)
329 print('%{_datadir}/dcpomatic2/zoom.png', file=f)
330 print('%{_datadir}/dcpomatic2/zoom_all.png', file=f)
331 print('%{_datadir}/dcpomatic2/tick.png', file=f)
332 print('%{_datadir}/dcpomatic2/no_tick.png', file=f)
333 print('%{_datadir}/dcpomatic2/link.png', file=f)
334 print('%{_datadir}/dcpomatic2/me.jpg', file=f)
335 print('%{_datadir}/dcpomatic2/LiberationSans-Regular.ttf', file=f)
336 print('%{_datadir}/dcpomatic2/LiberationSans-Italic.ttf', file=f)
337 print('%{_datadir}/dcpomatic2/LiberationSans-Bold.ttf', file=f)
338 print('%{_datadir}/dcpomatic2/splash.png', file=f)
339 for r in ['128x128', '16x16', '22x22', '256x256', '32x32', '48x48', '512x512', '64x64']:
340 print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2.png' % r, file=f)
341 print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_batch.png' % r, file=f)
342 print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_kdm.png' % r, file=f)
343 print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_server.png' % r, file=f)
344 print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_player.png' % r, file=f)
345 print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_playlist.png' % r, file=f)
346 print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_disk.png' % r, file=f)
347 print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_combiner.png' % r, file=f)
348 for l in ['de_DE', 'es_ES', 'fr_FR', 'it_IT', 'sv_SE', 'nl_NL', 'ru_RU', 'pl_PL', 'da_DK',
349 'pt_PT', 'pt_BR', 'sk_SK', 'cs_CZ', 'uk_UA', 'zh_CN', 'tr_TR']:
350 print('%%{_datadir}/locale/%s/LC_MESSAGES/dcpomatic2.mo' % l, file=f)
351 print('%%{_datadir}/locale/%s/LC_MESSAGES/libdcpomatic2-wx.mo' % l, file=f)
352 print('%%{_datadir}/locale/%s/LC_MESSAGES/libdcpomatic2.mo' % l, file=f)
353 print('%{_datadir}/libdcp/tags/*', file=f)
354 print('%{_datadir}/libdcp/xsd/*', file=f)
355 print('%{_datadir}/polkit-1/actions/com.dcpomatic.write-drive.policy', file=f)
357 print('%prep', file=f)
358 print('rm -rf $RPM_BUILD_DIR/dcpomatic-%s' % version, file=f)
359 print('tar xjf $RPM_SOURCE_DIR/dcpomatic-%s.tar.bz2' % version, file=f)
360 print('%build', file=f)
361 print('cd dcpomatic-%s' % version, file=f)
362 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)
363 print('CXXFLAGS="-I%s/include" LDFLAGS="-L%s/lib" ./waf configure --prefix=%%{buildroot}/usr --destdir=/usr %s' %
364 (target.directory, target.directory, configure_options(target, options)), file=f)
365 print('./waf', file=f)
366 print('%install', file=f)
367 print('cd dcpomatic-%s' % version, file=f)
368 print('./waf install', file=f)
369 print('/bin/cp %s/src/openssl/apps/openssl %%{buildroot}/usr/bin/dcpomatic2_openssl' % target.directory, file=f)
370 print('/bin/mkdir -p %{buildroot}/usr/share/libdcp', file=f)
371 print('/bin/cp -r %s/src/libdcp/tags %%{buildroot}/usr/share/libdcp' % target.directory, file=f)
372 print('/bin/cp -r %s/src/libdcp/xsd %%{buildroot}/usr/share/libdcp' % target.directory, file=f)
373 print('/bin/mv %s/bin/dcpverify %%{buildroot}/usr/bin/dcpomatic2_verify' % target.directory, file=f)
375 print('%post', file=f)
376 print('/bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :', file=f)
377 print('setcap "cap_dac_override+ep cap_sys_admin+ep" /usr/bin/dcpomatic2_disk_writer', file=f)
379 print('%postun', file=f)
380 print('if [ $1 -eq 0 ] ; then', file=f)
381 print(' /bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null', file=f)
382 print(' /usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :', file=f)
385 print('%posttrans', file=f)
386 print('/usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :', file=f)
388 def dependencies(target, options):
390 if target.platform == 'linux':
391 ffmpeg_options = { 'shared': False }
395 if target.platform != 'linux' or target.distro != 'arch':
396 deps = [('ffmpeg-cdist', 'cb2b073d4f88230fca1d1d74e45235f5268fd825', ffmpeg_options)]
398 # Use distro-provided FFmpeg on Arch
401 deps.append(('libdcp', 'v1.8.7'))
402 deps.append(('libsub', 'v1.6.7'))
403 deps.append(('leqm-nrt', '93ae9e6'))
404 deps.append(('rtaudio', 'f619b76'))
405 # We get our OpenSSL libraries from the environment, but we
406 # also need a patched openssl binary to make certificates.
407 # This dependency is to get that binary, which is added into
408 # the appropriate place later
409 deps.append(('openssl', '7f29dd5'))
410 if can_build_disk(target):
411 deps.append(('lwext4', 'cce3730'))
412 deps.append(('ffcmp', '10934f1a9cd9770ef0b38da153f9576e77e7e925'))
416 option_defaults = { "gui": True, "variant": None }
418 def configure_options(target, options):
419 opt = ' --warnings-are-errors'
421 if not ((target.platform == 'linux' and target.distro == 'ubuntu' and target.version == '18.04') or
422 (target.platform == 'osx') or
423 (target.platform == 'windows')):
424 # Currently we only build tests on Ubuntu 18.04, macOS and Windows
425 opt += ' --disable-tests'
428 opt += ' --enable-debug'
429 if target.platform == 'windows':
430 opt += ' --target-windows'
431 elif target.platform == 'linux':
432 opt += ' --static-dcpomatic --static-wxwidgets --static-ffmpeg --static-dcp --static-sub --static-cxml'
433 if target.distro == 'centos':
434 if target.version == '6.5':
435 opt += ' --static-boost --static-xmlpp'
436 elif target.version == '7':
437 opt += ' --workaround-gssapi'
439 if not options['gui']:
440 opt += ' --disable-gui'
442 if options['variant'] is not None:
443 opt += ' --variant=%s' % options['variant']
445 # Build Windows debug versions with static linking as I think gdb works better then
446 if target.debug and target.platform == 'windows':
447 opt += ' --static-dcpomatic'
449 if can_build_disk(target):
450 opt += ' --enable-disk'
452 if target.platform == 'osx' and target.arch == 'arm64':
453 opt += ' --target-macos-arm64 --wx-config=%s/wx-config' % target.bin
457 def build(target, options):
458 if target.platform == 'flatpak':
459 target.checkout_dependencies()
460 prefix = 'https://dcpomatic.com/deps'
462 modules.append({'name': 'libzip',
463 'buildsystem': 'cmake',
464 'sources': [{'type': 'archive',
465 'url': '%s/libzip-1.4.0.tar.xz' % prefix,
466 'sha256': 'e508aba025f5f94b267d5120fc33761bcd98440ebe49dbfe2ed3df3afeacc7b1'}]})
467 modules.append({'name': 'libsigc++',
468 'sources': [{'type': 'archive',
469 'url': '%s/libsigc++-2.10.0.tar.xz' % prefix,
470 'sha256': 'f843d6346260bfcb4426259e314512b99e296e8ca241d771d21ac64f28298d81'}]})
471 modules.append({'name': 'glibmm',
472 'sources': [{'type': 'archive',
473 'url': '%s/glibmm-2.48.1.tar.xz' % prefix,
474 'sha256': 'dc225f7d2f466479766332483ea78f82dc349d59399d30c00de50e5073157cdf'}]})
475 modules.append({'name': 'cairomm',
476 'sources': [{'type': 'archive',
477 'url': '%s/cairomm-1.12.2.tar.gz' % prefix,
478 'sha256': '45c47fd4d0aa77464a75cdca011143fea3ef795c4753f6e860057da5fb8bd599'}]})
479 modules.append({'name': 'pangomm',
480 'sources': [{'type': 'archive',
481 'url': '%s/pangomm-2.40.1.tar.xz' % prefix,
482 'sha256': '9762ee2a2d5781be6797448d4dd2383ce14907159b30bc12bf6b08e7227be3af'}]})
483 modules.append({'name': 'libxml++',
484 'sources': [{'type': 'archive',
485 'url': '%s/libxml++-2.40.1.tar.xz' % prefix,
486 'sha256': '4ad4abdd3258874f61c2e2a41d08e9930677976d303653cd1670d3e9f35463e9'}]})
487 modules.append({'name': 'xmlsec1',
488 'sources': [{'type': 'archive',
489 'url': '%s/xmlsec1-1.2.25.tar.gz' % prefix,
490 'sha256': '967ca83edf25ccb5b48a3c4a09ad3405a63365576503bf34290a42de1b92fcd2'}]})
491 modules.append({'name': 'openjpeg2',
492 'buildsystem': 'cmake',
493 'sources': [{'type': 'dir', 'path': os.path.abspath('../openjpeg2-cdist')}]})
494 modules.append({'name': 'boost',
495 'buildsystem': 'simple',
497 './bootstrap.sh --prefix=/app',
500 'sources': [{'type': 'archive',
501 'url': '%s/boost_1_66_0.tar.bz2' % prefix,
502 'sha256': '5721818253e6a0989583192f96782c4a98eb6204965316df9f5ad75819225ca9'}]})
503 modules.append({'name': 'asdcplib',
504 'buildsystem': 'simple',
506 './waf configure --prefix=/app --libdir=/app/lib build install'
508 'sources': [{'type': 'dir', 'path': os.path.abspath('../asdcplib-carl')}]})
509 modules.append({'name': 'locked_sstream',
510 'buildsystem': 'simple',
512 './waf configure --prefix=/app build install'
514 'sources': [{'type': 'dir', 'path': os.path.abspath('../locked_sstream')}]})
515 modules.append({'name': 'libcxml',
516 'buildsystem': 'simple',
518 './waf configure --prefix=/app --libdir=/app/lib build install'
520 'sources': [{'type': 'dir', 'path': os.path.abspath('../libcxml')}]})
521 modules.append({'name': 'libdcp',
522 'buildsystem': 'simple',
524 './waf configure --prefix=/app --libdir=/app/lib build install'
526 'sources': [{'type': 'dir', 'path': os.path.abspath('../libdcp')}]})
527 modules.append({'name': 'libsub',
528 'buildsystem': 'simple',
530 './waf configure --prefix=/app --libdir=/app/lib build install'
532 'sources': [{'type': 'dir', 'path': os.path.abspath('../libsub')}]})
533 modules.append({'name': 'rtaudio',
541 'sources': [{'type': 'dir', 'path': os.path.abspath('../rtaudio-cdist')}]})
542 modules.append({'name': 'wxwidgets',
543 'sources': [{'type': 'archive',
544 'url': '%s/wxWidgets-3.0.3.tar.bz2' % prefix,
545 'sha256': '08c8033f48ec1b23520f036cde37b5ae925a6a65f137ded665633ca159b9307b'}]})
546 modules.append({'name': 'libssh',
547 'buildsystem': 'cmake',
549 'sources': [{'type': 'archive',
550 'url': '%s/libssh-0.7.5.tar.xz' % prefix,
551 'sha256': '54e86dd5dc20e5367e58f3caab337ce37675f863f80df85b6b1614966a337095'}]})
552 modules.append({'name': 'dcpomatic',
553 'buildsystem': 'simple',
555 './waf configure --prefix=/app build install'
558 'build-args': ['--share=network']
560 'sources': [{'type': 'dir', 'path': os.path.abspath('.')}]})
561 desc = {'app-id': 'com.dcpomatic.DCP-o-matic',
562 'runtime': 'org.gnome.Sdk',
563 'runtime-version': '3.26',
564 'sdk': 'org.gnome.Sdk',
565 'command': 'dcpomatic2',
566 'finish-args': ['--socket=x11', '--share=ipc', '--share=network', '--socket=pulseaudio', '--filesystem=host'],
568 os.makedirs('build/platform')
569 with open('build/com.dcpomatic.DCP-o-matic.json', 'w') as outfile:
570 json.dump(desc, outfile)
571 target.command('%s --repo=build/platform/repo build/platform/flatpak build/com.dcpomatic.DCP-o-matic.json' % target.flatpak_builder())
573 target.command('./waf configure --prefix=%s %s' % (target.directory, configure_options(target, options)))
574 target.command('./waf')
575 target.command('./waf install')
577 def package_windows(target):
579 if target.version is not None:
580 identifier = '%s.' % target.version
581 identifier += '%d' % target.bits
582 shutil.copyfile('build/platform/windows/installer.%s.nsi' % identifier, 'build/platform/windows/installer2.%s.nsi' % identifier)
583 target.command('sed -i "s~%%resources%%~%s/platform/windows~g" build/platform/windows/installer2.%s.nsi' % (os.getcwd(), identifier))
584 target.command('sed -i "s~%%graphics%%~%s/graphics~g" build/platform/windows/installer2.%s.nsi' % (os.getcwd(), identifier))
585 target.command('sed -i "s~%%static_deps%%~%s~g" build/platform/windows/installer2.%s.nsi' % (target.windows_prefix, identifier))
586 target.command('sed -i "s~%%cdist_deps%%~%s~g" build/platform/windows/installer2.%s.nsi' % (target.directory, identifier))
587 target.command('sed -i "s~%%mingw%%~%s~g" build/platform/windows/installer2.%s.nsi' % (target.environment_prefix, identifier))
588 target.command('sed -i "s~%%binaries%%~%s/build~g" build/platform/windows/installer2.%s.nsi' % (os.getcwd(), identifier))
589 target.command('sed -i "s~%%bits%%~32~g" build/platform/windows/installer2.%s.nsi' % identifier)
590 target.command('makensis build/platform/windows/installer2.%s.nsi' % identifier)
591 return os.path.abspath(glob.glob('build/platform/windows/*%s*.exe' % target.bits)[0])
593 def package_debian(target, cpu, version, options):
594 make_control(target.version, target.bits, 'debian/control', target.debug, options['gui'])
595 if target.version != '9' and target.version != '16.04' and options['gui']:
596 with open('debian/postinst', 'w') as f:
597 print('#!/bin/sh', file=f)
598 # Get the required capability to write to disks
599 print('setcap "cap_dac_override+ep cap_sys_admin+ep" /usr/bin/dcpomatic2_disk_writer', file=f)
600 target.command('./waf dist')
601 f = open('debian/files', 'w')
602 suffix = '' if options['gui'] else '-cli'
603 print(f'dcpomatic{suffix}_{version}-1_{cpu}.deb video extra', file=f)
604 shutil.rmtree('build/deb', ignore_errors=True)
606 os.makedirs('build/deb')
607 os.chdir('build/deb')
608 shutil.move('../../dcpomatic-%s.tar.bz2' % version, 'dcpomatic_%s.orig.tar.bz2' % version)
609 target.command('tar xjf dcpomatic_%s.orig.tar.bz2' % version)
610 os.chdir('dcpomatic-%s' % version)
611 target.set('EMAIL', 'carl@dcpomatic.com')
612 target.command('dch -b -v %s-1 "New upstream release."' % version)
613 target.set('CDIST_LINKFLAGS', target.get('LINKFLAGS'))
614 target.set('CDIST_CXXFLAGS', target.get('CXXFLAGS'))
615 target.set('CDIST_PKG_CONFIG_PATH', target.get('PKG_CONFIG_PATH'))
616 target.set('CDIST_DIRECTORY', target.directory)
618 target.set('CDIST_CONFIGURE', '"' + configure_options(target, options) + '"')
619 target.set('CDIST_PACKAGE', f'dcpomatic{suffix}')
621 target.set('CDIST_DEBUG_PACKAGE_FLAG', '--no-ddebs')
623 target.command('dpkg-buildpackage -uc -us')
626 for p in glob.glob('../*.deb'):
627 debs.append(os.path.abspath(p))
631 def package_rpm(target, cpu, version, options):
632 topdir = os.path.realpath('build/rpmbuild')
633 os.makedirs('%s/BUILD' % topdir)
634 os.makedirs('%s/RPMS' % topdir)
635 os.makedirs('%s/SOURCES' % topdir)
636 os.makedirs('%s/SPECS' % topdir)
637 os.makedirs('%s/SRPMS' % topdir)
639 target.command('./waf dist')
641 "%s/src/dcpomatic/dcpomatic-%s.tar.bz2" % (target.directory, version),
642 "%s/SOURCES/dcpomatic-%s.tar.bz2" % (topdir, version)
646 if target.distro == 'mageia':
647 requires = "lib64xmlsec1-devel lib64canberra-gtk0 libcap-utils"
649 make_spec('dcpomatic2.spec', version, target, options, requires)
650 cmd = 'rpmbuild --define "_topdir %s" -bb dcpomatic2.spec' % topdir
659 for p in glob.glob('%s/RPMS/%s/*.rpm' % (topdir, cpu)):
660 rpms.append(os.path.abspath(p))
664 def make_appimage(target, nice_name, internal_name, version):
665 nice_filename = nice_name.replace(' ', '_')
666 appdir = f'build/{nice_filename}.AppDir'
667 os.makedirs(f'{appdir}/usr/bin')
668 target.command(f'cp {target.directory}/bin/{internal_name} {appdir}/usr/bin')
669 target.command(f'cp {target.directory}/src/openssl/apps/openssl {appdir}/usr/bin/dcpomatic2_openssl')
670 target.command(f'cp {target.directory}/bin/dcpverify {appdir}/usr/bin/dcpomatic2_verify')
671 target.command(f'mkdir -p {appdir}/usr/share/libdcp')
672 target.command(f'cp -r {target.directory}/share/dcpomatic2 {appdir}/usr/share/')
673 target.command(f'cp -r {target.directory}/share/libdcp/xsd {appdir}/usr/share/libdcp/')
674 target.command(f'cp -r {target.directory}/share/libdcp/tags {appdir}/usr/share/libdcp/')
675 lib = 'usr/lib/x86_64-linux-gnu'
676 target.command(f'mkdir -p build/{nice_filename}.AppDir/{lib}/gdk-pixbuf-2.0/2.10.0')
677 target.command(f'cp -a /{lib}/gdk-pixbuf-2.0 build/{nice_filename}.AppDir/usr/lib/x86_64-linux-gnu/')
678 target.command('apt update')
679 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']:
680 target.command(f'apt download {package}')
681 target.command(f'dpkg-deb -x {package}*.deb {appdir}')
682 target.command(f'glib-compile-schemas {appdir}/usr/share/glib-2.0/schemas')
683 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')
684 # Stop anything loading from outside the AppImage
685 target.command(f'sed -i -e "s|/usr|/xxx|g" {appdir}/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2')
687 if internal_name == 'dcpomatic2_disk':
688 target.command(f'mkdir -p {appdir}/usr/share/polkit-1/actions')
689 target.command(f'cp {target.directory}/share/polkit-1/actions/com.dcpomatic.write-drive.policy {appdir}/usr/share/polkit-1/actions')
691 with open(f'{appdir}/AppRun', 'w') as f:
692 print('#!/bin/bash', file=f)
693 print('export PATH=$APPDIR/usr/bin:$PATH', file=f)
694 print('export XDG_DATA_DIRS="$APPDIR/usr/share/:/usr/share/:$XDG_DATA_DIRS"', file=f)
695 print('export GDK_PIXBUF_MODULEDIR=$(readlink -f "$APPDIR"/usr/lib/x86_64-linux-gnu/gdk-pixbuf-*/*/loaders/ )', file=f)
696 print('export GDK_PIXBUF_MODULE_FILE=$(readlink -f "$APPDIR"/usr/lib/x86_64-linux-gnu/gdk-pixbuf-*/*/loaders.cache )', file=f)
697 print('export LD_LIBRARY_PATH=$GDK_PIXBUF_MODULEDIR:$APPDIR/usr/lib:$APPDIR/usr/lib/x86_64-linux-gnu', file=f)
698 print(f'"$APPDIR"/usr/bin/{internal_name} $@', file=f)
699 target.command(f'chmod a+rx {appdir}/AppRun')
700 with open(f'{appdir}/{internal_name}.desktop', 'w') as f:
701 print('[Desktop Entry]', file=f)
702 print('Type=Application', file=f)
703 print('Categories=AudioVideo;', file=f)
704 print(f'Name={nice_name}', file=f)
705 print(f'Icon={internal_name}', file=f)
706 target.command(f'cp graphics/linux/256/{internal_name}.png {appdir}')
707 target.command(f'linuxdeploy-x86_64.AppImage --appdir {appdir}')
708 target.command(f'appimagetool-x86_64.AppImage {appdir}')
709 target.command(f'mv {nice_filename}-x86_64.AppImage build/{nice_filename}-{version}-x86_64.AppImage')
710 return os.path.abspath(f'build/{nice_filename}-{version}-x86_64.AppImage')
712 def package(target, version, options):
713 """version: DCP-o-matic version string"""
714 if target.platform != 'linux' or target.detail == 'appimage':
715 # In most cases we need to build ourselves before packaging, but on some Linux targets the packaging
716 # tool wants to build DCP-o-matic so we don't bother here.
717 build(target, options)
718 if target.platform == 'windows':
719 return package_windows(target)
720 elif target.platform == 'linux':
721 if target.detail == 'appimage':
723 out.append(make_appimage(target, 'DCP-o-matic', 'dcpomatic2', version))
724 out.append(make_appimage(target, 'DCP-o-matic Player', 'dcpomatic2_player', version))
725 out.append(make_appimage(target, 'DCP-o-matic Playlist Editor', 'dcpomatic2_playlist', version))
726 out.append(make_appimage(target, 'DCP-o-matic KDM Creator', 'dcpomatic2_kdm', version))
727 out.append(make_appimage(target, 'DCP-o-matic Batch Converter', 'dcpomatic2_batch', version))
728 out.append(make_appimage(target, 'DCP-o-matic Encode Server', 'dcpomatic2_server', version))
729 out.append(make_appimage(target, 'DCP-o-matic Combiner', 'dcpomatic2_combiner', version))
732 if target.bits == 32:
737 if target.distro == 'debian' or target.distro == 'ubuntu':
738 return package_debian(target, cpu, version, options)
739 elif target.distro == 'centos' or target.distro == 'fedora' or target.distro == 'mageia':
740 return package_rpm(target, cpu, version, options)
741 elif target.platform == 'osx':
742 archs = ' '.join(f'{t.arch}/{t.deployment}' for t in target.sub_targets)
743 target.command('bash platform/osx/make_dmg.sh %s %s %s %s %s' % (target.environment_prefix, target.directory, target.apple_id, target.apple_password, archs))
745 for x in glob.glob('build/platform/osx/DCP-o-matic*.dmg'):
746 a = os.path.abspath(x)
747 if x.find("Player") != -1:
748 packages.append((a, "com.dcpomatic.player"))
749 elif x.find("Playlist Editor") != -1:
750 packages.append((a, "com.dcpomatic.playlist"))
751 elif x.find("KDM Creator") != -1:
752 packages.append((a, "com.dcpomatic.kdm"))
753 elif x.find("Batch Converter") != -1:
754 packages.append((a, "com.dcpomatic.batch"))
755 elif x.find("Encode Server") != -1:
756 packages.append((a, "com.dcpomatic.server"))
757 elif x.find("Disk Writer") != -1:
758 packages.append((a, "com.dcpomatic.disk"))
759 elif x.find("Combiner") != -1:
760 packages.append((a, "com.dcpomatic.combiner"))
762 packages.append((a, "com.dcpomatic"))
764 elif target.platform == 'docker':
765 shutil.copyfile(target.deb, 'build/platform/docker')
766 f = open('build/platform/docker/Dockerfile', 'w')
767 print('FROM debian:jessie', file=f)
768 print('MAINTAINER carl@dcpomatic.com', file=f)
769 print('ADD build/platform/docker/dcpomatic_%s-1_amd64.deb /tmp' % (version, version), file=f)
770 print('RUN apt-get -o Acquire:http::Timeout="5" update; exit 0', file=f)
771 print('RUN dpkg -i /tmp/dcpomatic_*.deb; exit 0', file=f)
772 print('RUN apt-get -y -f install', file=f)
773 print('RUN apt-get clean', file=f)
774 print('EXPOSE 6192', file=f)
775 print('CMD ["/usr/bin/dcpomatic2_server_cli", "--verbose"]', file=f)
777 target.command('docker build build/platform/docker -t dcpomatic-server:%s' % version)
778 target.command('docker save dcpomatic-server:%s -o dcpomatic-server-%s-docker.tar' % (version, version))
779 elif target.platform == 'flatpak':
780 target.command('%s build-bundle build/platform/repo build/dcpomatic_%s.flatpak com.dcpomatic.DCP-o-matic' % (target.flatpak(), version))
781 return os.path.abspath('build/dcpomatic_%s.flatpak' % version)
783 def make_pot(target):
784 target.command('./waf pot')
785 return [os.path.abspath('build/src/lib/libdcpomatic.pot'),
786 os.path.abspath('build/src/wx/libdcpomatic-wx.pot'),
787 os.path.abspath('build/src/tools/dcpomatic.pot')]
789 def make_manual(target):
790 target.command('make -C doc/manual LIBDCP=../../../libdcp')
791 os.chdir('doc/manual')
792 target.command('pdflatex colour.tex')
793 return [os.path.abspath('pdf'), os.path.abspath('html'), os.path.abspath('colour.pdf')]
795 def test(target, options, test):
796 target.set('LC_ALL', 'C')
797 if target.platform == 'windows':
802 cmd += '--backtrace '
804 cmd += '-t %s' % test