Cleanup: missing word in comment.
[dcpomatic.git] / cscript
diff --git a/cscript b/cscript
index f70e7ca36df11813ff3b7f6507a9b78541ad984b..6f7399f55403bfcdddf7cddcee14adc56eeb9384 100644 (file)
--- a/cscript
+++ b/cscript
 #
 
 from __future__ import print_function
+import datetime
 import glob
 import shutil
 import os
 import copy
 import json
 
+def dmg_prefix(variant):
+    return 'DCP-o-matic'
+
+def debian_name(variant):
+    return 'dcpomatic'
+
 deb_build_depends = dict()
 
 deb_build_depends_base = ['debhelper', 'g++', 'pkg-config', 'libsndfile1-dev', 'libgtk2.0-dev', 'libx264-dev']
@@ -353,9 +360,9 @@ def packages(name, packages, f):
         s += str(p) + ', '
     print(s[:-2], file=f)
 
-def make_control(debian_version, bits, filename, debug, gui):
+def make_control(debian_version, bits, filename, debug, gui, name):
     f = open(filename, 'w')
-    print('Source: dcpomatic', file=f)
+    print(f'Source: {name}', file=f)
     print('Section: video', file=f)
     print('Priority: extra', file=f)
     print('Maintainer: Carl Hetherington <carl@dcpomatic.com>', file=f)
@@ -364,9 +371,9 @@ def make_control(debian_version, bits, filename, debug, gui):
     print('Homepage: https://dcpomatic.com/', file=f)
     print('', file=f)
     suffix = '' if gui else '-cli'
-    print(f'Package: dcpomatic{suffix}', file=f)
+    print(f'Package: {name}{suffix}', file=f)
     if gui:
-        print('Replaces: dcpomatic-cli', file=f)
+        print(f'Replaces: {name}-cli', file=f)
     if bits == 32:
         print('Architecture: i386', file=f)
     else:
@@ -387,7 +394,7 @@ def make_control(debian_version, bits, filename, debug, gui):
 
     if debug:
         print('', file=f)
-        print(f'Package: dcpomatic{suffix}-dbg', file=f)
+        print(f'Package: {name}{suffix}-dbg', file=f)
         if bits == 32:
             print('Architecture: i386', file=f)
         else:
@@ -395,8 +402,8 @@ def make_control(debian_version, bits, filename, debug, gui):
         print('Section: debug', file=f)
         print('Priority: extra', file=f)
         packages('Depends', pkg, f)
-        print('Description: debugging symbols for dcpomatic', file=f)
-        print('  This package contains the debugging symbols for dcpomatic.', file=f)
+        print(f'Description: debugging symbols for {name}', file=f)
+        print(f'  This package contains the debugging symbols for {name}.', file=f)
         print('', file=f)
 
 def make_spec(filename, version, target, options, requires=None):
@@ -430,7 +437,8 @@ def make_spec(filename, version, target, options, requires=None):
     print('%{_bindir}/dcpomatic2_playlist', file=f)
     print('%{_bindir}/dcpomatic2_openssl', file=f)
     print('%{_bindir}/dcpomatic2_combiner', file=f)
-    print('%{_bindir}/dcpomatic2_verify', file=f)
+    print('%{_bindir}/dcpomatic2_verify_cli', file=f)
+    print('%{_bindir}/dcpomatic2_verifier', file=f)
     print('%{_bindir}/dcpomatic2_kdm_inspect', file=f)
     print('%{_bindir}/dcpomatic2_map', file=f)
     if can_build_disk(target):
@@ -439,6 +447,7 @@ def make_spec(filename, version, target, options, requires=None):
     print('%{_datadir}/applications/dcpomatic2.desktop', file=f)
     print('%{_datadir}/applications/dcpomatic2_batch.desktop', file=f)
     print('%{_datadir}/applications/dcpomatic2_editor.desktop', file=f)
+    print('%{_datadir}/applications/dcpomatic2_verifier.desktop', file=f)
     print('%{_datadir}/applications/dcpomatic2_server.desktop', file=f)
     print('%{_datadir}/applications/dcpomatic2_kdm.desktop', file=f)
     print('%{_datadir}/applications/dcpomatic2_player.desktop', file=f)
@@ -472,6 +481,7 @@ def make_spec(filename, version, target, options, requires=None):
         print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2.png' % r, file=f)
         print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_batch.png' % r, file=f)
         print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_editor.png' % r, file=f)
+        print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_verifier.png' % r, file=f)
         print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_kdm.png' % r, file=f)
         print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_server.png' % r, file=f)
         print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_player.png' % r, file=f)
