Compare commits

...

3 Commits

@ -15,6 +15,7 @@ You can install shell scripts globally (on `${PREFIX:-/usr/local/bin}`) or use t
* [Usage](#usage)
* [Installing packages](#installing-packages)
* [Packages With Dependencies](#packages-with-dependencies)
* [Running packages with `bpkg`](#running-packages-with-bpkg)
* [Retrieving package info](#retrieving-package-info)
* [Package details](#package-details)
* [bpkg.json](#bpkgjson)
@ -24,11 +25,14 @@ You can install shell scripts globally (on `${PREFIX:-/usr/local/bin}`) or use t
* [global](#global)
* [install](#install-1)
* [scripts](#scripts)
* [files](#files)
* [files (optional)](#files-optional)
* [dependencies (optional)](#dependencies-optional)
* [commands (optional)](#commands-optional)
* [Packaging best practices](#packaging-best-practices)
* [Package exports](#package-exports)
* [Sponsors](#sponsors)
* [Contributors](#contributors)
* [Backers](#backers)
* [License](#license)
<!-- END-MARKDOWN-TOC -->
@ -240,9 +244,9 @@ This is an array of scripts that will be installed into a project.
"scripts": ["script.sh"]
```
### files
### files (optional)
This is an array of files that will be installed into a project.
This is an array of non-script files that will be installed into a project.
```json
"files": ["bar.txt", "foo.txt"]
@ -258,6 +262,23 @@ This is a hash of dependencies. The keys are the package names, and the values a
}
```
### commands (optional)
This is a hash of commands. The keys are the names of the commands and the values are the commands to execute in a shell. The commands can be called from the command line with `bpkg run` followed by the command name.
```json
"commands": {
"say-hello": "echo \"Hello $1\""
}
```
The commands are run with `eval`, which runs the command as if on the command line. Commands can contain environment variables, and supports [shell features] (including *[special parameters]* and *[shell expansions]*). Passed parameters (on the command line after the command name) can be accessed in the command by using `$@` or `$1`.
```bash
$ bpkg run say-hello "Bash Package Manager"
Hello Bash Package Manager
```
## Packaging best practices
These are guidelines that we strongly encourage developers to follow.

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

@ -1,9 +1,12 @@
#!/usr/bin/env bash
let install_dev=0
## output usage
usage () {
echo "Installs dependencies for a package."
echo "usage: bpkg-getdeps [-h|--help]"
echo " or: bpkg-getdeps [-d|--dev]"
echo " or: bpkg-getdeps"
}
@ -18,6 +21,11 @@ bpkg_getdeps () {
usage
return 0
;;
-d|--dev)
shift
install_dev=1
;;
esac
## ensure there is a package to read
@ -30,10 +38,17 @@ bpkg_getdeps () {
fi
# shellcheck disable=SC2002
dependencies=$(cat "${pkg}" | bpkg-json -b | grep '\[\"dependencies' | sed "s/\[\"dependencies\",//" | sed "s/\"\]$(printf '\t')\"/@/" | tr -d '"')
dependencies=$(cat "${pkg}" | bpkg-json -b | grep '\["dependencies"' | sed "s/\[\"dependencies\",//" | sed "s/\"\]$(printf '\t')\"/@/" | tr -d '"')
# shellcheck disable=SC2206
dependencies=(${dependencies[@]})
if (( 1 == install_dev )); then
# shellcheck disable=SC2002
dependencies_dev=$(cat "${pkg}" | bpkg-json -b | grep '\["dependencies-dev"' | sed "s/\[\"dependencies-dev\",//" | sed "s/\"\]$(printf '\t')\"/@/" | tr -d '"')
# shellcheck disable=SC2206
dependencies=(${dependencies[@]} ${dependencies_dev[@]})
fi
## run bpkg install for each dependency
for (( i = 0; i < ${#dependencies[@]} ; ++i )); do
(

@ -30,6 +30,7 @@ fi
bpkg_initrc
let prevent_prune=0
let install_dev=0
let force_actions=${BPKG_FORCE_ACTIONS:-0}
let needs_global=0
@ -42,10 +43,11 @@ validate_parameters () {
return 0
}
## outut usage
## output usage
usage () {
echo 'usage: bpkg-install [directory]'
echo ' or: bpkg-install [-h|--help]'
echo ' or: bpkg-install [-d|--dev]'
echo ' or: bpkg-install [-g|--global] [-f|--force] ...<package>'
echo ' or: bpkg-install [-g|--global] [-f|--force] ...<user>/<package>'
}
@ -192,6 +194,11 @@ bpkg_install () {
force_actions=1
;;
-d|--dev)
shift
install_dev=1
;;
--no-prune)
shift
prevent_prune=1
@ -211,9 +218,14 @@ bpkg_install () {
export BPKG_FORCE_ACTIONS=$force_actions
BPKG_DEPS_EXEC="bpkg_getdeps"
if (( 1 == install_dev )); then
BPKG_DEPS_EXEC="${BPKG_DEPS_EXEC} --dev"
fi
## ensure there is a package to install
if (( ${#pkgs[@]} == 0 )); then
bpkg_getdeps
${BPKG_DEPS_EXEC}
return $?
fi
@ -221,7 +233,7 @@ bpkg_install () {
for pkg in "${pkgs[@]}"; do
if test -d "$(bpkg_realpath "$pkg" 2>/dev/null)"; then
if ! (cd "$pkg" && bpkg_getdeps); then
if ! (cd "$pkg" && ${BPKG_DEPS_EXEC}); then
return 1
fi
@ -233,7 +245,7 @@ bpkg_install () {
local i=0
for remote in "${BPKG_REMOTES[@]}"; do
local git_remote=${BPKG_GIT_REMOTES[$i]}
if bpkg_install_from_remote "$pkg" "$remote" "$git_remote" $needs_global; then
if bpkg_install_from_remote "$pkg" "$remote" "$git_remote" $needs_global $install_dev; then
did_fail=0
break
elif [[ "$?" == '2' ]]; then
@ -262,6 +274,7 @@ bpkg_install_from_remote () {
local remote=$2
local git_remote=$3
local needs_global=$4
local install_dev=$5
local url=''
local uri=''
@ -506,7 +519,13 @@ bpkg_install_from_remote () {
# install package dependencies
info "Install dependencies for $name"
(cd "$BPKG_PACKAGE_DEPS/$name" && bpkg_getdeps)
BPKG_DEPS_EXEC="bpkg_getdeps"
if (( 1 == install_dev )); then
BPKG_DEPS_EXEC="${BPKG_DEPS_EXEC} --dev"
fi
(cd "$BPKG_PACKAGE_DEPS/$name" && ${BPKG_DEPS_EXEC})
## grab each script and place in deps directory
for script in "${scripts[@]}"; do

@ -9,7 +9,7 @@
# " ""
# bash package manager
VERSION="1.1.3"
VERSION="1.1.4"
TAG=${TAG:-$VERSION}
BRANCH=${BRANCH:-$TAG}
REMOTE=${REMOTE:-https://github.com/bpkg/bpkg.git}

Loading…
Cancel
Save