diff options
author | jmmv <jmmv@pkgsrc.org> | 2013-07-28 23:32:58 +0000 |
---|---|---|
committer | jmmv <jmmv@pkgsrc.org> | 2013-07-28 23:32:58 +0000 |
commit | 06451ac2a67cac6561933bd49ae1ae9a80e0d449 (patch) | |
tree | 9f2504a1ee0ebc6f251167e576fd8031aee5e072 /sysutils/sysbuild | |
parent | 10f8a1f5d0ea9e4de6325927f725b1882dcc6213 (diff) | |
download | pkgsrc-06451ac2a67cac6561933bd49ae1ae9a80e0d449.tar.gz |
Update to 2.7:
Released on 2013-07-28.
* Sources migrated to a GitHub project from the previous copy in
the pkgsrc repository. sysbuild is now a first-class package and
includes a traditional build system based on automake and autoconf.
Diffstat (limited to 'sysutils/sysbuild')
-rw-r--r-- | sysutils/sysbuild/Makefile | 80 | ||||
-rw-r--r-- | sysutils/sysbuild/PLIST | 6 | ||||
-rw-r--r-- | sysutils/sysbuild/distinfo | 5 | ||||
-rw-r--r-- | sysutils/sysbuild/files/Kyuafile | 6 | ||||
-rw-r--r-- | sysutils/sysbuild/files/default.conf | 45 | ||||
-rw-r--r-- | sysutils/sysbuild/files/env.sh | 52 | ||||
-rw-r--r-- | sysutils/sysbuild/files/sysbuild.1 | 320 | ||||
-rw-r--r-- | sysutils/sysbuild/files/sysbuild.conf.5 | 192 | ||||
-rw-r--r-- | sysutils/sysbuild/files/sysbuild.sh | 373 | ||||
-rw-r--r-- | sysutils/sysbuild/files/sysbuild4cron.1 | 88 | ||||
-rw-r--r-- | sysutils/sysbuild/files/sysbuild4cron.sh | 108 | ||||
-rw-r--r-- | sysutils/sysbuild/files/sysbuild4cron_test.sh | 197 | ||||
-rw-r--r-- | sysutils/sysbuild/files/sysbuild_test.sh | 1176 |
13 files changed, 23 insertions, 2625 deletions
diff --git a/sysutils/sysbuild/Makefile b/sysutils/sysbuild/Makefile index d1da7a873c6..21d4664d0df 100644 --- a/sysutils/sysbuild/Makefile +++ b/sysutils/sysbuild/Makefile @@ -1,9 +1,8 @@ -# $NetBSD: Makefile,v 1.25 2013/06/18 13:24:55 jmmv Exp $ +# $NetBSD: Makefile,v 1.26 2013/07/28 23:32:58 jmmv Exp $ -DISTNAME= sysbuild-2.6 +DISTNAME= sysbuild-2.7 CATEGORIES= sysutils -MASTER_SITES= # empty -DISTFILES= # empty +MASTER_SITES= https://github.com/jmmv/sysbuild/releases/download/sysbuild-2.7/ MAINTAINER= jmmv@NetBSD.org COMMENT= Automates builds of NetBSD and manages source trees @@ -11,15 +10,15 @@ LICENSE= modified-bsd PKG_INSTALLATION_TYPES= overwrite pkgviews -WRKSRC= ${WRKDIR} -NO_CONFIGURE= YES - -BUILD_SUBST= -e 's,@SYSBUILD_BINDIR@,${PREFIX}/bin,g' -BUILD_SUBST+= -e 's,@SYSBUILD_EGDIR@,${EGDIR},g' -BUILD_SUBST+= -e 's,@SYSBUILD_ETCDIR@,${PKG_SYSCONFDIR},g' -BUILD_SUBST+= -e 's,@SYSBUILD_SHAREDIR@,${PREFIX}/share/sysbuild,g' +GNU_CONFIGURE= yes +TEST_TARGET= check +USE_LANGUAGES= # empty +USE_TOOLS= pkg-config PKG_SYSCONFSUBDIR= sysbuild +CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR} +CONFIGURE_ARGS+= SYSBUILD_CONFSUBDIR= +INSTALL_MAKE_FLAGS+= sysbuild_confdir=${EGDIR} EGDIR= ${PREFIX}/share/examples/sysbuild CONF_FILES+= ${EGDIR}/default.conf ${PKG_SYSCONFDIR}/default.conf @@ -30,66 +29,13 @@ PKG_SUGGESTED_OPTIONS= tests .include "../../mk/bsd.options.mk" .if $(PKG_OPTIONS:Mtests) -TEST_PROGS= sysbuild_test sysbuild4cron_test - -PLIST_SUBST+= TESTS= +BUILDLINK_API_DEPENDS.atf-libs+= atf-libs>=0.17 . include "../../devel/atf-libs/buildlink3.mk" - -BUILD_SUBST+= -e 's,@ATF_SH@,${BUILDLINK_PREFIX.atf-libs}/bin/atf-sh,g' - -do-build: build-tests -build-tests: - cp ${FILESDIR}/Kyuafile ${WRKSRC} -.for file in ${TEST_PROGS} - sed ${BUILD_SUBST} <${FILESDIR}/${file}.sh >${WRKSRC}/${file} - chmod +x ${WRKSRC}/${file} -.endfor - -INSTALLATION_DIRS+= tests/sysbuild - -do-install: install-tests -install-tests: - ${INSTALL_DATA} ${WRKSRC}/Kyuafile ${DESTDIR}${PREFIX}/tests/sysbuild -.for file in ${TEST_PROGS} - ${INSTALL_SCRIPT} ${WRKSRC}/${file} ${DESTDIR}${PREFIX}/tests/sysbuild/ -.endfor - -do-test: - cd ${WRKSRC} && PATH="${WRKSRC}:${PATH}" \ - SYSBUILD_SHAREDIR="${WRKSRC}" kyua test +PLIST_SUBST+= TESTS= .else PLIST_SUBST+= TESTS=@comment .endif -do-build: -.for file in sysbuild sysbuild4cron - sed ${BUILD_SUBST} ${FILESDIR}/${file}.sh \ - | ${BUILDLINK_PREFIX.shtk}/bin/shtk build \ - -s ${SH} -m ${file}_main -o ${WRKSRC}/${file} - -.endfor -.for file in sysbuild.1 sysbuild4cron.1 sysbuild.conf.5 default.conf - sed ${BUILD_SUBST} <${FILESDIR}/${file} >${WRKSRC}/${file} -.endfor - cp ${FILESDIR}/env.sh ${WRKSRC} - chmod +x ${WRKSRC}/env.sh - -INSTALLATION_DIRS+= bin ${PKGMANDIR}/man1 ${PKGMANDIR}/man5 \ - share/examples/sysbuild share/sysbuild - -do-install: - ${INSTALL_SCRIPT} ${WRKSRC}/sysbuild ${DESTDIR}${PREFIX}/bin/ - ${INSTALL_SCRIPT} ${WRKSRC}/sysbuild4cron ${DESTDIR}${PREFIX}/bin/ - ${INSTALL_MAN} ${WRKSRC}/sysbuild.1 \ - ${DESTDIR}${PREFIX}/${PKGMANDIR}/man1/ - ${INSTALL_MAN} ${WRKSRC}/sysbuild4cron.1 \ - ${DESTDIR}${PREFIX}/${PKGMANDIR}/man1/ - ${INSTALL_MAN} ${WRKSRC}/sysbuild.conf.5 \ - ${DESTDIR}${PREFIX}/${PKGMANDIR}/man5/ -.for file in default.conf - ${INSTALL_DATA} ${WRKSRC}/${file} ${DESTDIR}${EGDIR} -.endfor - ${INSTALL_SCRIPT} ${WRKSRC}/env.sh ${DESTDIR}${PREFIX}/share/sysbuild - -BUILDLINK_API_DEPENDS.shtk+= shtk>=1.2 +BUILDLINK_API_DEPENDS.shtk+= shtk>=1.3 .include "../../devel/shtk/buildlink3.mk" .include "../../mk/bsd.pkg.mk" diff --git a/sysutils/sysbuild/PLIST b/sysutils/sysbuild/PLIST index 61358651234..86ec9c43f44 100644 --- a/sysutils/sysbuild/PLIST +++ b/sysutils/sysbuild/PLIST @@ -1,9 +1,13 @@ -@comment $NetBSD: PLIST,v 1.7 2012/10/13 18:40:33 jmmv Exp $ +@comment $NetBSD: PLIST,v 1.8 2013/07/28 23:32:58 jmmv Exp $ bin/sysbuild bin/sysbuild4cron man/man1/sysbuild.1 man/man1/sysbuild4cron.1 man/man5/sysbuild.conf.5 +share/doc/sysbuild/AUTHORS +share/doc/sysbuild/COPYING +share/doc/sysbuild/NEWS +share/doc/sysbuild/README share/examples/sysbuild/default.conf share/sysbuild/env.sh ${TESTS}tests/sysbuild/Kyuafile diff --git a/sysutils/sysbuild/distinfo b/sysutils/sysbuild/distinfo new file mode 100644 index 00000000000..59096c0fffe --- /dev/null +++ b/sysutils/sysbuild/distinfo @@ -0,0 +1,5 @@ +$NetBSD: distinfo,v 1.1 2013/07/28 23:32:58 jmmv Exp $ + +SHA1 (sysbuild-2.7.tar.gz) = 3c490167de6f4bd03af874eac24b336f8bbecd82 +RMD160 (sysbuild-2.7.tar.gz) = 6e7218d49672ab326de76226e12d13456b2239b5 +Size (sysbuild-2.7.tar.gz) = 76479 bytes diff --git a/sysutils/sysbuild/files/Kyuafile b/sysutils/sysbuild/files/Kyuafile deleted file mode 100644 index a6456c745e8..00000000000 --- a/sysutils/sysbuild/files/Kyuafile +++ /dev/null @@ -1,6 +0,0 @@ -syntax("kyuafile", 1) - -test_suite("sysbuild") - -atf_test_program{name="sysbuild_test"} -atf_test_program{name="sysbuild4cron_test"} diff --git a/sysutils/sysbuild/files/default.conf b/sysutils/sysbuild/files/default.conf deleted file mode 100644 index d33db4b4f17..00000000000 --- a/sysutils/sysbuild/files/default.conf +++ /dev/null @@ -1,45 +0,0 @@ -# $NetBSD: default.conf,v 1.7 2013/06/18 13:24:55 jmmv Exp $ - -# System-wide configuration file for sysbuild(1). -# -# This default configuration file tells sysbuild to use the source trees from -# the standard locations documented by hier(7) and allows any user to easily -# perform NetBSD builds on their home directories using those. - -# Place all build files in the user's home directory. -BUILD_ROOT="${HOME}/sysbuild" - -# Store release files relative to the build root. -RELEASEDIR="${BUILD_ROOT}/release" - -# Use the standard source trees as documented by hier(7), and honor if the -# system has X installed or not. -SRCDIR="/usr/src" -[ ! -f /etc/mtree/set.xbase ] || XSRCDIR="/usr/xsrc" - -# Build for the current machine only. -MACHINES="$(uname -m)" - -# What to build for every machine. -BUILD_TARGETS="release" - -# Do not perform update builds by default. -INCREMENTAL_BUILD="no" - -# Determine the CVS root and the current release. -if [ -f "${SRCDIR}/CVS/Root" ]; then - CVSROOT="$(cat ${SRCDIR}/CVS/Root)" -else - CVSROOT=":ext:anoncvs@anoncvs.NetBSD.org:/cvsroot" -fi -if [ -f "${SRCDIR}/CVS/Tag" ]; then - CVSTAG="$(sed -e 's,^T,,' ${SRCDIR}/CVS/Tag)" -else - if ! head -n 1 /etc/release | grep 99 >/dev/null; then - CVSTAG="$(head -n 1 /etc/release | cut -d . -f 1 \ - | tr '[A-Z] ' '[a-z]-')" - fi -fi - -# Use as many CPUs as are available. -NJOBS="$(/sbin/sysctl -n hw.ncpuonline)" diff --git a/sysutils/sysbuild/files/env.sh b/sysutils/sysbuild/files/env.sh deleted file mode 100644 index 54ff107be1b..00000000000 --- a/sysutils/sysbuild/files/env.sh +++ /dev/null @@ -1,52 +0,0 @@ -# Copyright 2012 Google Inc. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of Google Inc. nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# 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. - -# \file env.sh -# Utility functions for interactive shells. -# -# This file is supposed to be loaded automatically when running: -# eval $(sysbuild env) -# Do not load it directly, as it depends on global variables defined by -# the command shown above. - - -# Locates the object directory that matches the current source directory. -curobj() { - local curdir="$(pwd)" - case "${curdir}" in - ${S:-non-existent}*) - echo "${O}${curdir##${S}}" - ;; - ${XS:-non-existent}*) - echo "${XO}${curdir##${XS}}" - ;; - *) - echo "NOT-FOUND" - ;; - esac -} diff --git a/sysutils/sysbuild/files/sysbuild.1 b/sysutils/sysbuild/files/sysbuild.1 deleted file mode 100644 index cb2b3e27d68..00000000000 --- a/sysutils/sysbuild/files/sysbuild.1 +++ /dev/null @@ -1,320 +0,0 @@ -.\" $NetBSD: sysbuild.1,v 1.7 2013/03/08 17:47:26 jmmv Exp $ -.\" Copyright 2012 Google Inc. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions are -.\" met: -.\" -.\" * Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" * Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" * Neither the name of Google Inc. nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -.\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -.\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -.\" 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 March 8, 2013 -.Dt SYSBUILD 1 -.Os -.Sh NAME -.Nm sysbuild -.Nd performs fully automatic builds of NetBSD -.Sh SYNOPSIS -.Nm -.Op Fl c Ar config_name -.Op Fl o Ar variable=value -build -.Op Fl f -.Op Ar build_targets -.Nm -.Op Fl c Ar config_name -.Op Fl o Ar variable=value -config -.Nm -.Op Fl c Ar config_name -.Op Fl o Ar variable=value -env -.Op Ar machine -.Nm -.Op Fl c Ar config_name -.Op Fl o Ar variable=value -fetch -.Sh DESCRIPTION -.Nm -is a utility to build -.Nx -releases in a fully automated manner. -The process is made unattended by relying on a configuration file that -prespecifies the location of all build components and the desired goals of -the build. -If you want to plug -.Nm -into -.Xr cron 8 , -please take a look to -.Xr sysbuild4cron 1 -now. -.Pp -.Nm -can be seen as a simple wrapper over -.Xr cvs 1 -and the -.Nm build.sh -script that ships with the -.Nx -source tree. -.Nm -provides the following additional features: -.Bl -bullet -.It -Automatically fetch or update the -.Nx -source trees (both src and xsrc) -before performing a build. -.It -Preconfigure the way -.Nm build.sh -is invoked by storing all relevant details in a configuration file. -.It -Perform builds for a variety of platforms with a single invocation. -.It -Trivially set up periodic -.Nx -rebuilds by adding a single line to your -.Xr crontab 5 . -.It -Hooks to plug other components into the build procedure. -For example: use -.Xr rsync 1 -to push the results of a successful build to a file server. -.El -.Pp -As you can see in the -.Sx SYNOPSIS -section, -.Nm -provides a subcommand-interface: the tool has several modes of operation, -and the particular mode to use for a given run is selected by the first -non-option argument in the command line. -.Pp -The following options apply to all commands: -.Bl -tag -width XXXX -.It Fl c Ar config_name -Specifies the configuration file to use. -The format of the file is described in -.Xr sysbuild.conf 5 . -.Pp -If -.Ar config_name -includes any directory separator (aka, one or more slashes) or the -.Sq .conf -suffix, then this specifies the path of the configuration file to load. -.Pp -.If -.Ar config_name -is a plain name without any directory components nor extension, then this -specifies the name of the configuration. -.Nm -will first look for a configuration file in -.Pa ~/.sysbuild/<config_name>.conf -and, if not found, will use -.Pa @SYSBUILD_ETCDIR@/<config_name>.conf . -Any of the two files must exist, or else -.Nm -will exit with an error. -.It Fl o Ar variable=value -Applies an override to the loaded configuration. -.Pp -The -.Ar variable -part of the argument must be any of the recognized configuration variables -described in -.Xr sysbuild.conf 5 . -The -.Ar value , -if not empty, specifies the value to set the configuration variable to. -If -.Ar value -is empty, then the configuration variable is unset. -.El -.Ss The build command -The build command provides the main functionality of -.Nm . -It performs the following steps: -.Bl -enum -.It -If -.Va UPDATE_SOURCES -is true, the fetch command is invoked first. -See -.Sx The fetch command -for more details. -.It -For every machine type listed in -.Va MACHINES , -issues a -.Nm build.sh -call for that particular machine using the rest of the settings defined in -the configuration file. -The targets passed to the -.Nm build.sh -script are those defined in the -.Va BUILD_TARGETS -variable, or the arguments passed through the command line if any. -.El -.Pp -The following options apply only to the build command: -.Bl -tag -width XXXX -.It Fl f -Enables fast mode, which skips updating the source trees and performs -update builds. -This is a shorthand for these generic flags: -.Fl o Ar INCREMENTAL_BUILD=true -.Fl o Ar UPDATE_SOURCES=false . -.El -.Ss The config command -The config command dumps the loaded configuration to the standard output. -The format of the output is not a script, so it cannot be fed back into -.Nm . -The purpose of this command is to aid in debugging the configuration of the -tool before performing any builds, particularly when the configuration -files use shell logic to determine the value of any variables. -.Ss The env command -The env command prints a shell script snippet that defines environment variables -to simplify working with the directory layout of a -.Nx -build for a particular machine. -If the -.Va MACHINES -variable is not defined, or if it lists more than one machine, then the -.Ar machine -argument is required. -.Pp -The common mechanism to use these variables is by executing -.Nm -in the following way: -.Bd -literal -offset indent -$ eval $(sysbuild env) -.Ed -.Pp -The following variables are defined and/or modified: -.Bl -tag -width PATH -.It Va PATH -The path to the tools is prepended to the path. -Of particular interest is the -.Pa nbmake-<machine> -script made available in this way, which allows you to build arbitrary targets -within the source directory using the tools. -.It Va D -Path to the destdir. -.It Va O -Path to the objects directory for the source tree. -.It Va S -Path to the source tree. -.It Va T -Path to the tools. -Note that this points to the root of the tools, not their -.Pa bin -subdirectory. -.It Va XO -If -.Va XSRCDIR -is defined, path to the objects directory for the X source tree. -.It Va XS -If -.Va XSRCDIR -is defined, path to the X source tree. -.El -.Pp -And the following functions are defined: -.Bl -tag -width curobj -.It Fn curobj -When invoked from a subdirectory of either src or xsrc, prints the path to that -same subdirectory within the objects hierarchy. -You may use this to reference temporary build files easily when you are working -within the source tree as follows: -.Bd -literal -offset indent -$ cd /usr/src/bin/ls -/usr/src/bin/ls$ nbmake-amd64 -/usr/src/bin/ls$ cd $(curobj) -/usr/obj/usr/src/bin/ls$ -.Ed -.El -.Ss The fetch command -The fetch command downloads or updates the -.Nx -source trees, which include src and, optionally, xsrc. -.Pp -If the modules do not exist yet in the locations specified by -.Va SRCDIR -and -.Va XSRCDIR , -this performs an initial CVS checkout of the trees. -If the modules exist, this performs a CVS update. -.Pp -The -.Va CVSROOT -and -.Va CVSTAG -variables are used to determine where to get the sources from and whether a -particular tag is desired. -.Pp -The major use of this subcommand is the following. -Consider that you wish to use the standard locations of -.Pa /usr/src -and -.Pa /usr/xsrc -for your source trees, and that you would like to keep these owned by root -while, at the same time, you run your -.Nx -builds as an unprivileged user. -In this situation, you can use the -.Sq fetch -command as root only, set -.Va UPDATE_SOURCES -to -.Sq false -in your user configuration files, and do your builds as another user. -.Sh FILES -.Bl -tag -width XXXX -.It Pa @SYSBUILD_ETCDIR@/ -Directory containing all system-wide configuration files. -.It Pa @SYSBUILD_ETCDIR@/default.conf -Default configuration file to load if the user does not have a -corresponding -.Pa ~/.sysbuild/default.conf -file and the -.Fl c -flag is not provided. -.It Pa ~/.sysbuild/ -Directory containing all user-specific configuration files. -.It Pa ~/.sysbuild/default.conf -Default configuration file to load when the -.Fl c -flag is not provided. -.El -.Sh SEE ALSO -.Xr cvs 1 , -.Xr sysbuild4cron 1 , -.Xr sysbuild.conf 5 , -.Xr hier 7 , -.Pa /usr/src/BUILDING -.Sh AUTHORS -The -.Nm -utility was developed by -.An Julio Merino -.Aq jmmv@NetBSD.org . diff --git a/sysutils/sysbuild/files/sysbuild.conf.5 b/sysutils/sysbuild/files/sysbuild.conf.5 deleted file mode 100644 index 792c2db1bda..00000000000 --- a/sysutils/sysbuild/files/sysbuild.conf.5 +++ /dev/null @@ -1,192 +0,0 @@ -.\" $NetBSD: sysbuild.conf.5,v 1.2 2013/03/08 17:47:26 jmmv Exp $ -.\" Copyright 2012 Google Inc. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions are -.\" met: -.\" -.\" * Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" * Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" * Neither the name of Google Inc. nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -.\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -.\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -.\" 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 March 8, 2013 -.Dt SYSBUILD.CONF 5 -.Os -.Sh NAME -.Nm sysbuild.conf -.Nd configuration file format for the sysbuild tool -.Sh DESCRIPTION -Configuration files for -.Xr sysbuild 1 -are plain shell scripts that define a set of recognized variables and can -optionally fill in a set of hooks provided as shell functions. -.Ss Configuration variables -As scripts, configuration files can perform any magic they desire to deduce -the value of configuration variables. -For example, the default configuration file shipped with -.Xr sysbuild 1 -automatically deduces the value of the -.Va NJOBS -variable by looking at how many CPUs are available in the system. -.Pp -The following variables configure the source trees: -.Bl -tag -width INCREMENTAL_BUILD -.It Va CVSROOT -Location of the CVS root from which to check out or update the src and xsrc -modules. -.Pp -Default: -.Sq :ext:anoncvs@anoncvs.NetBSD.org:/cvsroot -.It Va CVSTAG -CVS tag to use during checkouts or updates of the src and xsrc modules. -.Pp -Default: not defined. -.It Va SRCDIR -Path to the src module. -If you want -.Xr sysbuild 1 -to perform an update of this directory before every build, you will need -write access to it. -Otherwise, you can use a read-only directory. -.Pp -Default: -.Pa /usr/src . -.It Va UPDATE_SOURCES -Whether to perform an update of the source tree before every build or not. -.Pp -Default: -.Sq true . -.It Va XSRCDIR -Path to the xsrc module. -If you want -.Xr sysbuild 1 -to perform an update of this directory before every build, you will need -write access to it. -Otherwise, you can use a read-only directory. -.Pp -Defining this variable causes -.Xr sysbuild 1 -to build the X Window System as part of the build of -.Nx . -.Pp -Default: not defined. -.El -.Pp -The following variables configure the location of the build files: -.Bl -tag -width INCREMENTAL_BUILD -.It Va BUILD_ROOT -Path to the directory in which to place build files. -These include the obj tree, the destdir and the cross-build tools generated -by the -.Nm build.sh -script. -The contents of this directory are sorted by machine type so that it can be -shared across builds for different machines. -.Pp -Default: -.Pa ~/sysbuild/ . -.It Va RELEASEDIR -Path to the directory that will contain the build products (aka the release -files). -The contents of this directory are sorted by machine type so that it can be -shared across builds for different machines. -.Pp -Default: -.Pa ~/sysbuild/release . -.El -.Pp -The following variables configure the build process: -.Bl -tag -width INCREMENTAL_BUILD -.It Va BUILD_TARGETS -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 . -.It Va INCREMENTAL_BUILD -Whether to perform update builds or not. -An update build reuses existing obj, destdir and tools trees. -.Pp -Of special note is that -.Xr sysbuild 1 -will take care of pruning files likely to cause breakage during update -builds before performing the build itself. -As an example, this includes deleting all the modules from -.Pa destdir/stand/<platform>/ . -.Pp -Default: -.Sq false . -.It Va MACHINES -Whitespace-separated list of machine types to build for. -.Pp -Default: the name of the host machine type. -.It Va MKVARS -Whitespace-separated list of -.Sq VARIABLE=value -.Xr make 1 -variable definitions to be set during the build. -A useful example would be: -.Sq MKVARS="MKDEBUG=yes" . -.Pp -Default: not defined. -.It Va NJOBS -Number of parallel jobs to use during the build. -If not set, disables parallel builds (which, due to -.Nm make 1 -semantics, is not the same as setting this to 1). -.Pp -Default: not defined. -.El -.Ss Hooks -Hooks are user-provided routines invoked at particular points during the -build process. -These are defined as shell functions and have access to the configuration -variables in the file. -Hooks must return a success error code and they cannot contain unprotected -shell commands. -In other words, they are run under a shell configured with -.Sq set -e . -.Pp -The following hooks can be defined: -.Bl -tag -width post_build_hookXX -.It Fn pre_build_hook -Function executed before invoking -.Nm build.sh -for any of the provided build targets and platforms. -.It Fn post_build_hook -Function executed at the end of all build operations. -In other words: if the system is being built for multiple machine targets, -this hook will only be run once. -.It Fn pre_fetch_hook -Function executed at the beginning of the -.Sq fetch -command before any operations are performed. -This cannot assume that the source directories exist yet. -.It Fn post_fetch_hook -Function executed right after all source trees have been updated by the -.Sq fetch -command. -.El -.Sh SEE ALSO -.Xr sysbuild 1 diff --git a/sysutils/sysbuild/files/sysbuild.sh b/sysutils/sysbuild/files/sysbuild.sh deleted file mode 100644 index 6273b1ef651..00000000000 --- a/sysutils/sysbuild/files/sysbuild.sh +++ /dev/null @@ -1,373 +0,0 @@ -# Copyright 2012 Google Inc. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of Google Inc. nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# 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. - -# \file sysbuild.sh -# Entry point and main program logic. - -shtk_import cli -shtk_import config -shtk_import cvs -shtk_import list -shtk_import process - - -# List of valid configuration variables. -# -# Please remember to update sysbuild.conf(5) if you change this list. -SYSBUILD_CONFIG_VARS="BUILD_ROOT BUILD_TARGETS CVSROOT CVSTAG INCREMENTAL_BUILD - MACHINES MKVARS NJOBS RELEASEDIR SRCDIR UPDATE_SOURCES - XSRCDIR" - - -# Paths to installed files. -# -# Can be overriden for test purposes only. -: ${SYSBUILD_ETCDIR="@SYSBUILD_ETCDIR@"} -: ${SYSBUILD_SHAREDIR="@SYSBUILD_SHAREDIR@"} - - -# Sets defaults for configuration variables and hooks that need to exist. -# -# This function should be before the configuration file has been loaded. This -# means that the user can undefine a required configuration variable, but we let -# him shoot himself in the foot if he so desires. -sysbuild_set_defaults() { - # Please remember to update sysbuild(1) if you change any default values. - shtk_config_set BUILD_ROOT "${HOME}/sysbuild" - shtk_config_set BUILD_TARGETS "release" - shtk_config_set CVSROOT ":ext:anoncvs@anoncvs.NetBSD.org:/cvsroot" - shtk_config_set INCREMENTAL_BUILD "false" - shtk_config_set MACHINES "$(uname -m)" - shtk_config_set RELEASEDIR "${HOME}/sysbuild/release" - shtk_config_set SRCDIR "${HOME}/sysbuild/src" - shtk_config_set UPDATE_SOURCES "true" - - pre_build_hook() { true; } - post_build_hook() { true; } - pre_fetch_hook() { true; } - post_fetch_hook() { true; } -} - - -# Performs a build for a single machine type. -# -# \param machine The type of the machine to build for. -do_one_build() { - local machine="${1}"; shift - - local basedir="$(shtk_config_get BUILD_ROOT)/${machine}" - - local jflag= - if shtk_config_has NJOBS; then - jflag="-j$(shtk_config_get NJOBS)" - fi - - local uflag= - if shtk_config_get_bool INCREMENTAL_BUILD; then - uflag=-u - - # Get rid of any possibly-old modules; they are a constant source of - # update-build problems. - rm -rf "${basedir}/destdir/stand"/* - else - shtk_cli_info "Cleaning up previous build files" - rm -rf "${basedir}/destdir" - rm -rf "${basedir}/obj" - rm -rf "${basedir}/tools" - fi - - local Vflags= - for Vflag in $(shtk_config_get_default MKVARS ""); do - Vflags="${Vflags} -V${Vflag}" - done - - local xflag= - local Xflag= - if shtk_config_has XSRCDIR; then - xflag=-x - 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" \ - -N2 \ - -R"$(shtk_config_get RELEASEDIR)" \ - -T"${basedir}/tools" \ - -U \ - ${Vflags} \ - ${Xflag} \ - ${jflag} \ - -m"${machine}" \ - ${uflag} \ - ${xflag} \ - ${targets} ) -} - - -# Builds the system. -# -# \params ... The options and arguments to the command. -sysbuild_build() { - while getopts ':f' arg "${@}"; do - case "${arg}" in - f) # Convenience flag for a "fast mode". - shtk_config_set "INCREMENTAL_BUILD" "true" - shtk_config_set "UPDATE_SOURCES" "false" - ;; - - \?) - shtk_cli_usage_error "Unknown option -${OPTARG}" - ;; - esac - done - shift $((${OPTIND} - 1)) - - [ ${#} -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 - - shtk_config_run_hook pre_build_hook - for machine in ${machines}; do - do_one_build "${machine}" - done - shtk_config_run_hook post_build_hook -} - - -# Dumps the loaded configuration. -# -# \params ... The options and arguments to the command. -sysbuild_config() { - [ ${#} -eq 0 ] || shtk_cli_usage_error "config does not take any arguments" - - for var in ${SYSBUILD_CONFIG_VARS}; do - if shtk_config_has "${var}"; then - echo "${var} = $(shtk_config_get "${var}")" - else - echo "${var} is undefined" - fi - done -} - - -# Outputs shell configuration commands. -# -# \params ... The options and arguments to the command. -sysbuild_env() { - [ ${#} -lt 2 ] || shtk_cli_usage_error "env takes zero or one arguments" - - local machine= - if [ ${#} -eq 1 ]; then - machine="${1}" - else - set -- $(shtk_config_get MACHINES) - [ ${#} -eq 1 ] || shtk_cli_usage_error "No machine name provided as" \ - "an argument and MACHINES contains more than one name" - machine="${1}" - fi - - local basedir="$(shtk_config_get BUILD_ROOT)/${machine}" - local srcdir="$(shtk_config_get SRCDIR)" - - [ -f "${SYSBUILD_SHAREDIR}/env.sh" ] \ - || shtk_cli_error "Cannot open ${SYSBUILD_SHAREDIR}/env.sh" - - # The semicolon after the sourcing of env.sh is required to get this output - # working when passed through eval. Running eval on the output collapses - # everything into a single line, and we need to separate the sourcing of - # env.sh from the definition of the global variables. - cat <<EOF -. "${SYSBUILD_SHAREDIR}/env.sh" ; -PATH="${basedir}/tools/bin:\${PATH}" -D="${basedir}/destdir" -O="${basedir}/obj${srcdir}" -S="${srcdir}" -T="${basedir}/tools" -EOF - - if shtk_config_has XSRCDIR; then - local xsrcdir="$(shtk_config_get XSRCDIR)" - cat <<EOF -XO="${basedir}/obj${xsrcdir}" -XS="${xsrcdir}" -EOF - fi -} - - -# Fetches a copy of the source tree, or updates an existing one. -# -# \params ... The options and arguments to the command. -sysbuild_fetch() { - [ ${#} -eq 0 ] || shtk_cli_usage_error "fetch does not take any arguments" - - shtk_config_run_hook pre_fetch_hook - - local cvsroot="$(shtk_config_get CVSROOT)" - - shtk_cli_info "Updating base source tree" - shtk_cvs_fetch "${cvsroot}" src "$(shtk_config_get_default CVSTAG '')" \ - "$(shtk_config_get SRCDIR)" - - if shtk_config_has XSRCDIR; then - shtk_cli_info "Updating X11 source tree" - shtk_cvs_fetch "${cvsroot}" xsrc \ - "$(shtk_config_get_default CVSTAG '')" "$(shtk_config_get XSRCDIR)" - fi - - shtk_config_run_hook post_fetch_hook -} - - -# Loads the configuration file specified in the command line. -# -# \param config_name Name of the desired configuration. It can be either a -# configuration name (no slashes) or a path. -sysbuild_config_load() { - local config_name="${1}"; shift - - local config_file= - case "${config_name}" in - */*|*.conf) - config_file="${config_name}" - ;; - - *) - local candidates= - candidates="${candidates} ${HOME}/.sysbuild/${config_name}.conf" - candidates="${candidates} ${SYSBUILD_ETCDIR}/${config_name}.conf" - for candidate in ${candidates}; do - if [ -e "${candidate}" ]; then - config_file="${candidate}" - break - fi - done - [ -n "${config_file}" ] \ - || shtk_cli_usage_error "Cannot locate configuration named" \ - "'${config_name}'" - ;; - esac - shtk_config_load "${config_file}" -} - - -# Entry point to the program. -# -# \param ... Command-line arguments to be processed. -# -# \return An exit code to be returned to the user. -sysbuild_main() { - local config_name="default" - - shtk_config_init ${SYSBUILD_CONFIG_VARS} - - while getopts ':c:o:' arg "${@}"; do - case "${arg}" in - c) # Name of the configuration to load. - config_name="${OPTARG}" - ;; - - o) # Override for a particular configuration variable. - shtk_config_override "${OPTARG}" - ;; - - \?) - shtk_cli_usage_error "Unknown option -${OPTARG}" - ;; - esac - done - shift $((${OPTIND} - 1)) - - [ ${#} -ge 1 ] || shtk_cli_usage_error "No command specified" - - local exit_code=0 - - local command="${1}"; shift - case "${command}" in - build|config|env|fetch) - sysbuild_set_defaults - sysbuild_config_load "${config_name}" - "sysbuild_${command}" "${@}" || exit_code="${?}" - ;; - - *) - shtk_cli_usage_error "Unknown command ${command}" - ;; - esac - - return "${exit_code}" -} diff --git a/sysutils/sysbuild/files/sysbuild4cron.1 b/sysutils/sysbuild/files/sysbuild4cron.1 deleted file mode 100644 index 37409767767..00000000000 --- a/sysutils/sysbuild/files/sysbuild4cron.1 +++ /dev/null @@ -1,88 +0,0 @@ -.\" $NetBSD: sysbuild4cron.1,v 1.2 2012/08/11 19:32:50 wiz Exp $ -.\" Copyright 2012 Google Inc. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions are -.\" met: -.\" -.\" * Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" * Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" * Neither the name of Google Inc. nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -.\" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -.\" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -.\" 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 -.Dt SYSBUILD4CRON 1 -.Os -.Sh NAME -.Nm sysbuild4cron -.Nd performs fully automatic builds of NetBSD from cron -.Sh SYNOPSIS -.Nm -.Op Fl l Ar logdir -.Op Fl r Ar recipient --- -.Ar sysbuild_arguments -.Sh DESCRIPTION -.Nm -is a wrapper over -.Xr sysbuild 1 -that allows plugging -.Nx -builds into -.Xr cron 8 -with minimal effort. -.Pp -.Nm -executes -.Xr sysbuild 1 -with the given arguments after the -.Sq -- -marker, stores the output of the build in a log file and, if the exit code of -the tool indicated an error, proceeds to send an error report to a given -recipient. -.Pp -Unless -.Nm -detects an error in the usage of this wrapper script, the tool does not print -any output to the console and does not return any error codes. -All errors are reported by means of email. -.Pp -The following options are supported: -.Bl -tag -width XXXX -.It Fl l Ar logdir -Path to the directory that will keep the logs of all the calls to -.Xr sysbuild 1 . -.Pp -Default: -.Pa ~/sysbuild/log . -.It Fl r Ar recipient -Email address of the recipient of the failure messages. -.Pp -Default: the current username, without a domain part. -.El -.Sh SEE ALSO -.Xr crontab 1 , -.Xr sysbuild 1 , -.Xr crontab 5 -.Sh AUTHORS -The -.Nm -utility was developed by -.An Julio Merino -.Aq jmmv@NetBSD.org . diff --git a/sysutils/sysbuild/files/sysbuild4cron.sh b/sysutils/sysbuild/files/sysbuild4cron.sh deleted file mode 100644 index bdb0924bcb0..00000000000 --- a/sysutils/sysbuild/files/sysbuild4cron.sh +++ /dev/null @@ -1,108 +0,0 @@ -# Copyright 2012 Google Inc. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of Google Inc. nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# 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. - -# \file sysbuild4cron.sh -# Entry point and main program logic. - -shtk_import cli - - -# Paths to installed files. -# -# Can be overriden for test purposes only. -: ${SYSBUILD_BINDIR="@SYSBUILD_BINDIR@"} - - -# Sends an email notification upon a failure. -# -# \param logfile File containing the output of the failed command. -# \param recipient Who to send the email to. -# \param ... Command that failed. -sysbuild4cron_email() { - local logfile="${1}"; shift - local recipient="${1}"; shift - - local maxlines=100 - { - echo "The following command has failed:" - echo - echo " $*" - echo - echo "The output of the failed command has been left in:" - echo - echo " ${logfile}" - echo - echo "The last ${maxlines} of the log follow:" - echo - tail -n${maxlines} "${logfile}" - } | mail -s "sysbuild failure report" "${recipient}" -} - - -# Entry point to the program. -# -# \param ... Command-line arguments to be processed. -# -# \return An exit code to be returned to the user. -sysbuild4cron_main() { - local logdir="${HOME}/sysbuild/log" - local recipient="$(id -u -n)" - - while getopts ':l:r:' arg "${@}"; do - case "${arg}" in - l) # Location of logs. - case "${OPTARG}" in - /*) logdir="${OPTARG}" ;; - *) logdir="$(pwd)/${OPTARG}" ;; - esac - ;; - - r) # Email recipient. - recipient="${OPTARG}" - ;; - - \?) - shtk_cli_usage_error "Unknown option -${OPTARG}" - ;; - esac - done - shift $((${OPTIND} - 1)) - - set -- "${SYSBUILD_BINDIR}/sysbuild" "${@}" - - if [ ! -d "${logdir}" ]; then - mkdir -p "$(dirname "${logdir}")" >/dev/null 2>/dev/null || true - mkdir "${logdir}" \ - || shtk_cli_error "Failed to create directory '${logdir}'" - fi - - local exit_code=0 - local logfile="${logdir}/$(shtk_cli_progname).$(date +%Y%m%d%H%M%S).log" - "${@}" >"${logfile}" 2>&1 \ - || sysbuild4cron_email "${logfile}" "${recipient}" "${@}" -} diff --git a/sysutils/sysbuild/files/sysbuild4cron_test.sh b/sysutils/sysbuild/files/sysbuild4cron_test.sh deleted file mode 100644 index fca4b0b3174..00000000000 --- a/sysutils/sysbuild/files/sysbuild4cron_test.sh +++ /dev/null @@ -1,197 +0,0 @@ -#! @ATF_SH@ -# Copyright 2012 Google Inc. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of Google Inc. nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# 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. - - -# Creates a fake program that records its invocations for later processing. -# -# The fake program, when invoked, will append its arguments to a commands.log -# file in the test case's work directory. -# -# \param binary The path to the program to create. -# \param get_stdin Whether to capture stdin or not. -create_mock_binary() { - local binary="${1}"; shift - local get_stdin="${1}"; shift - - cat >"${binary}" <<EOF -#! /bin/sh - -logfile="${HOME}/commands.log" -echo "Command: \${0##*/}" >>"\${logfile}" -for arg in "\${@}"; do - echo "Arg: \${arg}" >>"\${logfile}" -done - [ "${get_stdin}" = no ] || sed -e 's,^,stdin: ,' >>"\${logfile}" - echo >>"\${logfile}" -EOF - chmod +x "${binary}" -} - - -setup_mocks() { - mkdir bin - create_mock_binary bin/mail yes - create_mock_binary bin/sysbuild no - PATH="$(pwd)/bin:${PATH}" - SYSBUILD_BINDIR="$(pwd)/bin"; export SYSBUILD_BINDIR -} - - -atf_test_case no_args -no_args_body() { - setup_mocks - atf_check sysbuild4cron - - cat >expout <<EOF -Command: sysbuild - -EOF - atf_check -o file:expout cat commands.log -} - - -atf_test_case some_args -some_args_body() { - setup_mocks - atf_check sysbuild4cron -- -k -Z foo bar - - cat >expout <<EOF -Command: sysbuild -Arg: -k -Arg: -Z -Arg: foo -Arg: bar - -EOF - atf_check -o file:expout cat commands.log -} - - -atf_test_case sysbuild_fails -sysbuild_fails_body() { - setup_mocks - for number in $(seq 150); do - echo "echo line ${number}" >>bin/sysbuild - done - echo "exit 1" >>bin/sysbuild - - atf_check sysbuild4cron a - - name="$(cd sysbuild/log && echo sysbuild4cron.*.log)" - cat >expout <<EOF -Command: sysbuild -Arg: a - -Command: mail -Arg: -s -Arg: sysbuild failure report -Arg: jmmv -stdin: The following command has failed: -stdin: -stdin: $(pwd)/bin/sysbuild a -stdin: -stdin: The output of the failed command has been left in: -stdin: -stdin: $(pwd)/sysbuild/log/${name} -stdin: -stdin: The last 100 of the log follow: -stdin: -EOF - for number in $(seq 51 150); do - echo "stdin: line ${number}" >>expout - done - echo >>expout - - atf_check -o file:expout cat commands.log -} - - -atf_test_case custom_flags -custom_flags_body() { - setup_mocks - echo "exit 1" >>bin/sysbuild - - atf_check sysbuild4cron -l path/to/logs -r somebody@example.net - - name="$(cd path/to/logs && echo sysbuild4cron.*.log)" - cat >expout <<EOF -Command: sysbuild - -Command: mail -Arg: -s -Arg: sysbuild failure report -Arg: somebody@example.net -stdin: The following command has failed: -stdin: -stdin: $(pwd)/bin/sysbuild -stdin: -stdin: The output of the failed command has been left in: -stdin: -stdin: $(pwd)/path/to/logs/${name} -stdin: -stdin: The last 100 of the log follow: -stdin: - -EOF - - atf_check -o file:expout cat commands.log -} - - -atf_test_case capture_out_and_err -capture_out_and_err_body() { - setup_mocks - echo "echo foo" >>bin/sysbuild - echo "echo bar 1>&2" >>bin/sysbuild - echo "exit 1" >>bin/sysbuild - - atf_check sysbuild4cron - - atf_check -o match:"stdin: foo" -o match:"stdin: bar" cat commands.log -} - - -atf_test_case unknown_flag -unknown_flag_body() { - cat >experr <<EOF -sysbuild4cron: E: Unknown option -Z -Type 'man sysbuild4cron' for help -EOF - atf_check -s exit:1 -e file:experr sysbuild4cron -Z -} - - -atf_init_test_cases() { - atf_add_test_case no_args - atf_add_test_case some_args - atf_add_test_case sysbuild_fails - atf_add_test_case custom_flags - atf_add_test_case capture_out_and_err - atf_add_test_case unknown_flag -} diff --git a/sysutils/sysbuild/files/sysbuild_test.sh b/sysutils/sysbuild/files/sysbuild_test.sh deleted file mode 100644 index 6eb1652e4bd..00000000000 --- a/sysutils/sysbuild/files/sysbuild_test.sh +++ /dev/null @@ -1,1176 +0,0 @@ -#! @ATF_SH@ -# Copyright 2012 Google Inc. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of Google Inc. nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# 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. - - -# Path to a local cvsroot for testing purposes. -MOCK_CVSROOT=":local:$(pwd)/cvsroot" - - -# Paths to installed files. -# -# Can be overriden for test purposes only. -: ${SYSBUILD_SHAREDIR="@SYSBUILD_SHAREDIR@"} - - -# Creates a fake program that records its invocations for later processing. -# -# The fake program, when invoked, will append its arguments to a commands.log -# file in the test case's work directory. -# -# \param binary The path to the program to create. -# \param delegate If set to 'yes', execute the real program afterwards. -create_mock_binary() { - local binary="${1}"; shift - local delegate=no - [ ${#} -eq 0 ] || { delegate="${1}"; shift; } - - cat >"${binary}" <<EOF -#! /bin/sh - -logfile="${HOME}/commands.log" -echo "Command: \${0##*/}" >>"\${logfile}" -echo "Directory: \$(pwd)" >>"\${logfile}" -for arg in "\${@}"; do - echo "Arg: \${arg}" >>"\${logfile}" -done - echo >>"\${logfile}" -EOF - - if [ "${delegate}" = yes ]; then - cat >>"${binary}" <<EOF -PATH="${PATH}" -exec "\${0##*/}" "\${@}" -EOF - fi - - chmod +x "${binary}" -} - - -# Creates a fake CVS repository with a src and an xsrc module. -# -# \param repository Path to the repository to create. -create_mock_cvsroot() { - local repository="${1}"; shift - - atf_check -o ignore -e ignore cvs -d "${repository}" init - - mkdir src - cd src - create_mock_binary build.sh - echo "first revision" >file-in-src - cvs -d "${repository}" import -m "Import." src VENDOR_TAG release_tag - cd - - rm -rf src - - mkdir xsrc - cd xsrc - echo "first revision" >file-in-xsrc - cvs -d "${repository}" import -m "Import." xsrc VENDOR_TAG release_tag - cd - - rm -rf xsrc -} - - -atf_test_case build__custom_dirs -build__custom_dirs_body() { - create_mock_cvsroot "${MOCK_CVSROOT}" - - create_mock_binary cvs yes - PATH="$(pwd):${PATH}" - - cat >test.conf <<EOF -BUILD_ROOT=$(pwd)/b -CVSROOT=${MOCK_CVSROOT} -RELEASEDIR=$(pwd)/r -SRCDIR=$(pwd)/s -XSRCDIR=$(pwd)/x -EOF - - atf_check -o save:stdout -e save:stderr sysbuild -c test.conf build - - cat >expout <<EOF -Command: cvs -Directory: ${HOME}/s/.cvs-checkout -Arg: -d${MOCK_CVSROOT} -Arg: -q -Arg: checkout -Arg: -P -Arg: src - -Command: cvs -Directory: ${HOME}/x/.cvs-checkout -Arg: -d${MOCK_CVSROOT} -Arg: -q -Arg: checkout -Arg: -P -Arg: xsrc - -Command: build.sh -Directory: ${HOME}/s -Arg: -D${HOME}/b/$(uname -m)/destdir -Arg: -M${HOME}/b/$(uname -m)/obj -Arg: -N2 -Arg: -R${HOME}/r -Arg: -T${HOME}/b/$(uname -m)/tools -Arg: -U -Arg: -X${HOME}/x -Arg: -m$(uname -m) -Arg: -x -Arg: release - -EOF - atf_check -o file:expout cat commands.log -} - - -atf_test_case build__defaults -build__defaults_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}" build - - 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/$(uname -m)/destdir -Arg: -M${HOME}/sysbuild/$(uname -m)/obj -Arg: -N2 -Arg: -R${HOME}/sysbuild/release -Arg: -T${HOME}/sysbuild/$(uname -m)/tools -Arg: -U -Arg: -m$(uname -m) -Arg: release - -EOF - atf_check -o file:expout cat commands.log -} - - -atf_test_case build__remove_all -build__remove_all_body() { - create_mock_cvsroot "${MOCK_CVSROOT}" - mkdir sysbuild - cd sysbuild - atf_check -o ignore -e ignore cvs -d"${MOCK_CVSROOT}" checkout -P src - cd - - - create_mock_binary cvs - PATH="$(pwd):${PATH}" - - mkdir -p "sysbuild/$(uname -m)/destdir/a" - mkdir -p "sysbuild/$(uname -m)/obj/b" - mkdir -p "sysbuild/$(uname -m)/tools/c" - mkdir -p "sysbuild/$(uname -m)/keep-me" - - atf_check -o save:stdout -e save:stderr sysbuild \ - -c /dev/null -o CVSROOT="${MOCK_CVSROOT}" build - - [ ! -d "sysbuild/$(uname -m)/destdir" ] || atf_fail "destdir not removed" - [ ! -d "sysbuild/$(uname -m)/obj" ] || atf_fail "obj not removed" - [ ! -d "sysbuild/$(uname -m)/tools" ] || atf_fail "tools not removed" - [ -d "sysbuild/$(uname -m)/keep-me" ] || atf_fail "All of buildroot removed" -} - - -atf_test_case build__fast_mode -build__fast_mode_body() { - create_mock_cvsroot "${MOCK_CVSROOT}" - mkdir sysbuild - cd sysbuild - atf_check -o ignore -e ignore cvs -d"${MOCK_CVSROOT}" checkout -P src - cd - - - create_mock_binary cvs - PATH="$(pwd):${PATH}" - - mkdir -p "sysbuild/$(uname -m)/destdir/bin" - mkdir -p "sysbuild/$(uname -m)/destdir/stand/$(uname -m)/1.2.3" - - atf_check -o save:stdout -e save:stderr sysbuild \ - -c /dev/null -o CVSROOT="${MOCK_CVSROOT}" build -f - - cat >expout <<EOF -Command: build.sh -Directory: ${HOME}/sysbuild/src -Arg: -D${HOME}/sysbuild/$(uname -m)/destdir -Arg: -M${HOME}/sysbuild/$(uname -m)/obj -Arg: -N2 -Arg: -R${HOME}/sysbuild/release -Arg: -T${HOME}/sysbuild/$(uname -m)/tools -Arg: -U -Arg: -m$(uname -m) -Arg: -u -Arg: release - -EOF - atf_check -o file:expout cat commands.log - - [ -d "sysbuild/$(uname -m)/destdir/bin" ] \ - || atf_fail "Deleted a directory that should not have been deleted" - [ ! -d "sysbuild/$(uname -m)/destdir/stand/$(uname -m)/1.2.3" ] \ - || atf_fail "Obsolete modules not deleted" -} - - -atf_test_case build__many_machines -build__many_machines_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 - - 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: 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: 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: release - -EOF - atf_check -o file:expout cat commands.log -} - - -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__mkvars -build__mkvars_body() { - mkdir -p sysbuild/src - create_mock_binary sysbuild/src/build.sh - - atf_check -o save:stdout -e save:stderr sysbuild \ - -c /dev/null -o CVSROOT="${MOCK_CVSROOT}" \ - -o MKVARS="MKDEBUG=yes FOO=bar" build -f - - cat >expout <<EOF -Command: build.sh -Directory: ${HOME}/sysbuild/src -Arg: -D${HOME}/sysbuild/$(uname -m)/destdir -Arg: -M${HOME}/sysbuild/$(uname -m)/obj -Arg: -N2 -Arg: -R${HOME}/sysbuild/release -Arg: -T${HOME}/sysbuild/$(uname -m)/tools -Arg: -U -Arg: -VMKDEBUG=yes -Arg: -VFOO=bar -Arg: -m$(uname -m) -Arg: -u -Arg: release - -EOF - atf_check -o file:expout cat commands.log -} - - -atf_test_case build__with_x11 -build__with_x11_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 XSRCDIR="${HOME}/sysbuild/xsrc" build - - cat >expout <<EOF -Command: cvs -Directory: ${HOME}/sysbuild/src/.cvs-checkout -Arg: -d${MOCK_CVSROOT} -Arg: -q -Arg: checkout -Arg: -P -Arg: src - -Command: cvs -Directory: ${HOME}/sysbuild/xsrc/.cvs-checkout -Arg: -d${MOCK_CVSROOT} -Arg: -q -Arg: checkout -Arg: -P -Arg: xsrc - -Command: build.sh -Directory: ${HOME}/sysbuild/src -Arg: -D${HOME}/sysbuild/$(uname -m)/destdir -Arg: -M${HOME}/sysbuild/$(uname -m)/obj -Arg: -N2 -Arg: -R${HOME}/sysbuild/release -Arg: -T${HOME}/sysbuild/$(uname -m)/tools -Arg: -U -Arg: -X${HOME}/sysbuild/xsrc -Arg: -m$(uname -m) -Arg: -x -Arg: release - -EOF - atf_check -o file:expout cat commands.log -} - - -atf_test_case build__some_args -build__some_args_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}" build a foo b - - 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/$(uname -m)/destdir -Arg: -M${HOME}/sysbuild/$(uname -m)/obj -Arg: -N2 -Arg: -R${HOME}/sysbuild/release -Arg: -T${HOME}/sysbuild/$(uname -m)/tools -Arg: -U -Arg: -m$(uname -m) -Arg: a -Arg: foo -Arg: b - -EOF - atf_check -o file:expout cat commands.log -} - - -atf_test_case build__hooks__ok -build__hooks__ok_body() { - create_mock_cvsroot "${MOCK_CVSROOT}" - - create_mock_binary cvs yes - PATH="$(pwd):${PATH}" - - cat >test.conf <<EOF -CVSROOT="${MOCK_CVSROOT}" -MACHINES="one two" # Build hooks are only supposed to be called once. -SRCDIR="$(pwd)/checkout/src" - -pre_fetch_hook() { - echo "Hook before fetch: \${SRCDIR}" -} - -post_fetch_hook() { - echo "Hook after fetch" -} - -pre_build_hook() { - echo "Hook before build: \${MACHINES}" -} - -post_build_hook() { - echo "Hook after build" -} -EOF - - atf_check -o save:stdout -e save:stderr sysbuild -c test.conf build - grep 'Command: build.sh' commands.log || atf_fail "build.sh not run" - - cat >exp_order <<EOF -Hook before fetch: $(pwd)/checkout/src -Hook after fetch -Hook before build: one two -Hook after build -EOF - atf_check -o file:exp_order grep '^Hook' stdout -} - - -atf_test_case build__hooks__pre_fail -build__hooks__pre_fail_body() { - create_mock_cvsroot "${MOCK_CVSROOT}" - cat >test.conf <<EOF -CVSROOT="${MOCK_CVSROOT}" -SRCDIR="$(pwd)/checkout/src" - -pre_fetch_hook() { - echo "Hook before fetch" -} - -post_fetch_hook() { - echo "Hook after fetch" -} - -pre_build_hook() { - echo "Hook before build" - false -} - -post_build_hook() { - echo "Hook after build" -} -EOF - - atf_check -s exit:1 -o save:stdout -e save:stderr \ - sysbuild -c test.conf build - if grep 'Command: build.sh' commands.log; then - atf_fail "build.sh should not have been run" - fi - - cat >exp_order <<EOF -Hook before fetch -Hook after fetch -Hook before build -EOF - atf_check -o file:exp_order grep '^Hook' stdout -} - - -atf_test_case build__hooks__post_fail -build__hooks__post_fail_body() { - create_mock_cvsroot "${MOCK_CVSROOT}" - cat >test.conf <<EOF -CVSROOT="${MOCK_CVSROOT}" -SRCDIR="$(pwd)/checkout/src" - -pre_build_hook() { - echo "Hook before build" -} - -post_build_hook() { - echo "Hook after build" - false -} -EOF - - atf_check -s exit:1 -o save:stdout -e save:stderr \ - sysbuild -c test.conf build - grep 'Command: build.sh' commands.log || atf_fail "build.sh not run" - - cat >exp_order <<EOF -Hook before build -Hook after build -EOF - atf_check -o file:exp_order grep '^Hook' stdout -} - - -atf_test_case build__cvs_fails -build__cvs_fails_body() { - create_mock_cvsroot "${MOCK_CVSROOT}" - mkdir sysbuild - cd sysbuild - atf_check -o ignore -e ignore cvs -d"${MOCK_CVSROOT}" checkout -P src - cd - - - create_mock_binary cvs yes - PATH="$(pwd):${PATH}" - - atf_check -s exit:1 -o save:stdout -e save:stderr sysbuild \ - -c /dev/null -o CVSROOT="${MOCK_CVSROOT}" -o CVSTAG=invalid build - - cat >expout <<EOF -Command: cvs -Directory: ${HOME}/sysbuild/src -Arg: -d${MOCK_CVSROOT} -Arg: -q -Arg: update -Arg: -d -Arg: -P -Arg: -rinvalid - -EOF - atf_check -o file:expout cat commands.log -} - - -atf_test_case config__builtins -config__builtins_body() { - cat >expout <<EOF -BUILD_ROOT = ${HOME}/sysbuild -BUILD_TARGETS = release -CVSROOT = :ext:anoncvs@anoncvs.NetBSD.org:/cvsroot -CVSTAG is undefined -INCREMENTAL_BUILD = false -MACHINES = $(uname -m) -MKVARS is undefined -NJOBS is undefined -RELEASEDIR = ${HOME}/sysbuild/release -SRCDIR = ${HOME}/sysbuild/src -UPDATE_SOURCES = true -XSRCDIR is undefined -EOF - atf_check -o file:expout sysbuild -c /dev/null config -} - - -atf_test_case config__path__components -config__path__components_body() { - mkdir .sysbuild - mkdir system - export SYSBUILD_ETCDIR="$(pwd)/system" - - echo "BUILD_TARGETS=foo" >my-file - atf_check -o match:"BUILD_TARGETS = foo" sysbuild -c ./my-file config -} - - -atf_test_case config__path__extension -config__path__extension_body() { - mkdir .sysbuild - mkdir system - export SYSBUILD_ETCDIR="$(pwd)/system" - - echo "BUILD_TARGETS=bar" >my-file.conf - atf_check -o match:"BUILD_TARGETS = bar" sysbuild -c my-file.conf config -} - - -atf_test_case config__name__system_directory -config__name__system_directory_body() { - mkdir .sysbuild - mkdir system - export SYSBUILD_ETCDIR="$(pwd)/system" - - echo "BUILD_TARGETS='some value'" >system/foo.conf - atf_check -o match:"BUILD_TARGETS = some value" sysbuild -c foo config -} - - -atf_test_case config__name__user_directory -config__name__user_directory_body() { - mkdir .sysbuild - mkdir system - export SYSBUILD_ETCDIR="$(pwd)/system" - - echo "BUILD_TARGETS='some value'" >system/foo.conf - echo "BUILD_TARGETS='other value'" >.sysbuild/foo.conf - atf_check -o match:"BUILD_TARGETS = other value" sysbuild -c foo config -} - - -atf_test_case config__name__not_found -config__name__not_found_body() { - mkdir .sysbuild - mkdir system - export SYSBUILD_ETCDIR="$(pwd)/system" - - cat >experr <<EOF -sysbuild: E: Cannot locate configuration named 'foobar' -Type 'man sysbuild' for help -EOF - atf_check -s exit:1 -o empty -e file:experr sysbuild -c foobar config -} - - -atf_test_case config__overrides -config__overrides_body() { - cat >custom.conf <<EOF -BUILD_ROOT=/tmp/test -CVSTAG=the-tag-override -EOF - - cat >expout <<EOF -BUILD_ROOT = /tmp/test -BUILD_TARGETS = release -CVSROOT = foo bar -CVSTAG = the-new-tag -INCREMENTAL_BUILD = false -MACHINES = $(uname -m) -MKVARS is undefined -NJOBS is undefined -RELEASEDIR = ${HOME}/sysbuild/release -SRCDIR is undefined -UPDATE_SOURCES = true -XSRCDIR is undefined -EOF - atf_check -o file:expout sysbuild -c custom.conf -o CVSROOT="foo bar" \ - -o CVSTAG=the-new-tag -o SRCDIR= config -} - - -atf_test_case config__too_many_args -config__too_many_args_body() { - cat >experr <<EOF -sysbuild: E: config does not take any arguments -Type 'man sysbuild' for help -EOF - atf_check -s exit:1 -e file:experr sysbuild -c /dev/null config foo -} - - -atf_test_case env__src_only -env__src_only_body() { - cat >expout <<EOF -. "${SYSBUILD_SHAREDIR}/env.sh" ; -PATH="/my/root/shark/tools/bin:\${PATH}" -D="/my/root/shark/destdir" -O="/my/root/shark/obj/usr/src" -S="/usr/src" -T="/my/root/shark/tools" -EOF - atf_check -s exit:0 -o file:expout sysbuild -c /dev/null \ - -o BUILD_ROOT=/my/root -o MACHINES=shark -o SRCDIR=/usr/src env -} - - -atf_test_case env__src_and_xsrc -env__src_and_xsrc_body() { - cat >expout <<EOF -. "${SYSBUILD_SHAREDIR}/env.sh" ; -PATH="/my/root/i386/tools/bin:\${PATH}" -D="/my/root/i386/destdir" -O="/my/root/i386/obj/a/b/src" -S="/a/b/src" -T="/my/root/i386/tools" -XO="/my/root/i386/obj/d/xsrc" -XS="/d/xsrc" -EOF - atf_check -s exit:0 -o file:expout sysbuild -c /dev/null \ - -o BUILD_ROOT=/my/root -o MACHINES=i386 -o SRCDIR=/a/b/src \ - -o XSRCDIR=/d/xsrc env -} - - -atf_test_case env__explicit_machine -env__explicit_machine_body() { - cat >expout <<EOF -. "${SYSBUILD_SHAREDIR}/env.sh" ; -PATH="/my/root/macppc/tools/bin:\${PATH}" -D="/my/root/macppc/destdir" -O="/my/root/macppc/obj/usr/src" -S="/usr/src" -T="/my/root/macppc/tools" -EOF - atf_check -s exit:0 -o file:expout sysbuild -c /dev/null \ - -o BUILD_ROOT=/my/root -o MACHINES="amd64 i386" -o SRCDIR=/usr/src \ - env macppc -} - - -atf_test_case env__eval -env__eval_body() { - make_one() { - mkdir -p "${1}" - touch "${1}/${2}" - } - make_one src src.cookie - make_one xsrc xsrc.cookie - make_one root/mach/destdir destdir.cookie - make_one root/mach/tools tools.cookie - make_one root/mach/"obj$(pwd)"/src src-obj.cookie - make_one root/mach/"obj$(pwd)"/xsrc xsrc-obj.cookie - - find src xsrc root - - mkdir -p root/mach/tools/bin - cat >root/mach/tools/bin/nbmake-mach <<EOF -#! /bin/sh -echo "This is nbmake!" -EOF - chmod +x root/mach/tools/bin/nbmake-mach - - atf_check -s exit:0 -o save:env.sh sysbuild -c /dev/null \ - -o BUILD_ROOT="$(pwd)/root" \ - -o MACHINES="mach" \ - -o SRCDIR="$(pwd)/src" \ - -o XSRCDIR="$(pwd)/xsrc" \ - env - - eval $(cat ./env.sh) - - [ -f "${D}/destdir.cookie" ] || atf_fail "D points to the wrong place" - [ -f "${O}/src-obj.cookie" ] || atf_fail "O points to the wrong place" - [ -f "${S}/src.cookie" ] || atf_fail "S points to the wrong place" - [ -f "${T}/tools.cookie" ] || atf_fail "T points to the wrong place" - [ -f "${XO}/xsrc-obj.cookie" ] || atf_fail "XO points to the wrong place" - [ -f "${XS}/xsrc.cookie" ] || atf_fail "XS points to the wrong place" - atf_check -o inline:"This is nbmake!\n" nbmake-mach - - mkdir -p src/bin/ls - atf_check_equal '$(pwd)/root/mach/obj$(pwd)/src/bin/ls' \ - '$(cd src/bin/ls && curobj)' - - mkdir -p xsrc/some/other/dir - atf_check_equal '$(pwd)/root/mach/obj$(pwd)/xsrc/some/other/dir' \ - '$(cd xsrc/some/other/dir && curobj)' - - mkdir a - atf_check_equal 'NOT-FOUND' '$(cd a && curobj)' - atf_check_equal 'NOT-FOUND' '$(cd /bin && curobj)' -} - - -atf_test_case env__too_many_machines -env__too_many_machines_body() { - cat >experr <<EOF -sysbuild: E: No machine name provided as an argument and MACHINES contains more than one name -Type 'man sysbuild' for help -EOF - atf_check -s exit:1 -e file:experr sysbuild -c /dev/null \ - -o MACHINES="amd64 i386" env -} - - -atf_test_case env__too_many_args -env__too_many_args_body() { - cat >experr <<EOF -sysbuild: E: env takes zero or one arguments -Type 'man sysbuild' for help -EOF - atf_check -s exit:1 -e file:experr sysbuild -c /dev/null env foo bar -} - - -atf_test_case fetch__checkout__src_only -fetch__checkout__src_only_body() { - create_mock_cvsroot "${MOCK_CVSROOT}" - cat >test.conf <<EOF -CVSROOT="${MOCK_CVSROOT}" -SRCDIR="$(pwd)/checkout/src" -XSRCDIR= -EOF - - atf_check -o ignore -e not-match:"xsrc" sysbuild -c test.conf fetch - test -f checkout/src/file-in-src || atf_fail "src not checked out" - test ! -d checkout/xsrc || atf_fail "xsrc checked out but not requested" -} - - -atf_test_case fetch__checkout__src_and_xsrc -fetch__checkout__src_and_xsrc_body() { - create_mock_cvsroot "${MOCK_CVSROOT}" - cat >test.conf <<EOF -CVSROOT="${MOCK_CVSROOT}" -SRCDIR="$(pwd)/checkout/src" -XSRCDIR="$(pwd)/checkout/xsrc" -EOF - - atf_check -o ignore -e ignore sysbuild -c test.conf fetch - test -f checkout/src/file-in-src || atf_fail "src not checked out" - test -f checkout/xsrc/file-in-xsrc || atf_fail "xsrc not checked out" -} - - -atf_test_case fetch__update__src_only -fetch__update__src_only_body() { - create_mock_cvsroot "${MOCK_CVSROOT}" - cat >test.conf <<EOF -CVSROOT="${MOCK_CVSROOT}" -SRCDIR="$(pwd)/checkout/src" -XSRCDIR= -EOF - - mkdir checkout - cd checkout - atf_check -o ignore -e ignore cvs -d"${MOCK_CVSROOT}" checkout -P src - cd - - - cp -rf checkout/src src-copy - cd src-copy - echo "second revision" >file-in-src - cvs commit -m "Second revision." - cd - - - test -f checkout/src/file-in-src || atf_fail "src not present yet" - if grep "second revision" checkout/src/file-in-src >/dev/null; then - atf_fail "second revision already present" - fi - - atf_check -o ignore -e not-match:"xsrc" sysbuild -c test.conf fetch - - grep "second revision" checkout/src/file-in-src >/dev/null \ - || atf_fail "src not updated" - test ! -d checkout/xsrc || atf_fail "xsrc checked out but not requested" -} - - -atf_test_case fetch__update__src_and_xsrc -fetch__update__src_and_xsrc_body() { - create_mock_cvsroot "${MOCK_CVSROOT}" - cat >test.conf <<EOF -CVSROOT="${MOCK_CVSROOT}" -SRCDIR="$(pwd)/checkout/src" -XSRCDIR="$(pwd)/checkout/xsrc" -EOF - - mkdir checkout - cd checkout - atf_check -o ignore -e ignore cvs -d"${MOCK_CVSROOT}" checkout -P src xsrc - cd - - - cp -rf checkout/src src-copy - cd src-copy - echo "second revision" >file-in-src - cvs commit -m "Second revision." - cd - - - cp -rf checkout/xsrc xsrc-copy - cd xsrc-copy - echo "second revision" >file-in-xsrc - cvs commit -m "Second revision." - cd - - - test -f checkout/src/file-in-src || atf_fail "src not present yet" - if grep "second revision" checkout/src/file-in-src >/dev/null; then - atf_fail "second revision already present" - fi - test -f checkout/xsrc/file-in-xsrc || atf_fail "xsrc not present yet" - if grep "second revision" checkout/xsrc/file-in-xsrc >/dev/null; then - atf_fail "second revision already present" - fi - - atf_check -o ignore -e ignore sysbuild -c test.conf fetch - - grep "second revision" checkout/src/file-in-src >/dev/null \ - || atf_fail "src not updated" - grep "second revision" checkout/xsrc/file-in-xsrc >/dev/null \ - || atf_fail "xsrc not updated" -} - - -atf_test_case fetch__hooks__ok -fetch__hooks__ok_body() { - create_mock_cvsroot "${MOCK_CVSROOT}" - cat >test.conf <<EOF -CVSROOT="${MOCK_CVSROOT}" -SRCDIR="$(pwd)/checkout/src" -XSRCDIR="$(pwd)/checkout/xsrc" - -pre_fetch_hook() { - echo "Hook before fetch: \${CVSROOT}" - test ! -d "${SRCDIR}" -} - -post_fetch_hook() { - test -d "${SRCDIR}" - echo "Hook after fetch" -} -EOF - - atf_check -o save:stdout -e ignore sysbuild -c test.conf fetch - test -f checkout/src/file-in-src || atf_fail "src not checked out" - test -f checkout/xsrc/file-in-xsrc || atf_fail "xsrc not checked out" - - cat >exp_order <<EOF -Hook before fetch: ${MOCK_CVSROOT} -Hook after fetch -EOF - atf_check -o file:exp_order grep '^Hook' stdout -} - - -atf_test_case fetch__hooks__pre_fail -fetch__hooks__pre_fail_body() { - create_mock_cvsroot "${MOCK_CVSROOT}" - cat >test.conf <<EOF -CVSROOT="${MOCK_CVSROOT}" -SRCDIR="$(pwd)/checkout/src" -XSRCDIR="$(pwd)/checkout/xsrc" - -pre_fetch_hook() { - echo "Hook before fetch" - false -} - -post_fetch_hook() { - echo "Hook after fetch" -} -EOF - - atf_check -s exit:1 -o save:stdout -e save:stderr \ - sysbuild -c test.conf fetch - grep 'pre_fetch_hook returned an error' stderr || \ - atf_fail "pre_fetch_hook didn't seem to fail" - test ! -f checkout/src/file-in-src || atf_fail "src checked out" - test ! -f checkout/xsrc/file-in-xsrc || atf_fail "xsrc checked out" - - cat >exp_order <<EOF -Hook before fetch -EOF - atf_check -o file:exp_order grep '^Hook' stdout -} - - -atf_test_case fetch__hooks__post_fail -fetch__hooks__post_fail_body() { - create_mock_cvsroot "${MOCK_CVSROOT}" - cat >test.conf <<EOF -CVSROOT="${MOCK_CVSROOT}" -SRCDIR="$(pwd)/checkout/src" -XSRCDIR="$(pwd)/checkout/xsrc" - -pre_fetch_hook() { - echo "Hook before fetch" -} - -post_fetch_hook() { - echo "Hook after fetch" - false -} -EOF - - atf_check -s exit:1 -o save:stdout -e save:stderr \ - sysbuild -c test.conf fetch - test -f checkout/src/file-in-src || atf_fail "src not checked out" - test -f checkout/xsrc/file-in-xsrc || atf_fail "xsrc not checked out" - grep 'post_fetch_hook returned an error' stderr || \ - atf_fail "post_fetch_hook didn't seem to fail" - - cat >exp_order <<EOF -Hook before fetch -Hook after fetch -EOF - atf_check -o file:exp_order grep '^Hook' stdout -} - - -atf_test_case fetch__too_many_args -fetch__too_many_args_body() { - cat >experr <<EOF -sysbuild: E: fetch does not take any arguments -Type 'man sysbuild' for help -EOF - atf_check -s exit:1 -e file:experr sysbuild -c /dev/null fetch foo -} - - -atf_test_case no_command -no_command_body() { - cat >experr <<EOF -sysbuild: E: No command specified -Type 'man sysbuild' for help -EOF - atf_check -s exit:1 -e file:experr sysbuild -} - - -atf_test_case unknown_command -unknown_command_body() { - cat >experr <<EOF -sysbuild: E: Unknown command foo -Type 'man sysbuild' for help -EOF - atf_check -s exit:1 -e file:experr sysbuild foo -} - - -atf_test_case unknown_flag -unknown_flag_body() { - cat >experr <<EOF -sysbuild: E: Unknown option -Z -Type 'man sysbuild' for help -EOF - atf_check -s exit:1 -e file:experr sysbuild -Z -} - - -atf_init_test_cases() { - atf_add_test_case build__custom_dirs - atf_add_test_case build__defaults - 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__mkvars - atf_add_test_case build__with_x11 - atf_add_test_case build__some_args - atf_add_test_case build__hooks__ok - atf_add_test_case build__hooks__pre_fail - atf_add_test_case build__hooks__post_fail - atf_add_test_case build__cvs_fails - - atf_add_test_case config__builtins - atf_add_test_case config__path__components - atf_add_test_case config__path__extension - atf_add_test_case config__name__system_directory - atf_add_test_case config__name__user_directory - atf_add_test_case config__name__not_found - atf_add_test_case config__overrides - atf_add_test_case config__too_many_args - - atf_add_test_case env__src_only - atf_add_test_case env__src_and_xsrc - atf_add_test_case env__explicit_machine - atf_add_test_case env__eval - atf_add_test_case env__too_many_machines - atf_add_test_case env__too_many_args - - atf_add_test_case fetch__checkout__src_only - atf_add_test_case fetch__checkout__src_and_xsrc - atf_add_test_case fetch__update__src_only - atf_add_test_case fetch__update__src_and_xsrc - atf_add_test_case fetch__hooks__ok - atf_add_test_case fetch__hooks__pre_fail - atf_add_test_case fetch__hooks__post_fail - atf_add_test_case fetch__too_many_args - - atf_add_test_case no_command - atf_add_test_case unknown_command - atf_add_test_case unknown_flag -} |