From 5c28285cdf58d0b38543b725edbaf67eb5e7577b Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Fri, 13 Dec 2013 09:35:05 -0600 Subject: [PATCH] kicad-install.sh and library-repos-install.sh utilize /etc/profile.d/kicad.sh for setting environment variables globally --- scripts/kicad-install.sh | 37 +++++++++++++++++++++++++++----- scripts/library-repos-install.sh | 7 +++--- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/scripts/kicad-install.sh b/scripts/kicad-install.sh index ae0c8d44b2..b527a7d8ea 100755 --- a/scripts/kicad-install.sh +++ b/scripts/kicad-install.sh @@ -71,6 +71,7 @@ install_prerequisites() cmake-curses-gui \ debhelper \ doxygen \ + grep \ libbz2-dev \ libcairo2-dev \ libglew-dev \ @@ -86,13 +87,14 @@ install_prerequisites() sudo yum install \ bzr \ bzrtools \ + bzip2-libs \ + bzip2-devel \ cmake \ cmake-gui \ doxygen \ - bzip2-libs \ - bzip2-devel \ cairo-devel \ glew-devel \ + grep \ openssl-devel \ wxGTK-devel \ wxPython @@ -136,6 +138,33 @@ cmake_uninstall() } +# Function set_env_var +# sets an environment variable globally. +set_env_var() +{ + local VAR=$1 + local VAL=$2 + + if [ -d /etc/profile.d ]; then + if [ ! -e /etc/profile.d/kicad.sh ] || ! grep "$VAR" /etc/profile.d/kicad.sh; then + echo + echo "Adding environment variable $VAR to file /etc/profile.d/kicad.sh" + echo "Please logout and back in after this script completes for environment" + echo "variable to get set into environment." + sudo sh -c "echo export $VAR=$VAL >> /etc/profile.d/kicad.sh" + fi + + elif [ -e /etc/environment ]; then + if ! grep "$VAR" /etc/environment; then + echo + echo "Adding environment variable $VAR to file /etc/environment" + echo "Please reboot after this script completes for environment variable to get set into environment." + sudo sh -c "echo $VAR=$VAL >> /etc/environment" + fi + fi +} + + install_or_update() { echo "step 1) installing pre-requisites" @@ -231,9 +260,7 @@ install_or_update() echo 'All KiCad "--install-or-update" steps completed, you are up to date.' if [ -z "${KIGITHUB}" ]; then - echo "Please set an environment variable by adding:" - echo "export KIGITHUB=https://github.com/KiCad" - echo "to your ~/.bashrc file. Then reboot." + set_env_var KIGITHUB https://github.com/KiCad fi } diff --git a/scripts/library-repos-install.sh b/scripts/library-repos-install.sh index 71b3930f8f..2ec26f04f7 100755 --- a/scripts/library-repos-install.sh +++ b/scripts/library-repos-install.sh @@ -17,9 +17,10 @@ # on https://github.com using Github plugin. After running this script you should be able to # a) $ cp ~/kicad_sources/library-repos/kicad-library/template/fp-lib-table.for-pretty ~/fp-lib-table # and then -# b) set your environment variable KISYSMOD to "~/kicad_sources/library-repos" -# before starting pcbnew. This will use the KiCad plugin against the *.pretty dirs in that base dir. - +# b) set your environment variable KISYSMOD to "~/kicad_sources/library-repos". +# Edit /etc/profile.d/kicad.sh, then reboot. +# +# This will use the KiCad plugin against the *.pretty dirs in that base dir. # Set where the library repos will go, use a full path