Compare commits

...

2 Commits

Author SHA1 Message Date
jwerle 4176a848e2 chore(): 1.0.8 2 years ago
jwerle 1ef61603b0 fix(): fix broken environment variables 2 years ago

@ -1,6 +1,6 @@
{
"name": "bpkg",
"version": "1.0.7",
"version": "1.0.8",
"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.7"
VERSION="1.0.8"
## output error to stderr
error () {

29
lib/env/env.sh vendored

@ -1,14 +1,5 @@
#!/usr/bin/env bash
if ! type -f bpkg-utils &>/dev/null; then
echo "error: bpkg-utils not found, aborting"
exit 1
else
# shellcheck disable=SC2230
# shellcheck source=lib/utils/utils.sh
source "$(which bpkg-utils)"
fi
if ! type -f bpkg-package &>/dev/null; then
echo "error: bpkg-package not found, aborting"
exit 1
@ -18,8 +9,6 @@ else
source "$(which bpkg-package)"
fi
bpkg_initrc
# Include config rc file if found
BPKG_USER_CONFIG_FILE="$HOME/.bpkgrc"
@ -29,13 +18,18 @@ BPKG_LOCAL_CONFIG_FILE="$(pwd)/.bpkgrc"
## meta
export BPKG_DATE="$(date)"
export BPKG_HOME="${BPKG_HOME:-$HOME}"
export BPKG_INDEX="$BPKG_INDEX"
export BPKG_INDEX
## os
export BPKG_OS="$(uname)"
export BPKG_CWD="$(pwd)"
export BPKG_BIN="$(which bpkg)"
export BPKG_USER="$USER"
export BPKG_BIN="${BPKG_BIN:-$(which bpkg)}"
export BPKG_USER="${BPKG_USER:-$USER}"
## git
export BPKG_REMOTES
export BPKG_GIT_REMOTE
export BPKG_GIT_REMOTES
## package
export BPKG_PACKAGE_USER
@ -44,12 +38,13 @@ export BPKG_PACKAGE_REPO="$(bpkg_package repo 2>/dev/null)"
export BPKG_PACKAGE_DEPS="${BPKG_PACKAGE_DEPS:-deps}"
export BPKG_PACKAGE_VERSION="$(bpkg_package version 2>/dev/null)"
export BPKG_PACKAGE_DESCRIPTION="$(bpkg_package description 2>/dev/null)"
export BPKG_PACKAGE_DEFAULT_USER="${BPKG_PACKAGE_DEFAULT_USER:-bpkg}"
## remote
export BPKG_REMOTE="$BPKG_REMOTE"
# shellcheck disable=SC2178
export BPKG_REMOTES="${BPKG_REMOTE[*]}"
export BPKG_REMOTE_RAW_PATH="$BPKG_REMOTE_RAW_PATH"
export BPKG_REMOTE
export BPKG_REMOTES
export BPKG_REMOTE_RAW_PATH
if test -f bpkg.json || test -f package.json; then
declare -a BPKG_SCRIPT_SOURCES=()

@ -1,14 +1,16 @@
#!/usr/bin/env bash
if ! type -f bpkg-env &>/dev/null; then
echo "error: bpkg-env not found, aborting"
if ! type -f bpkg-utils &>/dev/null; then
echo "error: bpkg-utils not found, aborting"
exit 1
else
# shellcheck disable=SC2230
# shellcheck source=lib/env/env.sh
source "$(which bpkg-env)"
# shellcheck source=lib/utils/utils.sh
source "$(which bpkg-utils)"
fi
bpkg_initrc
let prevent_prune=0
## check parameter consistency
@ -173,6 +175,7 @@ bpkg_install () {
shift
needs_global=1
;;
--no-prune)
shift
prevent_prune=1

@ -10,7 +10,7 @@ usage () {
## main
suggest () {
local found paths seen
local found paths seen find_supports_maxdepth
declare -a paths=()
declare -a seen=()
declare -a found=()
@ -35,6 +35,12 @@ suggest () {
;;
esac
if find --help 2>/dev/null | grep 'maxdepth'; then
find_supports_maxdepth=1
else
find_supports_maxdepth=0
fi
## search path
{
local res=""
@ -63,16 +69,20 @@ suggest () {
## mark seen
seen+=("$path")
if (( find_supports_maxdepth == 1 )); then
res=$(find "$path" -name "$query*" -prune -print -maxdepth 1 2>/dev/null | tr '\n' ' ');
else
res=$(find "$path" -name "$query*" -prune -print >/dev/null | tr '\n' ' ');
fi
## find in path
if res=$(find "$path" -name "$query*" -prune -print 2>/dev/null); then
if [ -z "$res" ]; then
continue
fi
res="$(echo "$res" | tr '\n' ' ')"
## add to found count
# shellcheck disable=SC2207
found+=($(echo -n "$res"))
if [ -z "$res" ]; then
continue
fi
## add to found count
# shellcheck disable=SC2207
found+=($(echo -n "$res"))
done
}

@ -1,5 +1,14 @@
#!/usr/bin/env bash
if ! type -f bpkg-env &>/dev/null; then
echo "error: bpkg-env not found, aborting"
exit 1
else
# shellcheck disable=SC2230
# shellcheck source=lib/env/env.sh
source "$(which bpkg-env)"
fi
## Collection of shared bpkg functions
## Init local config and set environmental defaults

@ -9,14 +9,17 @@
# " ""
# bash package manager
VERSION="1.0.8"
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"
@ -84,6 +89,7 @@ CMDS+=("suggest")
CMDS+=("term")
CMDS+=("update")
CMDS+=("utils")
CMDS+=("realpath")
make_install () {
local source
@ -97,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")
if [ -f "$source" ]; then
install "$source" "$PREFIX/bin/$BIN-$cmd"
else
install "$BIN-$cmd" "$PREFIX/bin"
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"
fi
fi
done
@ -115,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"
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"
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