2020-05-02 19:54:37 +02:00
|
|
|
#!/usr/bin/env bash
|
2016-11-03 22:19:44 +01:00
|
|
|
|
|
|
|
##########################################################
|
|
|
|
# This function is simply a banner to introduce the script
|
|
|
|
##########################################################
|
|
|
|
banner()
|
2017-01-02 22:46:23 +01:00
|
|
|
{
|
2016-11-03 22:19:44 +01:00
|
|
|
echo "|------------------------------------------|"
|
|
|
|
echo "|----- Welcome to the redox bootstrap -----|"
|
|
|
|
echo "|------------------------------------------|"
|
|
|
|
}
|
|
|
|
|
2016-11-09 01:48:10 +01:00
|
|
|
###################################################################################
|
|
|
|
# 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
|
|
|
|
|
2017-02-24 19:25:39 +01:00
|
|
|
BIN_LOCATION=$(which $BIN_NAME || true)
|
2016-11-09 01:48:10 +01:00
|
|
|
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" $@
|
|
|
|
}
|
|
|
|
|
2016-11-03 22:19:44 +01:00
|
|
|
###############################################################################
|
2016-11-09 01:48:10 +01:00
|
|
|
# This function checks which of the supported package managers
|
|
|
|
# is available on the OSX Host.
|
2017-01-03 13:14:37 +01:00
|
|
|
# If a supported package manager is found, it delegates the installing work to
|
2016-11-09 01:48:10 +01:00
|
|
|
# the relevant function.
|
|
|
|
# Otherwise this function will exit this script with an error.
|
2016-11-03 22:19:44 +01:00
|
|
|
###############################################################################
|
|
|
|
osx()
|
|
|
|
{
|
2016-11-09 01:48:10 +01:00
|
|
|
echo "Detected OSX!"
|
|
|
|
|
|
|
|
if [ ! -z "$(which brew)" ]; then
|
|
|
|
osx_homebrew $@
|
|
|
|
elif [ ! -z "$(which port)" ]; then
|
|
|
|
osx_macports $@
|
|
|
|
else
|
2017-01-03 13:14:37 +01:00
|
|
|
echo "Please install either Homebrew or MacPorts, if you wish to use this script"
|
2016-11-09 01:48:10 +01:00
|
|
|
echo "Re-run this script once you installed one of those package managers"
|
|
|
|
echo "Will not install, now exiting..."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# This function takes care of installing all dependencies using MacPorts
|
|
|
|
# for building redox on Mac OSX
|
|
|
|
# @params: $1 the emulator to install, virtualbox or qemu
|
|
|
|
###############################################################################
|
|
|
|
osx_macports()
|
|
|
|
{
|
|
|
|
echo "Macports detected! Now updating..."
|
|
|
|
sudo port -v selfupdate
|
|
|
|
|
|
|
|
echo "Installing missing packages..."
|
|
|
|
|
|
|
|
install_macports_pkg "git"
|
|
|
|
|
|
|
|
if [ "$1" == "qemu" ]; then
|
|
|
|
install_macports_pkg "qemu" "qemu-system-x86_64"
|
|
|
|
else
|
|
|
|
install_macports_pkg "virtualbox"
|
|
|
|
fi
|
|
|
|
|
2017-07-13 22:00:55 +02:00
|
|
|
install_macports_pkg "coreutils"
|
|
|
|
install_macports_pkg "findutils"
|
2016-11-09 01:48:10 +01:00
|
|
|
install_macports_pkg "gcc49" "gcc-4.9"
|
|
|
|
install_macports_pkg "nasm"
|
2016-11-25 15:07:24 +01:00
|
|
|
install_macports_pkg "pkgconfig"
|
2016-11-09 01:48:10 +01:00
|
|
|
install_macports_pkg "osxfuse"
|
|
|
|
install_macports_pkg "x86_64-elf-gcc"
|
2017-12-10 17:00:44 +01:00
|
|
|
install_macports_pkg "cmake"
|
2016-11-09 01:48:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
###############################################################################
|
2017-01-03 13:14:37 +01:00
|
|
|
# This function takes care of installing all dependencies using Homebrew
|
2016-11-09 01:48:10 +01:00
|
|
|
# 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 "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
|
|
|
|
|
2020-03-07 11:10:02 +01:00
|
|
|
install_brew_pkg "automake"
|
|
|
|
install_brew_pkg "bison"
|
|
|
|
install_brew_pkg "gettext"
|
|
|
|
install_brew_pkg "libtool"
|
|
|
|
install_brew_pkg "make"
|
2016-11-09 01:48:10 +01:00
|
|
|
install_brew_pkg "nasm"
|
2020-03-07 11:10:02 +01:00
|
|
|
install_brew_pkg "gcc@7" "gcc-7"
|
2016-11-09 01:48:10 +01:00
|
|
|
install_brew_pkg "pkg-config"
|
2020-03-07 11:10:02 +01:00
|
|
|
install_brew_pkg "Caskroom/cask/osxfuse"
|
2016-11-09 01:48:10 +01:00
|
|
|
|
2020-03-07 11:10:02 +01:00
|
|
|
install_brew_pkg "redox-os/gcc_cross_compilers/x86_64-elf-gcc" "x86_64-elf-gcc"
|
2016-11-03 22:19:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# This function takes care of installing all dependencies for building redox on
|
|
|
|
# Arch linux
|
|
|
|
# @params: $1 the emulator to install, virtualbox or qemu
|
|
|
|
###############################################################################
|
|
|
|
archLinux()
|
|
|
|
{
|
|
|
|
echo "Detected Arch Linux"
|
2019-05-24 07:54:19 +02:00
|
|
|
packages="cmake fuse git gperf perl-html-parser nasm wget texinfo bison flex"
|
2016-11-03 22:19:44 +01:00
|
|
|
if [ "$1" == "qemu" ]; then
|
2018-10-30 07:15:59 +01:00
|
|
|
packages="$packages qemu"
|
|
|
|
elif [ "$1" == "virtualbox" ]; then
|
|
|
|
packages="$packages virtualbox"
|
2016-11-03 22:19:44 +01:00
|
|
|
fi
|
|
|
|
|
2019-10-27 19:59:52 +01:00
|
|
|
# Scripts should not cause a system update in order to just install a couple
|
|
|
|
# of packages. If pacman -S --needed is going to fail, let it fail and the
|
|
|
|
# user will figure out the issues (without updating if required) and rerun
|
|
|
|
# the script.
|
|
|
|
#echo "Updating system..."
|
|
|
|
#sudo pacman -Syu
|
2018-10-30 07:15:59 +01:00
|
|
|
|
|
|
|
echo "Installing packages $packages..."
|
|
|
|
sudo pacman -S --needed $packages
|
2016-11-03 22:19:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# This function takes care of installing all dependencies for building redox on
|
|
|
|
# debian based linux
|
|
|
|
# @params: $1 the emulator to install, virtualbox or qemu
|
2017-01-02 22:46:23 +01:00
|
|
|
# $2 the package manager to use
|
2016-11-03 22:19:44 +01:00
|
|
|
###############################################################################
|
|
|
|
ubuntu()
|
|
|
|
{
|
|
|
|
echo "Detected Ubuntu/Debian"
|
|
|
|
echo "Updating system..."
|
|
|
|
sudo "$2" update
|
|
|
|
echo "Installing required packages..."
|
2019-10-21 03:32:50 +02:00
|
|
|
sudo "$2" install \
|
|
|
|
autoconf \
|
|
|
|
autopoint \
|
|
|
|
bison \
|
|
|
|
build-essential \
|
|
|
|
cmake \
|
|
|
|
curl \
|
|
|
|
file \
|
|
|
|
flex \
|
|
|
|
fuse \
|
|
|
|
genisoimage \
|
|
|
|
git \
|
|
|
|
gperf \
|
|
|
|
libc6-dev-i386 \
|
|
|
|
libfuse-dev \
|
|
|
|
libhtml-parser-perl \
|
|
|
|
libpng-dev \
|
|
|
|
libtool \
|
|
|
|
m4 \
|
|
|
|
nasm \
|
|
|
|
pkg-config \
|
|
|
|
syslinux-utils \
|
|
|
|
texinfo
|
2016-11-03 22:19:44 +01:00
|
|
|
if [ "$1" == "qemu" ]; then
|
2017-01-16 18:23:52 +01:00
|
|
|
if [ -z "$(which qemu-system-x86_64)" ]; then
|
2016-11-03 22:19:44 +01:00
|
|
|
echo "Installing QEMU..."
|
|
|
|
sudo "$2" install qemu-system-x86 qemu-kvm
|
|
|
|
else
|
|
|
|
echo "QEMU already installed!"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
if [ -z "$(which virtualbox)" ]; then
|
|
|
|
echo "Installing Virtualbox..."
|
|
|
|
sudo "$2" install virtualbox
|
|
|
|
else
|
|
|
|
echo "Virtualbox already installed!"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# This function takes care of installing all dependencies for building redox on
|
|
|
|
# fedora linux
|
|
|
|
# @params: $1 the emulator to install, virtualbox or qemu
|
|
|
|
###############################################################################
|
|
|
|
fedora()
|
|
|
|
{
|
|
|
|
echo "Detected Fedora"
|
|
|
|
if [ -z "$(which git)" ]; then
|
|
|
|
echo "Installing git..."
|
2016-11-06 20:33:06 +01:00
|
|
|
sudo dnf install git-all
|
2016-11-03 22:19:44 +01:00
|
|
|
fi
|
|
|
|
if [ "$1" == "qemu" ]; then
|
2017-01-16 18:23:52 +01:00
|
|
|
if [ -z "$(which qemu-system-x86_64)" ]; then
|
2016-11-03 22:19:44 +01:00
|
|
|
echo "Installing QEMU..."
|
2016-11-06 20:33:06 +01:00
|
|
|
sudo dnf install qemu-system-x86 qemu-kvm
|
2016-11-03 22:19:44 +01:00
|
|
|
else
|
|
|
|
echo "QEMU already installed!"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
if [ -z "$(which virtualbox)" ]; then
|
|
|
|
echo "Installing virtualbox..."
|
2016-11-06 20:33:06 +01:00
|
|
|
sudo dnf install virtualbox
|
2016-11-03 22:19:44 +01:00
|
|
|
else
|
|
|
|
echo "Virtualbox already installed!"
|
|
|
|
fi
|
|
|
|
fi
|
2016-12-20 18:33:12 +01:00
|
|
|
# Use rpm -q <package> to check if it's already installed
|
2019-12-21 21:33:30 +01:00
|
|
|
PKGS=$(for pkg in gcc gcc-c++ glibc-devel.i686 nasm make fuse-devel cmake texinfo gettext-devel bison flex perl-HTML-Parser; do rpm -q $pkg > /dev/null || echo $pkg; done)
|
2016-12-20 18:33:12 +01:00
|
|
|
# If the list of packages is not empty, install missing
|
|
|
|
COUNT=$(echo $PKGS | wc -w)
|
|
|
|
if [ $COUNT -ne 0 ]; then
|
|
|
|
echo "Installing necessary build tools..."
|
|
|
|
sudo dnf install $PKGS
|
|
|
|
fi
|
2016-11-03 22:19:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# This function takes care of installing all dependencies for building redox on
|
|
|
|
# *suse linux
|
|
|
|
# @params: $1 the emulator to install, virtualbox or qemu
|
|
|
|
###############################################################################
|
|
|
|
suse()
|
|
|
|
{
|
2017-01-03 13:14:37 +01:00
|
|
|
echo "Detected SUSE Linux"
|
2016-11-03 22:19:44 +01:00
|
|
|
if [ -z "$(which git)" ]; then
|
|
|
|
echo "Installing git..."
|
|
|
|
zypper install git
|
|
|
|
fi
|
|
|
|
if [ "$1" == "qemu" ]; then
|
2017-01-16 18:23:52 +01:00
|
|
|
if [ -z "$(which qemu-system-x86_64)" ]; then
|
2016-11-03 22:19:44 +01:00
|
|
|
echo "Installing QEMU..."
|
|
|
|
sudo zypper install qemu-x86 qemu-kvm
|
|
|
|
else
|
|
|
|
echo "QEMU already installed!"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
if [ -z "$(which virtualbox)" ]; then
|
|
|
|
echo "Please install Virtualbox and re-run this script,"
|
|
|
|
echo "or run with -e qemu"
|
|
|
|
exit
|
|
|
|
else
|
|
|
|
echo "Virtualbox already installed!"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
echo "Installing necessary build tools..."
|
2017-12-10 17:00:44 +01:00
|
|
|
sudo zypper install gcc gcc-c++ glibc-devel-32bit nasm make fuse-devel cmake
|
2016-11-03 22:19:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
##############################################################################
|
2017-11-05 06:57:41 +01:00
|
|
|
# This function takes care of installing all dependencies for building redox on
|
2016-11-03 22:19:44 +01:00
|
|
|
# gentoo linux
|
|
|
|
# @params: $1 the emulator to install, virtualbox or qemu
|
|
|
|
##############################################################################
|
|
|
|
gentoo()
|
|
|
|
{
|
|
|
|
echo "Detected Gentoo Linux"
|
|
|
|
if [ -z "$(which nasm)" ]; then
|
|
|
|
echo "Installing nasm..."
|
|
|
|
sudo emerge dev-lang/nasm
|
|
|
|
fi
|
|
|
|
if [ -z "$(which git)" ]; then
|
|
|
|
echo "Installing git..."
|
|
|
|
sudo emerge dev-vcs/git
|
|
|
|
fi
|
2017-07-27 02:14:18 +02:00
|
|
|
if [ -z "$(which fusermount)" ]; then
|
|
|
|
echo "Installing fuse..."
|
|
|
|
sudo emerge sys-fs/fuse
|
|
|
|
fi
|
2016-11-03 22:19:44 +01:00
|
|
|
if [ "$2" == "qemu" ]; then
|
2017-01-16 18:23:52 +01:00
|
|
|
if [ -z "$(which qemu-system-x86_64)" ]; then
|
2016-11-03 22:19:44 +01:00
|
|
|
echo "Please install QEMU and re-run this script"
|
2017-07-27 03:53:23 +02:00
|
|
|
echo "Step1. Add QEMU_SOFTMMU_TARGETS=\"x86_64\" to /etc/portage/make.conf"
|
2016-11-03 22:19:44 +01:00
|
|
|
echo "Step2. Execute \"sudo emerge app-emulation/qemu\""
|
|
|
|
else
|
|
|
|
echo "QEMU already installed!"
|
|
|
|
fi
|
|
|
|
fi
|
2017-12-10 17:00:44 +01:00
|
|
|
if [ -z "$(which cmake)" ]; then
|
|
|
|
echo "Installing cmake..."
|
|
|
|
sudo emerge dev-util/cmake
|
|
|
|
fi
|
2016-11-03 22:19:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
##############################################################################
|
2017-11-05 06:57:41 +01:00
|
|
|
# This function takes care of installing all dependencies for building redox on
|
2016-11-03 22:19:44 +01:00
|
|
|
# SolusOS
|
|
|
|
# @params: $1 the emulator to install, virtualbox or qemu
|
|
|
|
##############################################################################
|
|
|
|
solus()
|
|
|
|
{
|
|
|
|
echo "Detected SolusOS"
|
2017-07-13 22:00:55 +02:00
|
|
|
|
2016-11-03 22:19:44 +01:00
|
|
|
if [ "$1" == "qemu" ]; then
|
2017-01-16 18:23:52 +01:00
|
|
|
if [ -z "$(which qemu-system-x86_64)" ]; then
|
2016-11-03 22:19:44 +01:00
|
|
|
sudo eopkg it qemu
|
|
|
|
else
|
|
|
|
echo "QEMU already installed!"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
if [ -z "$(which virtualbox)" ]; then
|
|
|
|
echo "Please install Virtualbox and re-run this script,"
|
|
|
|
echo "or run with -e qemu"
|
|
|
|
exit
|
|
|
|
else
|
|
|
|
echo "Virtualbox already installed!"
|
|
|
|
fi
|
|
|
|
fi
|
2017-07-13 22:00:55 +02:00
|
|
|
|
2017-05-24 23:09:32 +02:00
|
|
|
echo "Installing necessary build tools..."
|
|
|
|
#if guards are not necessary with eopkg since it does nothing if latest version is already installed
|
2017-12-10 17:00:44 +01:00
|
|
|
sudo eopkg it fuse-devel git gcc g++ libgcc-32bit libstdc++-32bit nasm make cmake
|
2016-11-03 22:19:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
######################################################################
|
|
|
|
# This function outlines the different options available for bootstrap
|
|
|
|
######################################################################
|
|
|
|
usage()
|
|
|
|
{
|
|
|
|
echo "------------------------"
|
|
|
|
echo "|Redox bootstrap script|"
|
|
|
|
echo "------------------------"
|
|
|
|
echo "Usage: ./bootstrap.sh"
|
|
|
|
echo "OPTIONS:"
|
|
|
|
echo
|
|
|
|
echo " -h,--help Show this prompt"
|
|
|
|
echo " -u [branch] Update git repo and update rust"
|
|
|
|
echo " If blank defaults to master"
|
|
|
|
echo " -s Check the status of the current travis build"
|
|
|
|
echo " -e [emulator] Install specific emulator, virtualbox or qemu"
|
|
|
|
echo " -p [package Choose an Ubuntu package manager, apt-fast or"
|
|
|
|
echo " manager] aptitude"
|
2017-01-02 22:46:23 +01:00
|
|
|
echo " -d Only install the dependencies, skip boot step"
|
2016-11-03 22:19:44 +01:00
|
|
|
echo "EXAMPLES:"
|
|
|
|
echo
|
2017-03-04 05:38:34 +01:00
|
|
|
echo "./bootstrap.sh -e qemu"
|
2016-11-03 22:19:44 +01:00
|
|
|
exit
|
|
|
|
}
|
|
|
|
|
2020-02-15 14:30:47 +01:00
|
|
|
|
|
|
|
#############################################################
|
|
|
|
# Looks for and installs a cargo-managed binary or subcommand
|
|
|
|
#############################################################
|
|
|
|
cargoInstall() {
|
|
|
|
if [[ "`cargo install --list`" != *"$1"* ]]; then
|
|
|
|
cargo install $1
|
|
|
|
else
|
|
|
|
echo "You have $1 installed already!"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2016-11-03 22:19:44 +01:00
|
|
|
####################################################################################
|
|
|
|
# This function takes care of everything associated to rust, and the version manager
|
2017-01-02 22:46:23 +01:00
|
|
|
# That controls it, it can install rustup and uninstall multirust as well as making
|
2016-11-03 22:19:44 +01:00
|
|
|
# sure that the correct version of rustc is selected by rustup
|
|
|
|
####################################################################################
|
|
|
|
rustInstall() {
|
|
|
|
# Check to see if multirust is installed, we don't want it messing with rustup
|
2016-11-04 19:47:06 +01:00
|
|
|
# In the future we can probably remove this but I believe it's good to have for now
|
2016-11-03 22:19:44 +01:00
|
|
|
if [ -e /usr/local/lib/rustlib/uninstall.sh ] ; then
|
|
|
|
echo "It appears that multirust is installed on your system."
|
|
|
|
echo "This tool has been deprecated by the maintainer, and will cause issues."
|
|
|
|
echo "This script can remove multirust from your system if you wish."
|
|
|
|
printf "Uninstall multirust (y/N):"
|
|
|
|
read multirust
|
|
|
|
if echo "$multirust" | grep -iq "^y" ;then
|
2017-01-02 22:46:23 +01:00
|
|
|
sudo /usr/local/lib/rustlib/uninstall.sh
|
2016-11-03 22:19:44 +01:00
|
|
|
else
|
|
|
|
echo "Please manually uninstall multirust and any other versions of rust, then re-run bootstrap."
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "Old multirust not installed, you are good to go."
|
|
|
|
fi
|
2017-01-02 22:46:23 +01:00
|
|
|
# If rustup is not installed we should offer to install it for them
|
2016-11-03 22:19:44 +01:00
|
|
|
if [ -z "$(which rustup)" ]; then
|
|
|
|
echo "You do not have rustup installed."
|
2017-01-03 13:14:37 +01:00
|
|
|
echo "We HIGHLY recommend using rustup."
|
2016-11-03 22:19:44 +01:00
|
|
|
echo "Would you like to install it now?"
|
|
|
|
echo "*WARNING* this involves a 'curl | sh' style command"
|
|
|
|
printf "(y/N): "
|
|
|
|
read rustup
|
|
|
|
if echo "$rustup" | grep -iq "^y" ;then
|
|
|
|
#install rustup
|
|
|
|
curl https://sh.rustup.rs -sSf | sh -s -- --default-toolchain nightly
|
2017-01-02 22:46:23 +01:00
|
|
|
# You have to add the rustup variables to the $PATH
|
2016-11-03 22:19:44 +01:00
|
|
|
echo "export PATH=\"\$HOME/.cargo/bin:\$PATH\"" >> ~/.bashrc
|
|
|
|
# source the variables so that we can execute rustup commands in the current shell
|
2017-01-02 22:46:23 +01:00
|
|
|
source ~/.cargo/env
|
2016-11-03 22:19:44 +01:00
|
|
|
rustup default nightly
|
|
|
|
else
|
|
|
|
echo "Rustup will not be installed!"
|
|
|
|
fi
|
2017-01-02 22:46:23 +01:00
|
|
|
fi
|
|
|
|
#
|
2016-11-03 22:19:44 +01:00
|
|
|
if [ -z "$(which rustc)" ]; then
|
|
|
|
echo "Rust is not installed"
|
|
|
|
echo "Please either run the script again, accepting rustup install"
|
2017-01-03 13:14:37 +01:00
|
|
|
echo "or install rustc nightly manually (not recommended) via:"
|
2016-11-03 22:19:44 +01:00
|
|
|
echo "\#curl -sSf https://static.rust-lang.org/rustup.sh | sh -s -- --channel=nightly"
|
2017-01-02 22:46:23 +01:00
|
|
|
exit
|
2016-11-03 22:19:44 +01:00
|
|
|
fi
|
|
|
|
# If the system has rustup installed then update rustc to the latest nightly
|
|
|
|
if hash 2>/dev/null rustup; then
|
|
|
|
rustup update nightly
|
|
|
|
rustup default nightly
|
|
|
|
fi
|
|
|
|
# Check to make sure that the default rustc is the nightly
|
|
|
|
if echo "$(rustc --version)" | grep -viq "nightly" ;then
|
|
|
|
echo "It appears that you have rust installed, but it"
|
|
|
|
echo "is not the nightly version, please either install"
|
2017-01-03 13:14:37 +01:00
|
|
|
echo "the nightly manually (not recommended) or run this"
|
|
|
|
echo "script again, accepting the rustup install"
|
2016-11-03 22:19:44 +01:00
|
|
|
echo
|
|
|
|
else
|
|
|
|
echo "Your rust install looks good!"
|
|
|
|
echo
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
####################################################################
|
2017-01-02 22:46:23 +01:00
|
|
|
# This function gets the current build status from travis and prints
|
2016-11-03 22:19:44 +01:00
|
|
|
# a message to the user
|
|
|
|
####################################################################
|
|
|
|
statusCheck() {
|
|
|
|
for i in $(echo "$(curl -sf https://api.travis-ci.org/repositories/redox-os/redox.json)" | tr "," "\n")
|
|
|
|
do
|
|
|
|
if echo "$i" | grep -iq "last_build_status" ;then
|
|
|
|
if echo "$i" | grep -iq "0" ;then
|
|
|
|
echo
|
|
|
|
echo "********************************************"
|
2017-01-03 13:14:37 +01:00
|
|
|
echo "Travis reports that the last build succeeded!"
|
2016-11-03 22:19:44 +01:00
|
|
|
echo "Looks like you are good to go!"
|
|
|
|
echo "********************************************"
|
|
|
|
elif echo "$i" | grep -iq "null" ;then
|
|
|
|
echo
|
2017-01-02 22:46:23 +01:00
|
|
|
echo "******************************************************************"
|
2016-11-03 22:19:44 +01:00
|
|
|
echo "The Travis build did not finish, this is an error with its config."
|
2017-01-03 13:14:37 +01:00
|
|
|
echo "I cannot reliably determine whether the build is succeeding or not."
|
2018-08-26 18:10:54 +02:00
|
|
|
echo "Consider checking for and maybe opening an issue on gitlab"
|
2016-11-03 22:19:44 +01:00
|
|
|
echo "******************************************************************"
|
|
|
|
else
|
|
|
|
echo
|
|
|
|
echo "**************************************************"
|
|
|
|
echo "Travis reports that the last build *FAILED* :("
|
|
|
|
echo "Might want to check out the issues before building"
|
|
|
|
echo "**************************************************"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
###########################################################################
|
|
|
|
# This function is the main logic for the bootstrap; it clones the git repo
|
|
|
|
# then it installs the rust version manager and the latest version of rustc
|
|
|
|
###########################################################################
|
|
|
|
boot()
|
|
|
|
{
|
2018-08-26 18:10:54 +02:00
|
|
|
echo "Cloning gitlab repo..."
|
2018-06-14 21:32:41 +02:00
|
|
|
git clone https://gitlab.redox-os.org/redox-os/redox.git --origin upstream --recursive
|
2016-11-03 22:19:44 +01:00
|
|
|
rustInstall
|
2020-02-15 14:30:47 +01:00
|
|
|
cargoInstall cargo-config
|
|
|
|
cargoInstall xargo
|
2016-11-03 22:19:44 +01:00
|
|
|
echo "Cleaning up..."
|
|
|
|
rm bootstrap.sh
|
|
|
|
echo
|
|
|
|
echo "---------------------------------------"
|
|
|
|
echo "Well it looks like you are ready to go!"
|
|
|
|
echo "---------------------------------------"
|
|
|
|
statusCheck
|
|
|
|
echo "Run the following commands to build redox:"
|
|
|
|
echo "cd redox"
|
|
|
|
echo "make all"
|
|
|
|
echo "make virtualbox or qemu"
|
|
|
|
echo
|
|
|
|
echo " Good luck!"
|
|
|
|
|
|
|
|
exit
|
|
|
|
}
|
|
|
|
|
2017-09-11 07:54:27 +02:00
|
|
|
if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then
|
2016-11-03 22:19:44 +01:00
|
|
|
usage
|
|
|
|
elif [ "$1" == "-u" ]; then
|
2016-11-04 19:46:38 +01:00
|
|
|
git pull upstream master
|
2016-11-03 22:19:44 +01:00
|
|
|
git submodule update --recursive --init
|
|
|
|
rustup update nightly
|
|
|
|
exit
|
|
|
|
elif [ "$1" == "-s" ]; then
|
|
|
|
statusCheck
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
emulator="qemu"
|
|
|
|
defpackman="apt-get"
|
2016-11-09 01:48:10 +01:00
|
|
|
dependenciesonly=false
|
2019-10-27 19:59:52 +01:00
|
|
|
update=false
|
|
|
|
while getopts ":e:p:udhs" opt
|
2016-11-03 22:19:44 +01:00
|
|
|
do
|
|
|
|
case "$opt" in
|
|
|
|
e) emulator="$OPTARG";;
|
|
|
|
p) defpackman="$OPTARG";;
|
2016-11-09 01:48:10 +01:00
|
|
|
d) dependenciesonly=true;;
|
2019-10-27 19:59:52 +01:00
|
|
|
u) update=true;;
|
|
|
|
h) usage;;
|
|
|
|
s) statusCheck && exit;;
|
2016-11-03 22:19:44 +01:00
|
|
|
\?) echo "I don't know what to do with that option, try -h for help"; exit;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2019-10-27 19:59:52 +01:00
|
|
|
if [ "$update" == "true" ]; then
|
|
|
|
git pull upstream master
|
|
|
|
git submodule update --recursive --init
|
|
|
|
rustup update nightly
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2016-11-03 22:19:44 +01:00
|
|
|
banner
|
|
|
|
if [ "Darwin" == "$(uname -s)" ]; then
|
|
|
|
osx "$emulator"
|
|
|
|
else
|
2017-09-07 01:09:10 +02:00
|
|
|
# Here we will use package managers to determine which operating system the user is using.
|
2018-10-30 07:15:59 +01:00
|
|
|
|
2016-11-03 22:19:44 +01:00
|
|
|
# Suse and derivatives
|
2018-11-17 20:02:51 +01:00
|
|
|
if hash 2>/dev/null zypper; then
|
2016-11-03 22:19:44 +01:00
|
|
|
suse "$emulator"
|
2017-09-07 01:09:10 +02:00
|
|
|
# Debian or any derivative of it
|
|
|
|
elif hash 2>/dev/null apt-get; then
|
|
|
|
ubuntu "$emulator" "$defpackman"
|
|
|
|
# Fedora
|
|
|
|
elif hash 2>/dev/null dnf; then
|
|
|
|
fedora "$emulator"
|
|
|
|
# Gentoo
|
|
|
|
elif hash 2>/dev/null emerge; then
|
|
|
|
gentoo "$emulator"
|
|
|
|
# SolusOS
|
|
|
|
elif hash 2>/dev/null eopkg; then
|
|
|
|
solus "$emulator"
|
2018-11-17 20:02:51 +01:00
|
|
|
# Arch linux
|
|
|
|
elif hash 2>/dev/null pacman; then
|
|
|
|
archLinux "$emulator"
|
2018-10-30 07:15:59 +01:00
|
|
|
fi
|
2016-11-03 22:19:44 +01:00
|
|
|
fi
|
2016-11-09 01:48:10 +01:00
|
|
|
|
|
|
|
if [ "$dependenciesonly" = false ]; then
|
|
|
|
boot
|
|
|
|
fi
|