@@ -506,7 +516,7 @@ def make_spec(filename, version, target, options, requires=None):
     print('/bin/cp -r %s/src/libdcp/tags %%{buildroot}/usr/share/libdcp' % target.directory, file=f)
     print('/bin/cp -r %s/src/libdcp/xsd %%{buildroot}/usr/share/libdcp' % target.directory, file=f)
     print('/bin/cp %s/src/libdcp/ratings %%{buildroot}/usr/share/libdcp' % target.directory, file=f)
-    print('/bin/mv %s/bin/dcpverify %%{buildroot}/usr/bin/dcpomatic2_verify' % target.directory, file=f)
+    print('/bin/mv %s/bin/dcpverify %%{buildroot}/usr/bin/dcpomatic2_verify_cli' % target.directory, file=f)
     print('/bin/mv %s/bin/dcpkdm %%{buildroot}/usr/bin/dcpomatic2_kdm_inspect' % target.directory, file=f)
     print('', file=f)
     print('%post', file=f)
@@ -523,19 +533,7 @@ def make_spec(filename, version, target, options, requires=None):
     print('/usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :', file=f)
 
 def dependencies(target, options):
-
-    if target.platform == 'linux':
-        ffmpeg_options = { 'shared': False }
-    else:
-        ffmpeg_options = {}
-
-    if target.platform != 'linux' or target.distro != 'arch':
-        deps = [('ffmpeg', '0b73d2f5e70a04a67aa902902c42e3025ef3bb77', ffmpeg_options)]
-    else:
-        # Use distro-provided FFmpeg on Arch
-        deps = []
-
-    deps.append(('libdcp', '56b3586247d76b2d07911018ccba63d4b05f4995', {'c++17': target.platform == 'osx'}))
+    deps = [('libdcp', 'v1.9.7', {'c++17': target.platform == 'osx'})]
     deps.append(('libsub', 'v1.6.47'))
     deps.append(('leqm-nrt', '30dcaea1373ac62fba050e02ce5b0c1085797a23'))
     deps.append(('rtaudio', 'f619b76'))
@@ -578,7 +576,7 @@ def configure_options(target, options, for_package=False):
     if not options['gui']:
         opt += ' --disable-gui'
 
-    if options['variant'] is not None:
+    if options['variant']:
         opt += ' --variant=%s' % options['variant']
 
     # Build Windows debug versions with static linking as I think gdb works better then
@@ -591,7 +589,7 @@ def configure_options(target, options, for_package=False):
     if target.platform == 'osx':
         opt += ' --c++17'
         if target.arch == 'arm64':
-            opt += ' --target-macos-arm64 --wx-config=%s/wx-config' % target.bin
+            opt += ' --wx-config=%s/wx-config' % target.bin
 
     if target.platform == 'linux' and target.distro == 'ubuntu' and target.version in ['22.04']:
         opt += ' --enable-grok'
@@ -719,10 +717,7 @@ def build(target, options, for_package):
         target.command('./waf install')
 
 def package_windows(target):
-    identifier = ''
-    if target.version is not None:
-        identifier = '%s.' % target.version
-    identifier += '%d' % target.bits
+    identifier = '%d' % target.bits
     shutil.copyfile('build/platform/windows/installer.%s.nsi' % identifier, 'build/platform/windows/installer2.%s.nsi' % identifier)
     target.command('sed -i "s~%%resources%%~%s/platform/windows~g" build/platform/windows/installer2.%s.nsi' % (os.getcwd(), identifier))
     target.command('sed -i "s~%%graphics%%~%s/graphics~g" build/platform/windows/installer2.%s.nsi' % (os.getcwd(), identifier))
@@ -735,7 +730,8 @@ def package_windows(target):
     return os.path.abspath(glob.glob('build/platform/windows/*%s*.exe' % target.bits)[0])
 
 def package_debian(target, cpu, version, options):
-    make_control(target.version, target.bits, 'debian/control', target.debug, options['gui'])
+    name = debian_name(options['variant'])
+    make_control(target.version, target.bits, 'debian/control', target.debug, options['gui'], name)
     if target.version != '9' and target.version != '16.04' and options['gui']:
         with open('debian/postinst', 'w') as f:
             print('#!/bin/sh', file=f)
@@ -744,23 +740,29 @@ def package_debian(target, cpu, version, options):
     target.command('./waf dist')
     f = open('debian/files', 'w')
     suffix = '' if options['gui'] else '-cli'
-    print(f'dcpomatic{suffix}_{version}-1_{cpu}.deb video extra', file=f)
+    print(f'{name}{suffix}_{version}-1_{cpu}.deb video extra', file=f)
     shutil.rmtree('build/deb', ignore_errors=True)
 
     os.makedirs('build/deb')
     os.chdir('build/deb')
