blob: a09fee44915d38fd2f5e7f17a7679519d50fb7ac (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
#!/usr/bin/env zsh
set -e
BIN="$0"
OPERATION="$1"
REPO="$2"
PKG="$3"
syntax() {
echo -e "\x1b[0;91mSyntax: $BIN <add|del|readd> <REPONAME> <PKG>\x1b[0m" 1>&2; exit 1;
}
if [[ "$REPO" == "" ]]; then syntax; fi
if [[ "$PKG" == "" ]]; then syntax; fi
if ! [[ -f "src/$REPO/$PKG/APKBUILD" ]]; then
echo -e "\x1b[0;91mThe package $PKG does not exist in $REPO in the current source tree.\x1b[0m" 1>&2; exit 1;
fi
if ! ls "target/$REPO/"*"/$PKG"*".apk" > /dev/null 2>/dev/null; then
echo -e "\x1b[0;91mThe package $PKG does not exist in $REPO in the current target, yet does exist in the source tree. Try building it.\x1b[0m" 1>&2; exit 1;
fi
if [[ "$OPERATION" == "readd" ]]; then
sudo apk del "$PKG";
sudo apk add --repository "$(busybox dirname "$(busybox realpath "$BIN")")/target/$REPO" "$PKG";
elif [[ "$OPERATION" == "del" ]]; then
sudo apk del "$PKG";
elif [[ "$OPERATION" == "add" ]]; then
sudo apk add --repository "$(busybox dirname "$(busybox realpath "$BIN")")/target/$REPO" "$PKG";
else
syntax;
fi
|