You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
632 B

  1. #!/bin/sh
  2. . /usr/share/libubox/jshn.sh
  3. case "$1" in
  4. list)
  5. json_init
  6. json_add_object "list"
  7. json_dump
  8. ;;
  9. call)
  10. case "$2" in
  11. list)
  12. json_init;
  13. json_add_object "packagelist"
  14. if [ -f /usr/lib/opkg/status ]; then
  15. while read var p1 p2 p3; do
  16. if [ "$var" = "Package:" ]; then
  17. pkg="$p1"
  18. fi
  19. if [ "$var" = "Version:" ]; then
  20. version="$p1"
  21. fi
  22. if [ "$var" = "Status:" \
  23. -a "$p1" = "install" \
  24. -a "$p2" = "user" \
  25. -a "$p3" = "installed" ]; then
  26. json_add_string "$pkg" "$version";
  27. fi
  28. done < /usr/lib/opkg/status
  29. fi
  30. json_close_object
  31. json_dump
  32. ;;
  33. esac
  34. ;;
  35. esac