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.
This commit is contained in:
parent
10f8a1f5d0
commit
06451ac2a6
13 changed files with 23 additions and 2625 deletions
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
|
5
sysutils/sysbuild/distinfo
Normal file
5
sysutils/sysbuild/distinfo
Normal file
|
@ -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
|
|
@ -1,6 +0,0 @@
|
|||
syntax("kyuafile", 1)
|
||||
|
||||
test_suite("sysbuild")
|
||||
|
||||
atf_test_program{name="sysbuild_test"}
|
||||
atf_test_program{name="sysbuild4cron_test"}
|
|
@ -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)"
|
|
@ -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
|
||||
}
|
|
@ -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 .
|
|
@ -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
|
|
@ -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}"
|
||||
}
|
|
@ -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 .
|
|
@ -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}" "${@}"
|
||||
}
|
|
@ -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
|
||||
}
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue