From: Loic Dachary Date: Sat, 20 Dec 2014 17:57:59 +0000 (+0100) Subject: install-deps.sh: do not require sudo when root X-Git-Tag: v0.92~109^2~13 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2de2c4b035ed9519842c82aaa7c5d942e625af74;p=ceph.git install-deps.sh: do not require sudo when root If the user is root, do not use sudo. The sudo package is not installed by default on centos by default and when building from script it may be that root is running install-deps.sh on a freshly install distribution. Signed-off-by: Loic Dachary --- diff --git a/install-deps.sh b/install-deps.sh index 4785d0050137..8bbfaaded9da 100755 --- a/install-deps.sh +++ b/install-deps.sh @@ -15,9 +15,13 @@ DIR=/tmp/install-deps.$$ trap "rm -fr $DIR" EXIT mkdir -p $DIR +if test $(id -u) != 0 ; then + SUDO=sudo +fi + case $(lsb_release -si) in Ubuntu|Debian|Devuan) - sudo apt-get install -y dpkg-dev + $SUDO apt-get install -y dpkg-dev touch $DIR/status packages=$(dpkg-checkbuilddeps --admindir=$DIR debian/control 2>&1 | \ perl -p -e 's/.*Unmet build dependencies: *//;' \ @@ -29,19 +33,19 @@ Ubuntu|Debian|Devuan) packages=$(echo $packages | perl -pe 's/\w*babeltrace\w*//g') ;; esac - sudo apt-get install -y $packages + $SUDO apt-get install -y $packages ;; CentOS|Fedora|SUSE*|RedHatEnterpriseServer) case $(lsb_release -si) in SUSE*) - sudo zypper -y yum-utils + $SUDO zypper -y yum-utils ;; *) - sudo yum install -y yum-utils + $SUDO yum install -y yum-utils ;; esac sed -e 's/@//g' < ceph.spec.in > $DIR/ceph.spec - sudo yum-builddep -y $DIR/ceph.spec + $SUDO yum-builddep -y $DIR/ceph.spec ;; *) echo "$(lsb_release -si) is unknown, dependencies will have to be installed manually."