2014-05-25 19:32:14 +00:00
|
|
|
#!/bin/bash
|
2014-06-17 06:31:17 +00:00
|
|
|
#
|
|
|
|
# # #
|
|
|
|
# #mmm mmmm # m mmmm
|
|
|
|
# #" "# #" "# # m" #" "#
|
|
|
|
# # # # # #"# # #
|
|
|
|
# ##m#" ##m#" # "m "#m"#
|
|
|
|
# # m #
|
|
|
|
# " ""
|
|
|
|
# bash package manager
|
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-06-17 06:31:17 +00:00
|
|
|
echo " info: Checking for ${1}..."
|
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-06-17 06:31:17 +00:00
|
|
|
echo >&2 " error: Missing \`${f}'! Make sure it exists and try again."
|
2014-05-25 19:32:14 +00:00
|
|
|
return 1
|
|
|
|
}
|
|
|
|
done
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
## main setup
|
|
|
|
setup () {
|
2014-06-17 06:31:17 +00:00
|
|
|
echo " info: Welcome to the 'bpkg' installer!"
|
2014-05-25 19:32:14 +00:00
|
|
|
## 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
|
2014-10-19 19:47:29 +00:00
|
|
|
cd "${TMPDIR}"
|
2014-06-17 06:31:17 +00:00
|
|
|
echo " info: Creating temporary files..."
|
2014-10-19 19:47:29 +00:00
|
|
|
test -d "${DEST}" && { echo " warn: Already exists: '${DEST}'"; }
|
|
|
|
rm -rf "${DEST}"
|
2014-06-17 06:31:17 +00:00
|
|
|
echo " info: Fetching latest 'bpkg'..."
|
2014-10-19 19:47:29 +00:00
|
|
|
git clone --depth=1 "${REMOTE}" "${DEST}" > /dev/null 2>&1
|
|
|
|
cd "${DEST}"
|
2014-06-17 06:31:17 +00:00
|
|
|
echo " info: Installing..."
|
2014-05-25 19:32:14 +00:00
|
|
|
echo
|
|
|
|
make install
|
2014-09-23 00:04:40 +00:00
|
|
|
echo " info: Done!"
|
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
|
|
|
|