From 2c22426c1f4b0f70da6f189401c14096c9ebc4b4 Mon Sep 17 00:00:00 2001 From: Andrew Schoen Date: Mon, 29 Jun 2015 17:28:12 -0500 Subject: [PATCH] bootstrap: add an install flag that installs missing required packages If you run ./bootstrap install the script will install any missing packages needed to complete the bootstrap. This feature requires that the user running ./bootstrap have sudo privileges. Signed-off-by: Andrew Schoen --- bootstrap | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/bootstrap b/bootstrap index ee5edfa13..23a4a47e3 100755 --- a/bootstrap +++ b/bootstrap @@ -1,6 +1,17 @@ #!/bin/sh set -e +if [ $# -eq 0 ]; then + install=false +else + if [ "$1" = "install" ]; then + install=true + else + echo "Invalid command, supported commands are: 'install'" + exit 1 + fi +fi + case "$(uname -s)" in Linux) case "$(lsb_release --id --short)" in @@ -23,9 +34,16 @@ Linux) fi done if [ -n "$missing" ]; then - echo "$0: missing required packages, installing them:" 1>&2 + echo "$0: missing required packages:" 1>&2 echo "$missing" - sudo apt-get -y install $missing + if [ "$install" = true ]; then + echo "Installing missing packages..." + sudo apt-get -y install $missing + else + echo "Please install missing packages or run './bootstrap install' if you have sudo" + echo "sudo apt-get -y install $missing" + exit 1 + fi fi ;; Fedora) @@ -35,9 +53,16 @@ Linux) fi done if [ -n "$missing" ]; then - echo "$0: missing required packages, installing them:" 1>&2 + echo "$0: missing required packages:" 1>&2 echo "$missing" - sudo yum -y install $missing + if [ "$install" = true ]; then + echo "Installing missing packages..." + sudo yum -y install $missing + else + echo "Please install missing packages or run './bootstrap install' if you have sudo" + echo "sudo yum -y install $missing" + exit 1 + fi fi ;; "openSUSE project"|"SUSE LINUX") -- 2.47.3