summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/cmd/build.sh40
1 files changed, 37 insertions, 3 deletions
diff --git a/lib/cmd/build.sh b/lib/cmd/build.sh
index 4a33b2d..33b7e97 100644
--- a/lib/cmd/build.sh
+++ b/lib/cmd/build.sh
@@ -21,6 +21,9 @@
use profile
use chroot
use rand
+use control
+
+cmd_build_deps=
cmd_build_main()
{
@@ -70,13 +73,20 @@ cmd_build_main()
;;
esac
- cmd_build_make_deps_pkg "${root}${dir}" "${rand_x}"
+ cmd_build_get_deps "${root}${dir}/pkg"
+ if [ "x${cmd_build_deps}" != 'x' ]; then
+ cmd_build_make_deps_pkg "${root}${dir}" "${rand_x}"
+ fi
chroot_exec "${root}" sh <<-EOF
cd '${dir}/pkg'
- opkg install ../builddeps.opk
+ if [ 'x${cmd_build_deps}' != 'x' ]; then
+ opkg install ../builddeps.opk
+ fi
opkbuild ${@}
- opkg remove prokit-builddeps-${rand_x}
+ if [ 'x${cmd_build_deps}' != 'x' ]; then
+ opkg remove prokit-builddeps-${rand_x}
+ fi
EOF
case "${uname_s}" in
@@ -92,6 +102,29 @@ cmd_build_main()
rmdir "${root}${dir}"
}
+cmd_build_get_deps()
+{
+ local pkg_dir="${1}"
+
+ cmd_build_deps=''
+ parse_control "${pkg_dir}/control" cmd_build_deps_field_cb false ''
+}
+
+cmd_build_deps_field_cb()
+{
+ local name="${1}"
+ local value="${2}"
+
+ name="$(printf '%s\n' "${name}" | tr 'A-Z' 'a-z')"
+
+ if [ "x${name}" = 'xbuild-depends' ]; then
+ cmd_build_deps="${value}"
+ return 1
+ fi
+
+ return 0
+}
+
cmd_build_make_deps_pkg()
{
local build_dir="${1}"
@@ -104,6 +137,7 @@ cmd_build_make_deps_pkg()
Version: 1.0
Architecture: all
Platform: all
+ Depends: ${cmd_build_deps}
Description: Build dependencies metapackage generated by prokit
EOF
(cd "${build_dir}/builddeps/data"; tar -czf ../data.tar.gz .)