chore(bpkg.json): 1.0.7

1.0.7
jwerle 2 years ago committed by Joseph Werle
parent 2b038c3ffe
commit ede72f9a05

@ -1,6 +1,6 @@
{
"name": "bpkg",
"version": "1.0.6",
"version": "1.0.7",
"description": "Lightweight bash package manager",
"global": true,
"repo": "bpkg/bpkg",

@ -7,7 +7,7 @@ if [[ ${BASH_SOURCE[0]} != "$0" ]]; then
fi
## bpkg version
VERSION="1.0.6"
VERSION="1.0.7"
## output error to stderr
error () {

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
#
# # #
# #mmm mmmm # m mmmm
@ -9,14 +9,17 @@
# " ""
# bash package manager
VERSION="1.0.7"
TAG=${TAG:-$VERSION}
BRANCH=${BRANCH:-$TAG}
REMOTE=${REMOTE:-https://github.com/bpkg/bpkg.git}
TMPDIR=${TMPDIR:-/tmp}
DEST=${DEST:-${TMPDIR}/bpkg-master}
DEST=${DEST:-$TMPDIR/bpkg-$BRANCH}
## test if command exists
ftest () {
echo " info: Checking for ${1}..."
if ! type -f "${1}" > /dev/null 2>&1; then
echo " info: Checking for $1..."
if ! type -f "$1" > /dev/null 2>&1; then
return 1
else
return 0
@ -26,8 +29,8 @@ ftest () {
## feature tests
features () {
for f in "${@}"; do
ftest "${f}" || {
echo >&2 " error: Missing \`${f}'! Make sure it exists and try again."
ftest "$f" || {
echo >&2 " error: Missing \`$f'! Make sure it exists and try again."
return 1
}
done
@ -43,13 +46,15 @@ setup () {
## build
{
echo
cd "${TMPDIR}" || exit
echo " info: Creating temporary files..."
test -d "${DEST}" && { echo " warn: Already exists: '${DEST}'"; }
rm -rf "${DEST}"
echo " info: Fetching latest 'bpkg'..."
git clone --depth=1 "${REMOTE}" "${DEST}" > /dev/null 2>&1
cd "${DEST}" || exit
cd "$TMPDIR" || exit
test -d "$DEST" && { echo " warn: Already exists: '$DEST'"; }
rm -rf "$DEST"
echo " info: Fetching 'bpkg@$BRANCH'..."
git clone --depth=1 --branch "$BRANCH" "$REMOTE" "$DEST" > /dev/null 2>&1
cd "$DEST" || exit
echo " info: Installing..."
echo
make_install
@ -61,7 +66,7 @@ setup () {
## make targets
BIN="bpkg"
if [ -z "$PREFIX" ]; then
if [ "$USER" == "root" ]; then
if [ "$(whoami)" == "root" ]; then
PREFIX="/usr/local"
else
PREFIX="$HOME/.local"
@ -69,7 +74,22 @@ if [ -z "$PREFIX" ]; then
fi
# All 'bpkg' supported commands
CMDS="json install package term suggest init utils update list show getdeps run source"
declare -a CMDS=()
CMDS+=("env")
CMDS+=("getdeps")
CMDS+=("init")
CMDS+=("install")
CMDS+=("json")
CMDS+=("list")
CMDS+=("package")
CMDS+=("run")
CMDS+=("show")
CMDS+=("source")
CMDS+=("suggest")
CMDS+=("term")
CMDS+=("update")
CMDS+=("utils")
CMDS+=("realpath")
make_install () {
local source
@ -83,17 +103,19 @@ make_install () {
if [ -f "$source" ]; then
install "$source" "$PREFIX/bin/$BIN"
else
install "$BIN" "$PREFIX/bin"
else
install "$BIN" "$PREFIX/bin"
fi
for cmd in $CMDS; do
source=$(<"$BIN-$cmd")
for cmd in "${CMDS[@]}"; do
if test -f "$BIN-$cmd"; then
source=$(<"$BIN-$cmd")
if [ -f "$source" ]; then
install "$source" "$PREFIX/bin/$BIN-$cmd"
else
install "$BIN-$cmd" "$PREFIX/bin"
if [ -f "$source" ]; then
install "$source" "$PREFIX/bin/$BIN-$cmd"
else
install "$BIN-$cmd" "$PREFIX/bin"
fi
fi
done
@ -101,20 +123,28 @@ make_install () {
}
make_uninstall () {
echo " info: Uninstalling $PREFIX/bin/$BIN..."
echo " info: Uninstalling $PREFIX/bin/$BIN*"
echo " rm: $PREFIX/bin/$BIN'"
rm -f "$PREFIX/bin/$BIN"
for cmd in $CMDS; do
rm -f "$PREFIX/bin/$BIN-$cmd"
for cmd in "${CMDS[@]}"; do
if test -f "$PREFIX/bin/$BIN-$cmd"; then
echo " rm: $PREFIX/bin/$BIN-$cmd'"
rm -f "$PREFIX/bin/$BIN-$cmd"
fi
done
return $?
}
make_link () {
make_uninstall
echo " info: Linking $PREFIX/bin/$BIN..."
echo " info: Linking $PREFIX/bin/$BIN*"
echo " link: '$PWD/$BIN' -> '$PREFIX/bin/$BIN'"
ln -s "$PWD/$BIN" "$PREFIX/bin/$BIN"
for cmd in $CMDS; do
ln -s "$PWD/$BIN-$cmd" "$PREFIX/bin"
for cmd in "${CMDS[@]}"; do
if test -f "$PWD/$BIN-$cmd"; then
echo " link: '$PWD/$BIN-$cmd' -> '$PREFIX/bin/$BIN-$cmd'"
ln -s "$PWD/$BIN-$cmd" "$PREFIX/bin/$BIN-$cmd"
fi
done
return $?
}

Loading…
Cancel
Save