_('Waiting for the <em>opkg %h</em> command to complete…').format(cmd))
]);
- var argv = [ '--force-removal-of-dependent-packages' ];
+ var argv = [ cmd, '--force-removal-of-dependent-packages' ];
if (rem && rem.checked)
argv.push('--autoremove');
if (owr && owr.checked)
argv.push('--force-overwrite');
- argv.push(cmd);
-
if (pkg != null)
argv.push(pkg);
- fs.exec('/bin/opkg', argv).then(function(res) {
+ fs.exec_direct('/usr/libexec/opkg-call', argv, 'json').then(function(res) {
dlg.removeChild(dlg.lastChild);
if (res.stdout)
{
return Promise.all([
callMountPoints(),
- fs.exec_direct('/usr/libexec/opkg-list', [ 'available' ]),
- fs.exec_direct('/usr/libexec/opkg-list', [ 'installed' ])
+ fs.exec_direct('/usr/libexec/opkg-call', [ 'list-available' ]),
+ fs.exec_direct('/usr/libexec/opkg-call', [ 'list-installed' ])
]);
}
--- /dev/null
+#!/bin/sh
+
+. /usr/share/libubox/jshn.sh
+
+action=$1
+shift
+
+case "$action" in
+ list-installed)
+ cat /usr/lib/opkg/status
+ ;;
+ list-available)
+ lists_dir=$(sed -rne 's#^lists_dir \S+ (\S+)#\1#p' /etc/opkg.conf /etc/opkg/*.conf 2>/dev/null | tail -n 1)
+ find "${lists_dir:-/tmp/opkg-lists}" -type f '!' -name '*.sig' | xargs -r gzip -cd
+ ;;
+ install|update|remove)
+ (
+ opkg="opkg"
+
+ while [ -n "$1" ]; do
+ case "$1" in
+ --autoremove|--force-overwrite|--force-removal-of-dependent-packages)
+ opkg="$opkg $1"
+ shift
+ ;;
+ -*)
+ shift
+ ;;
+ *)
+ break
+ ;;
+ esac
+ done
+
+ if flock -x 200; then
+ $opkg $action "$@" </dev/null >/tmp/opkg.out 2>/tmp/opkg.err
+ code=$?
+ stdout=$(cat /tmp/opkg.out)
+ stderr=$(cat /tmp/opkg.err)
+ else
+ code=255
+ stderr="Failed to acquire lock"
+ fi
+
+ json_init
+ json_add_int code $code
+ [ -n "$stdout" ] && json_add_string stdout "$stdout"
+ [ -n "$stderr" ] && json_add_string stderr "$stderr"
+ json_dump
+ ) 200>/tmp/opkg.lock
+
+ rm -f /tmp/opkg.lock /tmp/opkg.err /tmp/opkg.out
+ ;;
+ *)
+ echo "Usage: $0 {list-installed|list-available}" >&2
+ echo " $0 {install|upgrade|remove} pkg[ pkg...]" >&2
+ exit 1
+ ;;
+esac
+++ /dev/null
-#!/bin/sh
-
-case "$1" in
- installed)
- cat /usr/lib/opkg/status
- ;;
- available)
- lists_dir=$(sed -rne 's#^lists_dir \S+ (\S+)#\1#p' /etc/opkg.conf /etc/opkg/*.conf 2>/dev/null | tail -n 1)
- find "${lists_dir:-/tmp/opkg-lists}" -type f '!' -name '*.sig' | xargs -r gzip -cd
- ;;
- *)
- echo "Usage: $0 {installed|available}" >&2
- exit 1
- ;;
-esac
"read": {
"cgi-io": [ "exec" ],
"file": {
- "/usr/libexec/opkg-list installed": [ "exec" ],
- "/usr/libexec/opkg-list available": [ "exec" ],
+ "/usr/libexec/opkg-call list-installed": [ "exec" ],
+ "/usr/libexec/opkg-call list-available": [ "exec" ],
"/etc/opkg.conf": [ "read" ],
"/etc/opkg/*.conf": [ "read" ]
},
},
"write": {
"file": {
- "/bin/opkg * install *": [ "exec" ],
- "/bin/opkg * remove *": [ "exec" ],
- "/bin/opkg * update": [ "exec" ],
+ "/usr/libexec/opkg-call install *": [ "exec" ],
+ "/usr/libexec/opkg-call remove *": [ "exec" ],
+ "/usr/libexec/opkg-call update *": [ "exec" ],
"/etc/opkg.conf": [ "write" ],
"/etc/opkg/*.conf": [ "write" ],
"/tmp/upload.ipk": [ "write" ]