Skip to content

Instantly share code, notes, and snippets.

@ihnorton
Last active November 7, 2019 03:05
Show Gist options
  • Save ihnorton/bafbf561a0a418885ae88f7c31fd45a8 to your computer and use it in GitHub Desktop.
Save ihnorton/bafbf561a0a418885ae88f7c31fd45a8 to your computer and use it in GitHub Desktop.
Installing devtoolset-3 without root
#!/bin/sh
# pull the listing
wget http://mirror.centos.org/centos/6/sclo/x86_64/rh/devtoolset-3/
# yank the hrefs
egrep -o 'href=\"(.*\.rpm)"' index.html | cut -d \" -f2 > rpm.list
# download them
for f in `cat rpm.list`;
do wget http://mirror.centos.org/centos/6/sclo/x86_64/rh/devtoolset-3/$f;
done
# extract them (will go to `./opt`)
# note we don't want all the eclipse stuff, just want the toolchain
# so we pull its requirements and install those.
for f in `rpm -qp ./devtoolset-3-toolchain-3.1-12.el6.x86_64.rpm --requires | grep devtoolset`; do
echo $f
fname=`ls $f*`
for fname in `ls $f*`; do # need to loop here for multiple matches
if [[ -a $fname ]]; then
rpm2cpio $fname | cpio -idmv
fi
done
done
# also need headers. This is normally pulled as require by gcc-c++
rpm2cpio devtoolset-3-libstdc++-devel-4.9.2-6.2.el6.x86_64.rpm | cpio -idmv
# now move it somewhere useful...
# we don't care about the eclipse stuff, that was deleted.
# in some HPC env these need to be unset so we don't accidentally pull in DSOs from
# either the default environment, or transitively from nomachine LD_PRELOAD libraries.
unset LD_PRELOAD
unset LD_LIBRARY_PATH
# General environment variables
#
export BASE=/path/to/devtoolset-3
export PATH=$BASE/root/usr/bin${PATH:+:${PATH}}
export MANPATH=$BASE/root/usr/share/man:${MANPATH}
export INFOPATH=$BASE/root/usr/share/info${INFOPATH:+:${INFOPATH}}
# bz847911 workaround:
# we need to evaluate rpm's installed run-time % { _libdir }, not rpmbuild time
# or else /etc/ld.so.conf.d files?
rpmlibdir=$(rpm --eval "%{_libdir}")
# bz1017604: On 64-bit hosts, we should include also the 32-bit library path.
if [ "$rpmlibdir" != "${rpmlibdir/lib64/}" ]; then
rpmlibdir32=":$BASE/root${rpmlibdir/lib64/lib}"
fi
export LD_LIBRARY_PATH=$BASE/root$rpmlibdir$rpmlibdir32${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment