grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] update-grub for Cygwin


From: Christian Franke
Subject: [PATCH] update-grub for Cygwin
Date: Thu, 24 Jul 2008 22:19:17 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) Gecko/20071128 SeaMonkey/1.1.7

This patch allows to run update-grub on Cygwin.

Christian

2008-07-24  Christian Franke  <address@hidden>

        * util/update-grub.in: Add a check for admin
        group for Cygwin.
        Add `-f' to `rm' and `mv' of grub.cfg to handle
        the different filesystem semantics on Windows.


diff --git a/util/update-grub.in b/util/update-grub.in
index c78444e..70607a5 100644
--- a/util/update-grub.in
+++ b/util/update-grub.in
@@ -73,8 +73,20 @@ if [ "x$EUID" = "x" ] ; then
 fi
 
 if [ "$EUID" != 0 ] ; then
-  echo "$0: You must run this as root" >&2
-  exit 1
+  root=f
+  case "`uname 2>/dev/null`" in
+    CYGWIN*)
+      # Cygwin: Assume root if member of admin group
+      for g in `id -G 2>/dev/null` ; do
+       case $g in
+         0|544) root=t ;;
+       esac
+      done ;;
+  esac
+  if [ $root != t ] ; then
+    echo "$0: You must run this as root" >&2
+    exit 1
+  fi
 fi
 
 set $grub_mkdevicemap dummy
@@ -154,6 +166,7 @@ export GRUB_DEVICE GRUB_DEVICE_UUID GRUB_DEVICE_BOOT 
GRUB_DEVICE_BOOT_UUID GRUB_
 # These are optional, user-defined variables.
 export GRUB_DEFAULT GRUB_TIMEOUT GRUB_DISTRIBUTOR GRUB_CMDLINE_LINUX 
GRUB_CMDLINE_LINUX_DEFAULT GRUB_TERMINAL GRUB_SERIAL_COMMAND 
GRUB_DISABLE_LINUX_UUID
 
+rm -f ${grub_cfg}.new
 exec > ${grub_cfg}.new
 
 # Allow this to fail, since /boot/grub/ might need to be fatfs to support some
@@ -187,6 +200,6 @@ for i in ${update_grub_dir}/* ; do
 done
 
 # none of the children aborted with error, install the new grub.cfg
-mv ${grub_cfg}.new ${grub_cfg}
+mv -f ${grub_cfg}.new ${grub_cfg}
 
 echo "done" >&2

reply via email to

[Prev in Thread] Current Thread [Next in Thread]