Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 6 Jun 2014 15:26:32 +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: r356802 - in head/sysutils: . grub2-pcbsd grub2-pcbsd/files
Message-ID:  <201406061526.s56FQW7Z091767@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kmoore
Date: Fri Jun  6 15:26:31 2014
New Revision: 356802
URL: http://svnweb.freebsd.org/changeset/ports/356802
QAT: https://qat.redports.org/buildarchive/r356802/

Log:
  - Add sysutils/grub2-pcbsd
  
  This installs PC-BSD's custom grub 2.02-prerelease, which includes
  various enhancements for Boot-Environments and ZFS support

Added:
  head/sysutils/grub2-pcbsd/
  head/sysutils/grub2-pcbsd/Makefile   (contents, props changed)
  head/sysutils/grub2-pcbsd/distinfo   (contents, props changed)
  head/sysutils/grub2-pcbsd/files/
  head/sysutils/grub2-pcbsd/files/00_header.in   (contents, props changed)
  head/sysutils/grub2-pcbsd/files/10_kfreebsd.in   (contents, props changed)
  head/sysutils/grub2-pcbsd/files/10_ktrueos.in   (contents, props changed)
  head/sysutils/grub2-pcbsd/files/30_os-prober.in   (contents, props changed)
  head/sysutils/grub2-pcbsd/files/patch-configure.ac   (contents, props changed)
  head/sysutils/grub2-pcbsd/files/patch-grub-core_disk_geli.c   (contents, props changed)
  head/sysutils/grub2-pcbsd/files/patch-grub-core_lib_libgcrypt-grub_src_types.h   (contents, props changed)
  head/sysutils/grub2-pcbsd/files/patch-util_grub-mkconfig.in   (contents, props changed)
  head/sysutils/grub2-pcbsd/files/patch-util_grub-mkconfig_lib.in   (contents, props changed)
  head/sysutils/grub2-pcbsd/pkg-descr   (contents, props changed)
  head/sysutils/grub2-pcbsd/pkg-message   (contents, props changed)
  head/sysutils/grub2-pcbsd/pkg-plist   (contents, props changed)
Modified:
  head/sysutils/Makefile

Modified: head/sysutils/Makefile
==============================================================================
--- head/sysutils/Makefile	Fri Jun  6 15:15:35 2014	(r356801)
+++ head/sysutils/Makefile	Fri Jun  6 15:26:31 2014	(r356802)
@@ -344,6 +344,7 @@
     SUBDIR += grub2
     SUBDIR += grub2-bhyve
     SUBDIR += grub2-efi
+    SUBDIR += grub2-pcbsd
     SUBDIR += gsmartcontrol
     SUBDIR += gstopd
     SUBDIR += gstreamer-plugins-cdio

Added: head/sysutils/grub2-pcbsd/Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/grub2-pcbsd/Makefile	Fri Jun  6 15:26:31 2014	(r356802)
@@ -0,0 +1,92 @@
+# Created by: kmoore@FreeBSD.org
+# $FreeBSD$
+
+PORTNAME=	grub2-pcbsd
+PORTVERSION=	2.02p
+CATEGORIES=	sysutils
+MASTER_SITES=   http://www.pcbsd.org/~kris/software/ \
+		ftp://ftp.pcbsd.org/pub/software/
+DISTNAME=	grub-2.02_1
+
+MAINTAINER=	kmoore@FreeBSD.org
+COMMENT=	Multiboot boot loader
+
+LICENSE=	GPLv3
+
+BUILD_DEPENDS=	${LOCALBASE}/bin/flex:${PORTSDIR}/textproc/flex \
+		${LOCALBASE}/bin/bash:${PORTSDIR}/shells/bash \
+		help2man:${PORTSDIR}/misc/help2man
+
+WRKSRC=		${WRKDIR}/grub-2.02
+CONFLICTS=	grub-0* grub2-2*
+SSP_UNSAFE=	yes
+USE_GCC=	yes
+USE_PYTHON=	yes
+USE_AUTOTOOLS=	automake aclocal autoconf
+ACLOCAL_ARGS=	-Im4
+GNU_CONFIGURE=	yes
+USES=		bison gettext gmake tar:xz
+ONLY_FOR_ARCHS=	i386 amd64
+INFO=		grub grub-dev
+MAKE_JOBS_UNSAFE=	yes
+
+CONFIGURE_ARGS=	--disable-werror --localedir=${PREFIX}/share/locale
+CONFIGURE_ENV=	CPP="${CC} -E" \
+		LEX=${LOCALBASE}/bin/flex
+
+SUB_FILES=	00_header 10_kfreebsd 10_ktrueos 30_os-prober
+
+OPTIONS_DEFINE=	MKFONT FUSE
+OPTIONS_DEFAULT=MKFONT
+MKFONT_DESC=	Build grub-mkfont (require freetype2)
+FUSE_DESC=	Build grub-mount (require FUSE)
+
+.include <bsd.port.pre.mk>
+
+.if ${ARCH} != "amd64"
+EFIEMU=		"@comment "
+.endif
+
+PLIST_SUB+=	EFIEMU=${EFIEMU}
+
+.if ${PORT_OPTIONS:MMKFONT}
+LIB_DEPENDS+=	libfreetype.so:${PORTSDIR}/print/freetype2
+BUILD_DEPENDS+=	${LOCALBASE}/lib/X11/fonts/dejavu/DejaVuSans.ttf:${PORTSDIR}/x11-fonts/dejavu \
+		${LOCALBASE}/lib/X11/fonts/local/unifont.pcf.gz:${PORTSDIR}/x11-fonts/gnu-unifont
+MAN1+=		grub-mkfont.1
+CONFIGURE_ARGS+=	--enable-grub-mkfont
+.else
+CONFIGURE_ARGS+=	--disable-grub-mkfont
+MKFONT=		"@comment "
+.endif
+
+PLIST_SUB+=	MKFONT=${MKFONT}
+
+.if ${PORT_OPTIONS:MFUSE}
+LIB_DEPENDS+=	fuse:${PORTSDIR}/sysutils/fusefs-libs
+CONFIGURE_ARGS+=	--enable-grub-mount
+.else
+CONFIGURE_ARGS+=	--disable-grub-mount
+FUSE=		"@comment "
+.endif
+
+PLIST_SUB+=	FUSE=${FUSE}
+
+post-patch:
+	@${TOUCH} -t 200001010000 ${WRKSRC}/Makefile.util.def
+
+pre-configure:
+	@${REINPLACE_CMD} -e 's|python|${PYTHON_CMD}|g' ${WRKSRC}/autogen.sh
+	cd ${WRKSRC} && ./autogen.sh
+
+post-configure:
+	@${LN} -sfh /usr/include/machine /usr/include/sys /usr/include/x86 ${WRKSRC}/grub-core
+
+post-install:
+	@${RM} -rf ${STAGEDIR}${PREFIX}/lib/charset.alias
+	@${INSTALL_SCRIPT} ${WRKDIR}/00_header ${STAGEDIR}${PREFIX}/etc/grub.d/
+	@${INSTALL_SCRIPT} ${WRKDIR}/10_kfreebsd ${STAGEDIR}${PREFIX}/etc/grub.d/
+	@${INSTALL_SCRIPT} ${WRKDIR}/10_ktrueos ${STAGEDIR}${PREFIX}/etc/grub.d/
+	@${INSTALL_SCRIPT} ${WRKDIR}/30_os-prober ${STAGEDIR}${PREFIX}/etc/grub.d/
+
+.include <bsd.port.post.mk>