-    shutil.move('../../dcpomatic-%s.tar.bz2' % version, 'dcpomatic_%s.orig.tar.bz2' % version)
-    target.command('tar xjf dcpomatic_%s.orig.tar.bz2' % version)
-    os.chdir('dcpomatic-%s' % version)
-    target.set('EMAIL', 'carl@dcpomatic.com')
-    target.command('dch -b -v %s-1 "New upstream release."' % version)
+    shutil.move(f'../../dcpomatic-{version}.tar.bz2', f'{name}_1+{version}.orig.tar.bz2')
+    target.command(f'tar xjf {name}_1+{version}.orig.tar.bz2')
+    os.chdir(f'dcpomatic-{version}')
+
+    with open('debian/changelog', 'w') as f:
+        print(f'{name} (1+{version}-1) unstable; urgency=medium', file=f)
+        print('', file=f)
+        print('  * New upstream release.', file=f)
+        print('', file=f)
+        print(f" -- Carl Hetherington <carl@dcpomatic.com>  {datetime.datetime.now().astimezone().strftime('%a, %d %b %Y %H:%M:%S %z')}", file=f)
+
     target.set('CDIST_LINKFLAGS', target.get('LINKFLAGS'))
     target.set('CDIST_CXXFLAGS', target.get('CXXFLAGS'))
     target.set('CDIST_PKG_CONFIG_PATH', target.get('PKG_CONFIG_PATH'))
     target.set('CDIST_DIRECTORY', target.directory)
 
     target.set('CDIST_CONFIGURE', '"' + configure_options(target, options, for_package=True) + '"')
-    target.set('CDIST_PACKAGE', f'dcpomatic{suffix}')
+    target.set('CDIST_PACKAGE', f'{name}{suffix}')
     target.set('CDIST_WX_VERSION', "3.2" if target.version in ("23.04", "23.10", "24.04") else "3.1")
     if not target.debug:
         target.set('CDIST_DEBUG_PACKAGE_FLAG', '--no-ddebs')
@@ -793,6 +795,8 @@ def package_rpm(target, cpu, version, options):
 
     make_spec('dcpomatic2.spec', version, target, options, requires)
     cmd = 'rpmbuild --define "_topdir %s" -bb dcpomatic2.spec' % topdir
+    # On Centos 7 we build and install boost ourselves, so we must look for it in the right place
+    target.set('LINKFLAGS', '-L/usr/local/lib')
     target.command(cmd)
     rpms = []
 
@@ -812,7 +816,7 @@ def make_appimage(target, nice_name, internal_name, version, extra_binaries=None
     os.makedirs(f'{appdir}/usr/bin')
     target.command(f'cp {target.directory}/bin/{internal_name} {appdir}/usr/bin')
     target.command(f'cp {target.directory}/src/openssl/apps/openssl {appdir}/usr/bin/dcpomatic2_openssl')
-    target.command(f'cp {target.directory}/bin/dcpverify {appdir}/usr/bin/dcpomatic2_verify')
+    target.command(f'cp {target.directory}/bin/dcpverify {appdir}/usr/bin/dcpomatic2_verify_cli')
     target.command(f'cp {target.directory}/bin/dcpkdm {appdir}/usr/bin/dcpomatic2_kdm_inspect')
     if extra_binaries:
         for bin in extra_binaries:
@@ -874,6 +878,7 @@ def package(target, version, options):
             out.append(make_appimage(target, 'DCP-o-matic Encode Server', 'dcpomatic2_server', version))
             out.append(make_appimage(target, 'DCP-o-matic Combiner', 'dcpomatic2_combiner', version))
             out.append(make_appimage(target, 'DCP-o-matic Editor', 'dcpomatic2_editor', version))
+            out.append(make_appimage(target, 'DCP-o-matic Verifier', 'dcpomatic2_verifier', version))
             return out
         else:
             if target.bits == 32:
@@ -890,8 +895,10 @@ def package(target, version, options):
         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)
         if 'part' in options:
             cmd += ' -b ' + options['part']
+        if options['variant']:
+            cmd += ' -v ' + options['variant']
         target.command(cmd)
-        return glob.glob('build/platform/osx/DCP-o-matic*.dmg')
+        return glob.glob('build/platform/osx/' + dmg_prefix(options['variant']) + '*.dmg')
     elif target.platform == 'docker':
         shutil.copyfile(target.deb, 'build/platform/docker')
         f = open('build/platform/docker/Dockerfile', 'w')
@@ -928,7 +935,11 @@ def test(target, options, test):
     if target.platform == 'windows':
         cmd = 'run\\tests '
     else:
-        cmd = 'run/tests --check --log_level=test_suite '
+        cmd = 'run/tests '
+    if target.environment_prefix:
+        cmd += '-e %s ' % target.environment_prefix
+    if target.platform != 'windows':
+        cmd += ' --check --log_level=test_suite '
     if target.debug:
         cmd += '--backtrace '
     if test is not None: