pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/sysutils/sysbuild Update to 2.3:



details:   https://anonhg.NetBSD.org/pkgsrc/rev/2ad7e50e7b62
branches:  trunk
changeset: 608020:2ad7e50e7b62
user:      jmmv <jmmv%pkgsrc.org@localhost>
date:      Sat Aug 25 19:20:53 2012 +0000

description:
Update to 2.3:

- Added the 'env' command.  This prints a small shell snippet that can be
  imported into the current shell.  The printed code defines a set of
  convenience global variables and functions to work with the source tree.

diffstat:

 sysutils/sysbuild/Makefile               |   14 ++-
 sysutils/sysbuild/PLIST                  |    3 +-
 sysutils/sysbuild/files/env.sh           |   52 +++++++++++
 sysutils/sysbuild/files/sysbuild.1       |   70 +++++++++++++++-
 sysutils/sysbuild/files/sysbuild.sh      |   48 ++++++++++-
 sysutils/sysbuild/files/sysbuild_test.sh |  136 +++++++++++++++++++++++++++++++
 6 files changed, 315 insertions(+), 8 deletions(-)

diffs (truncated from 452 to 300 lines):

diff -r b897b7a62abe -r 2ad7e50e7b62 sysutils/sysbuild/Makefile
--- a/sysutils/sysbuild/Makefile        Sat Aug 25 15:31:46 2012 +0000
+++ b/sysutils/sysbuild/Makefile        Sat Aug 25 19:20:53 2012 +0000
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.20 2012/08/23 02:26:56 jmmv Exp $
+# $NetBSD: Makefile,v 1.21 2012/08/25 19:20:53 jmmv Exp $
 
-DISTNAME=      sysbuild-2.2
+DISTNAME=      sysbuild-2.3
 CATEGORIES=    sysutils
 MASTER_SITES=  # empty
 DISTFILES=     # empty
@@ -18,6 +18,7 @@
 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'
 
 PKG_SYSCONFSUBDIR=     sysbuild
 EGDIR=                 ${PREFIX}/share/examples/sysbuild
@@ -55,7 +56,8 @@
 .endfor
 
 do-test:
-       cd ${WRKSRC} && PATH="${WRKSRC}:${PATH}" kyua test
+       cd ${WRKSRC} && PATH="${WRKSRC}:${PATH}" \
+           SYSBUILD_SHAREDIR="${WRKSRC}" kyua test
 .else
 PLIST_SUBST+=  TESTS=@comment
 .endif
@@ -69,8 +71,11 @@
 .for file in sysbuild.1 sysbuild4cron.1 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 share/examples/sysbuild
+INSTALLATION_DIRS+=    bin ${PKGMANDIR}/man1 \
+                       share/examples/sysbuild share/sysbuild
 
 do-install:
        ${INSTALL_SCRIPT} ${WRKSRC}/sysbuild ${DESTDIR}${PREFIX}/bin/
@@ -82,6 +87,7 @@
 .for file in default.conf
        ${INSTALL_DATA} ${WRKSRC}/${file} ${DESTDIR}${EGDIR}
 .endfor
+       ${INSTALL_SCRIPT} ${WRKSRC}/env.sh ${DESTDIR}${PREFIX}/share/sysbuild
 
 .include "../../devel/shtk/buildlink3.mk"
 .include "../../mk/bsd.pkg.mk"
diff -r b897b7a62abe -r 2ad7e50e7b62 sysutils/sysbuild/PLIST
--- a/sysutils/sysbuild/PLIST   Sat Aug 25 15:31:46 2012 +0000
+++ b/sysutils/sysbuild/PLIST   Sat Aug 25 19:20:53 2012 +0000
@@ -1,9 +1,10 @@
-@comment $NetBSD: PLIST,v 1.5 2012/08/15 21:20:14 jmmv Exp $
+@comment $NetBSD: PLIST,v 1.6 2012/08/25 19:20:53 jmmv Exp $
 bin/sysbuild
 bin/sysbuild4cron
 man/man1/sysbuild.1
 man/man1/sysbuild4cron.1
 share/examples/sysbuild/default.conf
+share/sysbuild/env.sh
 ${TESTS}tests/sysbuild/Kyuafile
 ${TESTS}tests/sysbuild/sysbuild_test
 ${TESTS}tests/sysbuild/sysbuild4cron_test
diff -r b897b7a62abe -r 2ad7e50e7b62 sysutils/sysbuild/files/env.sh
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sysutils/sysbuild/files/env.sh    Sat Aug 25 19:20:53 2012 +0000
@@ -0,0 +1,52 @@
+# 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 -r b897b7a62abe -r 2ad7e50e7b62 sysutils/sysbuild/files/sysbuild.1
--- a/sysutils/sysbuild/files/sysbuild.1        Sat Aug 25 15:31:46 2012 +0000
+++ b/sysutils/sysbuild/files/sysbuild.1        Sat Aug 25 19:20:53 2012 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: sysbuild.1,v 1.4 2012/08/23 02:26:57 jmmv Exp $
+.\" $NetBSD: sysbuild.1,v 1.5 2012/08/25 19:20:53 jmmv Exp $
 .\" Copyright 2012 Google Inc.
 .\" All rights reserved.
 .\"
@@ -26,7 +26,7 @@
 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 .\" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-.Dd August 22, 2012
+.Dd August 25, 2012
 .Dt SYSBUILD 1
 .Os
 .Sh NAME
@@ -46,6 +46,11 @@
 .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
@@ -181,6 +186,67 @@
 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
diff -r b897b7a62abe -r 2ad7e50e7b62 sysutils/sysbuild/files/sysbuild.sh
--- a/sysutils/sysbuild/files/sysbuild.sh       Sat Aug 25 15:31:46 2012 +0000
+++ b/sysutils/sysbuild/files/sysbuild.sh       Sat Aug 25 19:20:53 2012 +0000
@@ -47,6 +47,7 @@
 #
 # Can be overriden for test purposes only.
 : ${SYSBUILD_ETCDIR="@SYSBUILD_ETCDIR@"}
+: ${SYSBUILD_SHAREDIR="@SYSBUILD_SHAREDIR@"}
 
 
 # Sets defaults for configuration variables that need a value.
@@ -209,6 +210,51 @@
 }
 
 
+# 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.
@@ -294,7 +340,7 @@
 
     local command="${1}"; shift
     case "${command}" in
-        build|config|fetch)
+        build|config|env|fetch)
             sysbuild_set_defaults
             sysbuild_config_load "${config_name}"
             "sysbuild_${command}" "${@}" || exit_code="${?}"
diff -r b897b7a62abe -r 2ad7e50e7b62 sysutils/sysbuild/files/sysbuild_test.sh
--- a/sysutils/sysbuild/files/sysbuild_test.sh  Sat Aug 25 15:31:46 2012 +0000
+++ b/sysutils/sysbuild/files/sysbuild_test.sh  Sat Aug 25 19:20:53 2012 +0000
@@ -32,6 +32,12 @@
 MOCK_CVSROOT=":local:$(pwd)/cvsroot"
 
 
+# Paths to installed files.



Home | Main Index | Thread Index | Old Index