diff options
Diffstat (limited to 'lib/cmd/opkg.sh')
-rw-r--r-- | lib/cmd/opkg.sh | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/lib/cmd/opkg.sh b/lib/cmd/opkg.sh index 3016773..9f0c0de 100644 --- a/lib/cmd/opkg.sh +++ b/lib/cmd/opkg.sh @@ -19,15 +19,16 @@ # <http://www.gnu.org/licenses/>. use profile -use chroot +use session use rand +cmd_opkg_opks= + cmd_opkg_main() { local root= local first_arg= local install_cmd= - local opks= local arg= local new_fname= @@ -41,7 +42,7 @@ cmd_opkg_main() first_arg=true install_cmd=false - opks='' + cmd_opkg_opks='' for arg in "${@}"; do if ${first_arg}; then set -- @@ -56,7 +57,9 @@ cmd_opkg_main() fi rand new_fname="/tmp/prokit.${rand_x}.opk" - opks="${opks} ${root}${new_fname}" + cmd_opkg_opks="$(printf '%s %s\n' \ + "${cmd_opkg_opks}" \ + "${root}${new_fname}")" cp "${arg}" "${root}${new_fname}" set -- "${@}" "${new_fname}" ;; @@ -75,11 +78,22 @@ cmd_opkg_main() . "${root}/etc/os-release" profile_set "${ID}" - chroot_exec "${root}" opkg "${@}" + session_begin "${root}" . cmd_opkg_fini false + + session_exec opkg "${@}" - case "${opks}" in + cmd_opkg_fini + session_end +} + +cmd_opkg_fini() +{ + case "${cmd_opkg_opks}" in *[!\ ]*) - rm -f ${opks} + rm -f ${cmd_opkg_opks} + # Hack to avoid this code branch if the function is + # called again in response to a signal. + cmd_opkg_opks='' ;; esac } |