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(['python'])
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('Replaces: dcpomatic-cli', file=f)
253 print('Architecture: i386', file=f)
255 print('Architecture: amd64', file=f)
257 pkg = deb_depends[debian_version]
258 if gui and debian_version in deb_depends_gui:
259 pkg.extend(deb_depends_gui[debian_version])
261 packages('Depends', pkg, f)
263 print('Description: Generator of Digital Cinema Packages (DCPs)', file=f)
264 print(' DCP-o-matic generates Digital Cinema Packages (DCPs) from videos, images,', file=f)
265 print(' sound and subtitle files. You can use it to make content for playback on DCI-compliant', file=f)
266 print(' cinema projectors.', file=f)
268 print(' This package contains the command-line tools only.', file=f)
272 print(f'Package: dcpomatic{suffix}-dbg', file=f)
274 print('Architecture: i386', file=f)
276 print('Architecture: amd64', file=f)
277 print('Section: debug', file=f)
278 print('Priority: extra', file=f)
279 packages('Depends', pkg, f)
280 print('Description: debugging symbols for dcpomatic', file=f)
281 print(' This package contains the debugging symbols for dcpomatic.', file=f)
284 def make_spec(filename, version, target, options, requires=None):
285 """Make a .spec file for a RPM build"""
286 f = open(filename, 'w')
287 print('Summary:A program that generates Digital Cinema Packages (DCPs) from video and audio files', file=f)
288 print('Name:dcpomatic2', file=f)
289 print('Version:%s' % version, file=f)
290 print('Release:1%{?dist}', file=f)
291 print('License:GPL', file=f)
292 print('Group:Applications/Multimedia', file=f)
293 print('URL:https://dcpomatic.com/', file=f)
294 if requires is not None:
295 print('Requires:%s' % requires, file=f)
297 print('%description', file=f)
298 print('DCP-o-matic generates Digital Cinema Packages (DCPs) from video and audio ', file=f)
299 print('files for presentation on DCI-compliant digital projectors.', file=f)
301 print('%files', file=f)
302 print('%{_bindir}/dcpomatic2', file=f)
303 print('%{_bindir}/dcpomatic2_batch', file=f)
304 print('%{_bindir}/dcpomatic2_cli', file=f)
305 print('%{_bindir}/dcpomatic2_create', file=f)
306 print('%{_bindir}/dcpomatic2_kdm', file=f)
307 print('%{_bindir}/dcpomatic2_server', file=f)
308 print('%{_bindir}/dcpomatic2_server_cli', file=f)
309 print('%{_bindir}/dcpomatic2_kdm_cli', file=f)
310 print('%{_bindir}/dcpomatic2_player', file=f)
311 print('%{_bindir}/dcpomatic2_playlist', file=f)
312 print('%{_bindir}/dcpomatic2_openssl', file=f)
313 print('%{_bindir}/dcpomatic2_combiner', file=f)
314 print('%{_bindir}/dcpomatic2_verify', file=f)
315 if can_build_disk(target):
316 print('%{_bindir}/dcpomatic2_disk', file=f)
317 print('%caps(cap_dac_override=ep) %{_bindir}/dcpomatic2_disk_writer', file=f)
318 print('%{_datadir}/applications/dcpomatic2.desktop', file=f)
319 print('%{_datadir}/applications/dcpomatic2_batch.desktop', file=f)
320 print('%{_datadir}/applications/dcpomatic2_server.desktop', file=f)
321 print('%{_datadir}/applications/dcpomatic2_kdm.desktop', file=f)
322 print('%{_datadir}/applications/dcpomatic2_player.desktop', file=f)
323 print('%{_datadir}/applications/dcpomatic2_playlist.desktop', file=f)
324 print('%{_datadir}/applications/dcpomatic2_combiner.desktop', file=f)
325 if can_build_disk(target):
326 print('%{_datadir}/applications/dcpomatic2_disk.desktop', file=f)
327 print('%{_datadir}/dcpomatic2/dcpomatic2_server_small.png', file=f)
328 print('%{_datadir}/dcpomatic2/select.png', file=f)
329 print('%{_datadir}/dcpomatic2/sequence.png', file=f)
330 print('%{_datadir}/dcpomatic2/snap.png', file=f)
331 print('%{_datadir}/dcpomatic2/zoom.png', file=f)
332 print('%{_datadir}/dcpomatic2/zoom_all.png', file=f)
333 print('%{_datadir}/dcpomatic2/tick.png', file=f)
334 print('%{_datadir}/dcpomatic2/no_tick.png', file=f)
335 print('%{_datadir}/dcpomatic2/link.png', file=f)
336 print('%{_datadir}/dcpomatic2/me.jpg', file=f)
337 print('%{_datadir}/dcpomatic2/LiberationSans-Regular.ttf', file=f)
338 print('%{_datadir}/dcpomatic2/LiberationSans-Italic.ttf', file=f)
339 print('%{_datadir}/dcpomatic2/LiberationSans-Bold.ttf', file=f)
340 print('%{_datadir}/dcpomatic2/splash.png', file=f)
341 for r in ['128x128', '16x16', '22x22', '256x256', '32x32', '48x48', '512x512', '64x64']:
342 print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2.png' % r, file=f)
343 print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_batch.png' % r, file=f)
344 print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_kdm.png' % r, file=f)
345 print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_server.png' % r, file=f)
346 print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_player.png' % r, file=f)
347 print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_playlist.png' % r, file=f)
348 print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_disk.png' % r, file=f)
349 print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_combiner.png' % r, file=f)
350 for l in ['de_DE', 'es_ES', 'fr_FR', 'it_IT', 'sv_SE', 'nl_NL', 'ru_RU', 'pl_PL', 'da_DK',
351 'pt_PT', 'pt_BR', 'sk_SK', 'cs_CZ', 'uk_UA', 'zh_CN', 'tr_TR']:
352 print('%%{_datadir}/locale/%s/LC_MESSAGES/dcpomatic2.mo' % l, file=f)
353 print('%%{_datadir}/locale/%s/LC_MESSAGES/libdcpomatic2-wx.mo' % l, file=f)
354 print('%%{_datadir}/locale/%s/LC_MESSAGES/libdcpomatic2.mo' % l, file=f)
355 print('%{_datadir}/libdcp/tags/*', file=f)
356 print('%{_datadir}/libdcp/xsd/*', file=f)
357 print('%{_datadir}/polkit-1/actions/com.dcpomatic.write-drive.policy', file=f)
359 print('%prep', file=f)
360 print('rm -rf $RPM_BUILD_DIR/dcpomatic-%s' % version, file=f)
361 print('tar xjf $RPM_SOURCE_DIR/dcpomatic-%s.tar.bz2' % version, file=f)
362 print('%build', file=f)
363 print('cd dcpomatic-%s' % version, file=f)
364 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)
365 print('CXXFLAGS="-I%s/include" LDFLAGS="-L%s/lib" ./waf configure --prefix=%%{buildroot}/usr --destdir=/usr %s' %
366 (target.directory, target.directory, configure_options(target, options)), file=f)
367 print('./waf', file=f)
368 print('%install', file=f)
369 print('cd dcpomatic-%s' % version, file=f)
370 print('./waf install', file=f)
371 print('/bin/cp %s/src/openssl/apps/openssl %%{buildroot}/usr/bin/dcpomatic2_openssl' % target.directory, file=f)
372 print('/bin/mkdir -p %{buildroot}/usr/share/libdcp', file=f)
373 print('/bin/cp -r %s/src/libdcp/tags %%{buildroot}/usr/share/libdcp' % target.directory, file=f)
374 print('/bin/cp -r %s/src/libdcp/xsd %%{buildroot}/usr/share/libdcp' % target.directory, file=f)
375 print('/bin/mv %s/bin/dcpverify %%{buildroot}/usr/bin/dcpomatic2_verify' % target.directory, file=f)
377 print('%post', file=f)
378 print('/bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :', file=f)
379 print('setcap "cap_dac_override+ep cap_sys_admin+ep" /usr/bin/dcpomatic2_disk_writer', file=f)
381 print('%postun', file=f)
382 print('if [ $1 -eq 0 ] ; then', file=f)
383 print(' /bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null', file=f)
384 print(' /usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :', file=f)
387 print('%posttrans', file=f)
388 print('/usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :', file=f)
390 def dependencies(target, options):
392 if target.platform == 'linux':
393 ffmpeg_options = { 'shared': False }
397 if target.platform != 'linux' or target.distro != 'arch':
398 deps = [('ffmpeg-cdist', 'cb2b073d4f88230fca1d1d74e45235f5268fd825', ffmpeg_options)]
400 # Use distro-provided FFmpeg on Arch
403 deps.append(('libdcp', 'e579b4c'))
404 deps.append(('libsub', 'f24a2c1'))
405 deps.append(('leqm-nrt', '93ae9e6'))
406 deps.append(('rtaudio', 'f619b76'))
407 # We get our OpenSSL libraries from the environment, but we
408 # also need a patched openssl binary to make certificates.
409 # This dependency is to get that binary, which is added into
410 # the appropriate place later
411 deps.append(('openssl', '7f29dd5'))
412 if can_build_disk(target):
413 deps.append(('lwext4', 'cce3730'))
414 deps.append(('ffcmp', '10934f1a9cd9770ef0b38da153f9576e77e7e925'))
418 option_defaults = { "gui": True, "variant": None }
420 def configure_options(target, options):
421 opt = ' --warnings-are-errors'
423 if not ((target.platform == 'linux' and target.distro == 'ubuntu' and target.version == '18.04') or
424 (target.platform == 'osx') or
425 (target.platform == 'windows')):
426 # Currently we only build tests on Ubuntu 18.04, macOS and Windows
427 opt += ' --disable-tests'
430 opt += ' --enable-debug'
431 if target.platform == 'windows':
432 opt += ' --target-windows'
433 elif target.platform == 'linux':
434 opt += ' --static-dcpomatic --static-wxwidgets --static-ffmpeg --static-dcp --static-sub --static-cxml'
435 if target.distro == 'centos':
436 if target.version == '6.5':
437 opt += ' --static-boost --static-xmlpp'
438 elif target.version == '7':
439 opt += ' --workaround-gssapi'
441 if not options['gui']:
442 opt += ' --disable-gui'
444 if options['variant'] is not None:
445 opt += ' --variant=%s' % options['variant']
447 # Build Windows debug versions with static linking as I think gdb works better then
448 if target.debug and target.platform == 'windows':
449 opt += ' --static-dcpomatic'
451 if can_build_disk(target):
452 opt += ' --enable-disk'
454 if target.platform == 'osx' and target.arch == 'arm64':
455 opt += ' --target-macos-arm64 --wx-config=%s/wx-config' % target.bin
459 def build(target, options):
460 if target.platform == 'flatpak':
461 target.checkout_dependencies()
462 prefix = 'https://dcpomatic.com/deps'
464 modules.append({'name': 'libzip',
465 'buildsystem': 'cmake',
466 'sources': [{'type': 'archive',
467 'url': '%s/libzip-1.4.0.tar.xz' % prefix,
468 'sha256': 'e508aba025f5f94b267d5120fc33761bcd98440ebe49dbfe2ed3df3afeacc7b1'}]})
469 modules.append({'name': 'libsigc++',
470 'sources': [{'type': 'archive',
471 'url': '%s/libsigc++-2.10.0.tar.xz' % prefix,
472 'sha256': 'f843d6346260bfcb4426259e314512b99e296e8ca241d771d21ac64f28298d81'}]})
473 modules.append({'name': 'glibmm',
474 'sources': [{'type': 'archive',
475 'url': '%s/glibmm-2.48.1.tar.xz' % prefix,
476 'sha256': 'dc225f7d2f466479766332483ea78f82dc349d59399d30c00de50e5073157cdf'}]})
477 modules.append({'name': 'cairomm',
478 'sources': [{'type': 'archive',
479 'url': '%s/cairomm-1.12.2.tar.gz' % prefix,
480 'sha256': '45c47fd4d0aa77464a75cdca011143fea3ef795c4753f6e860057da5fb8bd599'}]})
481 modules.append({'name': 'pangomm',
482 'sources': [{'type': 'archive',
483 'url': '%s/pangomm-2.40.1.tar.xz' % prefix,
484 'sha256': '9762ee2a2d5781be6797448d4dd2383ce14907159b30bc12bf6b08e7227be3af'}]})
485 modules.append({'name': 'libxml++',
486 'sources': [{'type': 'archive',
487 'url': '%s/libxml++-2.40.1.tar.xz' % prefix,
488 'sha256': '4ad4abdd3258874f61c2e2a41d08e9930677976d303653cd1670d3e9f35463e9'}]})
489 modules.append({'name': 'xmlsec1',
490 'sources': [{'type': 'archive',
491 'url': '%s/xmlsec1-1.2.25.tar.gz' % prefix,
492 'sha256': '967ca83edf25ccb5b48a3c4a09ad3405a63365576503bf34290a42de1b92fcd2'}]})
493 modules.append({'name': 'openjpeg2',
494 'buildsystem': 'cmake',
495 'sources': [{'type': 'dir', 'path': os.path.abspath('../openjpeg2-cdist')}]})
496 modules.append({'name': 'boost',
497 'buildsystem': 'simple',
499 './bootstrap.sh --prefix=/app',
502 'sources': [{'type': 'archive',
503 'url': '%s/boost_1_66_0.tar.bz2' % prefix,
504 'sha256': '5721818253e6a0989583192f96782c4a98eb6204965316df9f5ad75819225ca9'}]})
505 modules.append({'name': 'asdcplib',
506 'buildsystem': 'simple',
508 './waf configure --prefix=/app --libdir=/app/lib build install'
510 'sources': [{'type': 'dir', 'path': os.path.abspath('../asdcplib-carl')}]})
511 modules.append({'name': 'locked_sstream',
512 'buildsystem': 'simple',
514 './waf configure --prefix=/app build install'
516 'sources': [{'type': 'dir', 'path': os.path.abspath('../locked_sstream')}]})
517 modules.append({'name': 'libcxml',
518 'buildsystem': 'simple',
520 './waf configure --prefix=/app --libdir=/app/lib build install'
522 'sources': [{'type': 'dir', 'path': os.path.abspath('../libcxml')}]})
523 modules.append({'name': 'libdcp',
524 'buildsystem': 'simple',
526 './waf configure --prefix=/app --libdir=/app/lib build install'
528 'sources': [{'type': 'dir', 'path': os.path.abspath('../libdcp')}]})
529 modules.append({'name': 'libsub',
530 'buildsystem': 'simple',
532 './waf configure --prefix=/app --libdir=/app/lib build install'
534 'sources': [{'type': 'dir', 'path': os.path.abspath('../libsub')}]})
535 modules.append({'name': 'rtaudio',
543 'sources': [{'type': 'dir', 'path': os.path.abspath('../rtaudio-cdist')}]})
544 modules.append({'name': 'wxwidgets',
545 'sources': [{'type': 'archive',
546 'url': '%s/wxWidgets-3.0.3.tar.bz2' % prefix,
547 'sha256': '08c8033f48ec1b23520f036cde37b5ae925a6a65f137ded665633ca159b9307b'}]})
548 modules.append({'name': 'libssh',
549 'buildsystem': 'cmake',
551 'sources': [{'type': 'archive',
552 'url': '%s/libssh-0.7.5.tar.xz' % prefix,
553 'sha256': '54e86dd5dc20e5367e58f3caab337ce37675f863f80df85b6b1614966a337095'}]})
554 modules.append({'name': 'dcpomatic',
555 'buildsystem': 'simple',
557 './waf configure --prefix=/app build install'
560 'build-args': ['--share=network']
562 'sources': [{'type': 'dir', 'path': os.path.abspath('.')}]})
563 desc = {'app-id': 'com.dcpomatic.DCP-o-matic',
564 'runtime': 'org.gnome.Sdk',
565 'runtime-version': '3.26',
566 'sdk': 'org.gnome.Sdk',
567 'command': 'dcpomatic2',
568 'finish-args': ['--socket=x11', '--share=ipc', '--share=network', '--socket=pulseaudio', '--filesystem=host'],
570 os.makedirs('build/platform')
571 with open('build/com.dcpomatic.DCP-o-matic.json', 'w') as outfile:
572 json.dump(desc, outfile)
573 target.command('%s --repo=build/platform/repo build/platform/flatpak build/com.dcpomatic.DCP-o-matic.json' % target.flatpak_builder())
574 elif target.platform != "linux":
575 # Build here if the packaging step won't do it
576 target.command('./waf configure --prefix=%s %s' % (target.directory, configure_options(target, options)))
577 target.command('./waf')
578 target.command('./waf install')
580 def package_windows(target):
582 if target.version is not None:
583 identifier = '%s.' % target.version
584 identifier += '%d' % target.bits
585 shutil.copyfile('build/platform/windows/installer.%s.nsi' % identifier, 'build/platform/windows/installer2.%s.nsi' % identifier)
586 target.command('sed -i "s~%%resources%%~%s/platform/windows~g" build/platform/windows/installer2.%s.nsi' % (os.getcwd(), identifier))
587 target.command('sed -i "s~%%graphics%%~%s/graphics~g" build/platform/windows/installer2.%s.nsi' % (os.getcwd(), identifier))
588 target.command('sed -i "s~%%static_deps%%~%s~g" build/platform/windows/installer2.%s.nsi' % (target.windows_prefix, identifier))
589 target.command('sed -i "s~%%cdist_deps%%~%s~g" build/platform/windows/installer2.%s.nsi' % (target.directory, identifier))
590 target.command('sed -i "s~%%mingw%%~%s~g" build/platform/windows/installer2.%s.nsi' % (target.environment_prefix, identifier))
591 target.command('sed -i "s~%%binaries%%~%s/build~g" build/platform/windows/installer2.%s.nsi' % (os.getcwd(), identifier))
592 target.command('sed -i "s~%%bits%%~32~g" build/platform/windows/installer2.%s.nsi' % identifier)
593 target.command('makensis build/platform/windows/installer2.%s.nsi' % identifier)
594 return os.path.abspath(glob.glob('build/platform/windows/*%s*.exe' % target.bits)[0])
596 def package_debian(target, cpu, version, options):
597 make_control(target.version, target.bits, 'debian/control', target.debug, options['gui'])
598 if target.version != '9' and target.version != '16.04' and options['gui']:
599 with open('debian/postinst', 'w') as f:
600 print('#!/bin/sh', file=f)
601 # Get the required capability to write to disks
602 print('setcap "cap_dac_override+ep cap_sys_admin+ep" /usr/bin/dcpomatic2_disk_writer', file=f)
603 target.command('./waf dist')
604 f = open('debian/files', 'w')
605 suffix = '' if options['gui'] else '-cli'
606 print(f'dcpomatic{suffix}_{version}-1_{cpu}.deb video extra', file=f)
607 shutil.rmtree('build/deb', ignore_errors=True)
609 os.makedirs('build/deb')
610 os.chdir('build/deb')
611 shutil.move('../../dcpomatic-%s.tar.bz2' % version, 'dcpomatic_%s.orig.tar.bz2' % version)
612 target.command('tar xjf dcpomatic_%s.orig.tar.bz2' % version)
613 os.chdir('dcpomatic-%s' % version)
614 target.set('EMAIL', 'carl@dcpomatic.com')
615 target.command('dch -b -v %s-1 "New upstream release."' % version)
616 target.set('CDIST_LINKFLAGS', target.get('LINKFLAGS'))
617 target.set('CDIST_CXXFLAGS', target.get('CXXFLAGS'))
618 target.set('CDIST_PKG_CONFIG_PATH', target.get('PKG_CONFIG_PATH'))
619 target.set('CDIST_DIRECTORY', target.directory)
621 target.set('CDIST_CONFIGURE', '"' + configure_options(target, options) + '"')
622 target.set('CDIST_PACKAGE', f'dcpomatic{suffix}')
624 target.set('CDIST_DEBUG_PACKAGE_FLAG', f'--dbg-package=dcpomatic{suffix}-dbg')
626 target.command('dpkg-buildpackage -uc -us')
629 for p in glob.glob('../*.deb'):
630 debs.append(os.path.abspath(p))
634 def package_rpm(target, cpu, version, options):
635 topdir = os.path.realpath('build/rpmbuild')
636 os.makedirs('%s/BUILD' % topdir)
637 os.makedirs('%s/RPMS' % topdir)
638 os.makedirs('%s/SOURCES' % topdir)
639 os.makedirs('%s/SPECS' % topdir)
640 os.makedirs('%s/SRPMS' % topdir)
642 target.command('./waf dist')
644 "%s/src/dcpomatic/dcpomatic-%s.tar.bz2" % (target.directory, version),
645 "%s/SOURCES/dcpomatic-%s.tar.bz2" % (topdir, version)
649 if target.distro == 'mageia':
650 requires = "lib64xmlsec1-devel lib64canberra-gtk0 libcap-utils"
652 make_spec('dcpomatic2.spec', version, target, options, requires)
653 cmd = 'rpmbuild --define "_topdir %s" -bb dcpomatic2.spec' % topdir
662 for p in glob.glob('%s/RPMS/%s/*.rpm' % (topdir, cpu)):
663 rpms.append(os.path.abspath(p))
667 def make_appimage(target, nice_name, internal_name, version):
668 nice_filename = nice_name.replace(' ', '_')
669 appdir = f'build/{nice_filename}.AppDir'
670 os.makedirs(f'{appdir}/usr/bin')
671 target.command(f'cp {target.directory}/bin/{internal_name} {appdir}/usr/bin')
672 target.command(f'cp {target.directory}/src/openssl/apps/openssl {appdir}/usr/bin/dcpomatic2_openssl')
673 target.command(f'cp {target.directory}/bin/dcpverify {appdir}/usr/bin/dcpomatic2_verify')
674 target.command(f'mkdir -p {appdir}/usr/share/libdcp')
675 target.command(f'cp -r {target.directory}/share/dcpomatic2 {appdir}/usr/share/')
676 target.command(f'cp -r {target.directory}/share/libdcp/xsd {appdir}/usr/share/libdcp/')
677 target.command(f'cp -r {target.directory}/share/libdcp/tags {appdir}/usr/share/libdcp/')
678 lib = 'usr/lib/x86_64-linux-gnu'
679 target.command(f'mkdir -p build/{nice_filename}.AppDir/{lib}/gdk-pixbuf-2.0/2.10.0')
680 target.command(f'cp -a /{lib}/gdk-pixbuf-2.0 build/{nice_filename}.AppDir/usr/lib/x86_64-linux-gnu/')
681 target.command('apt update')
682 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']:
683 target.command(f'apt download {package}')
684 target.command(f'dpkg-deb -x {package}*.deb {appdir}')
685 target.command(f'glib-compile-schemas {appdir}/usr/share/glib-2.0/schemas')
686 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')
687 # Stop anything loading from outside the AppImage
688 target.command(f'sed -i -e "s|/usr|/xxx|g" {appdir}/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2')
690 if internal_name == 'dcpomatic2_disk':
691 target.command(f'mkdir -p {appdir}/usr/share/polkit-1/actions')
692 target.command(f'cp {target.directory}/share/polkit-1/actions/com.dcpomatic.write-drive.policy {appdir}/usr/share/polkit-1/actions')
694 with open(f'{appdir}/AppRun', 'w') as f:
695 print('#!/bin/bash', file=f)
696 print('export PATH=$APPDIR/usr/bin:$PATH', file=f)
697 print('export XDG_DATA_DIRS="$APPDIR/usr/share/:/usr/share/:$XDG_DATA_DIRS"', file=f)
698 print('export GDK_PIXBUF_MODULEDIR=$(readlink -f "$APPDIR"/usr/lib/x86_64-linux-gnu/gdk-pixbuf-*/*/loaders/ )', file=f)
699 print('export GDK_PIXBUF_MODULE_FILE=$(readlink -f "$APPDIR"/usr/lib/x86_64-linux-gnu/gdk-pixbuf-*/*/loaders.cache )', file=f)
700 print('export LD_LIBRARY_PATH=$GDK_PIXBUF_MODULEDIR:$APPDIR/usr/lib:$APPDIR/usr/lib/x86_64-linux-gnu', file=f)
701 print(f'"$APPDIR"/usr/bin/{internal_name} $@', file=f)
702 target.command(f'chmod a+rx {appdir}/AppRun')
703 with open(f'{appdir}/{internal_name}.desktop', 'w') as f:
704 print('[Desktop Entry]', file=f)
705 print('Type=Application', file=f)
706 print('Categories=AudioVideo;', file=f)
707 print(f'Name={nice_name}', file=f)
708 print(f'Icon={internal_name}', file=f)
709 target.command(f'cp graphics/linux/256/{internal_name}.png {appdir}')
710 target.command(f'linuxdeploy-x86_64.AppImage --appdir {appdir}')
711 target.command(f'appimagetool-x86_64.AppImage {appdir}')
712 target.command(f'mv {nice_filename}-x86_64.AppImage build/{nice_filename}-{version}-x86_64.AppImage')
713 return os.path.abspath(f'build/{nice_filename}-{version}-x86_64.AppImage')
715 def package(target, version, options):
716 """version: DCP-o-matic version string"""
717 if target.platform == 'windows':
718 return package_windows(target)
719 elif target.platform == 'linux':
720 if target.detail == 'appimage':
722 out.append(make_appimage(target, 'DCP-o-matic', 'dcpomatic2', version))
723 out.append(make_appimage(target, 'DCP-o-matic Player', 'dcpomatic2_player', version))
724 out.append(make_appimage(target, 'DCP-o-matic Playlist Editor', 'dcpomatic2_playlist', version))
725 out.append(make_appimage(target, 'DCP-o-matic KDM Creator', 'dcpomatic2_kdm', version))
726 out.append(make_appimage(target, 'DCP-o-matic Batch Converter', 'dcpomatic2_batch', version))
727 out.append(make_appimage(target, 'DCP-o-matic Encode Server', 'dcpomatic2_server', version))
728 out.append(make_appimage(target, 'DCP-o-matic Combiner', 'dcpomatic2_combiner', version))
731 if target.bits == 32:
736 if target.distro == 'debian' or target.distro == 'ubuntu':
737 return package_debian(target, cpu, version, options)
738 elif target.distro == 'centos' or target.distro == 'fedora' or target.distro == 'mageia':
739 return package_rpm(target, cpu, version, options)
740 elif target.platform == 'osx':
741 archs = ' '.join(f'{t.arch}/{t.deployment}' for t in target.sub_targets)
742 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))
744 for x in glob.glob('build/platform/osx/DCP-o-matic*.dmg'):
745 a = os.path.abspath(x)
746 if x.find("Player") != -1:
747 packages.append((a, "com.dcpomatic.player"))
748 elif x.find("Playlist Editor") != -1:
749 packages.append((a, "com.dcpomatic.playlist"))
750 elif x.find("KDM Creator") != -1:
751 packages.append((a, "com.dcpomatic.kdm"))
752 elif x.find("Batch Converter") != -1:
753 packages.append((a, "com.dcpomatic.batch"))
754 elif x.find("Encode Server") != -1:
755 packages.append((a, "com.dcpomatic.server"))
756 elif x.find("Disk Writer") != -1:
757 packages.append((a, "com.dcpomatic.disk"))
758 elif x.find("Combiner") != -1:
759 packages.append((a, "com.dcpomatic.combiner"))
761 packages.append((a, "com.dcpomatic"))
763 elif target.platform == 'docker':
764 shutil.copyfile(target.deb, 'build/platform/docker')
765 f = open('build/platform/docker/Dockerfile', 'w')
766 print('FROM debian:jessie', file=f)
767 print('MAINTAINER carl@dcpomatic.com', file=f)
768 print('ADD build/platform/docker/dcpomatic_%s-1_amd64.deb /tmp' % (version, version), file=f)
769 print('RUN apt-get -o Acquire:http::Timeout="5" update; exit 0', file=f)
770 print('RUN dpkg -i /tmp/dcpomatic_*.deb; exit 0', file=f)
771 print('RUN apt-get -y -f install', file=f)
772 print('RUN apt-get clean', file=f)
773 print('EXPOSE 6192', file=f)
774 print('CMD ["/usr/bin/dcpomatic2_server_cli", "--verbose"]', file=f)
776 target.command('docker build build/platform/docker -t dcpomatic-server:%s' % version)
777 target.command('docker save dcpomatic-server:%s -o dcpomatic-server-%s-docker.tar' % (version, version))
778 elif target.platform == 'flatpak':
779 target.command('%s build-bundle build/platform/repo build/dcpomatic_%s.flatpak com.dcpomatic.DCP-o-matic' % (target.flatpak(), version))
780 return os.path.abspath('build/dcpomatic_%s.flatpak' % version)
782 def make_pot(target):
783 target.command('./waf pot')
784 return [os.path.abspath('build/src/lib/libdcpomatic.pot'),
785 os.path.abspath('build/src/wx/libdcpomatic-wx.pot'),
786 os.path.abspath('build/src/tools/dcpomatic.pot')]
788 def make_manual(target):
789 target.command('make -C doc/manual LIBDCP=../../../libdcp')
790 os.chdir('doc/manual')
791 target.command('pdflatex colour.tex')
792 return [os.path.abspath('pdf'), os.path.abspath('html'), os.path.abspath('colour.pdf')]
794 def test(target, options, test):
795 target.set('LC_ALL', 'C')
796 if target.platform == 'windows':
801 cmd += '--backtrace '
803 cmd += '-t %s' % test