3 # Copyright (C) 2012-2015 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.04'] = {'libc6': '2.21-0ubuntu4',
72 'libssh-4': '0.6.3-3ubuntu3',
73 'libboost-filesystem1.55.0': '1.55.0+dfsg-3ubuntu2',
74 'libboost-thread1.55.0': '1.55.0+dfsg-3ubuntu2',
75 'libboost-regex1.55.0': '1.55.0+dfsg-3ubuntu2',
76 'libsndfile1': '1.0.25-9.1',
77 'libmagick++-6.q16-5': '8:6.8.9.9-5',
78 'libxml++2.6-2': '2.36.0-2.1',
79 'libgtk2.0-0': '2.24.27-0ubuntu1',
80 'libxmlsec1': '1.2.20-2ubuntu2',
81 'libxmlsec1-openssl': '1.2.20-2ubuntu2',
82 'libboost-date-time1.55.0': '1.55.0+dfsg-3ubuntu2',
83 'libcurl3': '7.38.0-3ubuntu2',
84 'libzip2': '0.11.2-1.2',
85 'libwxgtk3.0-0': '3.0.2-1',
86 'libsamplerate0': '0.1.8-8',
89 deb_depends['15.10'] = {'libc6': '2.21-0ubuntu4',
90 'libssh-4': '0.6.3-3ubuntu3',
91 'libboost-filesystem1.58.0': '1.58.0+dfsg-3.1ubuntu1',
92 'libboost-thread1.58.0': '1.58.0+dfsg-3.1ubuntu1',
93 'libboost-regex1.58.0': '1.58.0+dfsg-3.1ubuntu1',
94 'libsndfile1': '1.0.25-9.1',
95 'libmagick++-6.q16-5v5': '8:6.8.9.9-5ubuntu2',
96 'libxml++2.6-2v5': '2.38.1-2',
97 'libgtk2.0-0': '2.24.28-1ubuntu1',
98 'libxmlsec1': '1.2.20-2ubuntu3',
99 'libxmlsec1-openssl': '1.2.20-2ubuntu3',
100 'libboost-date-time1.58.0': '1.58.0+dfsg-3.1ubuntu1',
101 'libcurl3': '7.43.0-1ubuntu2',
102 'libzip4': '1.0.1-0ubuntu1',
103 'libwxgtk3.0-0v5': '3.0.2+dfsg-1.2',
104 'libsamplerate0': '0.1.8-8',
105 'libicu55': '55.1-4ubuntu1'}
107 deb_depends['7'] = {'libc6': '2.13',
109 'libboost-filesystem1.49.0': '1.49.0',
110 'libboost-thread1.49.0': '1.49.0',
111 'libboost-regex1.49.0': '1.49.0',
112 'libsndfile1': '1.0.25',
113 'libmagick++5': '8:6.7.7.10',
114 'libxml++2.6-2': '2.34.2',
115 'libgtk2.0-0': '2.24.10',
116 'libxmlsec1': '1.2.18',
117 'libboost-date-time1.49.0': '1.49.0',
118 'libxmlsec1-openssl': '1.2.18',
119 'libcurl3': '7.26.0',
121 'libcairomm-1.0-1': '1.10.0-1',
122 'libpangomm-1.4-1': '2.28.4-1',
123 'libsamplerate0': '0.1.8-5',
124 'libicu48': '4.8.1.1-12+deb7u3'}
126 deb_depends['8'] = {'libc6': '2.19-18',
127 'libssh-4': '0.6.3-4',
128 'libboost-filesystem1.55.0': '1.55.0',
129 'libboost-thread1.55.0': '1.55.0',
130 'libboost-date-time1.55.0': '1.55.0',
131 'libboost-regex1.55.0': '1.55.0',
132 'libsndfile1': '1.0.25-9.1',
133 'libmagick++-6.q16-5': '8:6.8.9.9-5',
134 'libxml++2.6-2': '2.36.0',
135 'libgtk2.0-0': '2.24.25',
136 'libxmlsec1': '1.2.20',
137 'libxmlsec1-openssl': '1.2.20',
138 'libcurl3': '7.38.0',
140 'libwxgtk3.0-0': '3.0.2',
141 'libxcb-xfixes0': '1.10',
142 'libxcb-shape0': '1.10',
143 'libsamplerate0': '0.1.8-8',
144 'libicu52': '52.1-8+deb8u2'}
146 deb_depends['unstable'] = {'libc6': '2.19-22',
147 'libssh-4': '0.6.3-4.1+b1',
148 'libboost-filesystem1.58.0': '1.58.0+dfsg-4',
149 'libboost-thread1.58.0': '1.58.0+dfsg-4',
150 'libboost-regex1.58.0': '1.58.0+dfsg-4',
151 'libsndfile1': '1.0.25-9.1',
152 'libmagick++-6.q16-5v5': '8:6.8.9.9-6',
153 'libxml++2.6-2v5': '2.40.1-1',
154 'libgtk2.0-0': '2.24.28-1',
155 'libxmlsec1': '1.2.20-2+b2',
156 'libboost-date-time1.58.0': '1.58.0+dfsg-4',
157 'libxmlsec1-openssl': '1.2.20-2+b2',
158 'libcurl3': '7.45.0-1+b1',
159 'libzip2': '0.11.2-1.2',
160 'libsamplerate0': '0.1.8-8',
161 'libicu52': '52.1-10'}
163 def packages(name, packages, f):
167 print(s[:-2], file=f)
169 def make_control(debian_version, bits, filename, debug):
170 f = open(filename, 'w')
171 print('Source: dcpomatic', file=f)
172 print('Section: video', file=f)
173 print('Priority: extra', file=f)
174 print('Maintainer: Carl Hetherington <carl@dcpomatic.com>', file=f)
175 packages('Build-Depends', deb_build_depends, f)
176 print('Standards-Version: 3.9.3', file=f)
177 print('Homepage: http://dcpomatic.com/', file=f)
179 print('Package: dcpomatic', file=f)
181 print('Architecture: i386', file=f)
183 print('Architecture: amd64', file=f)
185 packages('Depends', deb_depends[debian_version], f)
187 print('Description: Generator of Digital Cinema Packages (DCPs)', file=f)
188 print(' DCP-o-matic generates Digital Cinema Packages (DCPs) from video and audio', file=f)
189 print(' files (such as those from DVDs or Blu-Rays) for presentation on DCI-compliant', file=f)
190 print(' digital projectors.', file=f)
194 print('Package: dcpomatic-dbg', file=f)
196 print('Architecture: i386', file=f)
198 print('Architecture: amd64', file=f)
199 print('Section: debug', file=f)
200 print('Priority: extra', file=f)
201 packages('Depends', deb_depends[debian_version], f)
202 print('Description: debugging symbols for dcpomatic', file=f)
203 print(' This package contains the debugging symbols for dcpomatic.', file=f)
206 def make_spec(filename, version, target):
207 """Make a .spec file for a RPM build"""
208 f = open(filename, 'w')
209 print('Summary:A program that generates Digital Cinema Packages (DCPs) from video and audio files', file=f)
210 print('Name:dcpomatic2', file=f)
211 print('Version:%s' % version, file=f)
212 print('Release:1%{?dist}', file=f)
213 print('License:GPL', file=f)
214 print('Group:Applications/Multimedia', file=f)
215 print('URL:http://dcpomatic.com/', file=f)
216 print('Requires: ImageMagick-c++, glibmm24, libzip', file=f)
218 print('%description', file=f)
219 print('DCP-o-matic generates Digital Cinema Packages (DCPs) from video and audio ', file=f)
220 print('files (such as those from DVDs or Blu-Rays) for presentation on DCI-compliant ', file=f)
221 print('digital projectors.', file=f)
223 print('%files', file=f)
224 print('%{_bindir}/dcpomatic2', file=f)
225 print('%{_bindir}/dcpomatic2_batch', file=f)
226 print('%{_bindir}/dcpomatic2_cli', file=f)
227 print('%{_bindir}/dcpomatic2_create', file=f)
228 print('%{_bindir}/dcpomatic2_kdm', file=f)
229 print('%{_bindir}/dcpomatic2_server', file=f)
230 print('%{_bindir}/dcpomatic2_server_cli', file=f)
231 print('%{_bindir}/dcpomatic2_kdm_cli', file=f)
232 print('%{_datadir}/applications/dcpomatic2.desktop', file=f)
233 print('%{_datadir}/applications/dcpomatic2_batch.desktop', file=f)
234 print('%{_datadir}/applications/dcpomatic2_server.desktop', file=f)
235 print('%{_datadir}/applications/dcpomatic2_kdm.desktop', file=f)
236 print('%{_datadir}/dcpomatic2/dcpomatic2_server_small.png', file=f)
237 print('%{_datadir}/dcpomatic2/LiberationSans-Regular.ttf', file=f)
238 print('%{_datadir}/dcpomatic2/LiberationSans-Italic.ttf', file=f)
239 print('%{_datadir}/dcpomatic2/LiberationSans-Bold.ttf', file=f)
240 print('%{_datadir}/dcpomatic2/splash.png', file=f)
241 for r in ['128x128', '16x16', '22x22', '256x256', '32x32', '48x48', '512x512', '64x64']:
242 print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2.png' % r, file=f)
243 print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_batch.png' % r, file=f)
244 print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_kdm.png' % r, file=f)
245 print('%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2_server.png' % r, file=f)
246 for l in ['de_DE', 'es_ES', 'fr_FR', 'it_IT', 'sv_SE', 'nl_NL', 'ru_RU', 'pl_PL', 'da_DK', 'pt_PT', 'sk_SK', 'cs_CZ']:
247 print('%%{_datadir}/locale/%s/LC_MESSAGES/dcpomatic2.mo' % l, file=f)
248 print('%%{_datadir}/locale/%s/LC_MESSAGES/libdcpomatic2-wx.mo' % l, file=f)
249 print('%%{_datadir}/locale/%s/LC_MESSAGES/libdcpomatic2.mo' % l, file=f)
251 print('%prep', file=f)
252 print('rm -rf $RPM_BUILD_DIR/dcpomatic-%s' % version, file=f)
253 print('tar xjf $RPM_SOURCE_DIR/dcpomatic-%s.tar.bz2' % version, file=f)
254 print('%build', file=f)
255 print('cd dcpomatic-%s' % version, file=f)
256 print('export PKG_CONFIG_PATH=%s/lib/pkgconfig:%s/lib64/pkgconfig:/usr/local/lib/pkgconfig' % (target.directory, target.directory), file=f)
257 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)
258 print('./waf', file=f)
259 print('%install', file=f)
260 print('cd dcpomatic-%s' % version, file=f)
261 print('./waf install', file=f)
263 print('%post', file=f)
264 print('/bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :', file=f)
266 print('%postun', file=f)
267 print('if [ $1 -eq 0 ] ; then', file=f)
268 print(' /bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null', file=f)
269 print(' /usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :', file=f)
272 print('%posttrans', file=f)
273 print('/usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :', file=f)
275 def dependencies(target):
277 if target.platform == 'linux':
278 ffmpeg_options = { 'shared': False }
282 return (('ffmpeg-cdist', '96d67de', ffmpeg_options),
283 ('libdcp', 'c009f67'),
284 ('libsub', '76462cc'))
286 def configure_options(target):
289 opt += ' --enable-debug'
290 if target.platform == 'windows':
291 opt += ' --target-windows'
292 elif target.platform == 'linux':
293 opt += ' --static-dcpomatic --static-wxwidgets --static-ffmpeg --static-dcp --static-sub --static-cxml'
294 if target.distro == 'centos':
295 opt += ' --static-xmlsec --static-ssh --disable-tests'
296 if target.version == '6.5':
297 opt += ' --static-boost --static-xmlpp'
298 elif target.version == '7':
299 opt += ' --workaround-gssapi --static-xmlpp'
303 def build(target, options):
304 target.command('./waf configure --prefix=%s %s' % (target.directory, configure_options(target)))
305 target.command('./waf')
307 if target.platform == 'linux' or target.platform == 'osx':
308 target.command('./waf install')
310 def package_windows(target):
311 shutil.copyfile('build/platform/windows/installer.%s.nsi' % target.bits, 'build/platform/windows/installer2.%s.nsi' % target.bits)
312 target.command('sed -i "s~%%resources%%~%s/platform/windows~g" build/platform/windows/installer2.%s.nsi' % (os.getcwd(), target.bits))
313 target.command('sed -i "s~%%graphics%%~%s/graphics~g" build/platform/windows/installer2.%s.nsi' % (os.getcwd(), target.bits))
314 target.command('sed -i "s~%%static_deps%%~%s~g" build/platform/windows/installer2.%s.nsi' % (target.windows_prefix, target.bits))
315 target.command('sed -i "s~%%cdist_deps%%~%s~g" build/platform/windows/installer2.%s.nsi' % (target.directory, target.bits))
316 target.command('sed -i "s~%%mingw%%~%s~g" build/platform/windows/installer2.%s.nsi' % (target.mingw_path, target.bits))
317 target.command('sed -i "s~%%binaries%%~%s/build~g" build/platform/windows/installer2.%s.nsi' % (os.getcwd(), target.bits))
318 target.command('sed -i "s~%%bits%%~32~g" build/platform/windows/installer2.%s.nsi' % target.bits)
319 target.command('makensis build/platform/windows/installer2.%s.nsi' % target.bits)
320 return os.path.abspath(glob.glob('build/platform/windows/*%s*.exe' % target.bits)[0])
322 def package_debian(target, cpu, version):
323 make_control(target.version, target.bits, 'debian/control', target.debug)
324 target.command('./waf dist')
325 f = open('debian/files', 'w')
326 print('dcpomatic_%s-1_%s.deb video extra' % (version, cpu), file=f)
327 shutil.rmtree('build/deb', ignore_errors=True)
329 os.makedirs('build/deb')
330 os.chdir('build/deb')
331 shutil.move('../../dcpomatic-%s.tar.bz2' % version, 'dcpomatic_%s.orig.tar.bz2' % version)
332 target.command('tar xjf dcpomatic_%s.orig.tar.bz2' % version)
333 os.chdir('dcpomatic-%s' % version)
334 target.command('dch -b -v %s-1 "New upstream release."' % version)
335 target.set('CDIST_LINKFLAGS', target.get('LINKFLAGS'))
336 target.set('CDIST_CXXFLAGS', target.get('CXXFLAGS'))
337 target.set('CDIST_PKG_CONFIG_PATH', target.get('PKG_CONFIG_PATH'))
339 target.set('CDIST_CONFIGURE', '"' + configure_options(target) + '"')
341 target.set('CDIST_DEBUG_PACKAGE', '--dbg-package=dcpomatic-dbg')
342 if target.version in ['15.04', '15.10', '8']:
343 target.set('CDIST_LOCALE_PREFIX', '/usr/share/locale')
345 target.set('CDIST_LOCALE_PREFIX', '/usr/local/share/locale')
347 target.command('dpkg-buildpackage -uc -us')
350 for p in glob.glob('../*.deb'):
351 debs.append(os.path.abspath(p))
355 def package_rpm(target, cpu, version):
356 topdir = os.path.realpath('build/rpmbuild')
357 os.makedirs('%s/BUILD' % topdir)
358 os.makedirs('%s/RPMS' % topdir)
359 os.makedirs('%s/SOURCES' % topdir)
360 os.makedirs('%s/SPECS' % topdir)
361 os.makedirs('%s/SRPMS' % topdir)
363 target.command('./waf dist')
365 "%s/src/dcpomatic/dcpomatic-%s.tar.bz2" % (target.directory, version),
366 "%s/SOURCES/dcpomatic-%s.tar.bz2" % (topdir, version)
369 make_spec('build/platform/linux/dcpomatic2.spec', version, target)
370 target.command('rpmbuild --define \'_topdir %s\' -bb build/platform/linux/dcpomatic2.spec' % topdir)
378 print('Looking in %s/RPMS/%s/*.rpm' % (topdir, cpu))
379 for p in glob.glob('%s/RPMS/%s/*.rpm' % (topdir, cpu)):
380 print('found %s' % p)
381 rpms.append(os.path.abspath(p))
385 def package(target, version):
386 if target.platform == 'windows':
387 return package_windows(target)
388 elif target.platform == 'linux':
389 if target.bits == 32:
394 if target.distro == 'debian' or target.distro == 'ubuntu':
395 return package_debian(target, cpu, version)
396 elif target.distro == 'centos' or target.distro == 'fedora':
397 return package_rpm(target, cpu, version)
398 elif target.platform == 'osx':
399 target.command('bash platform/osx/make_dmg.sh %s' % target.directory)
400 return os.path.abspath(glob.glob('build/platform/osx/DCP-o-matic*.dmg')[0])
402 def make_pot(target):
403 target.command('./waf pot')
404 return [os.path.abspath('build/src/lib/libdcpomatic.pot'),
405 os.path.abspath('build/src/wx/libdcpomatic-wx.pot'),
406 os.path.abspath('build/src/tools/dcpomatic.pot')]
408 def make_manual(target):
409 os.chdir('doc/manual')
410 target.command('make')
411 target.command('pdflatex colour.tex')
412 return [os.path.abspath('pdf'), os.path.abspath('html'), os.path.abspath('colour.pdf')]
415 if target.platform != 'windows':
416 target.set('LC_ALL', 'C')
417 target.command('run/tests')