Date: Fri, 30 Jan 2015 16:42:15 +0000 (UTC) From: Kris Moore <kmoore@FreeBSD.org> To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r378163 - in head/sysutils/grub2-pcbsd: . files Message-ID: <201501301642.t0UGgFSD032425@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kmoore Date: Fri Jan 30 16:42:14 2015 New Revision: 378163 URL: https://svnweb.freebsd.org/changeset/ports/378163 QAT: https://qat.redports.org/buildarchive/r378163/ Log: - Add support to probe for and add chainloaded disks to the grub menus - Bump PORTREV Modified: head/sysutils/grub2-pcbsd/Makefile head/sysutils/grub2-pcbsd/files/10_ktrueos.in head/sysutils/grub2-pcbsd/files/30_os-prober.in Modified: head/sysutils/grub2-pcbsd/Makefile ============================================================================== --- head/sysutils/grub2-pcbsd/Makefile Fri Jan 30 16:35:51 2015 (r378162) +++ head/sysutils/grub2-pcbsd/Makefile Fri Jan 30 16:42:14 2015 (r378163) @@ -3,7 +3,7 @@ PORTNAME= grub2-pcbsd PORTVERSION= 2.02p -PORTREVISION= 21 +PORTREVISION= 22 CATEGORIES= sysutils MASTER_SITES= http://www.pcbsd.org/~kris/software/ \ ftp://ftp.pcbsd.org/pub/software/ Modified: head/sysutils/grub2-pcbsd/files/10_ktrueos.in ============================================================================== --- head/sysutils/grub2-pcbsd/files/10_ktrueos.in Fri Jan 30 16:35:51 2015 (r378162) +++ head/sysutils/grub2-pcbsd/files/10_ktrueos.in Fri Jan 30 16:42:14 2015 (r378163) @@ -176,9 +176,6 @@ display_loaderopts() if [ "$haveGELI" = "true" ] ; then echo " set kFreeBSD.kern.geom.eli.passphrase=\"\$pass\"" fi - - # GRUB does NOT support gptid labels yet - echo " set kFreeBSD.kern.geom.label.gptid.enable=\"0\"" } detect_beadm() Modified: head/sysutils/grub2-pcbsd/files/30_os-prober.in ============================================================================== --- head/sysutils/grub2-pcbsd/files/30_os-prober.in Fri Jan 30 16:35:51 2015 (r378162) +++ head/sysutils/grub2-pcbsd/files/30_os-prober.in Fri Jan 30 16:42:14 2015 (r378163) @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright 2013 iXsystems (Kris Moore) +# Copyright 2015 iXsystems (Kris Moore) # All rights reserved # # Redistribution and use in source and binary forms, with or without @@ -48,14 +48,87 @@ menuentry "Microsoft Windows ($disk)" { EOF } -# Start by looking for disks -for disk in `cd /dev/ && ls ada[0-9]s[0-9] da[0-9]s[0-9] ada[0-9]p[0-9] da[0-9]p[0-9] 2>/dev/null` +print_uefichain() { + cat << EOF +menuentry "Chainload Disk (hd${hdnum} - $1)" { + set root=('hd${hdnum},${rootpre}1') + chainloader $1 +} + +EOF +} + +# Look for file-systems on the zpool disk +for disk in `zpool status | grep ONLINE | grep -v "state:" | awk '{print $1}'` +do + disk="`echo $disk | sed 's|.eli||g'`" + if [ ! -e "/dev/$disk" ] ; then continue ; fi + + # Get the parent disk name + parentdisk=`grub-probe --target=disk --device /dev/$disk` + parentdisk="`echo $parentdisk | sed 's|/dev/||g'`" + if [ ! -e "/dev/$parentdisk" ] ; then continue ; fi + + for ldisk in `cd /dev/ && ls ${parentdisk}s[0-9] ${parentdisk}p[0-99] 2>/dev/null` + do + fs_type=`grub-probe --device /dev/${ldisk} --target=fs 2>/dev/null` + case $fs_type in + ntfs) check_ntfs_part "$ldisk" ;; # Start checking for NTFS + *) ;; # Unknown for now, add more! + esac + done +done + +# Look for other disks to chainload +hdnum=0 +for disk in `cd /dev/ && ls ada[0-9] da[0-9] 2>/dev/null` do - - # Start checking for NTFS - fs_type=`grub-probe --device /dev/${disk} --target=fs 2>/dev/null` - case $fs_type in - ntfs) check_ntfs_part "$disk" ;; - *) ;; # Unknown for now, add more! - esac + # Skip disks apart of zpool + zpool status | grep ONLINE | grep -v "state:" | grep -q "$disk" + if [ $? -eq 0 ] ; then + hdnum=`expr $hdnum + 1` + continue + fi + + # Check if the first partition on this disk is EFI + if [ -e "/dev/${disk}s1" ] ; then + fp="/dev/${disk}s1" + rootpre="" + else + fp="/dev/${disk}p1" + rootpre="gpt" + fi + + # Add UEFI chainloader + if [ "`grub-probe --device -t fs $fp`" = "fat" ] ; then + + # Lets mount the FAT partition and look for UEFI boots + uefimnt="/tmp/.grub-uefi.$$" + if [ ! -d "$uefimnt" ] ; then mkdir $uefimnt; fi + mount_msdosfs $fp $uefimnt + if [ $? -eq 0 ] ; then + if [ -e "${uefimnt}/EFI/Boot/bootx64.efi" ] ; then + print_uefichain "/EFI/Boot/bootx64.efi" + fi + cd $uefimnt + for i in `find . | grep \.efi$ | grep -v "./EFI/Boot/bootx64.efi"` + do + i="`echo $i | sed 's|\./|/|g'`" + print_uefichain "$i" + done + cd /dev + umount $uefimnt + rmdir $uefimnt + fi + + else + # Add BIOS chainloader + cat << EOF +menuentry "Chainload Disk (hd${hdnum})" { + set root=(hd${hdnum}) + chainloader +1 +} +EOF + fi + hdnum=`expr $hdnum + 1` done
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201501301642.t0UGgFSD032425>