#NEWLINE# def grub1_mbr( install_device , boot_disk , boot_part , chroot = '' ) : #NEWLINE# #INDENT# batch = 'device (hd0) {0}\n' . format ( install_device ) #NEWLINE# batch += 'geometry (hd0) 130 255 63\n' #NEWLINE# if ( boot_disk != install_device ) : #NEWLINE# #INDENT# batch += 'device (hd1) {0}\n' . format ( boot_disk ) #NEWLINE# batch += 'geometry (hd1) 130 255 63\n' #NEWLINE# batch += 'root (hd1,{0})\n' . format ( boot_part ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# batch += 'root (hd0,{0})\n' . format ( boot_part ) #NEWLINE# #UNINDENT# batch += 'setup (hd0)\n' #NEWLINE# batch += 'quit\n' #NEWLINE# with open ( ( chroot + '/tmp/grub.batch' ) , 'wt' , encoding = 'utf-8' ) as f : #NEWLINE# #INDENT# LOG . debug ( ( 'Grub batch content: \n%s' % batch ) ) #NEWLINE# f . write ( six . text_type ( batch ) ) #NEWLINE# #UNINDENT# script = 'cat /tmp/grub.batch | {0} --no-floppy --batch' . format ( guess_grub ( chroot = chroot ) ) #NEWLINE# with open ( ( chroot + '/tmp/grub.sh' ) , 'wt' , encoding = 'utf-8' ) as f : #NEWLINE# #INDENT# LOG . debug ( ( 'Grub script content: \n%s' % script ) ) #NEWLINE# f . write ( six . text_type ( script ) ) #NEWLINE# #UNINDENT# os . chmod ( ( chroot + '/tmp/grub.sh' ) , 493 ) #NEWLINE# cmd = [ '/tmp/grub.sh' ] #NEWLINE# if chroot : #NEWLINE# #INDENT# cmd [ : 0 ] = [ 'chroot' , chroot ] #NEWLINE# #UNINDENT# ( stdout , stderr ) = utils . execute ( * cmd , run_as_root = True , check_exit_code = [ 0 ] ) #NEWLINE# LOG . debug ( ( 'Grub script stdout: \n%s' % stdout ) ) #NEWLINE# LOG . debug ( ( 'Grub script stderr: \n%s' % stderr ) )