3 # Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 from __future__ import print_function
25 deb_build_depends = {'debhelper': '8.0.0',
29 'libssh-dev': '0.5.2',
30 'libsndfile1-dev': '1.0.25',
31 'libgtk2.0-dev': '2.24.10'}
35 deb_depends['12.04'] = {'libc6': '2.15',
37 'libboost-filesystem1.48.0': '1.48.0-3',
38 'libboost-thread1.48.0': '1.48.0-3',
39 'libboost-regex1.48.0': '1.48.0-3',
40 'libsndfile1': '1.0.25',
41 'libmagick++4': '8:6.6.9.7',
42 'libxml++2.6-2': '2.34.1',
43 'libgtk2.0-0': '2.24.10',
44 'libxmlsec1': '1.2.14-1.2build1',
45 'libxmlsec1-openssl': '1.2.14-1.2build1',
46 'libboost-date-time1.48.0': '1.48.0-3',
47 'libcurl3': '7.22.0-3ubuntu4',
48 'libzip2': '0.10-1ubuntu1',
49 'libsamplerate0': '0.1.8-4',
50 'libicu48': '4.8.1.1-3'}
52 deb_depends['14.04'] = {'libc6': '2.19-0ubuntu6',
53 'libssh-4': '0.6.1-0ubuntu3',
54 'libboost-filesystem1.54.0': '1.54.0-4ubuntu3',
55 'libboost-thread1.54.0': '1.54.0-4ubuntu3',
56 'libboost-regex1.54.0': '1.54.0-4ubuntu3',
57 'libsndfile1': '1.0.25-7ubuntu2',
58 'libmagick++5': '8:6.7.7.10-6ubuntu3',
59 'libxml++2.6-2': '2.36.0-2ubuntu1',
60 'libgtk2.0-0': '2.24.23-0ubuntu1',
61 'libxmlsec1': '1.2.18-2ubuntu1',
62 'libxmlsec1-openssl': '1.2.18-2ubuntu1',
63 'libboost-date-time1.54.0': '1.54.0-4ubuntu3',
64 'libcurl3': '7.35.0-1ubuntu2',
65 'libzip2': '0.10.1-1.2',
66 'libsamplerate0': '0.1.8-7',
67 'libcairomm-1.0-1': '1.10.0-1ubuntu3',
68 'libpangomm-1.4-1': '2.34.0-1ubuntu1',
71 deb_depends['15.10'] = {'libc6': '2.21-0ubuntu4',
72 'libssh-4': '0.6.3-3ubuntu3',
73 'libboost-filesystem1.58.0': '1.58.0+dfsg-3.1ubuntu1',
74 'libboost-thread1.58.0': '1.58.0+dfsg-3.1ubuntu1',
75 'libboost-regex1.58.0': '1.58.0+dfsg-3.1ubuntu1',
76 'libsndfile1': '1.0.25-9.1',
77 'libmagick++-6.q16-5v5': '8:6.8.9.9-5ubuntu2',
78 'libxml++2.6-2v5': '2.38.1-2',
79 'libgtk2.0-0': '2.24.28-1ubuntu1',
80 'libxmlsec1': '1.2.20-2ubuntu3',
81 'libxmlsec1-openssl': '1.2.20-2ubuntu3',
82 'libboost-date-time1.58.0': '1.58.0+dfsg-3.1ubuntu1',
83 'libcurl3': '7.43.0-1ubuntu2',
84 'libzip4': '1.0.1-0ubuntu1',
85 'libwxgtk3.0-0v5': '3.0.2+dfsg-1.2',
86 'libsamplerate0': '0.1.8-8',
87 'libicu55': '55.1-4ubuntu1'}
89 deb_depends['7'] = {'libc6': '2.13',
91 'libboost-filesystem1.49.0': '1.49.0',
92 'libboost-thread1.49.0': '1.49.0',
93 'libboost-regex1.49.0': '1.49.0',
94 'libsndfile1': '1.0.25',
95 'libmagick++5': '8:6.7.7.10',
96 'libxml++2.6-2': '2.34.2',
97 'libgtk2.0-0': '2.24.10',
98 'libxmlsec1': '1.2.18',
99 'libboost-date-time1.49.0': '1.49.0',
100 'libxmlsec1-openssl': '1.2.18',
101 'libcurl3': '7.26.0',
103 'libcairomm-1.0-1': '1.10.0-1',
104 'libpangomm-1.4-1': '2.28.4-1',
105 'libsamplerate0': '0.1.8-5',
106 'libicu48': '4.8.1.1-12+deb7u3'}
108 deb_depends['8'] = {'libc6': '2.19-18',
109 'libssh-4': '0.6.3-4',
110 'libboost-filesystem1.55.0': '1.55.0',
111 'libboost-thread1.55.0': '1.55.0',
112 'libboost-date-time1.55.0': '1.55.0',
113 'libboost-regex1.55.0': '1.55.0',
114 'libsndfile1': '1.0.25-9.1',
115 'libmagick++-6.q16-5': '8:6.8.9.9-5',
116 'libxml++2.6-2': '2.36.0',
117 'libgtk2.0-0': '2.24.25',
118 'libxmlsec1': '1.2.20',
119 'libxmlsec1-openssl': '1.2.20',
120 'libcurl3': '7.38.0',
122 'libwxgtk3.0-0': '3.0.2',
123 'libxcb-xfixes0': '1.10',
124 'libxcb-shape0': '1.10',
125 'libsamplerate0': '0.1.8-8',
126 'libicu52': '52.1-8+deb8u2'}
128 deb_depends['unstable'] = {'libc6': '2.19-22',
129 'libssh-4': '0.6.3-4.1+b1',
130 'libboost-filesystem1.58.0': '1.58.0+dfsg-4',
131 'libboost-thread1.58.0': '1.58.0+dfsg-4',
132 'libboost-regex1.58.0': '1.58.0+dfsg-4',
133 'libsndfile1': '1.0.25-9.1',
134 'libmagick++-6.q16-5v5': '8:6.8.9.9-6',
135 'libxml++2.6-2v5': '2.40.1-1',
136 'libgtk2.0-0': '2.24.28-1',
137 'libxmlsec1': '1.2.20-2+b2',
138 'libboost-date-time1.58.0': '1.58.0+dfsg-4',
139 'libxmlsec1-openssl': '1.2.20-2+b2',
140 'libcurl3': '7.45.0-1+b1',
141 'libzip2': '0.11.2-1.2',
142 'libsamplerate0': '0.1.8-8',
143 'libicu52': '52.1-10'}
145 def packages(name, packages, f):
149 print(s[:-2], file=f)
151 def make_control(debian_version, bits, filename, debug):
152 f = open(filename, 'w')
153 print('Source: dcpomatic', file=f)
154 print('Section: video', file=f)
155 print('Priority: extra', file=f)
156 print('Maintainer: Carl Hetherington <carl@dcpomatic.com>', file=f)
157 packages('Build-Depends', deb_build_depends, f)
158 print('Standards-Version: 3.9.3', file=f)
159 print('Homepage: http://dcpomatic.com/', file=f)
161 print('Package: dcpomatic', file=f)
163 print('Architecture: i386', file=f)
165 print('Architecture: amd64', file=f)
167 packages('Depends', deb_depends[debian_version], f)
169 print('Description: Generator of Digital Cinema Packages (DCPs)', file=f)
170 print(' DCP-o-matic generates Digital Cinema Packages (DCPs) from video and audio', file=f)
171 print(' files (such as those from DVDs or Blu-Rays) for presentation on DCI-compliant', file=f)
172 print(' digital projectors.', file=f)
176 print('Package: dcpomatic-dbg', file=f)
178 print('Architecture: i386', file=f)
180 print('Architecture: amd64', file=f)
181 print('Section: debug', file=f)
182 print('Priority: extra', file=f)
183 packages('Depends', deb_depends[debian_version], f)
184 print('Description: debugging symbols for dcpomatic', file=f)
185 print(' This package contains the debugging symbols for dcpomatic.', file=f)
188 def make_spec(filename, version, target):
189 """Make a .spec file for a RPM build"""
190 f = open(filename, 'w')
191 print('Summary:A program that generates Digital Cinema Packages (DCPs) from video and audio files', file=f)
192 print('Name:dcpomatic2', file=f)
193 print('Version:%s' % version, file=f)
194 print('Release:1%{?dist}', file=f)
195 print('License:GPL', file=f)
196 print('Group:Applications/Multimedia', file=f)
197 print('URL:http://dcpomatic.com/', file=f)
198 print('Requires: ImageMagick-c++, glibmm24, libzip', file=f)
200 print('%description', file=f)
201 print('DCP-o-matic generates Digital Cinema Packages (DCPs) from video and audio ', file=f)
202 print('files (such as those from DVDs or Blu-Rays) for presentation on DCI-compliant ', file=f)
203 print('digital projectors.', file=f)
205 print('%files', file=f)
206 print('%{_bindir}/dcpomatic2', file=f)
207 print('%{_bindir}/dcpomatic2_batch', file=f)
208 print('%{_bindir}/dcpomatic2_cli', file=f)
209 print('%{_bindir}/dcpomatic2_create', file=f)
210 print('%{_bindir}/dcpomatic2_kdm', file=f)
211 print('%{_bindir}/dcpomatic2_server', file=f)
212 print('%{_bindir}/dcpomatic2_server_cli', file=f)
213 print('%{_bindir}/dcpomatic2_kdm_cli', file=f)
214 print('%{_datadir}/applications/dcpomatic2.desktop', file=f)
215 print('%{_datadir}/applications/dcpomatic2_batch.desktop', file=f)
216 print('%{_datadir}/applications/dcpomatic2_server.desktop', file=f)
217 print('%{_datadir}/applications/dcpomatic2_kdm.desktop', file=f)
218 print('%{_datadir}/dcpomatic2/dcpomatic2_server_small.png', file=f)
219 print('%{_datadir}/dcpomatic2/LiberationSans-Regular.ttf', file=f)
220 print('%{_datadir}/dcpomatic2/LiberationSans-Italic.ttf', file=f)
221 print('%{_datadir}/dcpomatic2/LiberationSans-Bold.ttf', file=f)
222 print('%{_datadir}/dcpomatic2/splash.png', file=f)
223 for r in ['128x128', '16x16', '22x22', '256x256', '32x32', '48x48', '512x512', '64x64']:
224 print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2.png' % r, file=f)
225 print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_batch.png' % r, file=f)
226 print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_kdm.png' % r, file=f)
227 print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_server.png' % r, file=f)
228 for l in ['de_DE', 'es_ES', 'fr_FR', 'it_IT', 'sv_SE', 'nl_NL', 'ru_RU', 'pl_PL', 'da_DK', 'pt_PT', 'pt_BR', 'sk_SK', 'cs_CZ', 'uk_UA', 'zh_CN']:
229 print('%%{_datadir}/locale/%s/LC_MESSAGES/dcpomatic2.mo' % l, file=f)
230 print('%%{_datadir}/locale/%s/LC_MESSAGES/libdcpomatic2-wx.mo' % l, file=f)
231 print('%%{_datadir}/locale/%s/LC_MESSAGES/libdcpomatic2.mo' % l, file=f)
233 print('%prep', file=f)
234 print('rm -rf $RPM_BUILD_DIR/dcpomatic-%s' % version, file=f)
235 print('tar xjf $RPM_SOURCE_DIR/dcpomatic-%s.tar.bz2' % version, file=f)
236 print('%build', file=f)
237 print('cd dcpomatic-%s' % version, file=f)
238 print('export PKG_CONFIG_PATH=%s/lib/pkgconfig:%s/lib64/pkgconfig:/usr/local/lib/pkgconfig' % (target.directory, target.directory), file=f)
239 print('CXXFLAGS="-I%s/include" LDFLAGS="-L%s/lib" ./waf configure --prefix=%%{buildroot}/usr --install-prefix=/usr %s' % (target.directory, target.directory, configure_options(target)), file=f)
240 print('./waf', file=f)
241 print('%install', file=f)
242 print('cd dcpomatic-%s' % version, file=f)
243 print('./waf install', file=f)
245 print('%post', file=f)
246 print('/bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :', file=f)
248 print('%postun', file=f)
249 print('if [ $1 -eq 0 ] ; then', file=f)
250 print(' /bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null', file=f)
251 print(' /usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :', file=f)
254 print('%posttrans', file=f)
255 print('/usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :', file=f)
257 def dependencies(target):
259 if target.platform == 'linux':
260 ffmpeg_options = { 'shared': False }
264 return (('ffmpeg-cdist', 'f2952f3', ffmpeg_options),
265 ('libdcp', '4b8c626'),
266 ('libsub', 'b9fb00d'))
268 def configure_options(target):
271 opt += ' --enable-debug'
272 if target.platform == 'windows':
273 opt += ' --target-windows'
274 elif target.platform == 'linux':
275 opt += ' --static-dcpomatic --static-wxwidgets --static-ffmpeg --static-dcp --static-sub --static-cxml'
276 if target.distro == 'centos':
277 opt += ' --static-xmlsec --static-ssh --disable-tests'
278 if target.version == '6.5':
279 opt += ' --static-boost --static-xmlpp'
280 elif target.version == '7':
281 opt += ' --workaround-gssapi --static-xmlpp'
285 def build(target, options):
286 target.command('./waf configure --prefix=%s %s' % (target.directory, configure_options(target)))
287 target.command('./waf')
289 if target.platform == 'linux' or target.platform == 'osx':
290 target.command('./waf install')
292 def package_windows(target):
293 shutil.copyfile('build/platform/windows/installer.%s.nsi' % target.bits, 'build/platform/windows/installer2.%s.nsi' % target.bits)
294 target.command('sed -i "s~%%resources%%~%s/platform/windows~g" build/platform/windows/installer2.%s.nsi' % (os.getcwd(), target.bits))
295 target.command('sed -i "s~%%graphics%%~%s/graphics~g" build/platform/windows/installer2.%s.nsi' % (os.getcwd(), target.bits))
296 target.command('sed -i "s~%%static_deps%%~%s~g" build/platform/windows/installer2.%s.nsi' % (target.windows_prefix, target.bits))
297 target.command('sed -i "s~%%cdist_deps%%~%s~g" build/platform/windows/installer2.%s.nsi' % (target.directory, target.bits))
298 target.command('sed -i "s~%%mingw%%~%s~g" build/platform/windows/installer2.%s.nsi' % (target.mingw_path, target.bits))
299 target.command('sed -i "s~%%binaries%%~%s/build~g" build/platform/windows/installer2.%s.nsi' % (os.getcwd(), target.bits))
300 target.command('sed -i "s~%%bits%%~32~g" build/platform/windows/installer2.%s.nsi' % target.bits)
301 target.command('makensis build/platform/windows/installer2.%s.nsi' % target.bits)
302 return os.path.abspath(glob.glob('build/platform/windows/*%s*.exe' % target.bits)[0])
304 def package_debian(target, cpu, version):
305 make_control(target.version, target.bits, 'debian/control', target.debug)
306 target.command('./waf dist')
307 f = open('debian/files', 'w')
308 print('dcpomatic_%s-1_%s.deb video extra' % (version, cpu), file=f)
309 shutil.rmtree('build/deb', ignore_errors=True)
311 os.makedirs('build/deb')
312 os.chdir('build/deb')
313 shutil.move('../../dcpomatic-%s.tar.bz2' % version, 'dcpomatic_%s.orig.tar.bz2' % version)
314 target.command('tar xjf dcpomatic_%s.orig.tar.bz2' % version)
315 os.chdir('dcpomatic-%s' % version)
316 target.command('dch -b -v %s-1 "New upstream release."' % version)
317 target.set('CDIST_LINKFLAGS', target.get('LINKFLAGS'))
318 target.set('CDIST_CXXFLAGS', target.get('CXXFLAGS'))
319 target.set('CDIST_PKG_CONFIG_PATH', target.get('PKG_CONFIG_PATH'))
321 target.set('CDIST_CONFIGURE', '"' + configure_options(target) + '"')
323 target.set('CDIST_DEBUG_PACKAGE', '--dbg-package=dcpomatic-dbg')
324 if target.version in ['15.04', '15.10', '8']:
325 target.set('CDIST_LOCALE_PREFIX', '/usr/share/locale')
327 target.set('CDIST_LOCALE_PREFIX', '/usr/local/share/locale')
329 target.command('dpkg-buildpackage -uc -us')
332 for p in glob.glob('../*.deb'):
333 debs.append(os.path.abspath(p))
337 def package_rpm(target, cpu, version):
338 topdir = os.path.realpath('build/rpmbuild')
339 os.makedirs('%s/BUILD' % topdir)
340 os.makedirs('%s/RPMS' % topdir)
341 os.makedirs('%s/SOURCES' % topdir)
342 os.makedirs('%s/SPECS' % topdir)
343 os.makedirs('%s/SRPMS' % topdir)
345 target.command('./waf dist')
347 "%s/src/dcpomatic/dcpomatic-%s.tar.bz2" % (target.directory, version),
348 "%s/SOURCES/dcpomatic-%s.tar.bz2" % (topdir, version)
351 make_spec('build/platform/linux/dcpomatic2.spec', version, target)
352 target.command('rpmbuild --define \'_topdir %s\' -bb build/platform/linux/dcpomatic2.spec' % topdir)
360 print('Looking in %s/RPMS/%s/*.rpm' % (topdir, cpu))
361 for p in glob.glob('%s/RPMS/%s/*.rpm' % (topdir, cpu)):
362 print('found %s' % p)
363 rpms.append(os.path.abspath(p))
367 def package(target, version):
368 if target.platform == 'windows':
369 return package_windows(target)
370 elif target.platform == 'linux':
371 if target.bits == 32:
376 if target.distro == 'debian' or target.distro == 'ubuntu':
377 return package_debian(target, cpu, version)
378 elif target.distro == 'centos' or target.distro == 'fedora':
379 return package_rpm(target, cpu, version)
380 elif target.platform == 'osx':
381 target.command('bash platform/osx/make_dmg.sh %s' % target.directory)
382 return os.path.abspath(glob.glob('build/platform/osx/DCP-o-matic*.dmg')[0])
384 def make_pot(target):
385 target.command('./waf pot')
386 return [os.path.abspath('build/src/lib/libdcpomatic.pot'),
387 os.path.abspath('build/src/wx/libdcpomatic-wx.pot'),
388 os.path.abspath('build/src/tools/dcpomatic.pot')]
390 def make_manual(target):
391 os.chdir('doc/manual')
392 target.command('make')
393 target.command('pdflatex colour.tex')
394 return [os.path.abspath('pdf'), os.path.abspath('html'), os.path.abspath('colour.pdf')]
397 if target.platform != 'windows':
398 target.set('LC_ALL', 'C')
399 target.command('run/tests')