mirror of
https://github.com/novatiq/packages.git
synced 2026-07-30 23:33:06 +01:00
rpcd-mod-packagelist: add package
Provides a way to acquire the list of installed packages without the need to have opkg available. It is being used for the GSoC 17 project implementing easy sysupgrade functionality. Signed-off-by: Paul Spooren <paul@spooren.de>
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"packagelist": {
|
||||
"description": "get list of installed software packages",
|
||||
"read": {
|
||||
"ubus": {
|
||||
"packagelist": [
|
||||
"list"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
#!/bin/sh
|
||||
|
||||
. /usr/share/libubox/jshn.sh
|
||||
|
||||
case "$1" in
|
||||
list)
|
||||
json_init
|
||||
json_add_object "list"
|
||||
json_dump
|
||||
;;
|
||||
call)
|
||||
case "$2" in
|
||||
list)
|
||||
json_init;
|
||||
json_add_object "packagelist"
|
||||
|
||||
if [ -f /usr/lib/opkg/status ]; then
|
||||
while read var p1 p2 p3; do
|
||||
if [ "$var" = "Package:" ]; then
|
||||
pkg="$p1"
|
||||
fi
|
||||
if [ "$var" = "Version:" ]; then
|
||||
version="$p1"
|
||||
fi
|
||||
|
||||
if [ "$var" = "Status:" \
|
||||
-a "$p1" = "install" \
|
||||
-a "$p2" = "user" \
|
||||
-a "$p3" = "installed" ]; then
|
||||
json_add_string "$pkg" "$version";
|
||||
fi
|
||||
done < /usr/lib/opkg/status
|
||||
fi
|
||||
|
||||
json_close_object
|
||||
json_dump
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
Reference in New Issue
Block a user