]> code.delx.au - refind/commitdiff
Modified install.sh script to include "--usedefault" and "--drivers"
authorsrs5694 <srs5694@users.sourceforge.net>
Fri, 9 Nov 2012 01:31:10 +0000 (20:31 -0500)
committersrs5694 <srs5694@users.sourceforge.net>
Fri, 9 Nov 2012 01:31:10 +0000 (20:31 -0500)
options, and to change the "esp" option to "--esp"

Make.tiano
NEWS.txt
docs/refind/getting.html
docs/refind/installing.html
docs/refind/todo.html
filesystems/Make.tiano
install.sh
mkdistrib

index 04a3eb7b89a0fbf071034eaa582fd4b4f0588f4c..03f189ec52c4f428fde4998dcea6b01d39e66260 100644 (file)
@@ -31,7 +31,7 @@ endif
 
 EDK2BASE = /usr/local/UDK2010/MyWorkSpace
 
-# Below file defines TARGET (RELEASE or DEBUG), TARGET_ARCH (X64 or IA32), and TOOL_CHAIN_TAG (GCC44, GCC45, GCC46, or GCC47)
+# Below file defines TARGET (RELEASE or DEBUG) and TOOL_CHAIN_TAG (GCC44, GCC45, GCC46, or GCC47)
 include $(EDK2BASE)/Conf/target.txt
 
 INCLUDE_DIRS    = -I $(EDK2BASE)/MdePkg \
index 2c6a92c95cb11d4a03375b94ea8bc23316431ea4..b9b1b5606b6435566d253afc99f5c79e845e010b 100644 (file)
--- a/NEWS.txt
+++ b/NEWS.txt
@@ -1,3 +1,9 @@
+0.4.8 (??/??/2012):
+-------------------
+
+- Added "--usedefault {devicename}" and "--drivers" options to the
+  install.sh script and changed the "esp" option to "--esp". 
+
 0.4.7 (11/6/2012):
 ------------------
 
index af4a5afc4d7d3ab570912e04d525964d2340e31a..d5d5ad487db6efa54e3e42504be010e1ce11c5fd 100644 (file)
@@ -131,6 +131,8 @@ href="mailto:rodsmith@rodsbooks.com">rodsmith@rodsbooks.com</a></p>
     either build.)</li>
 -->
 
+<p class="sidebar"><b>Tip:</b> If you want a bootable USB flash drive, download the binary zip file or CD-R image file, prepare a USB flash drive with a FAT32 ESP, and then use the <tt>install.sh</tt> program's <tt>--usedefault</tt> option, as in <tt class="userinput">bash install.sh --usedefault /dev/sdd1</tt> to install to the first partition on <tt>/dev/sdd</tt>. This procedure should work even on a BIOS-booted computer.</p>
+
 <li><b><a
     href="http://sourceforge.net/projects/refind/files/0.4.7/refind-cd-0.4.7.zip/download">A
     CD-R image file</a></b>&mdash;This download contains the same files as
index f8989974d67bb38cda98b17a87178bd1f0270267..57dcf0b0210e867940970eb09591a3c53261ef3b 100644 (file)
@@ -159,7 +159,7 @@ Installation has completed successfully.</pre>
     the Terminal window. You'll need to press the Return or Enter key to
     run the script.</li>
 
-<li>Under OS X, passing the "esp" option causes the script to install
+<li>Under OS X, passing the "--esp" option causes the script to install
     rEFInd to the ESP. The script finds the first ESP that's identified by
     the <tt>diskutil</tt> program and, if it's not already mounted, mounts
     it to install rEFInd. Thus, it's conceivable that <tt>install.sh</tt>
@@ -168,7 +168,7 @@ Installation has completed successfully.</pre>
     may need to re-install manually.</li>
 
 <li>If you're using OS X 10.7's Whole Disk Encryption (WDE) feature, you
-    <i>must</i> install rEFInd to the ESP, so the <tt>esp</tt> option to
+    <i>must</i> install rEFInd to the ESP, so the <tt>--esp</tt> option to
     <tt>install.sh</tt> is required. I'm still a little bit foggy about
     what's required to boot the system once this is done; see <a
     href="https://sourceforge.net/p/refind/discussion/general/thread/5c7d0195/">this
@@ -198,6 +198,25 @@ Installation has completed successfully.</pre>
     script's output. (Note that rEFInd can only boot such OSes on Macs at
     the moment.)</li>
 
+<li>Under both Linux and OS X, you can add the <tt>--drivers</tt> option to
+    have <tt>install.sh</tt> install all the filesystem drivers along with
+    the main rEFInd program. (The default is to <i>not</i> install any
+    drivers.)</li>
+
+<li>Under both Linux and OS X, you can add the <tt>--usedefault <tt
+    class="variable">devicepath</tt></tt> option to install rEFInd to the
+    specified device as <tt>EFI/BOOT/bootx64.efi</tt> and
+    <tt>EFI/BOOT/bootia32.efi</tt>. The specified device must be a valid
+    FAT partition. The idea is that you can easily create a bootable USB
+    flash drive with this option: Create a proper FAT-formatted ESP on a
+    disk (say, <tt>/dev/sdd1</tt>) and then type <tt class="userinput">sh
+    ./install --usedefault /dev/sdd1</tt> to turn the disk into an
+    emergency disk. This option can also be used to install rEFInd to an
+    ESP using the <a href="#naming">alternative naming options</a>
+    described later. This latter usage will result in a bootable rEFInd
+    only if no other OS has already created an NVRAM variable pointing to
+    itself.</li>
+
 </ul>
 
 <p>In any event, you should peruse the script's output to ensure that everything looks OK. <tt>install.sh</tt> displays error messages when it encounters errors, such as if the ESP is mounted read-only or if you run out of disk space. You may need to correct such problems manually and re-run the script. In some cases you may need to fall back on manual installation, which gives you better control over details such as which partition to use for installation.</p>
index 7d398be4a1b58ea5450523eb15e5210fb930066e..5919dbc63f9171c187a57e665d4946d52f072c6b 100644 (file)
@@ -328,9 +328,6 @@ href="mailto:rodsmith@rodsbooks.com">rodsmith@rodsbooks.com</a></p>
        href="http://www.rodsbooks.com/bios2uefi/">DUET</a>). Nonetheless,
        I'd like to track down the cause and fix it.</li>
 
-    <li>The driver installation procedure could be improved, perhaps by
-        adding support for drivers to the <tt>install.sh</tt> script.</li>
-
     <li>The HFS+ driver returns a volume label of "HFS+ volume", no matter
         what the volume's real label is.</li>
 
index 960a651bdf9e4a3f8d4a9c08e8fd3a5b8cf3d1b2..35e487a7ee0d4f7c74c8df9d8ad2866d0bf168ba 100644 (file)
@@ -32,7 +32,7 @@ endif
 EDK2BASE = /usr/local/UDK2010/MyWorkSpace
 #EDK2BASE = /usr/local/edk2
 
-# Below file defines TARGET (RELEASE or DEBUG), TARGET_ARCH (X64 or IA32), and TOOL_CHAIN_TAG (GCC44, GCC45, or GCC46)
+# Below file defines TARGET (RELEASE or DEBUG) and TOOL_CHAIN_TAG (GCC44, GCC45, or GCC46)
 include $(EDK2BASE)/Conf/target.txt
 
 EFILIB          = $(EDK2BASE)/Build/Mde/$(TARGET)_$(TOOL_CHAIN_TAG)/$(UC_ARCH)/MdePkg/Library
index d77b8b0af0f73c152488d3b008dbac39c7c459a6..4e32b90a203f19693e102d44c7965d569eea0ae8 100755 (executable)
@@ -17,6 +17,7 @@
 #
 # Revision history:
 #
+# 0.4.8   -- Added --usedefault & --drivers options & changed "esp" option to "--esp"
 # 0.4.5   -- Fixed check for rEFItBlesser in OS X
 # 0.4.2   -- Added notice about BIOS-based OSes & made NVRAM changes in Linux smarter
 # 0.4.1   -- Added check for rEFItBlesser in OS X
@@ -33,6 +34,32 @@ TargetDir=/EFI/refind
 # Functions used by both OS X and Linux....
 #
 
+GetParams() {
+   InstallToEspOnMac=0
+   InstallDrivers=0
+   while [[ $# -gt 0 ]]; do
+      case $1 in
+         --esp | --ESP) InstallToEspOnMac=1
+              ;;
+         --usedefault) TargetDir=/EFI/BOOT
+              TargetPart=$2
+              shift
+              ;;
+         --drivers) InstallDrivers=1
+              ;;
+         * ) echo "Usage: $0 [--esp | --usedefault {device-file}] [--drivers]"
+             echo "Aborting!"
+             exit 1
+      esac
+      shift
+   done
+   if [[ $InstallToEspOnMac == 1 && $TargetDir == '/EFI/BOOT' ]] ; then
+      echo "You may use --esp OR --usedefault, but not both! Aborting!"
+      exit 1
+   fi
+#   exit 1
+} # GetParams()
+
 # Abort if the rEFInd files can't be found.
 # Also sets $ConfFile to point to the configuration file, and
 # $IconsDir to point to the icons directory
@@ -67,18 +94,39 @@ CheckForFiles() {
 # Copy the rEFInd files to the ESP or OS X root partition.
 # Sets Problems=1 if any critical commands fail.
 CopyRefindFiles() {
-   mkdir -p $InstallPart/$TargetDir &> /dev/null
-   if [[ $Platform == 'EFI32' ]] ; then
-      cp $RefindDir/refind_ia32.efi $InstallPart/$TargetDir
+   mkdir -p $InstallDir/$TargetDir &> /dev/null
+   if [[ $TargetDir == '/EFI/BOOT' ]] ; then
+      cp $RefindDir/refind_ia32.efi $InstallDir/$TargetDir/bootia32.efi 2> /dev/null
+      if [[ $? != 0 ]] ; then
+         echo "Note: IA32 (x86) binary not installed!"
+      fi
+      cp $RefindDir/refind_x64.efi $InstallDir/$TargetDir/bootx64.efi 2> /dev/null
       if [[ $? != 0 ]] ; then
          Problems=1
       fi
+      if [[ $InstallDrivers == 1 ]] ; then
+         cp -r $RefindDir/drivers_* $InstallDir/$TargetDir/
+      fi
+      Refind=""
+   elif [[ $Platform == 'EFI32' ]] ; then
+      cp $RefindDir/refind_ia32.efi $InstallDir/$TargetDir
+      if [[ $? != 0 ]] ; then
+         Problems=1
+      fi
+      if [[ $InstallDrivers == 1 ]] ; then
+         mkdir -p $InstallDir/$TargetDir/drivers_ia32
+         cp -r $RefindDir/drivers_ia32/*_ia32.efi $InstallDir/$TargetDir/drivers_ia32/
+      fi
       Refind="refind_ia32.efi"
    elif [[ $Platform == 'EFI64' ]] ; then
-      cp $RefindDir/refind_x64.efi $InstallPart/$TargetDir
+      cp $RefindDir/refind_x64.efi $InstallDir/$TargetDir
       if [[ $? != 0 ]] ; then
          Problems=1
       fi
+      if [[ $InstallDrivers == 1 ]] ; then
+         mkdir -p $InstallDir/$TargetDir/drivers_x64
+         cp -r $RefindDir/drivers_x64/*_x64.efi $InstallDir/$TargetDir/drivers_x64/
+      fi
       Refind="refind_x64.efi"
    else
       echo "Unknown platform! Aborting!"
@@ -86,20 +134,20 @@ CopyRefindFiles() {
    fi
    echo "Copied rEFInd binary file $Refind"
    echo ""
-   if [[ -d $InstallPart/$TargetDir/icons ]] ; then
-      rm -rf $InstallPart/$TargetDir/icons-backup &> /dev/null
-      mv -f $InstallPart/$TargetDir/icons $InstallPart/$TargetDir/icons-backup
+   if [[ -d $InstallDir/$TargetDir/icons ]] ; then
+      rm -rf $InstallDir/$TargetDir/icons-backup &> /dev/null
+      mv -f $InstallDir/$TargetDir/icons $InstallDir/$TargetDir/icons-backup
       echo "Notice: Backed up existing icons directory as icons-backup."
    fi
-   cp -r $IconsDir $InstallPart/$TargetDir
+   cp -r $IconsDir $InstallDir/$TargetDir
    if [[ $? != 0 ]] ; then
       Problems=1
    fi
-   if [[ -f $InstallPart/$TargetDir/refind.conf ]] ; then
+   if [[ -f $InstallDir/$TargetDir/refind.conf ]] ; then
       echo "Existing refind.conf file found; copying sample file as refind.conf-sample"
       echo "to avoid collision."
       echo ""
-      cp -f $ConfFile $InstallPart/$TargetDir
+      cp -f $ConfFile $InstallDir/$TargetDir
       if [[ $? != 0 ]] ; then
          Problems=1
       fi
@@ -107,13 +155,29 @@ CopyRefindFiles() {
       echo "Copying sample configuration file as refind.conf; edit this file to configure"
       echo "rEFInd."
       echo ""
-      cp -f $ConfFile $InstallPart/$TargetDir/refind.conf
+      cp -f $ConfFile $InstallDir/$TargetDir/refind.conf
       if [[ $? != 0 ]] ; then
          Problems=1
       fi
    fi
 } # CopyRefindFiles()
 
+# Mount the partition the user specified with the --usedefault option
+MountDefaultTarget() {
+   InstallDir=/tmp/refind_install
+   mkdir -p $InstallDir
+   if [[ $OSName == 'Darwin' ]] ; then
+      mount -t msdos $TargetPart $InstallDir
+   elif [[ $OSName == 'Linux' ]] ; then
+      mount -t vfat $TargetPart $InstallDir
+   fi
+   if [[ $? != 0 ]] ; then
+      echo "Couldn't mount $TargetPart ! Aborting!"
+      rmdir $InstallDir
+      exit 1
+   fi
+   UnmountEsp=1
+} # MountDefaultTarget()
 
 #
 # A series of OS X support functions....
@@ -121,7 +185,7 @@ CopyRefindFiles() {
 
 # Mount the ESP at /Volumes/ESP or determine its current mount
 # point.
-# Sets InstallPart to the ESP mount point
+# Sets InstallDir to the ESP mount point
 # Sets UnmountEsp if we mounted it
 MountOSXESP() {
    # Identify the ESP. Note: This returns the FIRST ESP found;
@@ -130,8 +194,8 @@ MountOSXESP() {
    Esp=/dev/`echo $Temp | cut -f 5 -d ' '`
    # If the ESP is mounted, use its current mount point....
    Temp=`df | grep $Esp`
-   InstallPart=`echo $Temp | cut -f 6 -d ' '`
-   if [[ $InstallPart == '' ]] ; then
+   InstallDir=`echo $Temp | cut -f 6 -d ' '`
+   if [[ $InstallDir == '' ]] ; then
       mkdir /Volumes/ESP &> /dev/null
       mount -t msdos $Esp /Volumes/ESP
       if [[ $? != 0 ]] ; then
@@ -139,7 +203,7 @@ MountOSXESP() {
          exit 1
       fi
       UnmountEsp=1
-      InstallPart="/Volumes/ESP"
+      InstallDir="/Volumes/ESP"
    fi
 } # MountOSXESP()
 
@@ -147,18 +211,20 @@ MountOSXESP() {
 # Sets Problems=1 if problems found during the installation.
 InstallOnOSX() {
    echo "Installing rEFInd on OS X...."
-   if [[ $1 == 'esp' || $1 == 'ESP' ]] ; then
+   if [[ $TargetDir == "/EFI/BOOT" ]] ; then
+      MountDefaultTarget
+   elif [[ $InstallToEspOnMac == "1" ]] ; then
       MountOSXESP
    else
-      InstallPart="/"
+      InstallDir="/"
    fi
-   echo "Installing rEFInd to the partition mounted at '$InstallPart'"
+   echo "Installing rEFInd to the partition mounted at '$InstallDir'"
    Platform=`ioreg -l -p IODeviceTree | grep firmware-abi | cut -d "\"" -f 4`
    CopyRefindFiles
-   if [[ $1 == 'esp' || $1 == 'ESP' ]] ; then
-      bless --mount $InstallPart --setBoot --file $InstallPart/$TargetDir/$Refind
-   else
-      bless --setBoot --folder $InstallPart/$TargetDir --file $InstallPart/$TargetDir/$Refind
+   if [[ $InstallToEspOnMac == "1" ]] ; then
+      bless --mount $InstallDir --setBoot --file $InstallDir/$TargetDir/$Refind
+   elif [[ $TargetDir != "/EFI/BOOT" ]] ; then
+      bless --setBoot --folder $InstallDir/$TargetDir --file $InstallDir/$TargetDir/$Refind
    fi
    if [[ $? != 0 ]] ; then
       Problems=1
@@ -181,11 +247,6 @@ InstallOnOSX() {
    echo "bless status with 'bless --info', since this is known to cause disk corruption"
    echo "on some systems!!"
    echo
-   echo "NOTE: If you want to boot an OS via BIOS emulation (such as Windows or some"
-   echo "Linux installations), you *MUST* edit the $InstallPart/$TargetDir/refind.conf"
-   echo "file's 'scanfor' line to include the 'hdbios' option, and perhaps"
-   echo "'biosexternal' and 'cd', as well."
-   echo
 } # InstallOnOSX()
 
 
@@ -195,17 +256,17 @@ InstallOnOSX() {
 
 # Identifies the ESP's location (/boot or /boot/efi); aborts if
 # the ESP isn't mounted at either location.
-# Sets InstallPart to the ESP mount point.
+# Sets InstallDir to the ESP mount point.
 FindLinuxESP() {
    EspLine=`df /boot/efi | grep boot`
-   InstallPart=`echo $EspLine | cut -d " " -f 6`
-   EspFilesystem=`grep $InstallPart /etc/mtab | cut -d " " -f 3`
+   InstallDir=`echo $EspLine | cut -d " " -f 6`
+   EspFilesystem=`grep $InstallDir /etc/mtab | cut -d " " -f 3`
    if [[ $EspFilesystem != 'vfat' ]] ; then
       echo "/boot/efi doesn't seem to be on a VFAT filesystem. The ESP must be mounted at"
       echo "/boot or /boot/efi and it must be VFAT! Aborting!"
       exit 1
    fi
-   echo "ESP was found at $InstallPart using $EspFilesystem"
+   echo "ESP was found at $InstallDir using $EspFilesystem"
 } # MountLinuxESP
 
 # Uses efibootmgr to add an entry for rEFInd to the EFI's NVRAM.
@@ -215,8 +276,8 @@ AddBootEntry() {
    Efibootmgr=`which efibootmgr 2> /dev/null`
    if [[ $Efibootmgr ]] ; then
       modprobe efivars &> /dev/null
-      InstallDisk=`grep $InstallPart /etc/mtab | cut -d " " -f 1 | cut -c 1-8`
-      PartNum=`grep $InstallPart /etc/mtab | cut -d " " -f 1 | cut -c 9-10`
+      InstallDisk=`grep $InstallDir /etc/mtab | cut -d " " -f 1 | cut -c 1-8`
+      PartNum=`grep $InstallDir /etc/mtab | cut -d " " -f 1 | cut -c 9-10`
       EntryFilename=$TargetDir/$Refind
       EfiEntryFilename=`echo ${EntryFilename//\//\\\}`
       EfiEntryFilename2=`echo ${EfiEntryFilename} | sed s/\\\\\\\\/\\\\\\\\\\\\\\\\/g`
@@ -260,7 +321,11 @@ AddBootEntry() {
 # Sets Problems=1 if something goes wrong.
 InstallOnLinux() {
    echo "Installing rEFInd on Linux...."
-   FindLinuxESP
+   if [[ $TargetDir == "/EFI/BOOT" ]] ; then
+      MountDefaultTarget
+   else
+      FindLinuxESP
+   fi
    CpuType=`uname -m`
    if [[ $CpuType == 'x86_64' ]] ; then
       Platform="EFI64"
@@ -286,7 +351,9 @@ InstallOnLinux() {
       exit 1
    fi
    CopyRefindFiles
-   AddBootEntry
+   if [[ $TargetDir != "/EFI/BOOT" ]] ; then
+      AddBootEntry
+   fi
 } # InstallOnLinux()
 
 #
@@ -295,6 +362,7 @@ InstallOnLinux() {
 # install under OS X or Linux, depending on the detected platform.
 #
 
+GetParams $@
 OSName=`uname -s`
 ThisDir="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
 RefindDir="$ThisDir/refind"
@@ -302,7 +370,7 @@ ThisScript="$ThisDir/`basename $0`"
 CheckForFiles
 if [[ `whoami` != "root" ]] ; then
    echo "Not running as root; attempting to elevate privileges via sudo...."
-   sudo $ThisScript $1
+   sudo $ThisScript $1 $2 $3
    if [[ $? != 0 ]] ; then
       echo "This script must be run as root (or using sudo). Exiting!"
       exit 1
@@ -332,5 +400,11 @@ else
 fi
 
 if [[ $UnmountEsp ]] ; then
-   umount $InstallPart
+   echo "Unmounting install dir"
+   umount $InstallDir
+fi
+
+if [[ $InstallDir == /tmp/refind_install ]] ; then
+#   sleep 5
+   rmdir $InstallDir
 fi
index bc24003b9e3f76eef828cfc77985bb5aecd84f3b..b1701eca9f59a9783806842cadd69947d35d55ee 100755 (executable)
--- a/mkdistrib
+++ b/mkdistrib
@@ -2,11 +2,13 @@
 #
 # Script to prepare source code and binary distribution files of rEFInd.
 # By Rod Smith, 3/11/2012
+# Updated 11/8/2012 to do more things automatically
 #
 # Usage: ./mkdistrib version
 # where "version" is a version number
-# MUST be run from an x86-64 system, on which the current IA32 build
-# (refind_ia32.efi) is already present in the same directory as this script
+# MUST be run from an x86-64 system, on which the TianoCore build
+# includes both X64 and IA32 build support ("TARGET_ARCH = IA32 X64"
+# in Conf/target.txt).
 
 
 StartDir=`pwd`
@@ -22,21 +24,30 @@ cp -a docs images include EfiLib libeg refind filesystems install.sh CREDITS.txt
 cd ../snapshots/$1/
 zip -9r refind-src-$1.zip refind-$1
 
-# Build the source code into binaries
+# Build the IA32 binaries
 cd refind-$1
+ARCH=ia32 make
+ARCH=ia32 make fs
+mkdir -p refind-bin-$1/refind/drivers_ia32
+cp --preserve=timestamps drivers/*_ia32.efi refind-bin-$1/refind/drivers_ia32/
+cp --preserve=timestamps filesystems/LICENSE*txt refind-bin-$1/refind/drivers_ia32/
+cp refind/refind_ia32.efi refind-bin-$1/refind/refind_ia32.efi
+cp refind/refind_ia32.efi $StartDir/
+
+# Build the X64 binaries
+make clean
 make
 make fs
 mkdir -p refind-bin-$1/refind/drivers_x64
-mkdir -p refind-bin-$1/refind/drivers_ia32
 cp -a icons refind-bin-$1/refind/
 cp --preserve=timestamps drivers/*_x64.efi refind-bin-$1/refind/drivers_x64/
 cp --preserve=timestamps filesystems/LICENSE*txt refind-bin-$1/refind/drivers_x64/
-cp --preserve=timestamps filesystems/LICENSE*txt refind-bin-$1/refind/drivers_ia32/
 cp --preserve=timestamps refind.conf-sample refind-bin-$1/refind/
 cp refind/refind_x64.efi refind-bin-$1/refind/refind_x64.efi
-cp $StartDir/refind_ia32.efi refind-bin-$1/refind/
-cp $StartDir/drivers/*_ia32.efi refind-bin-$1/refind/drivers_ia32/
+cp refind/refind_x64.efi $StartDir
 cp -a COPYING.txt LICENSE.txt README.txt docs CREDITS.txt install.sh refind-bin-$1
+
+# Prepare the final .zip file and clean up
 zip -9r ../refind-bin-$1.zip refind-bin-$1
 cd ..
 rm -r refind-$1