update bootstrap.sh script (#753)

* update bootstrap.sh script

+ macOS users using MacPorts are now supported (fix issue #720);
+ dependencies for macOS users using brew have been updated;
+ the boot step can now be skipped with the '-d' flag, effectively only installing dependencies

* update summary build instructions in README dependencies step

as these are meant as quick instructions, it's probably better to simply use the bootstrap.sh script available in the repo root folder, using the '-d' flag to just install the dependencies, using whatever package manager is available for the host system, rather than forcing the user to manually install those one by one
This commit is contained in:
Glen De Cauwsemaecker 2016-11-08 19:48:10 -05:00 committed by Jeremy Soller
parent 4e314292f8
commit a8319379c6
2 changed files with 126 additions and 54 deletions

View file

@ -127,14 +127,7 @@ $ git clone git@github.com:redox-os/redox.git --origin upstream --recursive
$ cd redox/ $ cd redox/
# Install/update dependencies # Install/update dependencies
# Linux Users: $ bash bootstrap.sh -d
$ sudo <your package manager> install make nasm qemu libfuse-dev
# MacOS Users using MacPorts:
$ sudo port install make nasm qemu gcc49 pkg-config osxfuse x86_64-elf-gcc
# MacOS Users using Hombrew:
$ brew install make nasm qemu gcc49 pkg-config Caskroom/cask/osxfuse
$ brew tap glendc/gcc_cross_compilers
$ brew install glendc/gcc_cross_compilers/x64-elf-binutils glendc/gcc_cross_compilers/x64-elf-gcc
# Install rustup.rs # Install rustup.rs
$ curl https://sh.rustup.rs -sSf | sh $ curl https://sh.rustup.rs -sSf | sh

View file

@ -10,54 +10,127 @@ banner()
echo "|------------------------------------------|" echo "|------------------------------------------|"
} }
###################################################################################
# This function takes care of installing a dependency via package manager of choice
# for building redox on MacOS.
# @params: $1 package manager
# $2 package name
# $3 binary name (optional)
###################################################################################
install_macos_pkg()
{
PKG_MANAGER=$1
PKG_NAME=$2
BIN_NAME=$3
if [ -z "$BIN_NAME" ]; then
BIN_NAME=$PKG_NAME
fi
BIN_LOCATION=$(which $BIN_NAME)
if [ -z "$BIN_LOCATION" ]; then
echo "$PKG_MANAGER install $PKG_NAME"
$PKG_MANAGER install "$PKG_NAME"
else
echo "$BIN_NAME already exists at $BIN_LOCATION, no need to install $PKG_NAME..."
fi
}
install_macports_pkg()
{
install_macos_pkg "sudo port" "$1" "$2"
}
install_brew_pkg()
{
install_macos_pkg "brew" $@
}
install_brew_cask_pkg()
{
install_macos_pkg "brew cask" $@
}
############################################################################### ###############################################################################
# This function takes care of installing all dependencies for building redox on # This function checks which of the supported package managers
# Mac OSX # is available on the OSX Host.
# @params: $1 the emulator to install, virtualbox or qemu # If a support package manager is found, it delegates the installing work to
# the relevant function.
# Otherwise this function will exit this script with an error.
############################################################################### ###############################################################################
osx() osx()
{ {
echo "Detected OSX!" echo "Detected OSX!"
if [ ! -z "$(which brew)" ]; then
echo "Homebrew detected! Now updating..." if [ ! -z "$(which brew)" ]; then
brew update osx_homebrew $@
if [ -z "$(which git)" ]; then elif [ ! -z "$(which port)" ]; then
echo "Now installing git..." osx_macports $@
brew install git else
fi echo "Please install either Hombrew or MacPorts, if you wish to use this script"
if [ "$1" == "qemu" ]; then echo "Re-run this script once you installed one of those package managers"
if [ -z "$(which qemu-system-i386)" ]; then echo "Will not install, now exiting..."
echo "Installing qemu..." exit 1
brew install qemu fi
else }
echo "QEMU already installed!"
fi ###############################################################################
else # This function takes care of installing all dependencies using MacPorts
if [ -z "$(which virtualbox)" ]; then # for building redox on Mac OSX
echo "Now installing virtualbox..." # @params: $1 the emulator to install, virtualbox or qemu
brew cask install virtualbox ###############################################################################
else osx_macports()
echo "Virtualbox already installed!" {
fi echo "Macports detected! Now updating..."
fi sudo port -v selfupdate
else
echo "Homebrew does not appear to be installed! Would you like me to install it?" echo "Installing missing packages..."
echo "*WARNING* this install involves a curl | sh style command"
printf "(Y/n): " install_macports_pkg "git"
read -r installit
if [ "$installit" == "Y" ]; then if [ "$1" == "qemu" ]; then
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" install_macports_pkg "qemu" "qemu-system-x86_64"
else else
echo "Will not install, now exiting..." install_macports_pkg "virtualbox"
exit fi
fi
fi install_macports_pkg "gcc49" "gcc-4.9"
echo "Running Redox setup script..." install_macports_pkg "nasm"
brew tap homebrew/versions install_macports_pkg "pkg-config"
brew install gcc49 install_macports_pkg "osxfuse"
brew tap nashenas88/gcc_cross_compilers install_macports_pkg "x86_64-elf-gcc"
brew install nashenas88/gcc_cross_compilers/i386-elf-binutils nashenas88/gcc_cross_compilers/i386-elf-gcc nasm pkg-config }
brew install Caskroom/cask/osxfuse
###############################################################################
# This function takes care of installing all dependencies using Hombrew
# for building redox on Mac OSX
# @params: $1 the emulator to install, virtualbox or qemu
###############################################################################
osx_homebrew()
{
echo "Homebrew detected! Now updating..."
brew update
echo "Tapping required taps..."
brew tap homebrew/versions
brew tap glendc/gcc_cross_compilers
echo "Installing missing packages..."
install_brew_pkg "git"
if [ "$1" == "qemu" ]; then
install_brew_pkg "qemu" "qemu-system-x86_64"
else
install_brew_pkg "virtualbox"
fi
install_brew_pkg "gcc49" "gcc-4.9"
install_brew_pkg "nasm"
install_brew_pkg "pkg-config"
install_brew_cask_pkg "osxfuse"
install_brew_pkg "glendc/gcc_cross_compilers/x64-elf-binutils" "x86_64-elf-gcc"
install_brew_pkg "glendc/gcc_cross_compilers/x64-elf-gcc" "x86_64-elf-gcc"
} }
############################################################################### ###############################################################################
@ -269,6 +342,7 @@ usage()
echo " -e [emulator] Install specific emulator, virtualbox or qemu" echo " -e [emulator] Install specific emulator, virtualbox or qemu"
echo " -p [package Choose an Ubuntu package manager, apt-fast or" echo " -p [package Choose an Ubuntu package manager, apt-fast or"
echo " manager] aptitude" echo " manager] aptitude"
echo " -d Only install the dependencies, skip boot step"
echo "EXAMPLES:" echo "EXAMPLES:"
echo echo
echo "./bootstrap.sh -b buddy -e qemu" echo "./bootstrap.sh -b buddy -e qemu"
@ -416,11 +490,13 @@ fi
emulator="qemu" emulator="qemu"
defpackman="apt-get" defpackman="apt-get"
while getopts ":e:p:" opt dependenciesonly=false
while getopts ":e:p:d" opt
do do
case "$opt" in case "$opt" in
e) emulator="$OPTARG";; e) emulator="$OPTARG";;
p) defpackman="$OPTARG";; p) defpackman="$OPTARG";;
d) dependenciesonly=true;;
\?) echo "I don't know what to do with that option, try -h for help"; exit;; \?) echo "I don't know what to do with that option, try -h for help"; exit;;
esac esac
done done
@ -455,4 +531,7 @@ else
solus "$emulator" solus "$emulator"
fi fi
fi fi
boot
if [ "$dependenciesonly" = false ]; then
boot
fi