@@ -495,8 +495,7 @@ def do_customize(self, guestaddr):
495495
496496 if packstr != '' :
497497 self .guest_execute_command (guestaddr ,
498- 'apt-get install -y %s' % (packstr ),
499- tunnels = None )
498+ 'apt-get install -y %s' % (packstr ))
500499
501500 self ._customize_files (guestaddr )
502501
@@ -552,7 +551,7 @@ def _get_kernel_from_txt_cfg(self, fetchurl):
552551 raise oz .OzException .OzException ("Could not find %s" % (txtcfgurl ))
553552
554553 txtcfg = os .path .join (self .icicle_tmp , "txt.cfg" )
555- self .log .debug ("Going to write txt.cfg to %s" % ( txtcfg ) )
554+ self .log .debug ("Going to write txt.cfg to %s" , txtcfg )
556555 txtcfgfd = os .open (txtcfg , os .O_RDWR | os .O_CREAT | os .O_TRUNC )
557556 os .unlink (txtcfg )
558557 fp = os .fdopen (txtcfgfd )
@@ -580,7 +579,7 @@ def _get_kernel_from_txt_cfg(self, fetchurl):
580579 if kernel is None or initrd is None :
581580 raise oz .OzException .OzException ("Empty kernel or initrd" )
582581
583- self .log .debug ("Returning kernel %s and initrd %s" % ( kernel , initrd ) )
582+ self .log .debug ("Returning kernel %s and initrd %s" , kernel , initrd )
584583 return (kernel , initrd )
585584
586585 def _gzip_file (self , inputfile , outputmode ):
@@ -606,7 +605,7 @@ def _create_cpio_initrd(self, preseedpath):
606605 Internal method to create a modified CPIO initrd
607606 """
608607 extrafname = os .path .join (self .icicle_tmp , "extra.cpio" )
609- self .log .debug ("Writing cpio to %s" % ( extrafname ) )
608+ self .log .debug ("Writing cpio to %s" , extrafname )
610609 cpiofiledict = {}
611610 cpiofiledict [preseedpath ] = 'preseed.cfg'
612611 oz .ozutil .write_cpio (cpiofiledict , extrafname )
@@ -631,30 +630,40 @@ def _initrd_inject_preseed(self, fetchurl, force_download):
631630 pass
632631
633632 if kernel is None :
634- self .log .debug ("Kernel was None, trying debian-installer/%s/linux" % ( self .debarch ) )
633+ self .log .debug ("Kernel was None, trying debian-installer/%s/linux" , self .debarch )
635634 # we couldn't find the kernel in the txt.cfg, so try a
636635 # hard-coded path
637636 kernel = "debian-installer/%s/linux" % (self .debarch )
638637 if initrd is None :
639- self .log .debug ("Initrd was None, trying debian-installer/%s/initrd.gz" % ( self .debarch ) )
638+ self .log .debug ("Initrd was None, trying debian-installer/%s/initrd.gz" , self .debarch )
640639 # we couldn't find the initrd in the txt.cfg, so try a
641640 # hard-coded path
642641 initrd = "debian-installer/%s/initrd.gz" % (self .debarch )
643642
644- self ._get_original_media ('/' .join ([self .url .rstrip ('/' ),
645- kernel .lstrip ('/' )]),
646- self .kernelcache , force_download )
643+ (fd , outdir ) = self ._open_locked_file (self .kernelcache )
647644
648645 try :
649646 self ._get_original_media ('/' .join ([self .url .rstrip ('/' ),
650- initrd .lstrip ('/' )]),
651- self .initrdcache , force_download )
652- except :
653- os .unlink (self .kernelfname )
654- raise
647+ kernel .lstrip ('/' )]),
648+ fd , outdir , force_download )
649+
650+ # if we made it here, then we can copy the kernel into place
651+ shutil .copyfile (self .kernelcache , self .kernelfname )
652+ finally :
653+ os .close (fd )
654+
655+ (fd , outdir ) = self ._open_locked_file (self .initrdcache )
655656
656- # if we made it here, then we can copy the kernel into place
657- shutil .copyfile (self .kernelcache , self .kernelfname )
657+ try :
658+ try :
659+ self ._get_original_media ('/' .join ([self .url .rstrip ('/' ),
660+ initrd .lstrip ('/' )]),
661+ fd , outdir , force_download )
662+ except :
663+ os .unlink (self .kernelfname )
664+ raise
665+ finally :
666+ os .close (fd )
658667
659668 try :
660669 preseedpath = os .path .join (self .icicle_tmp , "preseed.cfg" )
0 commit comments