Skip to content

Commit ac4ff2f

Browse files
committed
Added dependencies.
1 parent afc9a88 commit ac4ff2f

2 files changed

Lines changed: 39 additions & 6 deletions

File tree

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
install:
2+
install -Dm755 pkg $(DESTDIR)/bin/pkg

pkg

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@
22

33
# shellcheck source=/dev/null
44

5+
log() {
6+
fmt="$1"
7+
shift
8+
# shellcheck disable=2059
9+
printf "\e[1m==> $fmt\e[m\n" "$@"
10+
}
11+
12+
error() {
13+
fmt="$2"
14+
errcode="$1"
15+
shift 2
16+
# shellcheck disable=2059
17+
printf "\e[1;31m$fmt\n" "$@"
18+
exit "$errcode"
19+
}
20+
521
pkg_search() {
622
IFS=:
723
for path in $PKG_PATH; do
@@ -36,6 +52,14 @@ pkg_build() {
3652
dir=$(pkg_search "$1")
3753
. "$dir/karafile"
3854

55+
# shellcheck disable=2154
56+
if [ -z "$depends" ]; then
57+
IFS=
58+
for pkg in $depends; do
59+
pkg -b "$pkg"
60+
pkg -i "$pkg"
61+
done
62+
fi
3963
builddir="/usr/pkg/build/$1-${version:?}"
4064
rootdir="/usr/pkg/root/$1-$version"
4165
mkdir "$builddir"
@@ -54,9 +78,7 @@ pkg_install() {
5478
dir=$(pkg_search "$1")
5579
. "$dir/karafile"
5680

57-
[ ! -d "/usr/pkg/root/$1-${version:?}" ] &&
58-
echo "Package not built" && exit 1
59-
81+
[ ! -d "/usr/pkg/root/$1-${version:?}" ] && error "Package not built"
6082
mkdir -p "/usr/pkg/manifests/$1/"
6183
echo "$version" > "/usr/pkg/manifests/$1/version"
6284
find "/usr/pkg/root/$1-$version" > "/usr/pkg/manifests/$1/files"
@@ -74,12 +96,21 @@ pkg_uninstall() {
7496

7597
case "$1" in
7698
-b)
77-
pkg_build "$2"
99+
shift
100+
for pkg in "$@"; do
101+
pkg_build "$pkg"
102+
done
78103
;;
79104
-i)
80-
pkg_install "$2"
105+
shift
106+
for pkg in "$@"; do
107+
pkg_install "$pkg"
108+
done
81109
;;
82110
-u)
83-
pkg_uninstall "$2"
111+
shift
112+
for pkg in "$@"; do
113+
pkg_uninstall "$pkg"
114+
done
84115
;;
85116
esac

0 commit comments

Comments
 (0)