blob: 2629bf3075970ae1ef6d7384df535423e7e4a153 [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
mbligh1e8858e2006-11-24 22:18:35 +000031 def __init__(self, job, base_tree, results_dir, tmp_dir, leave = False):
mblighc86b0b42006-07-28 17:35:28 +000032 """Initialize the kernel build environment
33
34 job
35 which job this build is part of
mblighc86b0b42006-07-28 17:35:28 +000036 base_tree
mbligh534015f2006-09-15 03:28:56 +000037 base kernel tree. Can be one of the following:
38 1. A local tarball
39 2. A URL to a tarball
40 3. A local directory (will symlink it)
41 4. A shorthand expandable (eg '2.6.11-git3')
mbligh1e8858e2006-11-24 22:18:35 +000042 results_dir
43 Results directory (holds config/, debug/, results/)
44 tmp_dir
45
46 leave
47 Boolean, whether to leave existing tmpdir or not
mblighc86b0b42006-07-28 17:35:28 +000048 """
mblighf4c35322006-03-13 01:01:10 +000049 self.job = job
mbligh678823f2006-12-07 18:49:00 +000050 self.autodir = job.autodir
mblighf4c35322006-03-13 01:01:10 +000051
mbligh1e8858e2006-11-24 22:18:35 +000052 self.src_dir = os.path.join(tmp_dir, 'src')
53 self.build_dir = os.path.join(tmp_dir, 'linux')
mbligha2508052006-05-28 21:29:53 +000054 # created by get_kernel_tree
mbligh1e8858e2006-11-24 22:18:35 +000055 self.config_dir = os.path.join(results_dir, 'config')
56 self.log_dir = os.path.join(results_dir, 'debug')
57 self.results_dir = os.path.join(results_dir, 'results')
58
59 if not leave:
60 if os.path.isdir(self.src_dir):
61 system('rm -rf ' + self.src_dir)
62 if os.path.isdir(self.build_dir):
63 system('rm -rf ' + self.build_dir)
64
mblighf4c35322006-03-13 01:01:10 +000065 os.mkdir(self.src_dir)
mbligh1e8858e2006-11-24 22:18:35 +000066 for path in [self.config_dir, self.log_dir, self.results_dir]:
67 if os.path.exists(path):
68 system('rm -rf ' + path)
69 os.mkdir(path)
mblighf4c35322006-03-13 01:01:10 +000070
mbligh4426de02006-10-10 07:18:28 +000071 logpath = os.path.join(self.log_dir, 'build_log')
72 self.logfile = open(logpath, 'w+')
73
mbligh5970cf02006-08-06 15:39:22 +000074 self.target_arch = None
mblighfdbcaec2006-10-01 23:28:57 +000075 self.build_target = 'bzImage'
76
77 if leave:
78 return
mbligh534015f2006-09-15 03:28:56 +000079
mbligh4426de02006-10-10 07:18:28 +000080 self.logfile.write('BASE: %s\n' % base_tree)
mbligh534015f2006-09-15 03:28:56 +000081 if os.path.exists(base_tree):
82 self.get_kernel_tree(base_tree)
83 else:
apw8ad56be2006-11-06 17:49:54 +000084 args = self.job.config_get('mirror.ftp_kernel_org')
mbligh548f29a2006-10-17 04:55:12 +000085 if args:
86 args = '-l ' + args
87 base_components = kernelexpand(base_tree, args)
mbligh534015f2006-09-15 03:28:56 +000088 print 'kernelexpand: '
89 print base_components
90 self.get_kernel_tree(base_components.pop(0))
91 if base_components: # apply remaining patches
92 self.patch(*base_components)
mblighf4c35322006-03-13 01:01:10 +000093
94
mblighd016ecc2006-11-25 21:41:07 +000095 def patch(self, *patches):
mblighc86b0b42006-07-28 17:35:28 +000096 """Apply a list of patches (in order)"""
mbligh1e8858e2006-11-24 22:18:35 +000097 if not patches:
98 return
mblighd016ecc2006-11-25 21:41:07 +000099 # if isinstance(patches, basestring):
100 # patches = [patches]
mbligh534015f2006-09-15 03:28:56 +0000101 print 'Applying patches: ', patches
102 # self.job.stdout.redirect(os.path.join(self.log_dir, 'stdout'))
mblighf4c35322006-03-13 01:01:10 +0000103 local_patches = self.get_patches(patches)
mbligh4426de02006-10-10 07:18:28 +0000104 for patch in patches:
105 self.logfile.write('PATCH: %s\n' % patch)
mblighf4c35322006-03-13 01:01:10 +0000106 self.apply_patches(local_patches)
mbligh534015f2006-09-15 03:28:56 +0000107 # self.job.stdout.restore()
mblighf4c35322006-03-13 01:01:10 +0000108
109
apwb449c7d2006-12-05 12:21:44 +0000110 def config(self, config_file = '', config_list = None,
111 defconfig = False):
mbligh93057012006-08-06 15:51:56 +0000112 self.job.stdout.redirect(os.path.join(self.log_dir, 'stdout'))
mbligh678823f2006-12-07 18:49:00 +0000113 self.set_cross_cc()
apwb449c7d2006-12-05 12:21:44 +0000114 config = kernel_config.kernel_config(self.job, self.build_dir,
115 self.config_dir, config_file, config_list, defconfig)
mblighf4c35322006-03-13 01:01:10 +0000116 self.job.stdout.restore()
117
118
119 def get_patches(self, patches):
mbligh1e8858e2006-11-24 22:18:35 +0000120 """fetch the patches to the local src_dir"""
mblighf4c35322006-03-13 01:01:10 +0000121 local_patches = []
122 for patch in patches:
mbligh1e8858e2006-11-24 22:18:35 +0000123 dest = os.path.join(self.src_dir, basename(patch))
124 print "get_file %s %s %s %s" % (patch, dest, self.src_dir, basename(patch))
mblighf4c35322006-03-13 01:01:10 +0000125 get_file(patch, dest)
126 local_patches.append(dest)
mbligh534015f2006-09-15 03:28:56 +0000127 return local_patches
mblighf4c35322006-03-13 01:01:10 +0000128
129
mbligh534015f2006-09-15 03:28:56 +0000130 def apply_patches(self, local_patches):
mblighc86b0b42006-07-28 17:35:28 +0000131 """apply the list of patches, in order"""
mblighf4c35322006-03-13 01:01:10 +0000132 builddir = self.build_dir
133 os.chdir(builddir)
134
mbligh534015f2006-09-15 03:28:56 +0000135 if not local_patches:
mblighf4c35322006-03-13 01:01:10 +0000136 return None
mbligh534015f2006-09-15 03:28:56 +0000137 for patch in local_patches:
mblighf4c35322006-03-13 01:01:10 +0000138 print 'Patching from', basename(patch), '...'
mbligh4426de02006-10-10 07:18:28 +0000139 cat_file_to_cmd(patch, 'patch -p1 > /dev/null')
mblighf4c35322006-03-13 01:01:10 +0000140
141
mbligh5970cf02006-08-06 15:39:22 +0000142 def get_kernel_tree(self, base_tree):
mblighc49af7b2006-11-24 04:02:21 +0000143 """Extract/link base_tree to self.build_dir"""
mbligh5970cf02006-08-06 15:39:22 +0000144
145 # if base_tree is a dir, assume uncompressed kernel
146 if os.path.isdir(base_tree):
147 print 'Symlinking existing kernel source'
mblighc49af7b2006-11-24 04:02:21 +0000148 os.symlink(base_tree, self.build_dir)
mblighf4c35322006-03-13 01:01:10 +0000149
mbligh5970cf02006-08-06 15:39:22 +0000150 # otherwise, extract tarball
151 else:
mblighc49af7b2006-11-24 04:02:21 +0000152 os.chdir(os.path.dirname(self.src_dir))
153 # Figure out local destination for tarball
154 tarball = os.path.join(self.src_dir, os.path.basename(base_tree))
mbligh5970cf02006-08-06 15:39:22 +0000155 get_file(base_tree, tarball)
mbligh5970cf02006-08-06 15:39:22 +0000156 print 'Extracting kernel tarball:', tarball, '...'
mblighc49af7b2006-11-24 04:02:21 +0000157 extract_tarball_to_dir(tarball, self.build_dir)
mbligh5970cf02006-08-06 15:39:22 +0000158
mblighf4c35322006-03-13 01:01:10 +0000159
mblighfdbcaec2006-10-01 23:28:57 +0000160 def extraversion(self, tag, append=1):
161 os.chdir(self.build_dir)
mbligh4426de02006-10-10 07:18:28 +0000162 extraversion_sub = r's/^EXTRAVERSION =\s*\(.*\)/EXTRAVERSION = '
mblighfdbcaec2006-10-01 23:28:57 +0000163 if append:
mbligh4426de02006-10-10 07:18:28 +0000164 p = extraversion_sub + '\\1-%s/' % tag
mblighfdbcaec2006-10-01 23:28:57 +0000165 else:
mbligh4426de02006-10-10 07:18:28 +0000166 p = extraversion_sub + '-%s/' % tag
167 system('sed -i.old "%s" Makefile' % p)
mblighfdbcaec2006-10-01 23:28:57 +0000168
169
170 def build(self, make_opts = '', logfile = '', extraversion='autotest'):
mblighc86b0b42006-07-28 17:35:28 +0000171 """build the kernel
172
173 make_opts
174 additional options to make, if any
175 """
mbligh10038012006-10-19 03:32:45 +0000176 os_dep.commands('gcc', 'make')
mbligh6d4c9412006-09-13 23:08:44 +0000177 if logfile == '':
178 logfile = os.path.join(self.log_dir, 'kernel_build')
mblighf4c35322006-03-13 01:01:10 +0000179 os.chdir(self.build_dir)
mblighfdbcaec2006-10-01 23:28:57 +0000180 if extraversion:
181 self.extraversion(extraversion)
mbligh93057012006-08-06 15:51:56 +0000182 print os.path.join(self.log_dir, 'stdout')
mbligh6d4c9412006-09-13 23:08:44 +0000183 self.job.stdout.redirect(logfile + '.stdout')
184 self.job.stderr.redirect(logfile + '.stderr')
mbligha2508052006-05-28 21:29:53 +0000185 self.set_cross_cc()
mblighf4c35322006-03-13 01:01:10 +0000186 # setup_config_file(config_file, config_overrides)
apwc7846102006-04-06 18:22:13 +0000187
188 # Not needed on 2.6, but hard to tell -- handle failure
mblighfdbcaec2006-10-01 23:28:57 +0000189 system('make dep', ignorestatus=1)
mblighf4c35322006-03-13 01:01:10 +0000190 threads = 2 * count_cpus()
mbligh6d4c9412006-09-13 23:08:44 +0000191 build_string = 'make -j %d %s %s' % (threads, make_opts,
192 self.build_target)
193 # eg make bzImage, or make zImage
194 print build_string
195 system(build_string)
mblighf4c35322006-03-13 01:01:10 +0000196 if kernel_config.modules_needed('.config'):
apwd4701972006-10-16 09:24:56 +0000197 system('make -j %d modules' % (threads))
apwc7846102006-04-06 18:22:13 +0000198
mblighf4c35322006-03-13 01:01:10 +0000199 self.job.stdout.restore()
200 self.job.stderr.restore()
mbligh4426de02006-10-10 07:18:28 +0000201
202 kernel_version = self.get_kernel_build_ver()
203 kernel_version = re.sub('-autotest', '', kernel_version)
204 self.logfile.write('BUILD VERSION: %s\n' % kernel_version)
mbligh1e8858e2006-11-24 22:18:35 +0000205
206 force_copy(self.build_dir+'/System.map', self.results_dir)
mblighf4c35322006-03-13 01:01:10 +0000207
208
209 def build_timed(self, threads, timefile = '/dev/null', make_opts = ''):
mblighc86b0b42006-07-28 17:35:28 +0000210 """time the bulding of the kernel"""
mblighb8a14e32006-05-06 00:17:35 +0000211 os.chdir(self.build_dir)
mbligh678823f2006-12-07 18:49:00 +0000212 self.set_cross_cc()
mblighb8a14e32006-05-06 00:17:35 +0000213 print "make clean"
214 system('make clean')
mbligha2bb9d62006-10-09 16:26:03 +0000215 build_string = "/usr/bin/time -o %s make %s -j %s vmlinux" % (timefile, make_opts, threads)
mblighf4c35322006-03-13 01:01:10 +0000216 print build_string
apwc7846102006-04-06 18:22:13 +0000217 system(build_string)
218 if (not os.path.isfile('vmlinux')):
219 raise TestError("no vmlinux found, kernel build failed")
mblighb8a14e32006-05-06 00:17:35 +0000220
221
222 def clean(self):
mblighc86b0b42006-07-28 17:35:28 +0000223 """make clean in the kernel tree"""
mblighb8a14e32006-05-06 00:17:35 +0000224 os.chdir(self.build_dir)
mblighf4c35322006-03-13 01:01:10 +0000225 print "make clean"
apwc7846102006-04-06 18:22:13 +0000226 system('make clean')
mblighf4c35322006-03-13 01:01:10 +0000227
mbligh50f42ea2006-09-30 22:22:21 +0000228
229 def mkinitrd(self, version, image, system_map, initrd):
230 """Build kernel initrd image.
231 Try to use distro specific way to build initrd image.
232 Parameters:
233 version
234 new kernel version
235 image
236 new kernel image file
237 system_map
238 System.map file
239 initrd
240 initrd image file to build
241 """
242 vendor = get_os_vendor()
243
244 if os.path.isfile(initrd):
mblighfdbcaec2006-10-01 23:28:57 +0000245 print "Existing %s file, will remove it." % initrd
mbligh50f42ea2006-09-30 22:22:21 +0000246 os.remove(initrd)
247
248 if vendor in ['Red Hat', 'Fedora Core']:
mblighfdbcaec2006-10-01 23:28:57 +0000249 system('mkinitrd %s %s' % (initrd, version))
mbligh50f42ea2006-09-30 22:22:21 +0000250 elif vendor in ['SUSE']:
mblighfdbcaec2006-10-01 23:28:57 +0000251 system('mkinitrd -k %s -i %s -M %s' % (image, initrd, system_map))
mbligh50f42ea2006-09-30 22:22:21 +0000252 else:
mblighfdbcaec2006-10-01 23:28:57 +0000253 raise TestError('Unsupported vendor %s' % vendor)
mbligh50f42ea2006-09-30 22:22:21 +0000254
255
mbligh6a1d4db2006-10-06 04:30:16 +0000256 def install(self, tag='autotest', prefix = '/'):
mblighc86b0b42006-07-28 17:35:28 +0000257 """make install in the kernel tree"""
mblighf4c35322006-03-13 01:01:10 +0000258 os.chdir(self.build_dir)
mbligh0ad65582006-10-06 04:16:36 +0000259
mbligh6a1d4db2006-10-06 04:30:16 +0000260 if not os.path.isdir(prefix):
261 os.mkdir(prefix)
mbligha87116f2006-10-10 02:47:08 +0000262 self.boot_dir = os.path.join(prefix, 'boot')
263 if not os.path.isdir(self.boot_dir):
264 os.mkdir(self.boot_dir)
mbligh0ad65582006-10-06 04:16:36 +0000265
apw9a61c5b2006-11-28 10:03:15 +0000266 images = glob.glob('arch/*/boot/' + self.build_target)
267 if len(images):
268 image = images[0]
269 else:
270 image = self.build_target
mbligha87116f2006-10-10 02:47:08 +0000271
272 # remember installed files
mbligha87116f2006-10-10 02:47:08 +0000273 self.vmlinux = self.boot_dir + '/vmlinux-' + tag
apw9a61c5b2006-11-28 10:03:15 +0000274 if (image != 'vmlinux'):
275 self.image = self.boot_dir + '/vmlinuz-' + tag
276 else:
277 self.image = self.vmlinux
mbligha87116f2006-10-10 02:47:08 +0000278 self.system_map = self.boot_dir + '/System.map-' + tag
279 self.config = self.boot_dir + '/config-' + tag
280 self.initrd = ''
281
282 # copy to boot dir
mbligha87116f2006-10-10 02:47:08 +0000283 force_copy('vmlinux', self.vmlinux)
apw9a61c5b2006-11-28 10:03:15 +0000284 if (image != 'vmlinux'):
285 force_copy(image, self.image)
mbligha87116f2006-10-10 02:47:08 +0000286 force_copy('System.map', self.system_map)
287 force_copy('.config', self.config)
288
mbligh6a1d4db2006-10-06 04:30:16 +0000289 if not kernel_config.modules_needed('.config'):
290 return
291
292 system('make modules_install INSTALL_MOD_PATH=%s' % prefix)
293 if prefix == '/':
mbligha87116f2006-10-10 02:47:08 +0000294 self.initrd = self.boot_dir + '/initrd-' + tag
295 self.mkinitrd(self.get_kernel_build_ver(), self.image, \
296 self.system_map, self.initrd)
297
298
299 def add_to_bootloader(self, tag='autotest', args=''):
300 """ add this kernel to bootloader, taking an
301 optional parameter of space separated parameters
302 e.g.: kernel.add_to_bootloader('mykernel', 'ro acpi=off')
303 """
304
305 # remove existing entry if present
306 self.job.bootloader.remove_kernel(tag)
307
308 # add the kernel entry
309 # add_kernel(image, title='autotest', inird='')
310 self.job.bootloader.add_kernel(self.image, tag, self.initrd)
311
apwcbe32572006-11-28 10:00:23 +0000312 # pull the base argument set from the job config,
313 # otherwise populate from /proc/cmdline
314 baseargs = self.job.config_get('boot.default_args')
315 if not baseargs:
316 baseargs = open('/proc/cmdline', 'r').readline().strip()
317
318 args = baseargs + " " + args
mbligha87116f2006-10-10 02:47:08 +0000319
320 # add args to entry one at a time
321 for a in args.split(' '):
322 self.job.bootloader.add_args(tag, a)
mbligh6a1d4db2006-10-06 04:30:16 +0000323
mbligh201aa892006-10-29 04:02:05 +0000324
mbligh548f29a2006-10-17 04:55:12 +0000325 def get_kernel_build_arch(self, arch=None):
mbligh201aa892006-10-29 04:02:05 +0000326 """
327 Work out the current kernel architecture (as a kernel arch)
328 """
mbligh548f29a2006-10-17 04:55:12 +0000329 if not arch:
330 arch = get_current_kernel_arch()
331 if re.match('i.86', arch):
332 return 'i386'
333 elif re.match('sun4u', arch):
334 return 'sparc64'
335 elif re.match('arm.*', arch):
336 return 'arm'
337 elif re.match('sa110', arch):
338 return 'arm'
339 elif re.match('s390x', arch):
340 return 's390'
341 elif re.match('parisc64', arch):
342 return 'parisc'
343 elif re.match('ppc.*', arch):
344 return 'powerpc'
345 elif re.match('mips.*', arch):
346 return 'mips'
347 else:
348 return arch
349
mbligh6a1d4db2006-10-06 04:30:16 +0000350
apw1b5dc362006-10-31 11:24:26 +0000351 def boot(self, args=''):
352 """ install and boot this kernel, do not care how
353 just make it happen.
354 """
355
356 # Install this kernel.
357 self.install()
358 self.add_to_bootloader(args=args)
359
360 # Boot it.
361 self.job.reboot()
362
363
mblighfdbcaec2006-10-01 23:28:57 +0000364 def get_kernel_build_ver(self):
mblighe11f5fc2006-10-04 04:42:22 +0000365 """Check Makefile and .config to return kernel version"""
366 version = patchlevel = sublevel = extraversion = localversion = ''
367
368 for line in open(self.build_dir + '/Makefile', 'r').readlines():
369 if line.startswith('VERSION'):
370 version = line[line.index('=') + 1:].strip()
371 if line.startswith('PATCHLEVEL'):
372 patchlevel = line[line.index('=') + 1:].strip()
373 if line.startswith('SUBLEVEL'):
374 sublevel = line[line.index('=') + 1:].strip()
375 if line.startswith('EXTRAVERSION'):
376 extraversion = line[line.index('=') + 1:].strip()
377
378 for line in open(self.build_dir + '/.config', 'r').readlines():
379 if line.startswith('CONFIG_LOCALVERSION='):
380 localversion = line.rstrip().split('"')[1]
381
382 return "%s.%s.%s%s%s" %(version, patchlevel, sublevel, extraversion, localversion)
mblighfdbcaec2006-10-01 23:28:57 +0000383
384
mbligh5970cf02006-08-06 15:39:22 +0000385 def set_cross_cc(self, target_arch=None, cross_compile=None,
386 build_target='bzImage'):
mblighc86b0b42006-07-28 17:35:28 +0000387 """Set up to cross-compile.
mblighcc2e6662006-09-14 01:24:07 +0000388 This is broken. We need to work out what the default
389 compile produces, and if not, THEN set the cross
390 compiler.
mblighc86b0b42006-07-28 17:35:28 +0000391 """
mblighcc2e6662006-09-14 01:24:07 +0000392
mbligh5970cf02006-08-06 15:39:22 +0000393 if self.target_arch:
394 return
mbligh678823f2006-12-07 18:49:00 +0000395
mbligh5970cf02006-08-06 15:39:22 +0000396 self.build_target = build_target
397
398 # If no 'target_arch' given assume native compilation
399 if target_arch == None:
mbligh548f29a2006-10-17 04:55:12 +0000400 target_arch = get_current_kernel_arch()
mbligh5970cf02006-08-06 15:39:22 +0000401 if target_arch == 'ppc64':
mbligh5970cf02006-08-06 15:39:22 +0000402 if self.build_target == 'bzImage':
apw9a61c5b2006-11-28 10:03:15 +0000403 self.build_target = 'vmlinux'
mbligh678823f2006-12-07 18:49:00 +0000404
405 if not cross_compile:
406 cross_compile = self.job.config_get('kernel.cross_cc')
407
408 if cross_compile:
409 os.environ['CROSS_COMPILE'] = cross_compile
410 else:
411 if os.environ.has_key('CROSS_COMPILE'):
412 del os.environ['CROSS_COMPILE']
413
mblighcc2e6662006-09-14 01:24:07 +0000414 return # HACK. Crap out for now.
mblighf4c35322006-03-13 01:01:10 +0000415
mblighcc2e6662006-09-14 01:24:07 +0000416 # At this point I know what arch I *want* to build for
417 # but have no way of working out what arch the default
418 # compiler DOES build for.
419
420 # Oh, and BTW, install_package() doesn't exist yet.
421
422 if target_arch == 'ppc64':
423 install_package('ppc64-cross')
mbligh678823f2006-12-07 18:49:00 +0000424 cross_compile = os.path.join(self.autodir, 'sources/ppc64-cross/bin')
mblighcc2e6662006-09-14 01:24:07 +0000425
426 elif target_arch == 'x86_64':
427 install_package('x86_64-cross')
mbligh678823f2006-12-07 18:49:00 +0000428 cross_compile = os.path.join(self.autodir, 'sources/x86_64-cross/bin')
mblighb8a14e32006-05-06 00:17:35 +0000429
mbligh5970cf02006-08-06 15:39:22 +0000430 os.environ['ARCH'] = self.target_arch = target_arch
431
432 self.cross_compile = cross_compile
433 if self.cross_compile:
434 os.environ['CROSS_COMPILE'] = self.cross_compile
mblighcc2e6662006-09-14 01:24:07 +0000435
436
mblighb8a14e32006-05-06 00:17:35 +0000437 def pickle_dump(self, filename):
mblighc86b0b42006-07-28 17:35:28 +0000438 """dump a pickle of ourself out to the specified filename
439
440 we can't pickle the backreference to job (it contains fd's),
mbligh709bb9b2006-10-12 04:32:16 +0000441 nor would we want to. Same for logfile (fd's).
mblighc86b0b42006-07-28 17:35:28 +0000442 """
mblighb8a14e32006-05-06 00:17:35 +0000443 temp = copy.copy(self)
444 temp.job = None
mbligh709bb9b2006-10-12 04:32:16 +0000445 temp.logfile = None
mblighb8a14e32006-05-06 00:17:35 +0000446 pickle.dump(temp, open(filename, 'w'))
447