diff options
author | Ryan S. Arnold <ryan.arnold@linaro.org> | 2015-03-06 13:06:28 -0600 |
---|---|---|
committer | Ryan S. Arnold <ryan.arnold@linaro.org> | 2015-03-06 13:06:28 -0600 |
commit | bbfd25e049f65461b3a5cc4452f422bf7b02522b (patch) | |
tree | 647b4804085c194a9333260db52ffa964169bc63 /scripts | |
parent | 685a3e7cfd2b6b0d90dfd74bf9ede3fdf646c7c8 (diff) |
script/fedora_lsb_install.sh: New helper script to install LSB dependencies on Fedora systems.
Note: This commit regenerated abe/configure so existing build
directories will need to have configure re-run.
This commit adds a helper script that will install Linux Foundation
LSB dependencies on RPM based systems, since they're not packaged
by default.
This change required an update to configure since it changed
abe/configure.ac. The Linux Foundation LSB packages for Fedora
are installed in /opt/lsb, whereas the Ubuntu distribution will
install them in standard library locations.
abe/configure.ac was changed to allow it to find/detect lsbcc and
lsbc++ in the directories where the Linux Foundation LSB executables
will be installed.
Change-Id: I53155a79ccd8a61d9735dac44344e711860de5e3
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/fedora_lsb_install.sh | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/scripts/fedora_lsb_install.sh b/scripts/fedora_lsb_install.sh new file mode 100755 index 00000000..93c02878 --- /dev/null +++ b/scripts/fedora_lsb_install.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +# This script adds the Linux Foundation LSB RPM Repository to the system +# repositories list and then installs the LSB packages and keys. +# This script must be run as sudo + +# Bail if any shell invocation fails. +set -e + +root_UID=0 +LSB_ARCH="x86_64" +LSB_VER="4.1" + +# Only allow this script to be run by: sudo <script> and not as root or +# as the user. +if test -z $SUDO_USER; then + if test $UID = $root_UID; then + echo "Don't execute this script as root, use sudo!" + exit 1 + elif test $UID != $root_UID; then + echo "You don't have sufficient privileges to run this script. Run this script under sudo." + exit 1 + fi +fi + +remote_keyfile="http://ftp.linuxfoundation.org/pub/lsb/keys-for-rpm/lsb-${LSB_VER}-release-key.asc" + +# Always store this temporarily +tmpdir=$(su - $SUDO_USER -c "mktemp -d") +tmp_keyfile="${tmpdir}/$(basename ${remote_keyfile})" + +# Don't execute this command under root permissions. +# Using -o forces this to overwrite the file if it's been downloaded multiple +# times. +su - $SUDO_USER -c "wget --quiet ${remote_keyfile} --output-document=${tmp_keyfile}" + +# Looking for "PGP public key block" +if test $(file ${tmp_keyfile} | awk -F ' ' '{ print $2 }') != "PGP"; then + echo "Keyfile: ${tmp_keyfile} downloaded from ${remote_keyfile} is not a PGP public key block." + exit 1 +fi + +# rpm won't complain if the key is already imported. +rpm --import ${tmp_keyfile} + +# Remove the keyfile, no priveleged permissions necessary. Do it in stages so +# we don't have to use a force-recursive remove. +su - $SUDO_USER -c "rm ${tmp_keyfile}" +su - $SUDO_USER -c "rmdir ${tmpdir}" + +# This is the REPO we want +# http://ftp.linuxfoundation.org/pub/lsb/repositories/yum/lsb-4.1/lsb-4.1-x86_64.repo + +# Download the repomd files into /etc/yum.repos.d/ for the lsb rpms: +TOP="http://ftp.linuxfoundation.org/pub/lsb/repositories/yum/lsb-${LSB_VER}" +wget --quiet -O /etc/yum.repos.d/LSB-${LSB_VER}-${LSB_ARCH}.repo $TOP/lsb-${LSB_VER}-${LSB_ARCH}.repo + +# Update the repo with the new lsb repository but don't force a system update +yum --assumeyes --quiet makecache + +# This will install all of the lsb packages +yum --assumeyes install lsb-task-dist-testkit lsb-task-app-testkit lsb-task-sdk + +exit 0 |