blob: 718253693ac7fe0f16c53bc756ee1f6459e9bf79 [file] [log] [blame]
mblighc86b0b42006-07-28 17:35:28 +00001__author__ = """Copyright Martin J. Bligh, 2006"""
mbligha2508052006-05-28 21:29:53 +00002
apwba5bbfd2006-10-16 09:25:45 +00003import os,os.path,shutil,urllib,copy,pickle,re,glob
mblighf4c35322006-03-13 01:01:10 +00004from autotest_utils import *
mbligh10038012006-10-19 03:32:45 +00005import kernel_config, test, os_dep
mblighf4c35322006-03-13 01:01:10 +00006
7class kernel:
mblighc86b0b42006-07-28 17:35:28 +00008 """ Class for compiling kernels.
9
10 Data for the object includes the src files
11 used to create the kernel, patches applied, config (base + changes),
12 the build directory itself, and logged output
13
14 Properties:
15 job
16 Backpointer to the job object we're part of
17 autodir
18 Path to the top level autotest dir (/usr/local/autotest)
mblighc86b0b42006-07-28 17:35:28 +000019 src_dir
mbligh1e8858e2006-11-24 22:18:35 +000020 <tmp_dir>/src/
mblighc49af7b2006-11-24 04:02:21 +000021 build_dir
mbligh1e8858e2006-11-24 22:18:35 +000022 <tmp_dir>/linux/
mblighc86b0b42006-07-28 17:35:28 +000023 config_dir
mbligh1e8858e2006-11-24 22:18:35 +000024 <results_dir>/config/
mblighc86b0b42006-07-28 17:35:28 +000025 log_dir
mbligh1e8858e2006-11-24 22:18:35 +000026 <results_dir>/debug/
27 results_dir
28 <results_dir>/results/
mblighc86b0b42006-07-28 17:35:28 +000029 """
30
mblighf4c35322006-03-13 01:01:10 +000031 autodir = ''
32
mbligh1e8858e2006-11-24 22:18:35 +000033 def __init__(self, job, base_tree, results_dir, tmp_dir, leave = False):
mblighc86b0b42006-07-28 17:35:28 +000034 """Initialize the kernel build environment
35
36 job
37 which job this build is part of
mblighc86b0b42006-07-28 17:35:28 +000038 base_tree
mbligh534015f2006-09-15 03:28:56 +000039 base kernel tree. Can be one of the following:
40 1. A local tarball
41 2. A URL to a tarball
42 3. A local directory (will symlink it)
43 4. A shorthand expandable (eg '2.6.11-git3')
mbligh1e8858e2006-11-24 22:18:35 +000044 results_dir
45 Results directory (holds config/, debug/, results/)
46 tmp_dir
47
48 leave
49 Boolean, whether to leave existing tmpdir or not
mblighc86b0b42006-07-28 17:35:28 +000050 """
mblighf4c35322006-03-13 01:01:10 +000051 self.job = job
52 autodir = job.autodir
mblighf4c35322006-03-13 01:01:10 +000053
mbligh1e8858e2006-11-24 22:18:35 +000054 self.src_dir = os.path.join(tmp_dir, 'src')
55 self.build_dir = os.path.join(tmp_dir, 'linux')
mbligha2508052006-05-28 21:29:53 +000056 # created by get_kernel_tree
mbligh1e8858e2006-11-24 22:18:35 +000057 self.config_dir = os.path.join(results_dir, 'config')
58 self.log_dir = os.path.join(results_dir, 'debug')
59 self.results_dir = os.path.join(results_dir, 'results')
60
61 if not leave:
62 if os.path.isdir(self.src_dir):
63 system('rm -rf ' + self.src_dir)
64 if os.path.isdir(self.build_dir):
65 system('rm -rf ' + self.build_dir)
66
mblighf4c35322006-03-13 01:01:10 +000067 os.mkdir(self.src_dir)
mbligh1e8858e2006-11-24 22:18:35 +000068 for path in [self.config_dir, self.log_dir, self.results_dir]:
69 if os.path.exists(path):
70 system('rm -rf ' + path)
71 os.mkdir(path)
mblighf4c35322006-03-13 01:01:10 +000072
mbligh4426de02006-10-10 07:18:28 +000073 logpath = os.path.join(self.log_dir, 'build_log')
74 self.logfile = open(logpath, 'w+')
75
mbligh5970cf02006-08-06 15:39:22 +000076 self.target_arch = None
mblighfdbcaec2006-10-01 23:28:57 +000077 self.build_target = 'bzImage'
78
79 if leave:
80 return
mbligh534015f2006-09-15 03:28:56 +000081
mbligh4426de02006-10-10 07:18:28 +000082 self.logfile.write('BASE: %s\n' % base_tree)
mbligh534015f2006-09-15 03:28:56 +000083 if os.path.exists(base_tree):
84 self.get_kernel_tree(base_tree)
85 else:
apw8ad56be2006-11-06 17:49:54 +000086 args = self.job.config_get('mirror.ftp_kernel_org')
mbligh548f29a2006-10-17 04:55:12 +000087 if args:
88 args = '-l ' + args
89 base_components = kernelexpand(base_tree, args)
mbligh534015f2006-09-15 03:28:56 +000090 print 'kernelexpand: '
91 print base_components
92 self.get_kernel_tree(base_components.pop(0))
93 if base_components: # apply remaining patches
94 self.patch(*base_components)
mblighf4c35322006-03-13 01:01:10 +000095
96
mblighd016ecc2006-11-25 21:41:07 +000097 def patch(self, *patches):
mblighc86b0b42006-07-28 17:35:28 +000098 """Apply a list of patches (in order)"""
mbligh1e8858e2006-11-24 22:18:35 +000099 if not patches:
100 return
mblighd016ecc2006-11-25 21:41:07 +0000101 # if isinstance(patches, basestring):
102 # patches = [patches]
mbligh534015f2006-09-15 03:28:56 +0000103 print 'Applying patches: ', patches
104 # self.job.stdout.redirect(os.path.join(self.log_dir, 'stdout'))
mblighf4c35322006-03-13 01:01:10 +0000105 local_patches = self.get_patches(patches)
mbligh4426de02006-10-10 07:18:28 +0000106 for patch in patches:
107 self.logfile.write('PATCH: %s\n' % patch)
mblighf4c35322006-03-13 01:01:10 +0000108 self.apply_patches(local_patches)
mbligh534015f2006-09-15 03:28:56 +0000109 # self.job.stdout.restore()
mblighf4c35322006-03-13 01:01:10 +0000110
111
apw220b5952006-12-05 12:16:39 +0000112 def config(self, config_file = '', config_list = None):
mbligh93057012006-08-06 15:51:56 +0000113 self.job.stdout.redirect(os.path.join(self.log_dir, 'stdout'))
apwc30cbd32006-12-05 12:16:24 +0000114 config = kernel_config.kernel_config(self.job, self.build_dir, self.config_dir, config_file, config_list)
mblighf4c35322006-03-13 01:01:10 +0000115 self.job.stdout.restore()
116
117
118 def get_patches(self, patches):
mbligh1e8858e2006-11-24 22:18:35 +0000119 """fetch the patches to the local src_dir"""
mblighf4c35322006-03-13 01:01:10 +0000120 local_patches = []
121 for patch in patches:
mbligh1e8858e2006-11-24 22:18:35 +0000122 dest = os.path.join(self.src_dir, basename(patch))
123 print "get_file %s %s %s %s" % (patch, dest, self.src_dir, basename(patch))
mblighf4c35322006-03-13 01:01:10 +0000124 get_file(patch, dest)
125 local_patches.append(dest)
mbligh534015f2006-09-15 03:28:56 +0000126 return local_patches
mblighf4c35322006-03-13 01:01:10 +0000127
128
mbligh534015f2006-09-15 03:28:56 +0000129 def apply_patches(self, local_patches):
mblighc86b0b42006-07-28 17:35:28 +0000130 """apply the list of patches, in order"""
mblighf4c35322006-03-13 01:01:10 +0000131 builddir = self.build_dir
132 os.chdir(builddir)
133
mbligh534015f2006-09-15 03:28:56 +0000134 if not local_patches:
mblighf4c35322006-03-13 01:01:10 +0000135 return None
mbligh534015f2006-09-15 03:28:56 +0000136 for patch in local_patches:
mblighf4c35322006-03-13 01:01:10 +0000137 print 'Patching from', basename(patch), '...'
mbligh4426de02006-10-10 07:18:28 +0000138 cat_file_to_cmd(patch, 'patch -p1 > /dev/null')
mblighf4c35322006-03-13 01:01:10 +0000139
140
mbligh5970cf02006-08-06 15:39:22 +0000141 def get_kernel_tree(self, base_tree):
mblighc49af7b2006-11-24 04:02:21 +0000142 """Extract/link base_tree to self.build_dir"""
mbligh5970cf02006-08-06 15:39:22 +0000143
144 # if base_tree is a dir, assume uncompressed kernel
145 if os.path.isdir(base_tree):
146 print 'Symlinking existing kernel source'
mblighc49af7b2006-11-24 04:02:21 +0000147 os.symlink(base_tree, self.build_dir)
mblighf4c35322006-03-13 01:01:10 +0000148
mbligh5970cf02006-08-06 15:39:22 +0000149 # otherwise, extract tarball
150 else:
mblighc49af7b2006-11-24 04:02:21 +0000151 os.chdir(os.path.dirname(self.src_dir))
152 # Figure out local destination for tarball
153 tarball = os.path.join(self.src_dir, os.path.basename(base_tree))
mbligh5970cf02006-08-06 15:39:22 +0000154 get_file(base_tree, tarball)
mbligh5970cf02006-08-06 15:39:22 +0000155 print 'Extracting kernel tarball:', tarball, '...'
mblighc49af7b2006-11-24 04:02:21 +0000156 extract_tarball_to_dir(tarball, self.build_dir)
mbligh5970cf02006-08-06 15:39:22 +0000157
mblighf4c35322006-03-13 01:01:10 +0000158
mblighfdbcaec2006-10-01 23:28:57 +0000159 def extraversion(self, tag, append=1):
160 os.chdir(self.build_dir)
mbligh4426de02006-10-10 07:18:28 +0000161 extraversion_sub = r's/^EXTRAVERSION =\s*\(.*\)/EXTRAVERSION = '
mblighfdbcaec2006-10-01 23:28:57 +0000162 if append:
mbligh4426de02006-10-10 07:18:28 +0000163 p = extraversion_sub + '\\1-%s/' % tag
mblighfdbcaec2006-10-01 23:28:57 +0000164 else:
mbligh4426de02006-10-10 07:18:28 +0000165 p = extraversion_sub + '-%s/' % tag
166 system('sed -i.old "%s" Makefile' % p)
mblighfdbcaec2006-10-01 23:28:57 +0000167
168
169 def build(self, make_opts = '', logfile = '', extraversion='autotest'):
mblighc86b0b42006-07-28 17:35:28 +0000170 """build the kernel
171
172 make_opts
173 additional options to make, if any
174 """
mbligh10038012006-10-19 03:32:45 +0000175 os_dep.commands('gcc', 'make')
mbligh6d4c9412006-09-13 23:08:44 +0000176 if logfile == '':
177 logfile = os.path.join(self.log_dir, 'kernel_build')
mblighf4c35322006-03-13 01:01:10 +0000178 os.chdir(self.build_dir)
mblighfdbcaec2006-10-01 23:28:57 +0000179 if extraversion:
180 self.extraversion(extraversion)
mbligh93057012006-08-06 15:51:56 +0000181 print os.path.join(self.log_dir, 'stdout')
mbligh6d4c9412006-09-13 23:08:44 +0000182 self.job.stdout.redirect(logfile + '.stdout')
183 self.job.stderr.redirect(logfile + '.stderr')
mbligha2508052006-05-28 21:29:53 +0000184 self.set_cross_cc()
mblighf4c35322006-03-13 01:01:10 +0000185 # setup_config_file(config_file, config_overrides)
apwc7846102006-04-06 18:22:13 +0000186
187 # Not needed on 2.6, but hard to tell -- handle failure
mblighfdbcaec2006-10-01 23:28:57 +0000188 system('make dep', ignorestatus=1)
mblighf4c35322006-03-13 01:01:10 +0000189 threads = 2 * count_cpus()
mbligh6d4c9412006-09-13 23:08:44 +0000190 build_string = 'make -j %d %s %s' % (threads, make_opts,
191 self.build_target)
192 # eg make bzImage, or make zImage
193 print build_string
194 system(build_string)
mblighf4c35322006-03-13 01:01:10 +0000195 if kernel_config.modules_needed('.config'):
apwd4701972006-10-16 09:24:56 +0000196 system('make -j %d modules' % (threads))
apwc7846102006-04-06 18:22:13 +0000197
mblighf4c35322006-03-13 01:01:10 +0000198 self.job.stdout.restore()
199 self.job.stderr.restore()
mbligh4426de02006-10-10 07:18:28 +0000200
201 kernel_version = self.get_kernel_build_ver()
202 kernel_version = re.sub('-autotest', '', kernel_version)
203 self.logfile.write('BUILD VERSION: %s\n' % kernel_version)
mbligh1e8858e2006-11-24 22:18:35 +0000204
205 force_copy(self.build_dir+'/System.map', self.results_dir)
mblighf4c35322006-03-13 01:01:10 +0000206
207
208 def build_timed(self, threads, timefile = '/dev/null', make_opts = ''):
mblighc86b0b42006-07-28 17:35:28 +0000209 """time the bulding of the kernel"""
mblighb8a14e32006-05-06 00:17:35 +0000210 os.chdir(self.build_dir)
211 print "make clean"
212 system('make clean')
mbligha2bb9d62006-10-09 16:26:03 +0000213 build_string = "/usr/bin/time -o %s make %s -j %s vmlinux" % (timefile, make_opts, threads)
mblighf4c35322006-03-13 01:01:10 +0000214 print build_string
apwc7846102006-04-06 18:22:13 +0000215 system(build_string)
216 if (not os.path.isfile('vmlinux')):
217 raise TestError("no vmlinux found, kernel build failed")
mblighb8a14e32006-05-06 00:17:35 +0000218
219
220 def clean(self):
mblighc86b0b42006-07-28 17:35:28 +0000221 """make clean in the kernel tree"""
mblighb8a14e32006-05-06 00:17:35 +0000222 os.chdir(self.build_dir)
mblighf4c35322006-03-13 01:01:10 +0000223 print "make clean"
apwc7846102006-04-06 18:22:13 +0000224 system('make clean')
mblighf4c35322006-03-13 01:01:10 +0000225
mbligh50f42ea2006-09-30 22:22:21 +0000226
227 def mkinitrd(self, version, image, system_map, initrd):
228 """Build kernel initrd image.
229 Try to use distro specific way to build initrd image.
230 Parameters:
231 version
232 new kernel version
233 image
234 new kernel image file
235 system_map
236 System.map file
237 initrd
238 initrd image file to build
239 """
240 vendor = get_os_vendor()
241
242 if os.path.isfile(initrd):
mblighfdbcaec2006-10-01 23:28:57 +0000243 print "Existing %s file, will remove it." % initrd
mbligh50f42ea2006-09-30 22:22:21 +0000244 os.remove(initrd)
245
246 if vendor in ['Red Hat', 'Fedora Core']:
mblighfdbcaec2006-10-01 23:28:57 +0000247 system('mkinitrd %s %s' % (initrd, version))
mbligh50f42ea2006-09-30 22:22:21 +0000248 elif vendor in ['SUSE']:
mblighfdbcaec2006-10-01 23:28:57 +0000249 system('mkinitrd -k %s -i %s -M %s' % (image, initrd, system_map))
mbligh50f42ea2006-09-30 22:22:21 +0000250 else:
mblighfdbcaec2006-10-01 23:28:57 +0000251 raise TestError('Unsupported vendor %s' % vendor)
mbligh50f42ea2006-09-30 22:22:21 +0000252
253
mbligh6a1d4db2006-10-06 04:30:16 +0000254 def install(self, tag='autotest', prefix = '/'):
mblighc86b0b42006-07-28 17:35:28 +0000255 """make install in the kernel tree"""
mblighf4c35322006-03-13 01:01:10 +0000256 os.chdir(self.build_dir)
mbligh0ad65582006-10-06 04:16:36 +0000257
mbligh6a1d4db2006-10-06 04:30:16 +0000258 if not os.path.isdir(prefix):
259 os.mkdir(prefix)
mbligha87116f2006-10-10 02:47:08 +0000260 self.boot_dir = os.path.join(prefix, 'boot')
261 if not os.path.isdir(self.boot_dir):
262 os.mkdir(self.boot_dir)
mbligh0ad65582006-10-06 04:16:36 +0000263
apw9a61c5b2006-11-28 10:03:15 +0000264 images = glob.glob('arch/*/boot/' + self.build_target)
265 if len(images):
266 image = images[0]
267 else:
268 image = self.build_target
mbligha87116f2006-10-10 02:47:08 +0000269
270 # remember installed files
mbligha87116f2006-10-10 02:47:08 +0000271 self.vmlinux = self.boot_dir + '/vmlinux-' + tag
apw9a61c5b2006-11-28 10:03:15 +0000272 if (image != 'vmlinux'):
273 self.image = self.boot_dir + '/vmlinuz-' + tag
274 else:
275 self.image = self.vmlinux
mbligha87116f2006-10-10 02:47:08 +0000276 self.system_map = self.boot_dir + '/System.map-' + tag
277 self.config = self.boot_dir + '/config-' + tag
278 self.initrd = ''
279
280 # copy to boot dir
mbligha87116f2006-10-10 02:47:08 +0000281 force_copy('vmlinux', self.vmlinux)
apw9a61c5b2006-11-28 10:03:15 +0000282 if (image != 'vmlinux'):
283 force_copy(image, self.image)
mbligha87116f2006-10-10 02:47:08 +0000284 force_copy('System.map', self.system_map)
285 force_copy('.config', self.config)
286
mbligh6a1d4db2006-10-06 04:30:16 +0000287 if not kernel_config.modules_needed('.config'):
288 return
289
290 system('make modules_install INSTALL_MOD_PATH=%s' % prefix)
291 if prefix == '/':
mbligha87116f2006-10-10 02:47:08 +0000292 self.initrd = self.boot_dir + '/initrd-' + tag
293 self.mkinitrd(self.get_kernel_build_ver(), self.image, \
294 self.system_map, self.initrd)
295
296
297 def add_to_bootloader(self, tag='autotest', args=''):
298 """ add this kernel to bootloader, taking an
299 optional parameter of space separated parameters
300 e.g.: kernel.add_to_bootloader('mykernel', 'ro acpi=off')
301 """
302
303 # remove existing entry if present
304 self.job.bootloader.remove_kernel(tag)
305
306 # add the kernel entry
307 # add_kernel(image, title='autotest', inird='')
308 self.job.bootloader.add_kernel(self.image, tag, self.initrd)
309
apwcbe32572006-11-28 10:00:23 +0000310 # pull the base argument set from the job config,
311 # otherwise populate from /proc/cmdline
312 baseargs = self.job.config_get('boot.default_args')
313 if not baseargs:
314 baseargs = open('/proc/cmdline', 'r').readline().strip()
315
316 args = baseargs + " " + args
mbligha87116f2006-10-10 02:47:08 +0000317
318 # add args to entry one at a time
319 for a in args.split(' '):
320 self.job.bootloader.add_args(tag, a)
mbligh6a1d4db2006-10-06 04:30:16 +0000321
mbligh201aa892006-10-29 04:02:05 +0000322
mbligh548f29a2006-10-17 04:55:12 +0000323 def get_kernel_build_arch(self, arch=None):
mbligh201aa892006-10-29 04:02:05 +0000324 """
325 Work out the current kernel architecture (as a kernel arch)
326 """
mbligh548f29a2006-10-17 04:55:12 +0000327 if not arch:
328 arch = get_current_kernel_arch()
329 if re.match('i.86', arch):
330 return 'i386'
331 elif re.match('sun4u', arch):
332 return 'sparc64'
333 elif re.match('arm.*', arch):
334 return 'arm'
335 elif re.match('sa110', arch):
336 return 'arm'
337 elif re.match('s390x', arch):
338 return 's390'
339 elif re.match('parisc64', arch):
340 return 'parisc'
341 elif re.match('ppc.*', arch):
342 return 'powerpc'
343 elif re.match('mips.*', arch):
344 return 'mips'
345 else:
346 return arch
347
mbligh6a1d4db2006-10-06 04:30:16 +0000348
apw1b5dc362006-10-31 11:24:26 +0000349 def boot(self, args=''):
350 """ install and boot this kernel, do not care how
351 just make it happen.
352 """
353
354 # Install this kernel.
355 self.install()
356 self.add_to_bootloader(args=args)
357
358 # Boot it.
359 self.job.reboot()
360
361
mblighfdbcaec2006-10-01 23:28:57 +0000362 def get_kernel_build_ver(self):
mblighe11f5fc2006-10-04 04:42:22 +0000363 """Check Makefile and .config to return kernel version"""
364 version = patchlevel = sublevel = extraversion = localversion = ''
365
366 for line in open(self.build_dir + '/Makefile', 'r').readlines():
367 if line.startswith('VERSION'):
368 version = line[line.index('=') + 1:].strip()
369 if line.startswith('PATCHLEVEL'):
370 patchlevel = line[line.index('=') + 1:].strip()
371 if line.startswith('SUBLEVEL'):
372 sublevel = line[line.index('=') + 1:].strip()
373 if line.startswith('EXTRAVERSION'):
374 extraversion = line[line.index('=') + 1:].strip()
375
376 for line in open(self.build_dir + '/.config', 'r').readlines():
377 if line.startswith('CONFIG_LOCALVERSION='):
378 localversion = line.rstrip().split('"')[1]
379
380 return "%s.%s.%s%s%s" %(version, patchlevel, sublevel, extraversion, localversion)
mblighfdbcaec2006-10-01 23:28:57 +0000381
382
mbligh5970cf02006-08-06 15:39:22 +0000383 def set_cross_cc(self, target_arch=None, cross_compile=None,
384 build_target='bzImage'):
mblighc86b0b42006-07-28 17:35:28 +0000385 """Set up to cross-compile.
mblighcc2e6662006-09-14 01:24:07 +0000386 This is broken. We need to work out what the default
387 compile produces, and if not, THEN set the cross
388 compiler.
mblighc86b0b42006-07-28 17:35:28 +0000389 """
mblighcc2e6662006-09-14 01:24:07 +0000390
mbligh5970cf02006-08-06 15:39:22 +0000391 if self.target_arch:
392 return
393
394 self.build_target = build_target
395
396 # If no 'target_arch' given assume native compilation
397 if target_arch == None:
mbligh548f29a2006-10-17 04:55:12 +0000398 target_arch = get_current_kernel_arch()
mbligh5970cf02006-08-06 15:39:22 +0000399 if target_arch == 'ppc64':
mbligh5970cf02006-08-06 15:39:22 +0000400 if self.build_target == 'bzImage':
apw9a61c5b2006-11-28 10:03:15 +0000401 self.build_target = 'vmlinux'
mblighcc2e6662006-09-14 01:24:07 +0000402
403 return # HACK. Crap out for now.
mblighf4c35322006-03-13 01:01:10 +0000404
mblighcc2e6662006-09-14 01:24:07 +0000405 # At this point I know what arch I *want* to build for
406 # but have no way of working out what arch the default
407 # compiler DOES build for.
408
409 # Oh, and BTW, install_package() doesn't exist yet.
410
411 if target_arch == 'ppc64':
412 install_package('ppc64-cross')
413 cross_compile = os.path.join(autodir, 'sources/ppc64-cross/bin')
414
415 elif target_arch == 'x86_64':
416 install_package('x86_64-cross')
417 cross_compile = os.path.join(autodir, 'sources/x86_64-cross/bin')
mblighb8a14e32006-05-06 00:17:35 +0000418
mbligh5970cf02006-08-06 15:39:22 +0000419 os.environ['ARCH'] = self.target_arch = target_arch
420
421 self.cross_compile = cross_compile
422 if self.cross_compile:
423 os.environ['CROSS_COMPILE'] = self.cross_compile
mblighcc2e6662006-09-14 01:24:07 +0000424
425
mblighb8a14e32006-05-06 00:17:35 +0000426 def pickle_dump(self, filename):
mblighc86b0b42006-07-28 17:35:28 +0000427 """dump a pickle of ourself out to the specified filename
428
429 we can't pickle the backreference to job (it contains fd's),
mbligh709bb9b2006-10-12 04:32:16 +0000430 nor would we want to. Same for logfile (fd's).
mblighc86b0b42006-07-28 17:35:28 +0000431 """
mblighb8a14e32006-05-06 00:17:35 +0000432 temp = copy.copy(self)
433 temp.job = None
mbligh709bb9b2006-10-12 04:32:16 +0000434 temp.logfile = None
mblighb8a14e32006-05-06 00:17:35 +0000435 pickle.dump(temp, open(filename, 'w'))
436