diff options
author | P. J. McDermott <pj@pehjota.net> | 2014-10-07 08:43:07 (EDT) |
---|---|---|
committer | P. J. McDermott <pj@pehjota.net> | 2014-10-07 08:43:07 (EDT) |
commit | 76862260820759798118e871a42b9e581b0ed89f (patch) | |
tree | 3003f27454e75c385e1ecd387ca69e65755e1608 /lib/cmd | |
parent | 5e3b8b78930d61d6f380edb84652f3a679dd9ffa (diff) |
cmd/build: Switch to using sessions
Diffstat (limited to 'lib/cmd')
-rw-r--r-- | lib/cmd/build.sh | 41 |
1 files changed, 14 insertions, 27 deletions
diff --git a/lib/cmd/build.sh b/lib/cmd/build.sh index 140ef4a..1d96a68 100644 --- a/lib/cmd/build.sh +++ b/lib/cmd/build.sh @@ -19,7 +19,7 @@ # <http://www.gnu.org/licenses/>. use profile -use chroot +use session use rand use package use control @@ -33,8 +33,7 @@ cmd_build_main() local first_arg= local prev_arg= local arg= - local dir= - local uname_s= + local session_dir= local build_deps= local f= @@ -81,47 +80,35 @@ cmd_build_main() package_init "${prev_arg}" package_set_substvars "${arch}" "${plat}" - rand - dir="/prokit/build.${rand_x}" - uname_s="$( (uname -s) 2>/dev/null)" || uname_s='unknown' - mkdir -p "${root}${dir}/pkg" - case "${uname_s}" in - 'Linux') - mount -o bind "${prev_arg}" "${root}${dir}/pkg" - ;; - esac + session_begin "${root}" "${prev_arg}" : + session_dir="$(session_dir)" build_deps="$(package_get_build_deps "${arch}" "${plat}")" if [ "x${build_deps}" != 'x' ]; then - mkdir -p "${root}${dir}/builddeps/control" \ - "${root}${dir}/builddeps/data" - cmd_build_make_deps_pkg "${root}${dir}" "${rand_x}" \ + mkdir -p "${root}${session_dir}/builddeps/control" \ + "${root}${session_dir}/builddeps/data" + cmd_build_make_deps_pkg "${root}${session_dir}" "$(session_id)" \ "${build_deps}" fi - chroot_exec "${root}" sh <<-EOF - cd '${dir}/pkg' + session_exec sh <<-EOF if [ 'x${build_deps}' != 'x' ]; then opkg install ../builddeps.opk fi opkbuild ${@} if [ 'x${build_deps}' != 'x' ]; then - opkg --autoremove remove prokit-builddeps-${rand_x} + opkg --autoremove remove prokit-builddeps-$(session_id) fi EOF - case "${uname_s}" in - 'Linux') - umount "${root}${dir}/pkg" - ;; - esac - rmdir "${root}${dir}/pkg" - rm -f "${root}${dir}/builddeps.opk" - for f in "${root}${dir}/"*; do + rm -f "${root}${session_dir}/builddeps.opk" + for f in "${root}${session_dir}/"*; do [ -e "${f}" ] || continue + [ "x${f##*/}" = 'xwd' ] && continue mv "${f}" "${prev_arg}/.." done - rmdir "${root}${dir}" + + session_end } cmd_build_make_deps_pkg() |