Branch
Hash :
029b8a31
Author :
Thomas de Grivel
Date :
2023-02-23T00:05:16
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
#!/bin/sh
set -e
usage () {
{
echo 'Usage :'
echo ' rbpkg_bootstrap [-f] [RBPKG_DIR]'
echo ' RBPKG_DIR=~/rbpkg rbpkg_bootstrap [-f]'
echo ' Installs rbpkg into RBPKG_DIR.'
echo 'Options :'
echo ' -f Clear RBPKG_DIR before installing.'
echo 'Environment variables :'
echo ' HOME Home directory.'
echo ' PATH Binaries path.'
echo ' RBPKG_DIR Target installation directory.'
} >&2
exit 1
}
# config
FORCE=No
while [ $# -gt 0 ]; do
if [ "x$1" = "x-h" ]; then
usage
elif [ "x$1" = "x-f" ]; then
FORCE=Yes
shift
else
RBPKG_DIR="$1"
shift
fi
done
if [ "x${RBPKG_DIR}" = "x" ]; then
if [ "x${HOME}" = "x" ]; then
echo "HOME is not set" >&2
exit 1
fi
RBPKG_DIR="${HOME}/rbpkg"
fi
# clone
if [ -d "${RBPKG_DIR}" ]; then
if [ "x$FORCE" = "xYes" ]; then
rm -rf "${RBPKG_DIR}"
git clone https://git.kmx.io/kmx.io/rbpkg.git "${RBPKG_DIR}"
fi
else
git clone https://git.kmx.io/kmx.io/rbpkg.git "${RBPKG_DIR}"
fi
# profile
mkdir -p "${RBPKG_DIR}/etc"
{
cat <<EOF
# rbpkg
: \${RBPKG_DIR:=$(cd "${RBPKG_DIR}" && pwd)}
export RBPKG_DIR
# runtime
export PATH="\${RBPKG_DIR}/bin:\${PATH}"
export LD_LIBRARY_PATH="\${RBPKG_DIR}/lib:${LD_LIBRARY_PATH}"
# compile time
export CPPFLAGS="${CPPFLAGS} -I\${RBPKG_DIR}/include"
export LDFLAGS="${LDFLAGS} -L\${RBPKG_DIR}/lib"
export PKG_CONFIG_PATH="\${RBPKG_DIR}/lib/pkgconfig"
EOF
} > "${RBPKG_DIR}/etc/profile"
# source profile
echo ". ${RBPKG_DIR}/etc/profile"
. "${RBPKG_DIR}/etc/profile"