Manual wording tweaks.
[dcpomatic.git] / cscript
1 # -*- mode: python -*-
2 #
3 #    Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
4 #
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.
9 #
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.
14 #
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.
18 #
19
20 import glob
21 import shutil
22 import os
23
24 deb_build_depends = {'debhelper': '8.0.0',
25                      'python': '2.7.3',
26                      'g++': '4:4.6.3',
27                      'pkg-config': '0.26',
28                      'libssh-dev': '0.5.2',
29                      'libsndfile1-dev': '1.0.25',
30                      'libgtk2.0-dev': '2.24.10'}
31
32 deb_depends = dict()
33
34 deb_depends['12.04'] = {'libc6': '2.15',
35                         'libssh-4': '0.5.2',
36                         'libboost-filesystem1.48.0': '1.48.0-3',
37                         'libboost-thread1.48.0': '1.48.0-3',
38                         'libboost-regex1.48.0': '1.48.0-3',
39                         'libsndfile1': '1.0.25',
40                         'libmagick++4': '8:6.6.9.7',
41                         'libxml++2.6-2': '2.34.1',
42                         'libgtk2.0-0': '2.24.10',
43                         'libxmlsec1': '1.2.14-1.2build1',
44                         'libxmlsec1-openssl': '1.2.14-1.2build1',
45                         'libboost-date-time1.48.0': '1.48.0-3',
46                         'libcurl3': '7.22.0-3ubuntu4',
47                         'libzip2': '0.10-1ubuntu1'}
48
49 deb_depends['14.04'] = {'libc6': '2.19-0ubuntu6',
50                         'libssh-4': '0.6.1-0ubuntu3',
51                         'libboost-filesystem1.54.0': '1.54.0-4ubuntu3',
52                         'libboost-thread1.54.0': '1.54.0-4ubuntu3',
53                         'libboost-regex1.54.0': '1.54.0-4ubuntu3',
54                         'libsndfile1': '1.0.25-7ubuntu2',
55                         'libmagick++5': '8:6.7.7.10-6ubuntu3',
56                         'libxml++2.6-2': '2.36.0-2ubuntu1',
57                         'libgtk2.0-0': '2.24.23-0ubuntu1',
58                         'libxmlsec1': '1.2.18-2ubuntu1',
59                         'libxmlsec1-openssl': '1.2.18-2ubuntu1',
60                         'libboost-date-time1.54.0': '1.54.0-4ubuntu3',
61                         'libcurl3': '7.35.0-1ubuntu2',
62                         'libzip2': '0.10.1-1.2'}
63
64 deb_depends['15.04'] = {'libc6': '2.21-0ubuntu4',
65                         'libssh-4': '0.6.3-3ubuntu3',
66                         'libboost-filesystem1.55.0': '1.55.0+dfsg-3ubuntu2',
67                         'libboost-thread1.55.0': '1.55.0+dfsg-3ubuntu2',
68                         'libboost-regex1.55.0': '1.55.0+dfsg-3ubuntu2',
69                         'libsndfile1': '1.0.25-9.1',
70                         'libmagick++-6.q16-5': '8:6.8.9.9-5',
71                         'libxml++2.6-2': '2.36.0-2.1',
72                         'libgtk2.0-0': '2.24.27-0ubuntu1',
73                         'libxmlsec1': '1.2.20-2ubuntu2',
74                         'libxmlsec1-openssl': '1.2.20-2ubuntu2',
75                         'libboost-date-time1.55.0': '1.55.0+dfsg-3ubuntu2',
76                         'libcurl3': '7.38.0-3ubuntu2',
77                         'libzip2': '0.11.2-1.2',
78                         'libwxgtk3.0-0': '3.0.2-1'}
79
80 deb_depends['7'] = {'libc6': '2.13',
81                     'libssh-4': '0.5.4',
82                     'libboost-filesystem1.49.0': '1.49.0',
83                     'libboost-thread1.49.0': '1.49.0',
84                     'libboost-regex1.49.0': '1.49.0',
85                     'libsndfile1': '1.0.25',
86                     'libmagick++5': '8:6.7.7.10',
87                     'libxml++2.6-2': '2.34.2',
88                     'libgtk2.0-0': '2.24.10',
89                     'libxmlsec1': '1.2.18',
90                     'libboost-date-time1.49.0': '1.49.0',
91                     'libxmlsec1-openssl': '1.2.18',
92                     'libcurl3': '7.26.0',
93                     'libzip2': '0.10.1'}
94
95 deb_depends['8'] = {'libc6': '2.19-18',
96                     'libssh-4': '0.6.3-4',
97                     'libboost-filesystem1.55.0': '1.55.0',
98                     'libboost-thread1.55.0': '1.55.0',
99                     'libboost-date-time1.55.0': '1.55.0',
100                     'libboost-regex1.55.0': '1.55.0',
101                     'libsndfile1': '1.0.25-9.1',
102                     'libmagick++-6.q16-5': '8:6.8.9.9-5',
103                     'libxml++2.6-2': '2.36.0',
104                     'libgtk2.0-0': '2.24.25',
105                     'libxmlsec1': '1.2.20',
106                     'libxmlsec1-openssl': '1.2.20',
107                     'libcurl3': '7.38.0',
108                     'libzip2': '0.11.2',
109                     'libwxgtk3.0-0': '3.0.2',
110                     'libxcb-xfixes0': '1.10',
111                     'libxcb-shape0': '1.10'}
112
113 deb_depends['unstable'] = {'libc6': '2.13',
114                     'libssh-4': '0.5.4',
115                     'libboost-filesystem1.55.0': '1.55.0',
116                     'libboost-thread1.55.0': '1.55.0',
117                     'libboost-regex1.55.0': '1.55.0',
118                     'libsndfile1': '1.0.25',
119                     'libmagick++5': '8:6.7.7.10',
120                     'libxml++2.6-2': '2.34.2',
121                     'libgtk2.0-0': '2.24.10',
122                     'libxmlsec1': '1.2.18',
123                     'libboost-date-time1.55.0': '1.55.0',
124                     'libxmlsec1-openssl': '1.2.18',
125                     'libcurl3': '7.26.0',
126                     'libzip2': '0.10.1'}
127
128
129 def packages(name, packages, f):
130     s = '%s: ' % name
131     for p in packages:
132         s += str(p) + ', '
133     print >>f,s[:-2]
134
135 def make_control(debian_version, bits, filename, debug):
136     f = open(filename, 'w')
137     print >>f,'Source: dcpomatic'
138     print >>f,'Section: video'
139     print >>f,'Priority: extra'
140     print >>f,'Maintainer: Carl Hetherington <carl@dcpomatic.com>'
141     packages('Build-Depends', deb_build_depends, f)
142     print >>f,'Standards-Version: 3.9.3'
143     print >>f,'Homepage: http://dcpomatic.com/'
144     print >>f,''
145     print >>f,'Package: dcpomatic'
146     if bits == 32:
147         print >>f,'Architecture: i386'
148     else:
149         print >>f,'Architecture: amd64'
150
151     packages('Depends', deb_depends[debian_version], f)
152
153     print >>f,'Description: Generator of Digital Cinema Packages (DCPs)'
154     print >>f,'  DCP-o-matic generates Digital Cinema Packages (DCPs) from video and audio'
155     print >>f,'  files (such as those from DVDs or Blu-Rays) for presentation on DCI-compliant'
156     print >>f,'  digital projectors.'
157
158     if debug:
159         print >>f,''
160         print >>f,'Package: dcpomatic-dbg'
161         if bits == 32:
162             print >>f,'Architecture: i386'
163         else:
164             print >>f,'Architecture: amd64'
165         print >>f,'Section: debug'
166         print >>f,'Priority: extra'
167         packages('Depends', deb_depends[debian_version], f)
168         print >>f,'Description: debugging symbols for dcpomatic'
169         print >>f,'  This package contains the debugging symbols for dcpomatic.'
170         print >>f,''
171
172 def make_spec(filename, version, target):
173     """Make a .spec file for a RPM build"""
174     f = open(filename, 'w')
175     print >>f,'Summary:A program that generates Digital Cinema Packages (DCPs) from video and audio files'
176     print >>f,'Name:dcpomatic2'
177     print >>f,'Version:%s' % version
178     print >>f,'Release:1%{?dist}'
179     print >>f,'License:GPL'
180     print >>f,'Group:Applications/Multimedia'
181     print >>f,'URL:http://dcpomatic.com/'
182     print >>f,'Requires: ImageMagick-c++, glibmm24, libzip'
183     print >>f,''
184     print >>f,'%description'
185     print >>f,'DCP-o-matic generates Digital Cinema Packages (DCPs) from video and audio '
186     print >>f,'files (such as those from DVDs or Blu-Rays) for presentation on DCI-compliant '
187     print >>f,'digital projectors.'
188     print >>f,''
189     print >>f,'%files'
190     print >>f,'%{_bindir}/dcpomatic2'
191     print >>f,'%{_bindir}/dcpomatic2_batch'
192     print >>f,'%{_bindir}/dcpomatic2_cli'
193     print >>f,'%{_bindir}/dcpomatic2_create'
194     print >>f,'%{_bindir}/dcpomatic2_kdm'
195     print >>f,'%{_bindir}/dcpomatic2_server'
196     print >>f,'%{_bindir}/dcpomatic2_server_cli'
197     print >>f,'%{_datadir}/applications/dcpomatic2.desktop'
198     print >>f,'%{_datadir}/applications/dcpomatic2_batch.desktop'
199     print >>f,'%{_datadir}/applications/dcpomatic2_server.desktop'
200     print >>f,'%{_datadir}/dcpomatic2/taskbar_icon.png'
201     print >>f,'%{_datadir}/dcpomatic2/LiberationSans-Regular.ttf'
202     print >>f,'%{_datadir}/dcpomatic2/splash.png'
203     for r in ['128x128', '22x22', '32x32', '48x48', '64x64']:
204         print >>f,'%%{_datadir}/icons/hicolor/%s/apps/dcpomatic2.png' % r
205     for l in ['de_DE', 'es_ES', 'fr_FR', 'it_IT', 'sv_SE', 'nl_NL', 'ru_RU', 'pl_PL', 'da_DK']:
206         print >>f,'%%{_datadir}/locale/%s/LC_MESSAGES/dcpomatic2.mo' % l
207         print >>f,'%%{_datadir}/locale/%s/LC_MESSAGES/libdcpomatic2-wx.mo' % l
208         print >>f,'%%{_datadir}/locale/%s/LC_MESSAGES/libdcpomatic2.mo' % l
209     print >>f,''
210     print >>f,'%prep'
211     print >>f,'rm -rf $RPM_BUILD_DIR/dcpomatic-%s' % version
212     print >>f,'tar xjf $RPM_SOURCE_DIR/dcpomatic-%s.tar.bz2' % version
213     print >>f,'%build'
214     print >>f,'cd dcpomatic-%s' % version
215     print >>f,'export PKG_CONFIG_PATH=%s/lib/pkgconfig:/usr/local/lib/pkgconfig' % target.directory
216     print >>f,'CXXFLAGS="-I%s/include" LDFLAGS="-L%s/lib" ./waf configure --prefix=%%{buildroot}/usr --install-prefix=/usr %s' % (target.directory, target.directory, configure_options(target))
217     print >>f,'./waf'
218     print >>f,'%install'
219     print >>f,'cd dcpomatic-%s' % version
220     print >>f,'./waf install'
221     print >>f,''
222     print >>f,'%post'
223     print >>f,'/bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null || :'
224     print >>f,''
225     print >>f,'%postun'
226     print >>f,'if [ $1 -eq 0 ] ; then'
227     print >>f,'    /bin/touch --no-create %{_datadir}/icons/hicolor &>/dev/null'
228     print >>f,'    /usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :'
229     print >>f,'fi'
230     print >>f,''
231     print >>f,'%posttrans'
232     print >>f,'/usr/bin/gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :'
233
234 def dependencies(target):
235     return (('ffmpeg-cdist', 'bd17594'),
236             ('libdcp', 'e4042b7'),
237             ('libsub', '05927c9'))
238
239 def configure_options(target):
240     opt = ''
241     if target.debug:
242         opt += ' --enable-debug'
243     if target.platform == 'windows':
244         opt += ' --target-windows'
245     elif target.platform == 'linux':
246         opt += ' --static-dcpomatic --static-openjpeg --static-wxwidgets --static-ffmpeg --static-dcp --static-sub --static-cxml'
247         if target.distro == 'centos':
248             opt += ' --static-xmlsec --static-ssh --disable-tests'
249             if target.version == '6.5':
250                 opt += ' --static-boost --static-xmlpp'
251             elif target.version == '7':
252                 opt += ' --workaround-gssapi'
253
254     return opt
255
256 def build(target, options):
257     target.command('./waf configure --prefix=%s %s' % (target.directory, configure_options(target)))
258     target.command('./waf')
259
260     if target.platform == 'linux' or target.platform == 'osx':
261         target.command('./waf install')
262
263 def package_windows(target):
264     shutil.copyfile('build/platform/windows/installer.%s.nsi' % target.bits, 'build/platform/windows/installer2.%s.nsi' % target.bits)
265     target.command('sed -i "s~%%resources%%~%s/platform/windows~g" build/platform/windows/installer2.%s.nsi' % (os.getcwd(), target.bits))
266     target.command('sed -i "s~%%graphics%%~%s/graphics~g" build/platform/windows/installer2.%s.nsi' % (os.getcwd(), target.bits))
267     target.command('sed -i "s~%%static_deps%%~%s~g" build/platform/windows/installer2.%s.nsi' % (target.windows_prefix, target.bits))
268     target.command('sed -i "s~%%cdist_deps%%~%s~g" build/platform/windows/installer2.%s.nsi' % (target.directory, target.bits))
269     target.command('sed -i "s~%%mingw%%~%s~g" build/platform/windows/installer2.%s.nsi' % (target.mingw_path, target.bits))
270     target.command('sed -i "s~%%binaries%%~%s/build~g" build/platform/windows/installer2.%s.nsi' % (os.getcwd(), target.bits))
271     target.command('sed -i "s~%%bits%%~32~g" build/platform/windows/installer2.%s.nsi' % target.bits)
272     target.command('makensis build/platform/windows/installer2.%s.nsi' % target.bits)
273     return os.path.abspath(glob.glob('build/platform/windows/*%s*.exe' % target.bits)[0])
274
275 def package_debian(target, cpu, version):
276     make_control(target.version, target.bits, 'debian/control', target.debug)
277     target.command('./waf dist')
278     f = open('debian/files', 'w')
279     print >>f,'dcpomatic_%s-1_%s.deb video extra' % (version, cpu)
280     shutil.rmtree('build/deb', ignore_errors=True)
281
282     os.makedirs('build/deb')
283     os.chdir('build/deb')
284     shutil.move('../../dcpomatic-%s.tar.bz2' % version, 'dcpomatic_%s.orig.tar.bz2' % version)
285     target.command('tar xjf dcpomatic_%s.orig.tar.bz2' % version)
286     os.chdir('dcpomatic-%s' % version)
287     target.command('dch -b -v %s-1 "New upstream release."' % version)
288     target.set('CDIST_LINKFLAGS', target.get('LINKFLAGS'))
289     target.set('CDIST_CXXFLAGS', target.get('CXXFLAGS'))
290     target.set('CDIST_PKG_CONFIG_PATH', target.get('PKG_CONFIG_PATH'))
291
292     target.set('CDIST_CONFIGURE', '"' + configure_options(target) + '"')
293     if target.debug:
294         target.set('CDIST_DEBUG_PACKAGE', '--dbg-package=dcpomatic-dbg')
295     if target.version == '15.04' or target.version == '8':
296         target.set('CDIST_LOCALE_PREFIX', '/usr/share/locale')
297     else:
298         target.set('CDIST_LOCALE_PREFIX', '/usr/local/share/locale')
299
300     target.command('dpkg-buildpackage -uc -us')
301
302     debs = []
303     for p in glob.glob('../*.deb'):
304         debs.append(os.path.abspath(p))
305
306     return debs
307
308 def package_centos(target, cpu, version):
309     topdir = os.path.realpath('build/rpmbuild')
310     os.makedirs('%s/BUILD' % topdir)
311     os.makedirs('%s/RPMS' % topdir)
312     os.makedirs('%s/SOURCES' % topdir)
313     os.makedirs('%s/SPECS' % topdir)
314     os.makedirs('%s/SRPMS' % topdir)
315
316     target.command('./waf dist')
317     shutil.copyfile(
318         "%s/src/dcpomatic2/dcpomatic-%s.tar.bz2" % (target.directory, version),
319         "%s/SOURCES/dcpomatic-%s.tar.bz2" % (topdir, version)
320         )
321
322     make_spec('build/platform/linux/dcpomatic2.spec', version, target)
323     target.command('rpmbuild --define \'_topdir %s\' -bb build/platform/linux/dcpomatic2.spec' % topdir)
324     rpms = []
325
326     if cpu == "amd64":
327         cpu = "x86_64"
328
329     for p in glob.glob('%s/RPMS/%s/*.rpm' % (topdir, cpu)):
330         rpms.append(os.path.abspath(p))
331
332     return rpms
333
334 def package(target, version):
335     if target.platform == 'windows':
336         return package_windows(target)
337     elif target.platform == 'linux':
338         if target.bits == 32:
339             cpu = 'i386'
340         else:
341             cpu = 'amd64'
342
343         if target.distro == 'debian' or target.distro == 'ubuntu':
344             return package_debian(target, cpu, version)
345         elif target.distro == 'centos':
346             return package_centos(target, cpu, version)
347     elif target.platform == 'osx':
348         target.command('bash platform/osx/make_dmg.sh %s' % target.directory)
349         return os.path.abspath(glob.glob('build/platform/osx/DCP-o-matic*.dmg')[0])
350
351 def make_pot(target):
352     target.command('./waf pot')
353     return [os.path.abspath('build/src/lib/libdcpomatic.pot'),
354             os.path.abspath('build/src/wx/libdcpomatic-wx.pot'),
355             os.path.abspath('build/src/tools/dcpomatic.pot')]
356
357 def make_manual(target):
358     os.chdir('doc/manual')
359     target.command('make')
360     target.command('pdflatex colour.tex')
361     return [os.path.abspath('pdf'), os.path.abspath('html'), os.path.abspath('colour.pdf')]
362
363 def test(target):
364     if target.platform != 'windows':
365         target.set('LC_ALL', 'C')
366         target.command('run/tests')