2
0
mirror of https://github.com/bpkg/bpkg synced 2024-11-08 01:10:36 +00:00
bpkg/install.sh

54 lines
867 B
Bash
Raw Normal View History

2014-05-25 19:32:14 +00:00
#!/bin/bash
2014-05-25 19:35:44 +00:00
VERSION="0.0.1"
2014-05-25 19:32:14 +00:00
REMOTE=${REMOTE:-https://github.com/bpkg/bpkg.git}
TMPDIR=${TMPDIR:-/tmp}
DEST=${DEST:-${TMPDIR}/bpkg-master}
## test if command exists
ftest () {
2014-05-25 19:35:44 +00:00
if ! type -f "${1}" > /dev/null 2>&1; then
2014-05-25 19:32:14 +00:00
return 1
else
return 0
fi
}
## feature tests
features () {
for f in "${@}"; do
2014-05-25 20:34:13 +00:00
ftest "${f}" || {
2014-05-25 19:35:44 +00:00
echo >&2 " error: Missing \`${f}'"
2014-05-25 19:32:14 +00:00
return 1
}
done
return 0
}
## main setup
setup () {
## test for require features
2014-05-25 20:34:13 +00:00
features git || return $?
2014-05-25 19:32:14 +00:00
2014-05-25 19:35:44 +00:00
## build
{
2014-05-25 19:32:14 +00:00
echo
cd ${TMPDIR}
echo " info: pruning..."
test -d ${DEST} && { echo " warn: exists: \`${DEST}'"; }
rm -rf ${DEST}
echo " info: fetching..."
git clone --depth=1 ${REMOTE} ${DEST} > /dev/null 2>&1
cd ${DEST}
echo " info: installing..."
echo
make install
2014-05-25 19:35:44 +00:00
} >&2
2014-05-25 19:32:14 +00:00
return $?
}
2014-05-25 19:35:44 +00:00
## go
2014-05-25 19:32:14 +00:00
setup
exit $?
2014-05-25 19:35:44 +00:00