]> code.delx.au - refind/blobdiff - install.sh
Version 0.6.9 release
[refind] / install.sh
index e5fd60452a7c702de5c8b0933f9e5a011075a980..66d3e9ce8ccb7e3dde9e710fb3faf5aa9ff90748 100755 (executable)
 #
 # Revision history:
 #
+# 0.6.9   -- Install gptsync on Macs if evidence of Windows found
+# 0.6.8   -- Bug fix: ESP scan now uses "uniq".
+# 0.6.6   -- Bug fix: Upgrade drivers when installed to EFI/BOOT. Also enable
+#            copying shim.efi and MokManager.efi over themselves.
+# 0.6.4   -- Copies ext2 driver rather than ext4 driver for ext2/3fs
 # 0.6.3   -- Support for detecting rEFInd in EFI/BOOT and EFI/Microsoft/Boot
 #            directories & for installing to EFI/BOOT in BIOS mode
 # 0.6.2-1 -- Added --yes option & tweaked key-copying for use with RPM install script
@@ -182,12 +187,12 @@ CheckForFiles() {
 # Helper for CopyRefindFiles; copies shim files (including MokManager, if it's
 # available) to target.
 CopyShimFiles() {
-   cp $ShimSource $InstallDir/$TargetDir/$TargetShim
+   cp -fb $ShimSource $InstallDir/$TargetDir/$TargetShim
    if [[ $? != 0 ]] ; then
       Problems=1
    fi
    if [[ -f $MokManagerSource ]] ; then
-      cp $MokManagerSource $InstallDir/$TargetDir/
+      cp -fb $MokManagerSource $InstallDir/$TargetDir/
    fi
    if [[ $? != 0 ]] ; then
       Problems=1
@@ -219,7 +224,11 @@ CopyDrivers() {
       BootFS=`blkid -o export $BootPart 2> /dev/null | grep TYPE= | cut -f 2 -d =`
       DriverType=""
       case $BootFS in
-         ext2 | ext3 | ext4) DriverType="ext4"
+         ext2 | ext3) DriverType="ext2"
+              # Could use ext4, but that can create unwanted entries from symbolic
+              # links in / to /boot/vmlinuz if a separate /boot partition is used.
+              ;;
+         ext4) DriverType="ext4"
               ;;
          reiserfs) DriverType="reiserfs"
               ;;
@@ -236,6 +245,20 @@ CopyDrivers() {
    fi
 }
 
+# Copy tools (currently only gptsync, and that only on Macs) to the EFI/tools
+# directory on the ESP. Must be passed a suitable architecture code (ia32
+# or x64).
+CopyTools() {
+   mkdir -p $InstallDir/EFI/tools
+   if [[ $OSName == 'Darwin' ]] ; then
+      cp -f $RefindDir/tools_$1/gptsync_$1.efi $InstallDir/EFI/tools/
+      if [[ -f $InstallDir/EFI/tools/gptsync.efi ]] ; then
+         mv $InstallDir/EFI/tools/gptsync.efi $InstallDir/EFI/tools/gptsync.efi-disabled
+         echo "Found old gptsync.efi; disabling it by renaming it to gptsync.efi-disabled"
+      fi
+   fi
+} # CopyTools()
+
 # Copy the rEFInd files to the ESP or OS X root partition.
 # Sets Problems=1 if any critical commands fail.
 CopyRefindFiles() {
@@ -256,6 +279,14 @@ CopyRefindFiles() {
       if [[ $InstallDrivers == "all" ]] ; then
          cp -r $RefindDir/drivers_* $InstallDir/$TargetDir/ 2> /dev/null
          cp -r $ThisDir/drivers_* $InstallDir/$TargetDir/ 2> /dev/null
+      elif [[ $Upgrade == 1 ]] ; then
+         if [[ $Platform == 'EFI64' ]] ; then
+            CopyDrivers x64
+            CopyTools x64
+         else
+            CopyDrivers ia32
+            CopyTools ia32
+         fi
       fi
       Refind=""
       CopyKeys
@@ -265,6 +296,7 @@ CopyRefindFiles() {
          Problems=1
       fi
       CopyDrivers x64
+      CopyTools x64
       Refind="refind_x64.efi"
       CopyKeys
       if [[ $ShimSource != "none" ]] ; then
@@ -286,6 +318,7 @@ CopyRefindFiles() {
          Problems=1
       fi
       CopyDrivers ia32
+      CopyTools ia32
       Refind="refind_ia32.efi"
    else
       echo "Unknown platform! Aborting!"
@@ -581,7 +614,7 @@ FindLinuxESP() {
    fi
    InstallDir=`echo $EspLine | cut -d " " -f 6`
    if [[ -n $InstallDir ]] ; then
-      EspFilesystem=`grep $InstallDir /etc/mtab | cut -d " " -f 3`
+      EspFilesystem=`grep $InstallDir /etc/mtab | uniq | cut -d " " -f 3`
    fi
    if [[ $EspFilesystem != 'vfat' ]] ; then
       echo "$RootDir/boot/efi doesn't seem to be on a VFAT filesystem. The ESP must be"