From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1MZOK4-0000lJ-Cj for mharc-grub-devel@gnu.org; Fri, 07 Aug 2009 08:13:25 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MZOJu-0000jo-0Y for grub-devel@gnu.org; Fri, 07 Aug 2009 08:13:14 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MZOJo-0000hw-UH for grub-devel@gnu.org; Fri, 07 Aug 2009 08:13:13 -0400 Received: from [199.232.76.173] (port=55472 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MZOJo-0000hk-P3 for grub-devel@gnu.org; Fri, 07 Aug 2009 08:13:08 -0400 Received: from xvm-190-8.ghst.net ([217.70.190.8]:60636 helo=aybabtu.com) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MZOJo-00006v-6Q for grub-devel@gnu.org; Fri, 07 Aug 2009 08:13:08 -0400 Received: from [192.168.10.10] (helo=thorin) by aybabtu.com with esmtp (Exim 4.69) (envelope-from ) id 1MZOJe-0004ya-0g for grub-devel@gnu.org; Fri, 07 Aug 2009 14:12:58 +0200 Received: from rmh by thorin with local (Exim 4.69) (envelope-from ) id 1MZOJd-00022Z-Bk for grub-devel@gnu.org; Fri, 07 Aug 2009 14:12:57 +0200 Date: Fri, 7 Aug 2009 14:12:57 +0200 From: Robert Millan To: grub-devel@gnu.org Message-ID: <20090807121257.GA7839@thorin> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="3V7upXqbjpZ4EhLz" Content-Disposition: inline Organization: free as in freedom X-Message-Flag: Worried about Outlook viruses? Switch to Thunderbird! www.mozilla.com/thunderbird X-Debbugs-No-Ack: true User-Agent: Mutt/1.5.18 (2008-05-17) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Subject: [PATCH] Reimplement 10_freebsd.in using 10_linux.in X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Aug 2009 12:13:14 -0000 --3V7upXqbjpZ4EhLz Content-Type: text/plain; charset=us-ascii Content-Disposition: inline This patch reimplements 10_freebsd.in using 10_linux.in as a base, with the kFreeBSD-specific parts of 10_freebsd.in. The new version brings in support for multiple kernel versions (the reason for the rewrite) and also handling of acpi.ko. It is diffed against 10_linux.in, since the old code structure is no longer used. -- Robert Millan The DRM opt-in fallacy: "Your data belongs to us. We will decide when (and how) you may access your data; but nobody's threatening your freedom: we still allow you to remove your data and not access it at all." --3V7upXqbjpZ4EhLz Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="kfreebsd-gnu.diff" --- util/grub.d/10_linux.in 2009-08-07 14:04:34.000000000 +0200 +++ util/grub.d/10_freebsd.in 2009-08-07 14:09:05.000000000 +0200 @@ -21,82 +21,79 @@ libdir=@libdir@ . ${libdir}/grub/grub-mkconfig_lib -if [ "x${GRUB_DISTRIBUTOR}" = "x" ] ; then - OS=GNU/Linux -else - OS="${GRUB_DISTRIBUTOR} GNU/Linux" -fi - -# loop-AES arranges things so that /dev/loop/X can be our root device, but -# the initrds that Linux uses don't like that. -case ${GRUB_DEVICE} in - /dev/loop/*|/dev/loop[0-9]) - GRUB_DEVICE=`losetup ${GRUB_DEVICE} | sed -e "s/^[^(]*(\([^)]\+\)).*/\1/"` - ;; +case "${GRUB_DISTRIBUTOR}" in + Debian) OS="${GRUB_DISTRIBUTOR} GNU/kFreeBSD" ;; + *) OS="FreeBSD" ;; esac -if [ "x${GRUB_DEVICE_UUID}" = "x" ] || [ "x${GRUB_DISABLE_LINUX_UUID}" = "xtrue" ] \ - || ! test -e "/dev/disk/by-uuid/${GRUB_DEVICE_UUID}" ; then - LINUX_ROOT_DEVICE=${GRUB_DEVICE} -else - LINUX_ROOT_DEVICE=UUID=${GRUB_DEVICE_UUID} -fi - -linux_entry () +kfreebsd_entry () { cat << EOF menuentry "$1" { EOF prepare_grub_to_access_device ${GRUB_DEVICE_BOOT} | sed -e "s/^/\t/" cat << EOF - linux ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro $2 + freebsd ${rel_dirname}/${basename} +EOF + + if test -n "${devices}" ; then + cat << EOF + freebsd_loadenv ${devices_rel_dirname}/${devices_basename} EOF - if test -n "${initrd}" ; then + fi + + if test -n "${acpi_ko}" ; then cat << EOF - initrd ${rel_dirname}/${initrd} + freebsd_module_elf ${acpi_ko_rel_dirname}/${acpi_ko_basename} EOF fi + cat << EOF + set FreeBSD.vfs.root.mountfrom=${kfreebsd_fs}:${GRUB_DEVICE} + set FreeBSD.vfs.root.mountfrom.options=rw } EOF } -list=`for i in /boot/vmlinu[xz]-* /vmlinu[xz]-* ; do +list=`for i in /boot/kfreebsd-* /boot/kernel/kernel ; do if grub_file_is_not_garbage "$i" ; then echo -n "$i " ; fi done` while [ "x$list" != "x" ] ; do - linux=`version_find_latest $list` - echo "Found linux image: $linux" >&2 - basename=`basename $linux` - dirname=`dirname $linux` + kfreebsd=`version_find_latest $list` + echo "Found kernel of FreeBSD: $kfreebsd" >&2 + basename=`basename $kfreebsd` + dirname=`dirname $kfreebsd` rel_dirname=`make_system_path_relative_to_its_root $dirname` - version=`echo $basename | sed -e "s,^[^0-9]*-,,g"` + + if [ x"$devices" != "x" ] ; then + devices_basename=`basename $devices` + devices_dirname=`dirname $devices` + devices_rel_dirname=`make_system_path_relative_to_its_root $devices_dirname` + fi + + # For "ufs" it's the same. Do we care about the others? + kfreebsd_fs=${GRUB_FS} + + version=`echo $basename | sed -e "s,^[^0-9]*-,,g;s/\.gz$//g"` alt_version=`echo $version | sed -e "s,\.old$,,g"` - linux_root_device_thisversion="${LINUX_ROOT_DEVICE}" - initrd= - for i in "initrd.img-${version}" "initrd-${version}.img" \ - "initrd-${version}" "initrd.img-${alt_version}" \ - "initrd-${alt_version}.img" "initrd-${alt_version}"; do - if test -e "${dirname}/${i}" ; then - initrd="$i" + acpi_ko= + for i in "/lib/modules/${version}/acpi.ko" "/lib/modules/${alt_version}/acpi.ko" \ + "/boot/kernel/acpi.ko"; do + if test -e "$i" ; then + acpi_ko="$i" break fi done - if test -n "${initrd}" ; then - echo "Found initrd image: ${dirname}/${initrd}" >&2 - else - # "UUID=" magic is parsed by initrds. Since there's no initrd, it can't work here. - linux_root_device_thisversion=${GRUB_DEVICE} + if test -n "${acpi_ko}" ; then + echo "Found ACPI module: ${acpi_ko}" >&2 + acpi_ko_basename=`basename ${acpi_ko}` + acpi_ko_dirname=`dirname ${acpi_ko}` + acpi_ko_rel_dirname=`make_system_path_relative_to_its_root $acpi_ko_dirname` fi - linux_entry "${OS}, Linux ${version}" \ - "${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}" - if [ "x${GRUB_DISABLE_LINUX_RECOVERY}" != "xtrue" ]; then - linux_entry "${OS}, Linux ${version} (recovery mode)" \ - "single ${GRUB_CMDLINE_LINUX}" - fi + kfreebsd_entry "${OS}, kFreeBSD ${version}" - list=`echo $list | tr ' ' '\n' | grep -vx $linux | tr '\n' ' '` + list=`echo $list | tr ' ' '\n' | grep -vx $kfreebsd | tr '\n' ' '` done --3V7upXqbjpZ4EhLz--