Remove need for shell wrap complexity
This commit is contained in:
@@ -4,7 +4,7 @@ import os
|
||||
import re
|
||||
import string
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
|
||||
class GrubUpdater(object):
|
||||
@@ -30,9 +30,12 @@ class GrubUpdater(object):
|
||||
return match.group('volume_id').decode('ascii')
|
||||
|
||||
def Update(self):
|
||||
grub_dir = os.path.join(self._boot_dir, 'grub')
|
||||
|
||||
with tempfile.NamedTemporaryFile(dir=grub_dir, delete=False) as fh:
|
||||
current = os.readlink(os.path.join(self._image_dir, 'current'))
|
||||
|
||||
sys.stdout.write("""
|
||||
fh.write("""
|
||||
set timeout=5
|
||||
set default=%(default_image_filename)s
|
||||
""" % {
|
||||
@@ -46,7 +49,7 @@ set default=%(default_image_filename)s
|
||||
files.append(filename)
|
||||
|
||||
for i, filename in enumerate(sorted(files, reverse=True)):
|
||||
sys.stdout.write("""
|
||||
fh.write("""
|
||||
menuentry "%(image_filename)s (%(volume_id)s)" --hotkey=%(hotkey)s {
|
||||
search --no-floppy --file --set=root %(image_path)s/%(image_filename)s
|
||||
iso_path="%(image_path)s/%(image_filename)s"
|
||||
@@ -61,3 +64,6 @@ menuentry "%(image_filename)s (%(volume_id)s)" --hotkey=%(hotkey)s {
|
||||
'hotkey': self._HOTKEYS[i],
|
||||
'volume_id': self._GetVolumeID(os.path.join(self._image_dir, filename)),
|
||||
})
|
||||
|
||||
fh.flush()
|
||||
os.rename(fh.name, os.path.join(grub_dir, 'grub.cfg'))
|
||||
|
||||
Reference in New Issue
Block a user