diff options
author | jmmv <jmmv> | 2012-08-23 02:26:56 +0000 |
---|---|---|
committer | jmmv <jmmv> | 2012-08-23 02:26:56 +0000 |
commit | ba3a65ec559ed647bc9bb5171fe3191a031e134c (patch) | |
tree | e877781f3c1dcd88c2c378062a437dc293eec79f | |
parent | cebd0117ed6740bb5249eef57699a4e7e3f75f95 (diff) | |
download | pkgsrc-ba3a65ec559ed647bc9bb5171fe3191a031e134c.tar.gz |
Update to 2.2:
- Add support to specify per-machine targets by prefixing the targets in
BUILD_TARGETS by the machine they correspond to. Useful, for example,
to build different kernels depending on the machine type.
-rw-r--r-- | sysutils/sysbuild/Makefile | 4 | ||||
-rw-r--r-- | sysutils/sysbuild/files/sysbuild.1 | 7 | ||||
-rw-r--r-- | sysutils/sysbuild/files/sysbuild.sh | 51 | ||||
-rw-r--r-- | sysutils/sysbuild/files/sysbuild_test.sh | 86 |
4 files changed, 142 insertions, 6 deletions
diff --git a/sysutils/sysbuild/Makefile b/sysutils/sysbuild/Makefile index 22173716da3..9eefce040e5 100644 --- a/sysutils/sysbuild/Makefile +++ b/sysutils/sysbuild/Makefile @@ -1,6 +1,6 @@ -# $NetBSD: Makefile,v 1.19 2012/08/15 21:20:14 jmmv Exp $ +# $NetBSD: Makefile,v 1.20 2012/08/23 02:26:56 jmmv Exp $ -DISTNAME= sysbuild-2.1 +DISTNAME= sysbuild-2.2 CATEGORIES= sysutils MASTER_SITES= # empty DISTFILES= # empty diff --git a/sysutils/sysbuild/files/sysbuild.1 b/sysutils/sysbuild/files/sysbuild.1 index 9575002ff10..ca6c16e4ceb 100644 --- a/sysutils/sysbuild/files/sysbuild.1 +++ b/sysutils/sysbuild/files/sysbuild.1 @@ -1,4 +1,4 @@ -.\" $NetBSD: sysbuild.1,v 1.3 2012/08/11 19:32:50 wiz Exp $ +.\" $NetBSD: sysbuild.1,v 1.4 2012/08/23 02:26:57 jmmv Exp $ .\" Copyright 2012 Google Inc. .\" All rights reserved. .\" @@ -26,7 +26,7 @@ .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -.Dd July 25, 2012 +.Dd August 22, 2012 .Dt SYSBUILD 1 .Os .Sh NAME @@ -301,6 +301,9 @@ The following variables configure the build process: Whitespace-separated list of targets to pass to .Nm build.sh during builds. +Targets can be prefixed by a machine name and a colon, in which case they only +apply to that machine; for example, +.Sq macppc:kernel=${HOME}/CUSTOM macppc:releasekernel=${HOME}/CUSTOM . .Pp Default: .Sq release . diff --git a/sysutils/sysbuild/files/sysbuild.sh b/sysutils/sysbuild/files/sysbuild.sh index 8560c0b7136..014d8a2356b 100644 --- a/sysutils/sysbuild/files/sysbuild.sh +++ b/sysutils/sysbuild/files/sysbuild.sh @@ -32,6 +32,7 @@ shtk_import cli shtk_import config shtk_import cvs +shtk_import list shtk_import process @@ -100,6 +101,27 @@ do_one_build() { Xflag="-X$(shtk_config_get XSRCDIR)" fi + local targets= + for target in $(shtk_config_get BUILD_TARGETS); do + case "${target}" in + *:*) + local submachine="$(echo "${target}" | cut -d : -f 1)" + local subtarget="$(echo "${target}" | cut -d : -f 2-)" + if [ "${submachine}" = "${machine}" ]; then + targets="${targets} ${subtarget}" + else + # The targets have already been validated, so there is + # nothing to do in this case. + : + fi + ;; + + *) + targets="${targets} ${target}" + ;; + esac + done + ( cd "$(shtk_config_get SRCDIR)" && shtk_process_run ./build.sh \ -D"${basedir}/destdir" \ -M"${basedir}/obj" \ @@ -112,7 +134,7 @@ do_one_build() { -m"${machine}" \ ${uflag} \ ${xflag} \ - $(shtk_config_get BUILD_TARGETS) ) + ${targets} ) } @@ -136,11 +158,36 @@ sysbuild_build() { [ ${#} -eq 0 ] || shtk_config_set BUILD_TARGETS "${*}" + local machines="$(shtk_config_get MACHINES)" + + # Ensure that the list of targets reference valid machines, if any. + local unmatched_targets= + for target in $(shtk_config_get BUILD_TARGETS); do + case "${target}" in + *:*) + local submachine="$(echo "${target}" | cut -d : -f 1)" + if ! shtk_list_contains "${submachine}" ${machines}; then + if [ -n "${unmatched_targets}" ]; then + unmatched_targets="${unmatched_targets} ${target}" + else + unmatched_targets="${target}" + fi + fi + ;; + + *) + ;; + esac + done + [ -z "${unmatched_targets}" ] || shtk_cli_error \ + "The '${unmatched_targets}' targets do not match any machine" \ + "in '${machines}'" + if shtk_config_get_bool UPDATE_SOURCES; then sysbuild_fetch fi - for machine in $(shtk_config_get MACHINES); do + for machine in ${machines}; do do_one_build "${machine}" done } diff --git a/sysutils/sysbuild/files/sysbuild_test.sh b/sysutils/sysbuild/files/sysbuild_test.sh index c06bd39111b..41c7c2e464a 100644 --- a/sysutils/sysbuild/files/sysbuild_test.sh +++ b/sysutils/sysbuild/files/sysbuild_test.sh @@ -306,6 +306,90 @@ EOF } +atf_test_case build__machine_targets__ok +build__machine_targets__ok_body() { + create_mock_cvsroot "${MOCK_CVSROOT}" + + create_mock_binary cvs yes + PATH="$(pwd):${PATH}" + + atf_check -o save:stdout -e save:stderr sysbuild \ + -c /dev/null -o CVSROOT="${MOCK_CVSROOT}" \ + -o MACHINES="amd64 macppc shark" -o NJOBS=2 build \ + tools macppc:kernel=/foo/bar shark:sets release +cat stdout + cat >expout <<EOF +Command: cvs +Directory: ${HOME}/sysbuild/src/.cvs-checkout +Arg: -d${MOCK_CVSROOT} +Arg: -q +Arg: checkout +Arg: -P +Arg: src + +Command: build.sh +Directory: ${HOME}/sysbuild/src +Arg: -D${HOME}/sysbuild/amd64/destdir +Arg: -M${HOME}/sysbuild/amd64/obj +Arg: -N2 +Arg: -R${HOME}/sysbuild/release +Arg: -T${HOME}/sysbuild/amd64/tools +Arg: -U +Arg: -j2 +Arg: -mamd64 +Arg: tools +Arg: release + +Command: build.sh +Directory: ${HOME}/sysbuild/src +Arg: -D${HOME}/sysbuild/macppc/destdir +Arg: -M${HOME}/sysbuild/macppc/obj +Arg: -N2 +Arg: -R${HOME}/sysbuild/release +Arg: -T${HOME}/sysbuild/macppc/tools +Arg: -U +Arg: -j2 +Arg: -mmacppc +Arg: tools +Arg: kernel=/foo/bar +Arg: release + +Command: build.sh +Directory: ${HOME}/sysbuild/src +Arg: -D${HOME}/sysbuild/shark/destdir +Arg: -M${HOME}/sysbuild/shark/obj +Arg: -N2 +Arg: -R${HOME}/sysbuild/release +Arg: -T${HOME}/sysbuild/shark/tools +Arg: -U +Arg: -j2 +Arg: -mshark +Arg: tools +Arg: sets +Arg: release + +EOF + atf_check -o file:expout cat commands.log +} + + +atf_test_case build__machine_targets__unmatched +build__machine_targets__unmatched_body() { + create_mock_binary cvs yes + PATH="$(pwd):${PATH}" + + cat >experr <<EOF +sysbuild: E: The 'macpp:kernel=/foo/bar a:b' targets do not match any machine in 'amd64 macppc shark' +EOF + atf_check -s exit:1 -o empty -e file:experr sysbuild \ + -c /dev/null -o CVSROOT="${MOCK_CVSROOT}" \ + -o MACHINES="amd64 macppc shark" -o NJOBS=2 build \ + tools macpp:kernel=/foo/bar a:b release + + test ! -f commands.log || atf_fail "cvs should not have been executed" +} + + atf_test_case build__with_x11 build__with_x11_body() { create_mock_cvsroot "${MOCK_CVSROOT}" @@ -655,6 +739,8 @@ atf_init_test_cases() { atf_add_test_case build__remove_all atf_add_test_case build__fast_mode atf_add_test_case build__many_machines + atf_add_test_case build__machine_targets__ok + atf_add_test_case build__machine_targets__unmatched atf_add_test_case build__with_x11 atf_add_test_case build__some_args |