Don't bother building debug packages.
[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                     'libboost-date-time1.49.0': '1.49.0',
42                     'libcurl3': '7.27.0-1ubuntu1',
43                     'libzip2': '0.10.1-1.1'}
44
45 depends['13.04'] = {'libc6': '2.15',
46                     'libssh-4': '0.5.2',
47                     'libboost-filesystem1.49.0': '1.49.0',
48                     'libboost-thread1.49.0': '1.49.0',
49                     'libsndfile1': '1.0.25',
50                     'libmagick++5': '8:6.7.7.10',
51                     'libxml++2.6-2': '2.34.2',
52                     'libgtk2.0-0': '2.24.13',
53                     'libxmlsec1': '1.2.18-2',
54                     'libxmlsec1-openssl': '1.2.14-1.2build1',
55                     'libboost-date-time1.49.0': '1.49.0',
56                     'libcurl3': '7.29.0-1ubuntu3',
57                     'libzip2': '0.10.1-1.1'}
58
59 depends['13.10'] = {'libc6': '2.17-93',
60                     'libssh-4': '0.5.4',
61                     'libboost-filesystem1.53.0': '1.53.0',
62                     'libboost-thread1.53.0': '1.53.0',
63                     'libsndfile1': '1.0.25',
64                     'libmagick++5': '8:6.7.7.10',
65                     'libxml++2.6-2': '2.36.0',
66                     'libgtk2.0-0': '2.24.20',
67                     'libxmlsec1': '1.2.18-2',
68                     'libxmlsec1-openssl': '1.2.14-1.2build1',
69                     'libboost-date-time1.49.0': '1.49.0',
70                     'libcurl3': '7.29.0-1ubuntu3',
71                     'libzip2': '0.10.1-1.1'}
72
73 depends['7'] = {'libc6': '2.13',
74                 'libssh-4': '0.5.4',
75                 'libboost-filesystem1.49.0': '1.49.0',
76                 'libboost-thread1.49.0': '1.49.0',
77                 'libsndfile1': '1.0.25',
78                 'libmagick++5': '8:6.7.7.10',
79                 'libxml++2.6-2': '2.34.2',
80                 'libgtk2.0-0': '2.24.10',
81                 'libxmlsec1': '1.2.18',
82                 'libboost-date-time1.49.0': '1.49.0',
83                 'libxmlsec1-openssl': '1.2.18',
84                 'libcurl3': '7.26.0',
85                 'libzip2': '0.10.1'}
86
87 def packages(name, packages, f):
88     s = '%s: ' % name
89     for p in packages:
90         s += str(p) + ', '
91     print >>f,s[:-2]
92
93 def make_control(version, bits, filename):
94     f = open(filename, 'w')
95     print >>f,'Source: dcpomatic'
96     print >>f,'Section: video'
97     print >>f,'Priority: extra'
98     print >>f,'Maintainer: Carl Hetherington <carl@dcpomatic.com>'
99     packages('Build-Depends', build_depends, f)
100     print >>f,'Standards-Version: 3.9.3'
101     print >>f,'Homepage: http://dcpomatic.com/'
102     print >>f,''
103     print >>f,'Package: dcpomatic'
104     if bits == 32:
105         print >>f,'Architecture: i386'
106     else:
107         print >>f,'Architecture: amd64'
108
109     packages('Depends', depends[version], f)
110     print >>f,'Description: Generator of Digital Cinema Packages (DCPs)'
111     print >>f,'  DCP-o-matic generates Digital Cinema Packages (DCPs) from video and audio'
112     print >>f,'  files (such as those from DVDs or Blu-Rays) for presentation on DCI-compliant'
113     print >>f,'  digital projectors.'
114
115 def dependencies(target):
116     return (('ffmpeg-cdist', '0b7ef017aca8b572914518c759db1e234d8fc505'),
117             ('libdcp', 'v0.85'))
118
119 def build(target):
120     cmd = './waf configure --prefix=%s' % target.work_dir_cscript()
121     if target.platform == 'windows':
122         cmd += ' --target-windows'
123     elif target.platform == 'linux':
124         cmd += ' --static'
125     target.command(cmd)
126
127     target.command('./waf')
128
129     if target.platform == 'linux' or target.platform == 'osx':
130         target.command('./waf install')
131
132 def package(target, version):
133     if target.platform == 'windows':
134         shutil.copyfile('build/platform/windows/installer.%s.nsi' % target.bits, 'build/platform/windows/installer2.%s.nsi' % target.bits)
135         target.command('sed -i "s~%%resources%%~%s/platform/windows~g" build/platform/windows/installer2.%s.nsi' % (os.getcwd(), target.bits))
136         target.command('sed -i "s~%%static_deps%%~%s~g" build/platform/windows/installer2.%s.nsi' % (target.windows_prefix, target.bits))
137         target.command('sed -i "s~%%cdist_deps%%~%s~g" build/platform/windows/installer2.%s.nsi' % (target.work_dir_cscript(), target.bits))
138         target.command('sed -i "s~%%binaries%%~%s/build~g" build/platform/windows/installer2.%s.nsi' % (os.getcwd(), target.bits))
139         target.command('sed -i "s~%%bits%%~32~g" build/platform/windows/installer2.%s.nsi' % target.bits)
140         target.command('makensis build/platform/windows/installer2.%s.nsi' % target.bits)
141         return os.path.abspath(glob.glob('build/platform/windows/*%s*.exe' % target.bits)[0])
142     elif target.platform == 'linux':
143         if target.bits == 32:
144             cpu = 'i386'
145         else:
146             cpu = 'amd64'
147
148         make_control(target.version, target.bits, 'debian/control')
149         target.command('./waf dist')
150         f = open('debian/files', 'w')
151         print >>f,'dcpomatic_%s-1_%s.deb video extra' % (version, cpu)
152         shutil.rmtree('build/deb', ignore_errors=True)
153
154         os.makedirs('build/deb')
155         os.chdir('build/deb')
156         shutil.move('../../dcpomatic-%s.tar.bz2' % version, 'dcpomatic_%s.orig.tar.bz2' % version)
157         target.command('tar xjf dcpomatic_%s.orig.tar.bz2' % version)
158         os.chdir('dcpomatic-%s' % version)
159         target.command('dch -b -v %s-1 "New upstream release."' % version)
160         target.set('CDIST_LINKFLAGS', target.get('LINKFLAGS'))
161         target.set('CDIST_CXXFLAGS', target.get('CXXFLAGS'))
162         target.set('CDIST_PKG_CONFIG_PATH', target.get('PKG_CONFIG_PATH'))
163         target.command('dpkg-buildpackage')
164         
165         debs = []
166         for p in glob.glob('../*.deb'):
167             debs.append(os.path.abspath(p))
168
169         return debs
170     elif target.platform == 'osx':
171         target.command('bash platform/osx/make_dmg.sh %s' % target.work_dir_cscript())
172         return os.path.abspath(glob.glob('build/platform/osx/DCP-o-matic*.dmg')[0])
173
174 def make_pot(target):
175     target.command('./waf pot')
176     return [os.path.abspath('build/src/lib/libdcpomatic.pot'),
177             os.path.abspath('build/src/wx/libdcpomatic-wx.pot'),
178             os.path.abspath('build/src/tools/dcpomatic.pot')]
179
180 def make_manual(target):
181     os.chdir('doc/manual')
182     target.command('make')
183     target.command('pdflatex colour.tex')
184     return [os.path.abspath('pdf'), os.path.abspath('html'), os.path.abspath('colour.pdf')]