Added: head/sysutils/grub2-pcbsd/distinfo
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/grub2-pcbsd/distinfo	Fri Jun  6 15:26:31 2014	(r356802)
@@ -0,0 +1,2 @@
+SHA256 (grub-2.02_1.tar.xz) = d88d7c7533250df2939acb7a33f92d41fac02fc2bc729d95d89b571604d438b5
+SIZE (grub-2.02_1.tar.xz) = 4466312

Added: head/sysutils/grub2-pcbsd/files/00_header.in
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/grub2-pcbsd/files/00_header.in	Fri Jun  6 15:26:31 2014	(r356802)
@@ -0,0 +1,335 @@
+#! /bin/sh
+set -e
+
+# grub-mkconfig helper script.
+# Copyright (C) 2006,2007,2008,2009,2010  Free Software Foundation, Inc.
+#
+# GRUB is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# GRUB is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
+
+transform="s,x,x,"
+
+prefix="/usr/local"
+exec_prefix="${prefix}"
+datarootdir="${prefix}/share"
+grub_lang=`echo $LANG | cut -d . -f 1`
+
+export TEXTDOMAIN=grub
+export TEXTDOMAINDIR="/usr/local/share/locale"
+
+. "${datarootdir}/grub/grub-mkconfig_lib"
+
+# Set indicator that we haven't written device access yet
+haveDevAccess=0
+
+# Do this as early as possible, since other commands might depend on it.
+# (e.g. the `loadfont' command might need lvm or raid modules)
+for i in ${GRUB_PRELOAD_MODULES} ; do
+  echo "insmod $i"
+done
+
+if [ "x${GRUB_DEFAULT}" = "x" ] ; then GRUB_DEFAULT=0 ; fi
+if [ "x${GRUB_DEFAULT}" = "xsaved" ] ; then GRUB_DEFAULT='${saved_entry}' ; fi
+if [ "x${GRUB_TIMEOUT}" = "x" ] ; then GRUB_TIMEOUT=5 ; fi
+if [ "x${GRUB_GFXMODE}" = "x" ] ; then GRUB_GFXMODE=auto ; fi
+
+# Check if we have more than one BE, and need to show the menu by default
+beNum=`beadm list 2>/dev/null | grep -v 'Mountpoint' | wc -l | awk '{print $1}'`
+if [ $beNum -gt 1 ] ; then GRUB_HIDDEN_TIMEOUT=""; fi
+
+if [ "x${GRUB_DEFAULT_BUTTON}" = "x" ] ; then GRUB_DEFAULT_BUTTON="$GRUB_DEFAULT" ; fi
+if [ "x${GRUB_DEFAULT_BUTTON}" = "xsaved" ] ; then GRUB_DEFAULT_BUTTON='${saved_entry}' ; fi
+if [ "x${GRUB_TIMEOUT_BUTTON}" = "x" ] ; then GRUB_TIMEOUT_BUTTON="$GRUB_TIMEOUT" ; fi
+
+cat << EOF
+if [ -s \$prefix/grubenv ]; then
+  load_env
+fi
+EOF
+if [ "x$GRUB_BUTTON_CMOS_ADDRESS" != "x" ]; then
+    cat <<EOF
+if cmostest $GRUB_BUTTON_CMOS_ADDRESS ; then
+   set default="${GRUB_DEFAULT_BUTTON}"
+else
+   set default="${GRUB_DEFAULT}"
+fi
+EOF
+else
+    cat <<EOF
+set default="${GRUB_DEFAULT}"
+EOF
+fi
+cat <<EOF
+
+if [ x"\${feature_menuentry_id}" = xy ]; then
+  menuentry_id_option="--id"
+else
+  menuentry_id_option=""
+fi
+
+export menuentry_id_option
+
+if [ "\${prev_saved_entry}" ]; then
+  set saved_entry="\${prev_saved_entry}"
+  save_env saved_entry
+  set prev_saved_entry=
+  save_env prev_saved_entry
+  set boot_once=true
+fi
+
+function savedefault {
+  if [ -z "\${boot_once}" ]; then
+    saved_entry="\${chosen}"
+    save_env saved_entry
+  fi
+}
+
+function load_video {
+EOF
+if [ -n "${GRUB_VIDEO_BACKEND}" ]; then
+    cat <<EOF
+  insmod ${GRUB_VIDEO_BACKEND}
+EOF
+else
+# If all_video.mod isn't available load all modules available
+# with versions prior to introduction of all_video.mod
+cat <<EOF
+  insmod vbe
+  insmod vga
+  insmod video_bochs
+  insmod video_cirrus
+EOF
+fi
+cat <<EOF
+}
+
+EOF
+
+serial=0;
+gfxterm=0;
+for x in ${GRUB_TERMINAL_INPUT} ${GRUB_TERMINAL_OUTPUT}; do
+    if [ xserial = "x$x" ]; then
+	serial=1;
+    fi
+    if [ xgfxterm = "x$x" ]; then
+	gfxterm=1;
+    fi
+done
+
+if [ "x$serial" = x1 ]; then
+    if [ "x${GRUB_SERIAL_COMMAND}" = "x" ] ; then
+	grub_warn "$(gettext "Requested serial terminal but GRUB_SERIAL_COMMAND is unspecified. Default parameters will be used.")"
+	GRUB_SERIAL_COMMAND=serial
+    fi
+    echo "${GRUB_SERIAL_COMMAND}"
+fi
+
+if [ "x$gfxterm" = x1 ]; then
+    if [ -n "$GRUB_FONT" ] ; then
+       # Make the font accessible
+       if [ $haveDevAccess -ne 1 ] ; then
+		haveDevAccess=1
+       		prepare_grub_to_access_device `${grub_probe} --target=device "${GRUB_FONT}"`
+       fi
+    cat << EOF
+if loadfont `make_system_path_relative_to_its_root "${GRUB_FONT}"` ; then
+EOF
+    else
+	for dir in "${pkgdatadir}" "`echo '/boot/grub' | sed "s,//*,/,g"`" /usr/share/grub ; do
+	    for basename in unicode unifont ascii; do
+		path="${dir}/${basename}.pf2"
+		if is_path_readable_by_grub "${path}" > /dev/null ; then
+		    font_path="${path}"
+		else
+		    continue
+		fi
+		break 2
+	    done
+	done
+	if [ -n "${font_path}" ] ; then
+    cat << EOF
+if [ x\$feature_default_font_path = xy ] ; then
+   font=unicode
+else
+EOF
+                # Make the font accessible
+       		if [ $haveDevAccess -ne 1 ] ; then
+			haveDevAccess=1
+			prepare_grub_to_access_device `${grub_probe} --target=device "${font_path}"`
+		fi
+    cat << EOF
+    font="`make_system_path_relative_to_its_root "${font_path}"`"
+fi
+
+if loadfont \$font ; then
+EOF
+	    else
+    cat << EOF
+if loadfont unicode ; then
+EOF
+	    fi
+	fi
+
+    cat << EOF
+  set gfxmode=${GRUB_GFXMODE}
+  load_video
+  insmod gfxterm
+EOF
+
+# Gettext variables and module
+if [ "x${LANG}" != "xC" -a "x${grub_lang}" != "xen_US" ] ; then
+  cat << EOF
+  set locale_dir=\$prefix/locale
+  set lang=${grub_lang}
+  insmod gettext
+EOF
+fi
+
+cat <<EOF
+fi
+EOF
+fi
+
+case x${GRUB_TERMINAL_INPUT} in
+  x)
+    # Just use the native terminal
+  ;;
+  x*)
+    cat << EOF
+terminal_input ${GRUB_TERMINAL_INPUT}
+EOF
+  ;;
+esac
+
+case x${GRUB_TERMINAL_OUTPUT} in
+  x)
+    # Just use the native terminal
+  ;;
+  x*)
+    cat << EOF
+terminal_output ${GRUB_TERMINAL_OUTPUT}
+EOF
+  ;;
+esac
+
+if [ "x$gfxterm" = x1 ]; then
+    if [ "x$GRUB_THEME" != x ] && [ -f "$GRUB_THEME" ] \
+	&& is_path_readable_by_grub "$GRUB_THEME"; then
+	gettext_printf "Found theme: %s\n" "$GRUB_THEME" >&2
+
+       	if [ $haveDevAccess -ne 1 ] ; then
+		haveDevAccess=1
+		prepare_grub_to_access_device `${grub_probe} --target=device "$GRUB_THEME"`
+        fi
+	cat << EOF
+insmod gfxmenu
+EOF
+	themedir="`dirname "$GRUB_THEME"`"
+	for x in "$themedir"/*.pf2 "$themedir"/f/*.pf2; do
+	    if [ -f "$x" ]; then
+		cat << EOF
+loadfont (\$root)`make_system_path_relative_to_its_root $x`
+EOF
+	    fi
+	done
+	if [ x"`echo "$themedir"/*.jpg`" != x"$themedir/*.jpg" ] || [ x"`echo "$themedir"/*.jpeg`" != x"$themedir/*.jpeg" ]; then
+	    cat << EOF
+insmod jpeg
+EOF
+	fi
+	if [ x"`echo "$themedir"/*.png`" != x"$themedir/*.png" ]; then
+	    cat << EOF
+insmod png
+EOF
+	fi
+	if [ x"`echo "$themedir"/*.tga`" != x"$themedir/*.tga" ]; then
+	    cat << EOF
+insmod tga
+EOF
+	fi
+	    
+	cat << EOF
+set theme=(\$root)`make_system_path_relative_to_its_root $GRUB_THEME`
+export theme
+EOF
+    elif [ "x$GRUB_BACKGROUND" != x ] && [ -f "$GRUB_BACKGROUND" ] \
+	    && is_path_readable_by_grub "$GRUB_BACKGROUND"; then
+	gettext_printf "Found background: %s\n" "$GRUB_BACKGROUND" >&2
+	case "$GRUB_BACKGROUND" in 
+	    *.png)         reader=png ;;
+	    *.tga)         reader=tga ;;
+	    *.jpg|*.jpeg)  reader=jpeg ;;
+	    *)             gettext "Unsupported image format" >&2; echo >&2; exit 1 ;;
+	esac
+       	if [ $haveDevAccess -ne 1 ] ; then
+		haveDevAccess=1
+		prepare_grub_to_access_device `${grub_probe} --target=device "$GRUB_BACKGROUND"`
+	fi
+	cat << EOF
+insmod $reader
+background_image -m stretch `make_system_path_relative_to_its_root "$GRUB_BACKGROUND"`
+EOF
+    fi
+fi
+
+make_timeout ()
+{
+    if [ "x${1}" != "x" ] ; then
+	if [ "x${GRUB_HIDDEN_TIMEOUT_QUIET}" = "xtrue" ] ; then
+	    verbose=
+	else
+	    verbose=" --verbose"
+	fi
+	cat << EOF
+echo "Hold Left-Shift for menu.."
+if sleep$verbose --interruptible ${1} ; then
+  if keystatus --shift; then
+    set timeout=-1
+  else
+    set timeout=0
+  fi
+fi
+EOF
+    else
+	cat << EOF
+set timeout=${2}
+EOF
+    fi
+}
+
+if [ "x$GRUB_BUTTON_CMOS_ADDRESS" != "x" ]; then
+    cat <<EOF
+if cmostest $GRUB_BUTTON_CMOS_ADDRESS ; then
+EOF
+make_timeout "${GRUB_HIDDEN_TIMEOUT_BUTTON}" "${GRUB_TIMEOUT_BUTTON}"
+echo else
+make_timeout "${GRUB_HIDDEN_TIMEOUT}" "${GRUB_TIMEOUT}"
+echo fi
+else
+make_timeout "${GRUB_HIDDEN_TIMEOUT}" "${GRUB_TIMEOUT}"
+fi
+
+if [ "x$GRUB_BUTTON_CMOS_ADDRESS" != "x" ] && [ "x$GRUB_BUTTON_CMOS_CLEAN" = "xyes" ]; then
+    cat <<EOF
+cmosclean $GRUB_BUTTON_CMOS_ADDRESS
+EOF
+fi
+
+# Play an initial tune
+if [ "x${GRUB_INIT_TUNE}" != "x" ] ; then
+  echo "play ${GRUB_INIT_TUNE}"
+fi
+
+if [ "x${GRUB_BADRAM}" != "x" ] ; then
+  echo "badram ${GRUB_BADRAM}"
+fi

Added: head/sysutils/grub2-pcbsd/files/10_kfreebsd.in
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/grub2-pcbsd/files/10_kfreebsd.in	Fri Jun  6 15:26:31 2014	(r356802)
@@ -0,0 +1,4 @@
+#! /bin/sh
+
+# Exit for now, we can use 10_ktrueos instead
+return 0

Added: head/sysutils/grub2-pcbsd/files/10_ktrueos.in
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/grub2-pcbsd/files/10_ktrueos.in	Fri Jun  6 15:26:31 2014	(r356802)
@@ -0,0 +1,298 @@
+#!/bin/sh
+#
+# Copyright 2013 iXsystems (Kris Moore)
+# All rights reserved
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted providing that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+# Script to detect TrueOS / PC-BSD disk installations and create grub
+# entries for them
+
+ROOTFS=`mount | awk '/ \/ / {print $1}'`
+BEDS="$( echo ${ROOTFS} | awk -F '/' '{print $2}' )"
+if [ "$BEDS" = "dev" ] ; then BEDS="ROOT"; fi
+
+
+display_loaderopts()
+{
+  # Optional ARG1, set to a ZFS dataset to mount and read values from
+  if [ -n "$1" ] ; then
+     fMnt="/mnt.$$"
+     mkdir $fMnt
+     mount -t zfs  ${1} $fMnt >/dev/null 
+     if [ $? -ne 0 ] ; then
+        echo "Failed to mount ${1}" >&2
+        return
+     fi
+  else
+     fMnt=""
+  fi
+  
+  # Create our placeholder to save _load entries to parse
+  touch /tmp/.lRObjs.$$
+  touch /tmp/.lSysCtls.$$
+
+  # Loader files, in order of which to read them
+  lFiles="${fMnt}/boot/loader.conf.local ${fMnt}/boot/loader.conf ${fMnt}/boot/loader.conf.trueos ${fMnt}/boot/loader.conf.pcbsd"
+  for f in $lFiles
+  do
+     if [ ! -e "$f" ] ; then continue ; fi
+
+     # Lets parse any of the _load= lines
+     grep "_load=" ${f} | grep -v "^#" >/tmp/.lObjs.$$
+     while read line
+     do
+       loadVal="`echo $line | cut -d '=' -f 1`"
+       # Is this value already set in a higher priority file?
+       grep -q "^${loadVal}" /tmp/.lRObjs.$$
+       if [ $? -eq 0 ];then continue; fi
+
+       # Save this value for later
+       echo "$line" >> /tmp/.lRObjs.$$
+       haveObjs=1
+
+     done < /tmp/.lObjs.$$
+     rm /tmp/.lObjs.$$
+
+     # Lets look for any sysctls to set
+     grep "." ${f} | grep "=" | grep -v "^#" | grep -v "_load" >/tmp/.sObjs.$$
+     while read line
+     do
+       loadVal="`echo $line | cut -d '=' -f 1`"
+       # Is this value already set in a higher priority file?
+       grep -q "^${loadVal}" /tmp/.lSysCtls.$$
+       if [ $? -eq 0 ];then continue; fi
+
+       # Save this value for later
+       echo "$line" >> /tmp/.lSysCtls.$$
+       haveSysCtls=1
+
+     done < /tmp/.sObjs.$$
+     rm /tmp/.sObjs.$$
+  done
+
+  # Now lets echo out the modules to load
+  if [ "$haveObjs" = "1" ] ; then
+    while read line
+    do
+      echo "$line" | grep -q '"YES"'
+      if [ $? -ne 0 ] ; then continue ; fi
+      module="`echo $line | cut -d '=' -f 1 | sed 's|_load||g'`"
+      # Try to locate module now
+      if [ -e "${fMnt}/boot/kernel/${module}.ko" ] ; then
+        mPath="kernel"
+      elif [ -e "${fMnt}/boot/modules/${module}.ko" ] ; then
+        mPath="modules"
+      else
+	# This isn't a module that we can see, lets set it as a variable
+	#echo "No such module $line, setting as a variable" >&2
+        echo "$line" >> /tmp/.lSysCtls.$$
+        continue
+      fi
+      echo "    kfreebsd_module_elf ${loadPrefix}/@/boot/${mPath}/${module}.ko"
+    done < /tmp/.lRObjs.$$
+  fi
+
+  # Any sysctls to set?
+  if [ "$haveSysCtls" = "1" ] ; then
+    while read line
+    do
+      # Strip out the vfs.root.mountfrom, we set that elsewhere
+      echo "$line" | grep -q "vfs.root.mountfrom"
+      if [ $? -eq 0 ] ; then continue ; fi
+
+      val="`echo $line | sed 's|"||g'`"
+      echo "    set kFreeBSD.${val}"
+    done < /tmp/.lSysCtls.$$
+  fi
+
+  rm /tmp/.lRObjs.$$
+  rm /tmp/.lSysCtls.$$
+  if [ -n "$1" ] ; then
+     umount /mnt.$$ >/dev/null
+     rmdir /mnt.$$ >/dev/null
+  fi
+}
+
+detect_beadm()
+{
+   which -s beadm
+   if [ $? -ne 0 ] ; then return 0; fi
+
+   # Check if we are running from the installer and use its beadm
+   if [ -e "/root/beadm.install" ] ; then
+      BEADM="/root/beadm.install"
+   else
+      BEADM="`which beadm`"
+   fi
+
+   ${BEADM} list >/dev/null 2>/dev/null
+   if [ $? -ne 0 ] ; then return 0; fi
+
+
+   if [ -e "/etc/defaults/pcbsd" ] ; then
+      NICK="PC-BSD"
+   else
+      NICK="TrueOS"
+   fi
+
+   # Get list of beadm datasets
+   for b in `${BEADM} list 2>/dev/null| grep -v "Created" | cut -d ' ' -f 1`
+   do
+      # Got a beadm snapshot, lets get the complete dataset name
+      beLine=`${BEADM} list -a | grep "/$BEDS/${b}"`
+      cdataset=`echo $beLine | awk '{print $1}'`
+      cdatadate=`echo $beLine | awk '{print $5}'`
+      cdatatime=`echo $beLine | awk '{print $6}'`
+      ztank=`echo $cdataset | cut -d '/' -f 1`
+      shortdataset="/`echo $cdataset | cut -d '/' -f 2-5`"
+
+      # First part of this dataset
+      cat > /tmp/.grubdataset.$$.1 << EOF
+    insmod zfs
+    search --no-floppy -s -l $ztank
+EOF
+
+      # Second part of loader to save
+      cat > /tmp/.grubdataset.$$.2 << EOF
+    kfreebsd_module ${shortdataset}/@/boot/zfs/zpool.cache type=/boot/zfs/zpool.cache
+    set kFreeBSD.vfs.root.mountfrom=zfs:$cdataset
+EOF
+      
+      # Now lets look for options in loader.conf to load
+      loadPrefix="${shortdataset}"
+      # If this is the current mounted dataset, we can skip mounting it
+      mount | grep -q -e "$cdataset on / (" -e "$cdataset on /mnt ("
+      if [ $? -eq 0 ] ; then
+        display_loaderopts >>/tmp/.grubdataset.$$.2
+      else
+        display_loaderopts $cdataset >> /tmp/.grubdataset.$$.2
+      fi
+
+      # Lets start a submenu for each BE
+cat << EOF
+# Start TrueOS BE Submenu
+submenu "${NICK} ($b) - ${cdatadate} ${cdatatime}" {
+EOF
+  
+  # Lets do the default entry first
+  #################################
+  cat << EOF
+  menuentry "Normal Bootup" {
+EOF
+  # Get the dataset guts
+  cat /tmp/.grubdataset.$$.1
+  echo "    kfreebsd ${shortdataset}/@/boot/kernel/kernel"
+  echo "    kfreebsd_loadenv ${shortdataset}@/boot/device.hints"
+  cat /tmp/.grubdataset.$$.2
+
+  # Set any options
+  cat << EOF
+  }
+EOF
+
+  # Next lets do single user mode
+  #################################
+  cat << EOF
+  menuentry "Single User Mode" {
+EOF
+  # Get the dataset guts
+  cat /tmp/.grubdataset.$$.1
+  echo "    kfreebsd ${shortdataset}/@/boot/kernel/kernel -s"
+  echo "    kfreebsd_loadenv ${shortdataset}@/boot/device.hints"
+  cat /tmp/.grubdataset.$$.2
+
+  # Set any options
+  cat << EOF
+  }
+EOF
+
+  # Next lets do verbose mode
+  #################################
+  cat << EOF
+  menuentry "Verbose Mode" {
+EOF
+  # Get the dataset guts
+  cat /tmp/.grubdataset.$$.1
+  echo "    kfreebsd ${shortdataset}/@/boot/kernel/kernel -v"
+  echo "    kfreebsd_loadenv ${shortdataset}@/boot/device.hints"
+  cat /tmp/.grubdataset.$$.2
+
+  # Set any options
+  cat << EOF
+  }
+EOF
+
+  if [ -e "/etc/defaults/pcbsd" ] ; then
+    # Next lets do display wizard
+    #################################
+    cat << EOF
+  menuentry "Run the Display Wizard" {
+EOF
+    # Get the dataset guts
+    cat /tmp/.grubdataset.$$.1
+    echo "    kfreebsd ${shortdataset}/@/boot/kernel/kernel"
+    echo "    kfreebsd_loadenv ${shortdataset}@/boot/device.hints"
+    cat /tmp/.grubdataset.$$.2
+
+    # Set any options
+    cat << EOF
+    set kFreeBSD.runwiz=YES
+  }
+EOF
+    # Now for vesa mode
+    #################################
+    cat << EOF
+  menuentry "Run X in vesa mode" {
+EOF
+    # Get the dataset guts
+    cat /tmp/.grubdataset.$$.1
+    echo "    kfreebsd ${shortdataset}/@/boot/kernel/kernel"
+    echo "    kfreebsd_loadenv ${shortdataset}@/boot/device.hints"
+    cat /tmp/.grubdataset.$$.2
+
+    # Set any options
+    cat << EOF
+    set kFreeBSD.xvesa=YES
+  }
+EOF
+  fi
+
+
+      # Lastly lets close the submenu section
+      cat << EOF
+}
+# End TrueOS BE
+
+EOF
+   done
+
+   # Cleanup after ourselves
+   if [ -e "/tmp/.grubdataset.$$.1" ] ; then
+     rm /tmp/.grubdataset.$$.1
+     rm /tmp/.grubdataset.$$.2
+   fi
+}
+
+# Detect our types of disk layouts
+detect_beadm
+

Added: head/sysutils/grub2-pcbsd/files/30_os-prober.in
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/grub2-pcbsd/files/30_os-prober.in	Fri Jun  6 15:26:31 2014	(r356802)
@@ -0,0 +1,61 @@
+#!/bin/sh
+#
+# Copyright 2013 iXsystems (Kris Moore)
+# All rights reserved
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted providing that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+
+# Script to detect other NON BSD OS's and add to grub.cfg
+
+check_ntfs_part()
+{
+   local disk="$1"
+   fs_label=`grub-probe --device /dev/${disk} --target=fs_label`
+
+   # Check for common windows NTFS labels for bootable partitions
+   if [ "$fs_label" != "System Reserved" -a "$fs_label" != "OS" -a "$fs_label" != "SYSTEM" ] ; then return; fi
+
+   fs_uuid=`grub-probe --device /dev/${disk} --target=fs_uuid`
+   if [ -z "$fs_uuid" ] ; then
+      echo "Warning: Could not get fs_uuid for $disk"
+      return
+   fi
+
+   cat << EOF
+menuentry "Microsoft Windows ($disk)" {
+   search --no-floppy --fs-uuid --set=root $fs_uuid
+   chainloader +1
+}
+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`
+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 
+done

Added: head/sysutils/grub2-pcbsd/files/patch-configure.ac
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/grub2-pcbsd/files/patch-configure.ac	Fri Jun  6 15:26:31 2014	(r356802)
@@ -0,0 +1,20 @@
+--- configure.ac.orig	2014-03-03 11:00:26.000000000 -0500
++++ configure.ac	2014-06-05 13:24:29.290891223 -0400
+@@ -1389,7 +1389,7 @@
+ 
+ if test x"$starfield_excuse" = x; then
+    for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
+-     for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/truetype/ttf-dejavu /usr/share/fonts/dejavu /usr/share/fonts/truetype; do
++     for dir in . /usr/src /usr/local/lib/X11/fonts/dejavu /usr/share/fonts/truetype/ttf-dejavu /usr/share/fonts/dejavu /usr/share/fonts/truetype; do
+         if test -f "$dir/DejaVuSans.$ext"; then
+           DJVU_FONT_SOURCE="$dir/DejaVuSans.$ext"
+           break 2
+@@ -1411,7 +1411,7 @@
+ FONT_SOURCE=
+ 
+ for ext in pcf pcf.gz bdf bdf.gz ttf ttf.gz; do
+-  for dir in . /usr/src /usr/share/fonts/X11/misc /usr/share/fonts/unifont /usr/share/fonts/uni /usr/share/fonts/truetype/unifont /usr/share/fonts/misc; do
++  for dir in . /usr/src /usr/local/lib/X11/fonts/local /usr/share/fonts/unifont /usr/share/fonts/uni /usr/share/fonts/truetype/unifont /usr/share/fonts/misc; do
+     if test -f "$dir/unifont.$ext"; then
+       md5="$(md5sum "$dir/unifont.$ext"|awk '{ print $1; }')"
+       # PCF and BDF from version 6.3 isn't hanled properly by libfreetype.

Added: head/sysutils/grub2-pcbsd/files/patch-grub-core_disk_geli.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/grub2-pcbsd/files/patch-grub-core_disk_geli.c	Fri Jun  6 15:26:31 2014	(r356802)
@@ -0,0 +1,20 @@
+--- grub-core/disk/geli.c.orig	2014-05-15 14:00:10.000000000 -0400
++++ grub-core/disk/geli.c	2014-05-20 14:46:07.604565349 -0400
+@@ -225,7 +225,7 @@
+ 
+   /* Look for GELI magic sequence.  */
+   if (grub_memcmp (header->magic, GELI_MAGIC, sizeof (GELI_MAGIC))
+-      || grub_le_to_cpu32 (header->version) > 5
++      || grub_le_to_cpu32 (header->version) > 7
+       || grub_le_to_cpu32 (header->version) < 1)
+     grub_util_error ("%s", _("wrong ELI magic or version"));
+ 
+@@ -265,7 +265,7 @@
+ 
+   /* Look for GELI magic sequence.  */
+   if (grub_memcmp (header.magic, GELI_MAGIC, sizeof (GELI_MAGIC))
+-      || grub_le_to_cpu32 (header.version) > 5
++      || grub_le_to_cpu32 (header.version) > 7
+       || grub_le_to_cpu32 (header.version) < 1)
+     {
+       grub_dprintf ("geli", "wrong magic %02x\n", header.magic[0]);

Added: head/sysutils/grub2-pcbsd/files/patch-grub-core_lib_libgcrypt-grub_src_types.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/grub2-pcbsd/files/patch-grub-core_lib_libgcrypt-grub_src_types.h	Fri Jun  6 15:26:31 2014	(r356802)
@@ -0,0 +1,11 @@
+--- grub-core/lib/libgcrypt/src/types.h.o	2014-03-03 17:14:46.722210112 -0500
++++ grub-core/lib/libgcrypt/src/types.h	2014-03-03 17:05:54.572824164 -0500
+@@ -113,6 +113,8 @@
+ #endif
+ #endif
+ 
++typedef uint64_t u64;
++
+ typedef union {
+     int a;
+     short b;

Added: head/sysutils/grub2-pcbsd/files/patch-util_grub-mkconfig.in
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/grub2-pcbsd/files/patch-util_grub-mkconfig.in	Fri Jun  6 15:26:31 2014	(r356802)
@@ -0,0 +1,59 @@
+--- util/grub-mkconfig.in.orig	2014-06-05 12:39:41.711496387 -0400
++++ util/grub-mkconfig.in	2014-06-05 12:43:08.310985691 -0400
+@@ -276,5 +276,56 @@
+   fi
+ fi
+ 
++# If doing a real grub.cfg update, make sure that our config gets
++# copied to the /default/ ZFS BE
++check_grub_zfs_be()
++{
++
++  ROOTFS=`mount | awk '/ \/ / {print $1}'`
++  BEDS="$( echo ${ROOTFS} | awk -F '/' '{print $2}' )"
++  if [ "$BEDS" = "dev" ] ; then BEDS="ROOT"; fi
++
++  if [ "$grub_cfg" = "/boot/grub/grub.cfg" ] ; then
++    for i in `beadm list -a 2>/dev/null | grep "/${BEDS}/" | awk '{print $1}'`
++    do
++      if ! mount | grep -q "$dTank on / ("; then
++         echo -e "Copying grub.cfg to $dTank...\c" >&2
++         fMnt="/mnt.$$"
++         mkdir $fMnt
++         if ! mount -t zfs ${dTank} $fMnt ; then
++            echo "Failed to mount ${dTank}" >&2
++            return
++         else
++           cp ${grub_cfg} ${fMnt}/boot/grub/grub.cfg
++           echo -e "done" >&2
++           umount ${fMnt} >/dev/null
++           rmdir ${fMnt} >/dev/null
++         fi
++      fi
++    done
++
++    # Check if we can re-stamp the boot-loader
++    TANK=`echo $ROOTFS | cut -d '/' -f 1`
++    for i in `zpool status $TANK | grep ONLINE | awk '{print $1}'`
++    do
++       if [ ! -e "/dev/${i}" ] ; then continue; fi
++       disk=`echo $i | sed 's|.eli||g'`
++
++       # Now get the root of the disk
++       disk=`echo $disk | sed 's|p[1-9]$||g' | sed "s|s[1-9][a-z]||g"`
++       if [ ! -e "/dev/${disk}" ] ; then continue; fi
++
++       # Re-install GRUB on this disk
++       echo "Installing GRUB to $disk" >&2
++       grub-install /dev/${disk}
++    done
++  fi
++
++}
++
+ gettext "done" >&2
+ echo >&2
++
++# Check if we need to copy this cfg to the original BE
++check_grub_zfs_be
++

Added: head/sysutils/grub2-pcbsd/files/patch-util_grub-mkconfig_lib.in
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/grub2-pcbsd/files/patch-util_grub-mkconfig_lib.in	Fri Jun  6 15:26:31 2014	(r356802)
@@ -0,0 +1,21 @@
+--- util/grub-mkconfig_lib.in.orig	2014-03-03 11:00:26.000000000 -0500
++++ util/grub-mkconfig_lib.in	2014-06-05 12:45:58.532199020 -0400
+@@ -139,7 +139,17 @@
+     echo "insmod ${module}"
+   done
+ 
+-  fs="`"${grub_probe}" --device $@ --target=fs`"
++  # KPM - 6-24-2013
++  # Add this work-around since GRUB doesn't like to identify ZFS
++  # partitions which are in a raidz configuration, gives Unknown FS error
++  # We can instead look at zpool to see if this device is used though
++  zpool status 2>/dev/null | grep -q "`echo ${device} | sed 's|/dev/||g'`"
++  if [ $? -eq 0 ] ; then
++     fs="zfs"
++  else
++     fs="`"${grub_probe}" --device $@ --target=fs`"
++  fi
++
+   for module in ${fs} ; do
+     echo "insmod ${module}"
+   done

Added: head/sysutils/grub2-pcbsd/pkg-descr
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/grub2-pcbsd/pkg-descr	Fri Jun  6 15:26:31 2014	(r356802)
@@ -0,0 +1,12 @@
+GNU GRUB is a multiboot boot loader.  It was derived from GRUB, the GRand
+Unified Bootloader, which was originally designed and implemented by Erich 
+Stefan Boleyn.
+
+This port does not install GRUB on the master boot record of your hard drive.
+To do this you will need to read the info page that is installed by the port.
+
+This port includes additional patches and fixes making it work properly
+with ZFS boot-environments. Users on UFS will probably want to install the
+regular sysutils/grub2 port. 
+
+WWW: http://www.gnu.org/software/grub/

Added: head/sysutils/grub2-pcbsd/pkg-message
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/grub2-pcbsd/pkg-message	Fri Jun  6 15:26:31 2014	(r356802)
@@ -0,0 +1,11 @@
+#############################################################
+To install GRUB on the master boot record of your hard drive
+use 'grub-install <drive-to-install>' command.
+
+A typical menu entry in /boot/grub/grub.cfg for FreeBSD:
+menuentry "FreeBSD" {
+	set root="(hd0,msdos1,bsd1)"
+	kfreebsd /boot/loader
+}
+Or use grub-mkconfig to create the config file.
+#############################################################

Added: head/sysutils/grub2-pcbsd/pkg-plist
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/grub2-pcbsd/pkg-plist	Fri Jun  6 15:26:31 2014	(r356802)
@@ -0,0 +1,649 @@
+%%FUSE%%bin/grub-mount
+%%FUSE%%man/man1/grub-mount.1.gz

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201406061526.s56FQW7Z091767>