mkefiboot: Add support for disk label files

The Apple boot picker provides drive names by reading small icon files
off the filesystem. Add support for including them.
This commit is contained in:
Matthew Garrett 2012-05-02 13:09:20 -04:00 committed by Brian C. Lane
parent c03ac93997
commit 3aa1fcadb9
2 changed files with 13 additions and 4 deletions

View File

@ -2,6 +2,7 @@
<%
EFIBOOTDIR="EFI/BOOT"
APPLE_EFI_ICON=inroot+"/usr/share/pixmaps/bootloader/fedora.icns"
APPLE_EFI_DISKNAME=inroot+"/usr/share/pixmaps/bootloader/fedora-media.vol"
%>
mkdir ${EFIBOOTDIR}
@ -19,7 +20,7 @@ ${make_efiboot("images/macboot.img", imgtype="apple")}
eficonf = "%s/BOOT%s.conf" % (EFIBOOTDIR, efiarch)
args = "--label=ANACONDA"
if disk: args += " --disk"
if imgtype == "apple": args += ' --apple --icon=%s --product="%s %s"' % (APPLE_EFI_ICON, product.name, product.version)
if imgtype == "apple": args += ' --apple --icon=%s --diskname=%s --product="%s %s"' % (APPLE_EFI_ICON, APPLE_EFI_DISKNAME, product.name, product.version)
%>
%if include_kernel:
copy ${KERNELDIR}/vmlinuz ${EFIBOOTDIR}

View File

@ -27,11 +27,14 @@ def mkefiboot(bootdir, outfile, label):
'''Make an EFI boot image with the contents of bootdir in EFI/BOOT'''
mkdosimg(None, outfile, label=label, graft={'EFI/BOOT':bootdir})
def mkmacboot(bootdir, outfile, label, icon=None, product='Generic'):
def mkmacboot(bootdir, outfile, label, icon=None, product='Generic',
diskname=None):
'''Make an EFI boot image for Apple's EFI implementation'''
graft = {'EFI/BOOT':bootdir}
if icon:
if icon and os.path.exists(icon):
graft['.VolumeIcon.icns'] = icon
if diskname and os.path.exists(diskname):
graft['EFI/BOOT/.disk_label'] = diskname
mkhfsimg(None, outfile, label=label, graft=graft)
macmunge(outfile, product)
@ -112,6 +115,8 @@ if __name__ == '__main__':
help="filesystem label to use (default: %(default)s)")
parser.add_argument("-i", "--icon", metavar="ICONFILE",
help="icon file to include (for Apple EFI image)")
parser.add_argument("-n", "--diskname", metavar="DISKNAME",
help="disk name image to include (for Apple EFI image)")
parser.add_argument("-p", "--product", metavar="PRODUCT",
help="product name to use (for Apple EFI image)")
parser.add_argument("bootdir", metavar="EFIBOOTDIR",
@ -126,9 +131,12 @@ if __name__ == '__main__':
parser.error("need root permissions")
if opt.icon and not opt.imgtype == "apple":
print "Warning: --icon is only useful for Apple EFI images"
if opt.diskname and not opt.imgtype == "apple":
print "Warning: --diskname is only useful for Apple EFI images"
# do the thing!
if opt.imgtype == "apple":
mkmacboot(opt.bootdir, opt.outfile, opt.label, opt.icon, opt.product)
mkmacboot(opt.bootdir, opt.outfile, opt.label, opt.icon, opt.product,
opt.diskname)
else:
mkefiboot(opt.bootdir, opt.outfile, opt.label)
if opt.disk: