From d621a172f5c2ce0a0aea09c1bd9041c1c2e9787d Mon Sep 17 00:00:00 2001 From: srs5694 Date: Sat, 5 May 2012 00:19:24 -0400 Subject: [PATCH] Small refinements to install.sh script --- BUILDING.txt | 8 ++++++++ NEWS.txt | 3 +++ install.sh | 34 +++++++++++++++++++++++++++++----- 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/BUILDING.txt b/BUILDING.txt index 3dcad8d..a3d2dc8 100644 --- a/BUILDING.txt +++ b/BUILDING.txt @@ -129,3 +129,11 @@ want to copy files on the ESP as follows: You'll then need to activate rEFInd in your EFI. This can be done with tools such as "efibootmgr" under Linux or "bless" under OS X. See the docs/installing.html file for details. + +You may have noticed an install.sh script in the source package. This +script is intended for distribution with my own binary packages of rEFInd, +and it copies files from the "refind" subdirectory (relative to the +script's location) -- namely refind_x64.efi or refind_ia32.efi, +refind.conf-sample, and an icons subdirectory. You can rearrange your files +to provide this layout, but it's no more work to copy the files as just +described. diff --git a/NEWS.txt b/NEWS.txt index 204c1cd..dd04016 100644 --- a/NEWS.txt +++ b/NEWS.txt @@ -1,3 +1,6 @@ +0.3.3 (?/?/2012): +----------------- + 0.3.2 (5/4/2012): ----------------- diff --git a/install.sh b/install.sh index 1037bea..479cef7 100755 --- a/install.sh +++ b/install.sh @@ -17,7 +17,8 @@ # # Revision history: # -# 0.3.2 -- Initial version +# 0.3.2.1 -- Check for presence of source files; aborts if not present +# 0.3.2 -- Initial version # # Note: install.sh version numbers match those of the rEFInd package # with which they first appeared. @@ -28,6 +29,16 @@ TargetDir=/EFI/refind # Functions used by both OS X and Linux.... # +# Abort if the rEFInd files can't be found. +CheckForFiles() { + if [[ ! -f $SourceDir/refind_ia32.efi || ! -f $SourceDir/refind_x64.efi || ! -f $SourceDir/refind.conf-sample || ! -d $SourceDir/icons ]] ; then + echo "One or more files missing! Aborting installation!" + exit 1 + fi +} # 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 @@ -105,6 +116,8 @@ MountOSXESP() { fi } # MountOSXESP() +# Control the OS X installation. +# Sets Problems=1 if problems found during the installation. InstallOnOSX() { echo "Installing rEFInd on OS X...." if [[ $1 == 'esp' || $1 == 'ESP' ]] ; then @@ -135,6 +148,9 @@ InstallOnOSX() { # Now a series of Linux support functions.... # +# 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. FindLinuxESP() { EspLine=`df /boot/efi | grep boot` InstallPart=`echo $EspLine | cut -d " " -f 6` @@ -147,6 +163,8 @@ FindLinuxESP() { echo "ESP was found at $InstallPart using $EspFilesystem" } # MountLinuxESP +# Uses efibootmgr to add an entry for rEFInd to the EFI's NVRAM. +# If this fails, sets Problems=1 AddBootEntry() { Efibootmgr=`which efibootmgr 2> /dev/null` if [[ $Efibootmgr ]] ; then @@ -182,6 +200,8 @@ AddBootEntry() { fi } # AddBootEntry() +# Controls rEFInd installation under Linux. +# Sets Problems=1 if something goes wrong. InstallOnLinux() { echo "Installing rEFInd on Linux...." FindLinuxESP @@ -213,10 +233,16 @@ InstallOnLinux() { AddBootEntry } # InstallOnLinux() -# The main part of the script; just checks the OS and calls a -# function for installing on that platform.... +# +# The main part of the script. Sets a few environment variables, +# performs a few startup checks, and then calls functions to +# install under OS X or Linux, depending on the detected platform. +# ThisScript=`readlink -f $0` +OSName=`uname -s` +SourceDir=`dirname $ThisScript`/refind +CheckForFiles if [[ `whoami` != "root" ]] ; then echo "Not running as root; attempting to elevate privileges via sudo...." sudo $ThisScript $1 @@ -227,8 +253,6 @@ if [[ `whoami` != "root" ]] ; then exit 0 fi fi -OSName=`uname -s` -SourceDir=`dirname $ThisScript`/refind if [[ $OSName == 'Darwin' ]] ; then InstallOnOSX $1 elif [[ $OSName == 'Linux' ]] ; then -- 2.39.2