summaryrefslogtreecommitdiffstats
path: root/lib/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'lib/cmd')
-rw-r--r--lib/cmd/build.sh41
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()