Based on the tips from goldilocks' answer, I have come up with this little script which does exactly what I want and no more. It was written on and tested on Scientific Linux 6.3, but might work on other RHEL derivatives. I named the script redhat-lsb.sh (how uncreative).
#!/usr/bin/env bash
WKPKG=redhat-lsb
WKDIR=$HOME/$WKPKG
[[ -d "$WKDIR" ]] && [[ "x$1" != "x-f" ]] && { echo "ERROR: not removing $WKDIR. Use -f to force it."; exit 1; }
(
[[ -d "$WKDIR" ]] && rm -rf "$WKDIR"
mkdir "$WKDIR" && \
cd "$WKDIR" && \
yumdownloader $WKPKG && \
cd / && \
rpm2cpio "$WKDIR"/redhat-lsb-*.$(uname -m).rpm | cpio -idmv
) && rm -rf "$WKDIR"
Call as sudo ./redhat-lsb.sh or sudo ./redhat-lsb.sh -f (the latter removes the working directory if it already exists).
What this does is:
- uses a folder
$HOME/redhat-lsb to work in.
- uses
yumdownloader to download the package.
- uses shell globbing to pick the correct
.rpm: redhat-lsb-*.$(uname -m).rpm
- changes to
/ because this is where we want to install it
- uses
rpm2cpio to unpack it to stdout
cpio catches it and unpacks it into the current directory (this is the step that requires sudo)
- finally removes the working folder
And after that, great success ... it works ... without all the dependencies:
$ lsb_release -a
LSB Version: :core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: Scientific
Description: Scientific Linux release 6.3 (Carbon)
Release: 6.3
Codename: Carbon
Turns out the package itself only contains a single statically linked executable. The rest are shell scripts and data.