[Bf-blender-cvs] [6ff0fcd] master: Some stupid systems give limited powers to sudo... So add a --no-sudo option disabling usage of sudo!

Bastien Montagne noreply at git.blender.org
Fri Apr 4 22:46:40 CEST 2014


Commit: 6ff0fcdae72e1e6e3aafda4e3eae5dc5f7bf2714
Author: Bastien Montagne
Date:   Fri Apr 4 22:36:28 2014 +0200
https://developer.blender.org/rB6ff0fcdae72e1e6e3aafda4e3eae5dc5f7bf2714

Some stupid systems give limited powers to sudo... So add a --no-sudo option disabling usage of sudo!

Note in this case, script becomes more or less useless, just spit out names of packages to install...

Requested by Dalai Felinto over IRC.

===================================================================

M	build_files/build_environment/install_deps.sh

===================================================================

diff --git a/build_files/build_environment/install_deps.sh b/build_files/build_environment/install_deps.sh
index 65fbd1b..bdc9e93 100755
--- a/build_files/build_environment/install_deps.sh
+++ b/build_files/build_environment/install_deps.sh
@@ -25,7 +25,7 @@
 ARGS=$( \
 getopt \
 -o s:i:t:h \
---long source:,install:,tmp:,threads:,help,with-all,with-opencollada,force-all,\
+--long source:,install:,tmp:,threads:,help,no-sudo,with-all,with-opencollada,force-all,\
 force-python,force-numpy,force-boost,force-ocio,force-oiio,force-llvm,force-osl,force-opencollada,\
 force-ffmpeg,skip-python,skip-numpy,skip-boost,skip-ocio,skip-oiio,skip-llvm,skip-osl,skip-ffmpeg,\
 skip-opencollada,required-numpy,libyaml-cpp-ver: \
@@ -77,6 +77,9 @@ ARGUMENTS_INFO="\"COMMAND LINE ARGUMENTS:
     -t n, --threads=n
         Use a specific number of threads when building the libraries (auto-detected as '\$THREADS').
 
+    --no_sudo
+        Disable use of sudo (this script won't be able to do much though, will just print needed packages...).
+
     --with-all
         By default, a number of optional and not-so-often needed libraries are not installed.
         This option will try to install them, at the cost of potential conflicts (depending on
@@ -166,6 +169,8 @@ ARGUMENTS_INFO="\"COMMAND LINE ARGUMENTS:
 
 ##### Main Vars #####
 
+SUDO="sudo"
+
 PYTHON_VERSION="3.3.3"
 PYTHON_VERSION_MIN="3.3"
 PYTHON_SOURCE="http://python.org/ftp/python/$PYTHON_VERSION/Python-$PYTHON_VERSION.tar.bz2"
@@ -339,6 +344,12 @@ while true; do
       PRINT ""
       exit 0
     ;;
+    --no-sudo)
+      PRINT ""
+      WARNING "--no-sudo enabled, this script might not be able to do much..."
+      PRINT ""
+      SUDO=""; shift; continue
+    ;;
     --with-all)
       WITH_ALL=true; shift; continue
     ;;
@@ -537,13 +548,16 @@ version_match() {
 ##### Generic compile helpers #####
 prepare_opt() {
   INFO "Ensuring $INST exists and is writable by us"
+  if [ ! $SUDO ]; then
+    WARNING "--no-sudo enabled, might be impossible to create install dir..."
+  fi
   if [ ! -d  $INST ]; then
-    sudo mkdir -p $INST
+    $SUDO mkdir -p $INST
   fi
 
   if [ ! -w $INST ]; then
-    sudo chown $USER $INST
-    sudo chmod 775 $INST
+    $SUDO chown $USER $INST
+    $SUDO chmod 775 $INST
   fi
 }
 
@@ -582,9 +596,13 @@ run_ldconfig() {
   _lib_path="$INST/$1/lib"
   _ldconf_path="/etc/ld.so.conf.d/$1.conf"
   PRINT ""
-  INFO "Running ldconfig for $1..."
-  sudo sh -c "echo \"$_lib_path\" > $_ldconf_path"
-  sudo /sbin/ldconfig  # XXX OpenSuse does not include sbin in command path with sudo!!!
+  if [ ! $SUDO ]; then
+    WARNING "--no-sudo enabled, impossible to run ldconfig for $1, you'll have to do it yourself..."
+  else
+    INFO "Running ldconfig for $1..."
+    $SUDO sh -c "echo \"$_lib_path\" > $_ldconf_path"
+    $SUDO /sbin/ldconfig  # XXX OpenSuse does not include sbin in command path with sudo!!!
+  fi
   PRINT ""
 }
 
@@ -1643,10 +1661,14 @@ check_package_version_ge_DEB() {
 }
 
 install_packages_DEB() {
-  sudo apt-get install -y --force-yes $@
-  if [ $? -ge 1 ]; then
-    ERROR "apt-get failed to install requested packages, exiting."
-    exit 1
+  if [ ! $SUDO ]; then
+    WARNING "--no-sudo enabled, impossible to run apt-get install for $@, you'll have to do it yourself..."
+  else
+    $SUDO apt-get install -y --force-yes $@
+    if [ $? -ge 1 ]; then
+      ERROR "apt-get failed to install requested packages, exiting."
+      exit 1
+    fi
   fi
 }
 
@@ -1688,7 +1710,11 @@ install_DEB() {
     fi
   fi
 
-  sudo apt-get update
+  if [ ! $SUDO ]; then
+    WARNING "--no-sudo enabled, impossible to run apt-get update, you'll have to do it yourself..."
+  else
+    $SUDO apt-get update
+  fi
 
   # These libs should always be available in debian/ubuntu official repository...
   OPENJPEG_DEV="libopenjpeg-dev"
@@ -2073,17 +2099,25 @@ check_package_version_ge_RPM() {
 install_packages_RPM() {
   rpm_flavour
   if [ $RPM = "FEDORA" -o $RPM = "RHEL" ]; then
-    sudo yum install -y $@
-    if [ $? -ge 1 ]; then
-      ERROR "yum failed to install requested packages, exiting."
-      exit 1
+    if [ ! $SUDO ]; then
+      WARNING "--no-sudo enabled, impossible to run yum install for $@, you'll have to do it yourself..."
+    else
+      $SUDO yum install -y $@
+      if [ $? -ge 1 ]; then
+        ERROR "yum failed to install requested packages, exiting."
+        exit 1
+      fi
     fi
 
   elif [ $RPM = "SUSE" ]; then
-    sudo zypper --non-interactive install --auto-agree-with-licenses $@
-    if [ $? -ge 1 ]; then
-      ERROR "zypper failed to install requested packages, exiting."
-      exit 1
+    if [ ! $SUDO ]; then
+      WARNING "--no-sudo enabled, impossible to run zypper install for $@, you'll have to do it yourself..."
+    else
+      $SUDO zypper --non-interactive install --auto-agree-with-licenses $@
+      if [ $? -ge 1 ]; then
+        ERROR "zypper failed to install requested packages, exiting."
+        exit 1
+      fi
     fi
   fi
 }
@@ -2099,57 +2133,61 @@ install_RPM() {
   [ "$(echo ${REPLY:=Y} | tr [:upper:] [:lower:])" != "y" ] && exit
 
   # Enable non-free repositories for all flavours
-  rpm_flavour
-  if [ $RPM = "FEDORA" ]; then
-    _fedora_rel="`egrep "[0-9]{1,}" /etc/fedora-release -o`"
-    sudo yum -y localinstall --nogpgcheck \
-    http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$_fedora_rel.noarch.rpm \
-    http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$_fedora_rel.noarch.rpm
+  if [ ! $SUDO ]; then
+    WARNING "--no-sudo enabled, impossible to install third party repositories, you'll have to do it yourself..."
+  else
+    rpm_flavour
+    if [ $RPM = "FEDORA" ]; then
+      _fedora_rel="`egrep "[0-9]{1,}" /etc/fedora-release -o`"
+      $SUDO yum -y localinstall --nogpgcheck \
+      http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$_fedora_rel.noarch.rpm \
+      http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$_fedora_rel.noarch.rpm
 
-    sudo yum -y update
+      $SUDO yum -y update
 
-    # Install cmake now because of difference with RHEL
-    sudo yum -y install cmake
+      # Install cmake now because of difference with RHEL
+      $SUDO yum -y install cmake
 
-  elif [ $RPM = "RHEL" ]; then
-    sudo yum -y localinstall --nogpgcheck \
-    http://download.fedoraproject.org/pub/epel/6/$(uname -i)/epel-release-6-8.noarch.rpm \
-    http://download1.rpmfusion.org/free/el/updates/6/$(uname -i)/rpmfusion-free-release-6-1.noarch.rpm \
-    http://download1.rpmfusion.org/nonfree/el/updates/6/$(uname -i)/rpmfusion-nonfree-release-6-1.noarch.rpm
+    elif [ $RPM = "RHEL" ]; then
+      $SUDO yum -y localinstall --nogpgcheck \
+      http://download.fedoraproject.org/pub/epel/6/$(uname -i)/epel-release-6-8.noarch.rpm \
+      http://download1.rpmfusion.org/free/el/updates/6/$(uname -i)/rpmfusion-free-release-6-1.noarch.rpm \
+      http://download1.rpmfusion.org/nonfree/el/updates/6/$(uname -i)/rpmfusion-nonfree-release-6-1.noarch.rpm
 
-    sudo yum -y update
+      $SUDO yum -y update
 
-    # Install cmake 2.8 from other repo
-    mkdir -p $SRC
-    if [ -f $SRC/cmake-2.8.8-4.el6.$(uname -m).rpm ]; then
-      PRINT ""
-      INFO "Special cmake already installed"
-    else
-      curl -O ftp://ftp.pbone.net/mirror/atrpms.net/el6-$(uname -i)/atrpms/testing/cmake-2.8.8-4.el6.$(uname -m).rpm
-      mv cmake-2.8.8-4.el6.$(uname -m).rpm $SRC/
-      sudo rpm -ihv $SRC/cmake-2.8.8-4.el6.$(uname -m).rpm
-    fi
+      # Install cmake 2.8 from other repo
+      mkdir -p $SRC
+      if [ -f $SRC/cmake-2.8.8-4.el6.$(uname -m).rpm ]; then
+        PRINT ""
+        INFO "Special cmake already installed"
+      else
+        curl -O ftp://ftp.pbone.net/mirror/atrpms.net/el6-$(uname -i)/atrpms/testing/cmake-2.8.8-4.el6.$(uname -m).rpm
+        mv cmake-2.8.8-4.el6.$(uname -m).rpm $SRC/
+        $SUDO rpm -ihv $SRC/cmake-2.8.8-4.el6.$(uname -m).rpm
+      fi
 
-  elif [ $RPM = "SUSE" ]; then
-    # Install this now to avoid using the version from packman repository...
-    if $WITH_ALL; then
-      install_packages_RPM libjack-devel
-    fi
+    elif [ $RPM = "SUSE" ]; then
+      # Install this now to avoid using the version from packman repository...
+      if $WITH_ALL; then
+        install_packages_RPM libjack-devel
+      fi
 
-    _suse_rel="`grep VERSION /etc/SuSE-release | gawk '{print $3}'`"
+      _suse_rel="`grep VERSION /etc/SuSE-release | gawk '{print $3}'`"
 
-    PRINT ""
-    INFO "About to add 'packman' repository from http://packman.inode.at/suse/openSUSE_$_suse_rel/"
-    INFO "This is only needed if you do not already have a packman repository enabled..."
-    read -p "Do you want to add this repo (Y/n)?"
-    if [ "$(echo ${REPLY:=Y} | tr [:upper:] [:lower:])" == "y" ]; then
-      INFO "    Installing packman..."
-      sudo zypper ar --refresh --name 'Packman Repository' http://ftp.gwdg.de/pub/linux/packman/suse/openSUSE_$_suse_rel/ ftp.gwdg.de-suse
-      INFO "    Done."
-    else
-      INFO "    Skipping packman installation."
+      PRINT ""
+      INFO "About to add 'packman' repository from http://packman.inode.at/suse/openSUSE_$_suse_rel/"
+      INFO "This is only needed if you do not already have a packman repository enabled..."
+      read -p "Do you want to add this repo (Y/n)?"
+      if [ "$(echo ${REPLY:=Y} | tr [:upper:] [:lower:])" == "y" ]; then
+        INFO "    Installing packman..."
+        $SUDO zypper ar --refresh --name 'Packman Repository' http://ftp.gwdg.de/pub/linux/packman/suse/openSUSE_$_suse_rel/ ftp.gwdg.de-suse
+        INFO "    Done."
+      else
+        INFO "    Skipping packman installation."
+      fi
+      $SUDO zypper --non-interactive --gpg-auto-import-keys update --auto-agree-with-licenses
     fi
-    sudo zypper --non-interactive --gpg-auto-import-keys update --auto-agree-with-licenses
   fi
 
   # These libs should always be available in fedora/suse official repository...
@@ -2464,10 +2502,14 @@ check_package_version_ge_ARCH() {
 }
 
 install_packages_ARCH() {
-  sudo pacman -S --needed --noconfirm $@
-  if [ $? -ge 1 ]; then
-    ERROR "pacman failed to install requested packages, exiting."


@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list