Skip to content

Commit 42bfc19

Browse files
committed
add missing install script
1 parent bf8eee9 commit 42bfc19

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/bin/sh
2+
3+
# Installs module dependencies, streaming the package-manager output straight to
4+
# stdout (no buffering) so BackgroundTaskHelper captures it line by line and the
5+
# UI can show progress in real time. Unlike package-manager-call.sh this does NOT
6+
# wrap the result in JSON — it favours a live log over a structured result.
7+
#
8+
# Usage: dependency-installer.sh [--dest <target>] <dep1> [dep2 ...]
9+
10+
DEST=""
11+
12+
if [ -f /usr/bin/apk ]; then
13+
PM="apk"
14+
INSTALL="add"
15+
else
16+
PM="opkg"
17+
INSTALL="install"
18+
fi
19+
20+
while [ "$#" -gt 0 ]; do
21+
case "$1" in
22+
--dest)
23+
# apk has no per-destination install; only opkg honours --dest
24+
[ "$PM" = "opkg" ] && DEST="--dest $2"
25+
shift 2
26+
;;
27+
*)
28+
break
29+
;;
30+
esac
31+
done
32+
33+
DEPS="$@"
34+
35+
if [ -z "$DEPS" ]; then
36+
echo "No dependencies specified."
37+
exit 1
38+
fi
39+
40+
log() {
41+
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1"
42+
}
43+
44+
(
45+
flock -x 200
46+
47+
log "Updating package lists..."
48+
$PM update 2>&1
49+
50+
log "Installing: $DEPS"
51+
$PM $DEST $INSTALL $DEPS 2>&1
52+
code=$?
53+
54+
log "Finished with exit code $code."
55+
) 200>/tmp/ipkg.lock

0 commit comments

Comments
 (0)