Skip to contentSkip to conversation

grub-install for FreeBSD

PATCH Andrey Shuvikov 7 participants 10 messages Sep 23, 2009 – Sep 25, 2009

lore
Share & tools
lore
#0 lore raw

Hello,

I tried to install Grub2 under FreeBSD but grub-install failed because readlink doesn't understand -f and stat doesn't have -c. I edited grub-mkconfig_lib.in to use different commands instead. I'm not sure it's the right way to handle this difference but it worked. The patch is attached.

Regards,
Andrey

grub-mkconfig_lib.in +15 -4
Index: util/grub-mkconfig_lib.in
===================================================================
@@ -25,6 +25,17 @@
 
 grub_probe=${sbindir}/`echo grub-probe | sed ${transform}`
 
+case "`uname 2>/dev/null`" in
+  FreeBSD*)
+    grub_readlink=realpath
+    grub_getdevice="stat -f %d"
+    ;;
+  *)
+    grub_readlink="readlink -f"
+    grub_getdevice="stat -c %d"
+    ;;
+esac
+
 grub_warn ()
 {
   echo "Warning: $@" >&2
@@ -39,7 +50,7 @@
   fi
 
   # canonicalize
-  if path=`readlink -f $path` ; then : ; else
+  if path=`$grub_readlink $path` ; then : ; else
     return 1
   fi
 
@@ -50,12 +61,12 @@
     dir=`echo $path | sed -e "s,/[^/]*$,,g"`
   fi
 
-  num=`stat -c %d $dir`
+  num=`$grub_getdevice $dir`
 
   # this loop sets $dir to the root directory of the filesystem we're inspecting
   while : ; do
-    parent=`readlink -f $dir/..`
-    if [ "x`stat -c %d $parent`" = "x$num" ] ; then : ; else
+    parent=`$grub_readlink $dir/..`
+    if [ "x`$grub_getdevice $parent`" = "x$num" ] ; then : ; else
       # $parent is another filesystem; we found it.
       break
     fi
#1 lore raw

Hi,

Quoting Andrey Shuvikov, who wrote the following on Tue, 22 Sep 2009:

Quoted 7 lines

Hello,

I tried to install Grub2 under FreeBSD but grub-install failed because readlink doesn't understand -f and stat doesn't have -c. I edited grub-mkconfig_lib.in to use different commands instead. I'm not sure it's the right way to handle this difference but it worked. The patch is attached.

Regards,
Andrey

Solaris has similar problems as well. The configure script needs to do a
better job with finding alternatives and substituting those alternatives in the script library.

--S

#2 lore raw
In reply to Andrey Shuvikov
Quoted 5 lines · Andrey Shuvikov

Hello,

I tried to install Grub2 under FreeBSD but grub-install failed because readlink doesn't understand -f and stat doesn't have -c. I edited grub-mkconfig_lib.in to use different commands instead. I'm not sure it's the right way to handle this difference but it worked. The patch is attached.

We're aware of this problem. Felix Zielcke has a solution but at this point it's deemed too intrusive. We'll probably commit it once feature freeze is over

Quoted 12 lines

Regards,
Andrey

------------------------------------------------------------------------

_______________________________________________
Grub-devel mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/grub-devel

#3 lore raw
Quoted 9 lines · Vladimir 'phcoder' Serbinenko
Quoted 5 lines · Andrey Shuvikov

Hello,

I tried to install Grub2 under FreeBSD but grub-install failed because readlink doesn't understand -f and stat doesn't have -c. I edited grub-mkconfig_lib.in to use different commands instead. I'm not sure it's the right way to handle this difference but it worked. The patch is attached.

We're aware of this problem. Felix Zielcke has a solution but at this point it's deemed too intrusive. We'll probably commit it once feature freeze is over

Alternatively, I could also allow a patch that checks the capabilities of those commands. It should try readlink first, and fallback to greadlink if necessary.

Signature · 5 lines
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."
#4 lore raw
Quoted 7 lines · Robert Millan
Quoted 6 lines · Vladimir 'phcoder' Serbinenko
Quoted 5 lines · Andrey Shuvikov

Hello,

I tried to install Grub2 under FreeBSD but grub-install failed because readlink doesn't understand -f and stat doesn't have -c. I edited grub-mkconfig_lib.in to use different commands instead. I'm not sure it's the right way to handle this difference but it worked. The patch is attached.

Quoted 8 lines
Quoted 3 lines

We're aware of this problem. Felix Zielcke has a solution but at this point it's deemed too intrusive. We'll probably commit it once feature freeze is over

Alternatively, I could also allow a patch that checks the capabilities of those commands. It should try readlink first, and fallback to greadlink if necessary.

Not sure if Felix's patch covers it, but there is also a problem with the 'sed' syntax in 10_freebsd and 30_os-prober. It turns out that freebsd 'sed' is quite retarded (at least in 7.2) and doesn't know that '\t' is supposed to be tab. Replacing 'sed' with 'gsed' or 'perl -p' fixes this issue.

Where would I go to view Felix's path? I am concerned because freebsd also has a 'gstat' command that does not work either. Only by installing the coreutils and pointing explicitly at the coreutils version of gstat did I get this to work.

Signature · 1 line
--Brian
#5 lore raw

Am Donnerstag, den 24.09.2009, 11:01 -0700 schrieb Brian R. Jones:

Quoted 18 lines
Quoted 7 lines · Robert Millan
Quoted 6 lines · Vladimir 'phcoder' Serbinenko
Quoted 5 lines · Andrey Shuvikov

Hello,

I tried to install Grub2 under FreeBSD but grub-install failed because readlink doesn't understand -f and stat doesn't have -c. I edited grub-mkconfig_lib.in to use different commands instead. I'm not sure it's the right way to handle this difference but it worked. The patch is attached.

Quoted 8 lines
Quoted 3 lines

We're aware of this problem. Felix Zielcke has a solution but at this point it's deemed too intrusive. We'll probably commit it once feature freeze is over

Alternatively, I could also allow a patch that checks the capabilities of those commands. It should try readlink first, and fallback to greadlink if necessary.

Quoted 4 lines

Not sure if Felix's patch covers it, but there is also a problem with the 'sed' syntax in 10_freebsd and 30_os-prober. It turns out that freebsd 'sed' is quite retarded (at least in 7.2) and doesn't know that '\t' is supposed to be tab. Replacing 'sed' with 'gsed' or 'perl -p' fixes this issue.

No it doestn't.
Autoconf has an AC_PROG_SED macro which checks for a POSIX sed.
http://www.gnu.org/software/autoconf/manual/html_node/Limitations-of-Usual-Tools.html#sed
Portable sed regular expressions should use ‘\’ only to escape characters in the string ‘$()*.0123456789[\^n{}’

If I understand that right, POSIX doestn't mandate \t so it wouldn't help us.

Quoted 4 lines

Where would I go to view Felix's path? I am concerned because freebsd also has a 'gstat' command that does not work either. Only by installing the coreutils and pointing explicitly at the coreutils version of gstat did I get this to work.

http://lists.gnu.org/archive/html/grub-devel/2009-08/msg00749.html

Signature · 2 lines
Felix Zielcke
Proud Debian Maintainer
#6 lore raw
In reply to Brian R. Jones
Quoted 5 lines · Brian R. Jones

Not sure if Felix's patch covers it, but there is also a problem with the 'sed' syntax in 10_freebsd and 30_os-prober. It turns out that freebsd 'sed' is quite retarded (at least in 7.2) and doesn't know that '\t' is supposed to be tab. Replacing 'sed' with 'gsed' or 'perl -p' fixes this issue.

Does putting a hard tab in the source file fix this? It's not pretty, but we could do that.

Signature · 1 line
Colin Watson                                       [[email protected]]
#7 lore raw
Quoted 6 lines · Colin Watson
Quoted 1 line · Brian R. Jones

Not sure if Felix's patch covers it, but there is also a problem with the 'sed' syntax in 10_freebsd and 30_os-prober. It turns out that freebsd 'sed' is quite retarded (at least in 7.2) and doesn't know that '\t' is supposed to be tab. Replacing 'sed' with 'gsed' or 'perl -p' fixes this issue.

Does putting a hard tab in the source file fix this? It's not pretty, but we could do that.

Yeah, hard tab works. But you're right, it's ugly.

Signature · 1 line
--Brian
#8 lore raw
In reply to Brian R. Jones
Quoted 5 lines · Brian R. Jones

Not sure if Felix's patch covers it, but there is also a problem with the 'sed' syntax in 10_freebsd and 30_os-prober. It turns out that freebsd 'sed' is quite retarded (at least in 7.2) and doesn't know that '\t' is supposed to be tab. Replacing 'sed' with 'gsed' or 'perl -p' fixes this issue.

Would you like to write a patch that makes autoconf check for a working option?

Signature · 5 lines
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."
#9 lore raw
Quoted 6 lines · Robert Millan
Quoted 1 line · Brian R. Jones

Not sure if Felix's patch covers it, but there is also a problem with the 'sed' syntax in 10_freebsd and 30_os-prober. It turns out that freebsd 'sed' is quite retarded (at least in 7.2) and doesn't know that '\t' is supposed to be tab. Replacing 'sed' with 'gsed' or 'perl -p' fixes this issue.

Would you like to write a patch that makes autoconf check for a working option?

I could give it a shot, as long as you accept that I don't have the slightest clue as to what I'm doing.

Signature · 1 line
--Brian