Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added bootstrap file #383

Merged
merged 1 commit into from
Dec 17, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
175 changes: 175 additions & 0 deletions bootstrap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
#! /bin/bash
banner() {
echo "|------------------------------------------|"
echo "|----- Welcome to the redox bootstrap -----|"
echo "|------------------------------------------|"
}

osx()
{
echo "Detected OSX!"
temp=$(brew --version)
if [ -n "$temp" ]; then
echo "Homebrew detected! Now updating..."
brew update
echo "Now installing git..."
brew install git
echo "Now installing virtualbox..."
brew cask install virtualbox
else
echo "Homebrew does not appear to be installed! Would you like me to install it?"
printf "(Y/n): "
#For now assume yes
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
fi
echo "Cloning Redox repo"
git clone -b $1 --recursive https://github.com/redox-os/redox.git
sh redox/setup/osx-homebrew.sh
sh redox/setup/binary.sh
}

archLinux()
{
echo "Detected Arch Linux, mah fav"
echo "Updating system..."
sudo pacman -Syu
echo "Installing git..."
sudo pacman -S git
echo "Cloning Redox repo"
if [ "$2" == "qemu" ]; then
echo "Installing QEMU..."
sudo pacman -S qemu
fi
git clone -b $1 --recursive https://github.com/redox-os/redox.git
sh redox/setup/arch.sh
sh redox/setup/binary.sh
}

ubuntu()
{
echo "Detected Ubuntu/Debian"
echo "Updating system..."
sudo apt-get upgrade
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. This does only work if the user has made a manual apt-get update before. upgrade does not enforce it.
  2. Also as well as install``update needs manual confirmation of the packages that shall be upgraded.
  3. There are situations when one does not want to mass-upgrade his system. eg. during the lecture-phase I am very picky with upgrades, since some upgrades could destroy stuff I have to rely on.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NobbZ
So would you suggest removing the update part completely?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since an upgrade of the system is not really necessary to get up and
running redox I think, drop it. Still we need to update package repositorys
via apt-get update to avoid problems when installing later. If you don't
do it, you might run into troubles because package versions shifted since
last update.

DomThePorcupine [email protected] schrieb am Do., 17. Dez. 2015 um
08:01 Uhr:

In bootstrap.sh
#383 (comment):

  • sudo pacman -S git
  • echo "Cloning Redox repo"
  • if [ "$2" == "qemu" ]; then
  •    echo "Installing QEMU..."
    
  •    sudo pacman -S qemu
    
  • fi
  • git clone -b $1 --recursive https://github.com/redox-os/redox.git
  • sh redox/setup/arch.sh
  • sh redox/setup/binary.sh
    +}

+ubuntu()
+{

  • echo "Detected Ubuntu/Debian"
  • echo "Updating system..."
  • sudo apt-get upgrade

So would you suggest removing the update part completely?


Reply to this email directly or view it on GitHub
https://github.com/redox-os/redox/pull/383/files#r47875060.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NobbZ
So drop apt-get upgrade in favor of apt-get update?

echo "Installing git..."
sudo apt-get -y install git
if [ "$2" == "qemu" ]; then
echo "Installing QEMU..."
sudo apt-get -y install qemu-system-x86 qemu-kvm
fi
echo "Cloning Redox repo"
git clone -b $1 --recursive https://github.com/redox-os/redox.git
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You do assume that I do not already have the sources and pull it straight away into the folder which is my current working dir. Perhaps It is already exactly here, perhaps I want it to be somewhere else?

When I really do run such installers, I do it always from inside a temporary location, then it is easier to clean up the mess that some of them leave around…

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NobbZ
So would you suggest requiring an directory location given by the user, something like
"Put repo in CWD?"
"(Y/n):"
if n
"Please enter full path to location:"

sudo apt-get -y install build-essential libc6-dev-i386 nasm curl file
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are missing a new status-message here. This is not cloning the repository anymore. Do them right or leave them out.
Also I dont like that -y, since it does not give me a choice. Also multiple runs of apt are enforced, why dont build up a list of packages and then install all in one run letting the user choose if he really want to do by ommiting -y.?

Some of the comments might apply for other OS as well

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

apt is not the sole package manager for Ubuntu, there is also aptitude and apt-fast (OK, it is a wrapper for apt and aptitude that predownloads the packages in parallel), I'd like to choose either by commandline argument or by environment variables.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NobbZ
Do aptitude/apt-fast work the same as apt-get? For example would 'apt-get install package-x' be the same as 'aptitude install package-x' and 'apt-fast install package-x'? I do not work in Ubuntu often, so I am not super familiar with these alternate package managers.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The interface is pretty much the same, at least the relevant parts…

The sole difference in the interface is how upgrades happen. There are upgrade and dist-upgrade in apt while there are safe-upgrade and full-upgrade in aptitude. If we remove upgrading, it would be irrelevant.

apt-fast just mimics the interface of the tool it is wrapping.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NobbZ
Okay so a command line option for this would not be difficult to implement at all then!
Also to address the -y, I attempted to run the script in a hastily prepared chroot and running the script it did not wait for me to press y it just assumed n and exited so that is why they are there. I guess I messed something up with that, I will drop them.

sh redox/setup/binary.sh
}

