From 8585983ef27e1ebad1edad0f6a9da818eb1c2422 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Fri, 29 Aug 2014 10:31:37 -0400 Subject: build: Parse and install build dependencies --- (limited to 'lib/cmd') 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 .) -- cgit v0.9.1