Bump libdcp to get some fixes for Interop XML
[dcpomatic.git] / cscript
1 import glob
2 import shutil
3 import os
4
5 build_depends = {'debhelper': '8.0.0',
6                  'python': '2.7.3',
7                  'g++': '4:4.6.3',
8                  'pkg-config': '0.26',
9                  'libssh-dev': '0.5.2',
10                  'libboost-filesystem-dev': '1.46.0',
11                  'libboost-thread-dev': '1.46.0',
12                  'libsndfile1-dev': '1.0.25',
13                  'libmagick++-dev': '8:6.6.9.7',
14                  'libgtk2.0-dev': '2.24.10'}
15
16 depends = dict()
17
18 depends['12.04'] = {'libc6': '2.15',
19                     'libssh-4': '0.5.2',
20                     'libboost-filesystem1.46.1': '1.46.1',
21                     'libboost-thread1.46.1': '1.46.1',
22                     'libsndfile1': '1.0.25',
23                     'libmagick++4': '8:6.6.9.7',
24                     'libxml++2.6-2': '2.34.1',
25                     'libgtk2.0-0': '2.24.10',
26                     'libxmlsec1': '1.2.14-1.2build1',
27                     'libxmlsec1-openssl': '1.2.14-1.2build1',
28                     'libboost-date-time1.46.1': '1.46.1',
29                     'libcurl3': '7.22.0-3ubuntu4',
30                     'libzip2': '0.10-1ubuntu1'}
31
32 depends['12.10'] = {'libc6': '2.15',
33                     'libssh-4': '0.5.2',
34                     'libboost-filesystem1.49.0': '1.49.0',
35                     'libboost-thread1.49.0': '1.49.0',
36                     'libsndfile1': '1.0.25',
37                     'libmagick++5': '8:6.7.7.10',
38                     'libxml++2.6-2': '2.34.2',
39                     'libgtk2.0-0': '2.24.13',
40                     'libxmlsec1': '1.2.18-2',
41                     'libxmlsec1-openssl': '1.2.18-2',
42                     'libboost-date-time1.49.0': '1.49.0',
43                     'libcurl3': '7.27.0-1ubuntu1',
44                     'libzip2': '0.10.1-1.1'}
45
46 depends['13.04'] = {'libc6': '2.15',
47                     'libssh-4': '0.5.2',
48                     'libboost-filesystem1.49.0': '1.49.0',
49                     'libboost-thread1.49.0': '1.49.0',
50                     'libsndfile1': '1.0.25',
51                     'libmagick++5': '8:6.7.7.10',
52                     'libxml++2.6-2': '2.34.2',
53                     'libgtk2.0-0': '2.24.13',
54                     'libxmlsec1': '1.2.18-2',
55                     'libxmlsec1-openssl': '1.2.18-2',
56                     'libboost-date-time1.49.0': '1.49.0',
57                     'libcurl3': '7.29.0-1ubuntu3',
58                     'libzip2': '0.10.1-1.1'}
59
60 depends['13.10'] = {'libc6': '2.17-93',
61                     'libssh-4': '0.5.4',
62                     'libboost-filesystem1.53.0': '1.53.0',
63                     'libboost-thread1.53.0': '1.53.0',
64                     'libsndfile1': '1.0.25',
65                     'libmagick++5': '8:6.7.7.10',
66                     'libxml++2.6-2': '2.36.0',
67                     'libgtk2.0-0': '2.24.20',
68                     'libxmlsec1': '1.2.18-2',
69                     'libxmlsec1-openssl': '1.2.18-2',
70                     'libboost-date-time1.49.0': '1.49.0',
71                     'libcurl3': '7.29.0-1ubuntu3',
72                     'libzip2': '0.10.1-1.1'}
73
74 depends['7'] = {'libc6': '2.13',
75                 'libssh-4': '0.5.4',
76                 'libboost-filesystem1.49.0': '1.49.0',
77                 'libboost-thread1.49.0': '1.49.0',
78                 'libsndfile1': '1.0.25',
79                 'libmagick++5': '8:6.7.7.10',
80                 'libxml++2.6-2': '2.34.2',
81                 'libgtk2.0-0': '2.24.10',
82                 'libxmlsec1': '1.2.18',
83                 'libboost-date-time1.49.0': '1.49.0',
84                 'libxmlsec1-openssl': '1.2.18',
85                 'libcurl3': '7.26.0',
86                 'libzip2': '0.10.1'}
87
88 def packages(name, packages, f):
89     s = '%s: ' % name
90     for p in packages:
91         s += str(p) + ', '
92     print >>f,s[:-2]
93
94 def make_control(version, bits, filename, debug):
95     f = open(filename, 'w')
96     print >>f,'Source: dcpomatic'
97     print >>f,'Section: video'
98     print >>f,'Priority: extra'
99     print >>f,'Maintainer: Carl Hetherington <carl@dcpomatic.com>'
100     packages('Build-Depends', build_depends, f)
101     print >>f,'Standards-Version: 3.9.3'
102     print >>f,'Homepage: http://dcpomatic.com/'
103     print >>f,''
104     print >>f,'Package: dcpomatic'
105     if bits == 32:
106         print >>f,'Architecture: i386'
107     else:
108         print >>f,'Architecture: amd64'
109
110     packages('Depends', depends[version], f)
111
112     print >>f,'Description: Generator of Digital Cinema Packages (DCPs)'
113     print >>f,'  DCP-o-matic generates Digital Cinema Packages (DCPs) from video and audio'
114     print >>f,'  files (such as those from DVDs or Blu-Rays) for presentation on DCI-compliant'
115     print >>f,'  digital projectors.'
116
117     if debug:
118         print >>f,''
119         print >>f,'Package: dcpomatic-dbg'
120         if bits == 32:
121             print >>f,'Architecture: i386'
122         else:
123             print >>f,'Architecture: amd64'
124         print >>f,'Section: debug'
125         print >>f,'Priority: extra'
126         packages('Depends', depends[version], f)
127         print >>f,'Description: debugging symbols for dcpomatic'
128         print >>f,'  This package contains the debugging symbols for dcpomatic.'
129         print >>f,''
130
131 def dependencies(target):
132     return (('ffmpeg-cdist', '5ac3a6af077c10f07c31954c372a8f29e4e18e2a'),
133             ('libdcp', '71de90f'))
134
135 def build(target, options):
136     cmd = './waf configure --prefix=%s' % target.work_dir_cscript()
137     if target.platform == 'windows':
138         cmd += ' --target-windows'
139     elif target.platform == 'linux':
140         if target.distro == 'debian' or target.distro == 'ubuntu':
141             cmd += ' --target-debian'
142         elif target.distro == 'centos':
143             cmd += ' --target-centos'
144
145     target.command(cmd)
146     target.command('./waf')
147
148     if target.platform == 'linux' or target.platform == 'osx':
149         target.command('./waf install')
150
151 def package_windows(target):
152     shutil.copyfile('build/platform/windows/installer.%s.nsi' % target.bits, 'build/platform/windows/installer2.%s.nsi' % target.bits)
153     target.command('sed -i "s~%%resources%%~%s/platform/windows~g" build/platform/windows/installer2.%s.nsi' % (os.getcwd(), target.bits))
154     target.command('sed -i "s~%%static_deps%%~%s~g" build/platform/windows/installer2.%s.nsi' % (target.windows_prefix, target.bits))
155     target.command('sed -i "s~%%cdist_deps%%~%s~g" build/platform/windows/installer2.%s.nsi' % (target.work_dir_cscript(), target.bits))
156     target.command('sed -i "s~%%binaries%%~%s/build~g" build/platform/windows/installer2.%s.nsi' % (os.getcwd(), target.bits))
157     target.command('sed -i "s~%%bits%%~32~g" build/platform/windows/installer2.%s.nsi' % target.bits)
158     target.command('makensis build/platform/windows/installer2.%s.nsi' % target.bits)
159     return os.path.abspath(glob.glob('build/platform/windows/*%s*.exe' % target.bits)[0])
160
161 def package_debian(target, cpu):
162     make_control(target.version, target.bits, 'debian/control')
163     target.command('./waf dist')
164     f = open('debian/files', 'w')
165     print >>f,'dcpomatic_%s-1_%s.deb video extra' % (version, cpu)
166     shutil.rmtree('build/deb', ignore_errors=True)
167     
168     os.makedirs('build/deb')
169     os.chdir('build/deb')
170     shutil.move('../../dcpomatic-%s.tar.bz2' % version, 'dcpomatic_%s.orig.tar.bz2' % version)
171     target.command('tar xjf dcpomatic_%s.orig.tar.bz2' % version)
172     os.chdir('dcpomatic-%s' % version)
173     target.command('dch -b -v %s-1 "New upstream release."' % version)
174     target.set('CDIST_LINKFLAGS', target.get('LINKFLAGS'))
175     target.set('CDIST_CXXFLAGS', target.get('CXXFLAGS'))
176     target.set('CDIST_PKG_CONFIG_PATH', target.get('PKG_CONFIG_PATH'))
177     target.command('dpkg-buildpackage')
178     
179     debs = []
180     for p in glob.glob('../*.deb'):
181         debs.append(os.path.abspath(p))
182     
183     return debs
184
185 def package_centos(target, cpu, version):
186     os.makedirs('%s/rpmbuild/BUILD' % target.work_dir_cdist())
187     os.makedirs('%s/rpmbuild/RPMS' % target.work_dir_cdist())
188     os.makedirs('%s/rpmbuild/SOURCES' % target.work_dir_cdist())
189     os.makedirs('%s/rpmbuild/SPECS' % target.work_dir_cdist())
190     os.makedirs('%s/rpmbuild/SRPMS' % target.work_dir_cdist())
191
192     f = open('%s/.rpmmacros' % target.dir_in_chroot, 'w')
193     print >>f,"%%_topdir %srpmbuild" % target.dir_in_chroot
194     f.close()
195
196     target.command('./waf dist')
197     shutil.copyfile(
198         "%s/src/dcpomatic/dcpomatic-%s.tar.bz2" % (target.work_dir_cdist(), version),
199         "%s/rpmbuild/SOURCES/dcpomatic-%s.tar.bz2" % (target.work_dir_cdist(), version)
200         )
201
202     target.command('rpmbuild -bb build/platform/linux/dcpomatic.spec')
203     rpms = []
204     for p in glob.glob('%s/rpmbuild/RPMS/x86_64/*.rpm' % target.work_dir_cdist()):
205         rpms.append(os.path.abspath(p))
206
207     return rpms
208
209 def package(target, version):
210     if target.bits == 32:
211         cpu = 'i386'
212     else:
213         cpu = 'amd64'
214
215     if target.platform == 'windows':
216         return package_windows(target)
217     elif target.platform == 'linux':
218         if target.distro == 'debian' or target.distro == 'ubuntu':
219             return package_debian(target, cpu)
220         elif target.distro == 'centos':
221             return package_centos(target, cpu, version)
222     elif target.platform == 'osx':
223         target.command('bash platform/osx/make_dmg.sh %s' % target.work_dir_cscript())
224         return os.path.abspath(glob.glob('build/platform/osx/DCP-o-matic*.dmg')[0])
225
226 def make_pot(target):
227     target.command('./waf pot')
228     return [os.path.abspath('build/src/lib/libdcpomatic.pot'),
229             os.path.abspath('build/src/wx/libdcpomatic-wx.pot'),
230             os.path.abspath('build/src/tools/dcpomatic.pot')]
231
232 def make_manual(target):
233     os.chdir('doc/manual')
234     target.command('make')
235     target.command('pdflatex colour.tex')
236     return [os.path.abspath('pdf'), os.path.abspath('html'), os.path.abspath('colour.pdf')]
237
238 def test(target):
239     if target.platform != 'windows':
240         target.set('LC_ALL', 'C')
241         target.command('run/tests')