fedora()
{
echo "Detected Fedora"
echo "Installing git..."
sudo yum install git-all
if [ "$2" == "qemu" ]; then
echo "Installing QEMU..."
sudo yum install qemu-system-x86 qemu-kvm
else
echo "Installing virtualbox..."
sudo yum install virtualbox
fi
echo "Cloning Redox repo"
git clone -b $1 --recursive https://github.com/redox-os/redox.git
sudo dnf install gcc gcc-c++ glibc-devel.i686 nasm make
sh redox/setup/binary.sh
}

suse()
{
echo "Detected a suse"
echo "Installing git..."
zypper install git
if [ "$2" == "qemu" ]; then
echo "Installing QEMU..."
sudo zypper install qemu-x86 qemu-kvm
else
which virtualbox && { "Virtualbox installed!"; break; }
echo "Please install Virtualbox and re-run this script,"
echo "or run with -e qemu"
exit
fi
echo "Cloning Redox repo..."
git clone -b $1 --recursive https://github.com/redox-os/redox.git
sudo zypper install gcc gcc-c++ glibc-devel-32bit nasm make
sh redox/setup/binary.sh
}

usage()
{
echo "------------------------"
echo "|Redox bootstrap script|"
echo "------------------------"
echo "Usage: ./bootstrap.sh"
echo "OPTIONS:"
echo
echo " -h,--help Show this prompt"
echo " -b [branch] Specify a branch of redox to clone"
echo " -u [branch] Update git repo and update rust"
echo " If blank defaults to master"
echo " -e [emulator] Install specific emulator, virtualbox or qemu"
echo "EXAMPLES:"
echo
echo "./bootstrap.sh -b buddy -e qemu"
exit
}

update()
{
git pull origin $1
sh setup/binary.sh
exit
}

endMessage()
{
echo "---------------------------------------"
echo "Well it looks like you are ready to go!"
echo "---------------------------------------"
echo " cd redox"
echo " make all"
echo " make virtualbox or qemu"
echo
echo " Good luck!"

exit
}
if [ "$1" == "-h" ]; then
usage
fi

if [ "$1" == "-u" ]; then
if [ -n "$2" ]; then
update $2
else
update "master"
fi
fi

branch="master"
emulator="virtualbox"

while getopts ":b:e:" opt
do
case "$opt" in
b) branch="$OPTARG";;
e) emulator="$OPTARG";;
\?) echo "I don't know what to do with that option..."; exit;;
esac
done

banner
kernel=$(uname -s)
if [ "$kernel" == "Darwin" ]; then
osx $branch
else
which pacman && { archLinux $branch $emulator; endMessage; }
which apt-get && { ubuntu $branch $emulator; endMessage; }
which yum && { fedora $branch $emulator; endMessage; }
which zypper && { suse $branch $emulator; endMessage; }
fi