diff options
| author | lukem <lukem@NetBSD.org> | 2003-01-26 05:34:32 +0000 |
|---|---|---|
| committer | lukem <lukem@NetBSD.org> | 2003-01-26 05:34:32 +0000 |
| commit | 46d44d89e95ef0b31eb7c8d3d2eff3b8f5ed91ac (patch) | |
| tree | 45c846575aad2f63996578c2faa3f993af266d92 | |
| parent | 6f90a0ed10afd2834db980ed3a4e6336933a728f (diff) | |
Change build.sh so that at least one operation is required.
Add "makewrapper" operation to build.sh.
[The above changes were suggested by Alan Barrett on current-users@]
Fail if building as non-root unless: UNPRIVED is set, -U is given, or -E
(expert mode) is given.
[Suggested by James Wetterau in private email]
Improve the examples in BUILDING.
| -rw-r--r-- | BUILDING | 48 | ||||
| -rwxr-xr-x | build.sh | 47 | ||||
| -rw-r--r-- | doc/BUILDING.mdoc | 53 |
3 files changed, 81 insertions, 67 deletions
@@ -462,6 +462,9 @@ BUILDING release Build a full release as per ``make release''. This option implies the distribution operation. + makewrapper Create the nbmake-MACHINE wrapper. This operation is auto- + matically performed for any of the other operations. + obj Perform ``make obj''. tools Build and install the host tools from src/tools. @@ -494,8 +497,13 @@ BUILDING -D dest Set the value of DESTDIR to dest. - -E Set `expert' mode; DESTDIR does not have to be set to a non- - root path for builds when this is set. + -E Set `expert' mode. This overrides various sanity checks, and + allows: DESTDIR does not have to be set to a non-root path for + builds, and UNPRIVED does not have to be set when building as a + non-root user. + + Note: It is highly recommended that you know what you are doing + when you use this option. -j njob Passed through to make(1). Makefiles should use .WAIT or have explicit dependancies as necessary to enforce build ordering. @@ -536,9 +544,7 @@ BUILDING -u Set the UPDATE variable. -V var=[value] - Set the variable var to value (which is optional). This is - useful for setting RELEASEDIR without actually building a re- - lease. + Set the variable var to value (which is optional). -w wrapper Create the nbmake wrapper script (see below) in a custom loca- @@ -558,35 +564,25 @@ BUILDING with an absolute path. EXAMPLES - ./build.sh tools - Build a new toolchain. - - cd ${KERNCONFDIR} ; ${TOOLDIR}/bin/nbconfig GENERIC - Use the new version of config(8) to prepare to build a new - GENERIC kernel. - - cd ${KERNOBJDIR}/GENERIC ; ${TOOLDIR}/bin/nbmake-${MACHINE} dependall - Use the new toolchain to build a new GENERIC kernel. - ./build.sh tools kernel=GENERIC Build a new toolchain, and use the new toolchain to configure and build a new GENERIC kernel. This is a simpler way to achieve what the first three examples do. - ./build.sh -U distribution + ./build.sh -U -D /some/DESTDIR distribution Using unprivileged mode, build a complete distribution in - DESTDIR. + /some/DESTDIR. - # ./build.sh -U installworld=/ + # ./build.sh -U -D /some/DESTDIR installworld=/ As root, install the distribution that was built with unprivi- - leged mode from DESTDIR to /. (Even though this is run as - root, -U is required so that the permissions stored in - DESTDIR/METALOG are correctly applied to the files as they're - copied to /). + leged mode from /some/DESTDIR to /. (Even though this is run + as root, -U is required so that the permissions stored in + /some/DESTDIR/METALOG are correctly applied to the files as + they're copied to /). - ./build.sh -U -R /some/dir/RELEASE release - Using unprivileged mode, build a complete release in the speci- - fied release directory. + ./build.sh -U -D /some/dir/DESTDIR -R /some/dir/RELEASE release + Using unprivileged mode, build a complete release in + /some/dir/RELEASE. OBSOLETE VARIABLES NBUILDJOBS Use the make(1) option -j, instead. @@ -605,4 +601,4 @@ HISTORY BUGS A few platforms are not yet using this build system. -NetBSD January 24, 2003 10 +NetBSD January 26, 2003 10 @@ -1,5 +1,5 @@ #! /usr/bin/env sh -# $NetBSD: build.sh,v 1.85 2003/01/24 01:17:52 lukem Exp $ +# $NetBSD: build.sh,v 1.86 2003/01/26 05:34:32 lukem Exp $ # # Copyright (c) 2001-2003 The NetBSD Foundation, Inc. # All rights reserved. @@ -234,15 +234,16 @@ usage() Usage: ${progname} [-EnorUu] [-a arch] [-B buildid] [-D dest] [-j njob] [-M obj] [-m mach] [-O obj] [-R release] [-T tools] [-V var=[value]] - [-w wrapper] [operation [...] ] + [-w wrapper] operation [...] - System build operations (all imply "obj" and "tools"): + Build operations (all imply "obj" and "tools"): build Run "make build" distribution Run "make distribution" (includes etc/ files) release Run "make release" (includes kernels & distrib media) Other operations: - obj Run "make obj" (default unless -o) + makewrapper Create ${toolprefix}make-${MACHINE} wrapper and ${toolprefix}make. (Always done) + obj Run "make obj" (default unless -o is used) tools Build and install tools kernel=conf Build kernel with config file \`conf' install=idir Run "make installworld" to \`idir' @@ -262,12 +263,12 @@ Usage: ${progname} [-EnorUu] [-a arch] [-B buildid] [-D dest] [-j njob] [-M obj] -R release Set RELEASEDIR to release -r Remove contents of TOOLDIR and DESTDIR before building -T tools Set TOOLDIR to tools. If unset, and TOOLDIR is not set in - the environment, ${toolprefix}make will be (re)built unconditionally. - -U Set UNPRIVED - -u Set UPDATE + the environment, ${toolprefix}make will be (re)built unconditionally + -U Set UNPRIVED (build without requiring root privileges) + -u Set UPDATE (do not run "make clean" first) -V v=[val] Set variable \`v' to \`val' -w wrapper Create ${toolprefix}make script as wrapper - (default: \${TOOLDIR}/bin/${toolprefix}make-\${MACHINE}) + (Default: \${TOOLDIR}/bin/${toolprefix}make-\${MACHINE}) _usage_ exit 1 @@ -314,7 +315,7 @@ parseoptions() ;; -b) - usage "'-b' has been removed; it is the default operation" + usage "'-b' has been replaced by 'makewrapper'" ;; -D) @@ -451,13 +452,13 @@ parseoptions() case "$op" in - tools|obj|build|distribution|release) + makewrapper|obj|tools|build|distribution|release) ;; kernel=*) arg=${op#*=} op=${op%%=*} - if [ "${arg}" = "" ]; then + if [ -z "${arg}" ]; then bomb "Must supply a kernel name with \`kernel=...'" fi ;; @@ -465,7 +466,7 @@ parseoptions() install=*) arg=${op#*=} op=${op%%=*} - if [ "${arg}" = "" ]; then + if [ -z "${arg}" ]; then bomb "Must supply a directory with \`install=...'" fi ;; @@ -477,6 +478,9 @@ parseoptions() esac eval do_$op=true done + if [ -z "${operations}" ]; then + usage "Missing operation to perform." + fi # Set up MACHINE*. On a NetBSD host, these are allowed to be unset. # @@ -554,7 +558,7 @@ validatemakeparams() EXTERNAL_TOOLCHAIN=$(getmakevar EXTERNAL_TOOLCHAIN) fi if [ "${TOOLCHAIN_MISSING}" = "yes" ] && \ - [ "${EXTERNAL_TOOLCHAIN}" = "" ]; then + [ -z "${EXTERNAL_TOOLCHAIN}" ]; then $runcmd echo "ERROR: build.sh (in-tree cross-toolchain) is not yet available for" $runcmd echo " MACHINE: ${MACHINE}" $runcmd echo " MACHINE_ARCH: ${MACHINE_ARCH}" @@ -619,6 +623,13 @@ validatemakeparams() else removedirs="$removedirs $DESTDIR" fi + if $do_build || $do_distribution || $do_release; then + if ! $do_expertmode && \ + [ $(id -u 2>/dev/null) -ne 0 ] &&\ + [ -z "$UNPRIVED" ] ; then + bomb "-U or -E must be set for build as an unprivileged user." + fi + fi } @@ -670,7 +681,7 @@ createmakewrapper() eval cat <<EOF $makewrapout #! /bin/sh # Set proper variables to allow easy "make" building of a NetBSD subtree. -# Generated from: \$NetBSD: build.sh,v 1.85 2003/01/24 01:17:52 lukem Exp $ +# Generated from: \$NetBSD: build.sh,v 1.86 2003/01/26 05:34:32 lukem Exp $ # EOF @@ -695,7 +706,7 @@ buildtools() bomb "failed to make obj-tools" fi $runcmd cd tools - if [ "$UPDATE" = "" ]; then + if [ -z "$UPDATE" ]; then cleandir=cleandir else cleandir= @@ -745,7 +756,7 @@ buildkernel() $runcmd echo "===> Kernel build directory: ${kernbuilddir}" $runcmd mkdir -p "${kernbuilddir}" || bomb "cannot mkdir: ${kernbuilddir}" - if [ "$UPDATE" = "" ]; then + if [ -z "$UPDATE" ]; then $runcmd cd "${kernbuilddir}" $runcmd "$makewrapper" cleandir || bomb "make cleandir failed in ${kernbuilddir}" @@ -784,6 +795,10 @@ main() for op in $operations; do case "$op" in + makewrapper) + # no-op + ;; + tools) buildtools ;; diff --git a/doc/BUILDING.mdoc b/doc/BUILDING.mdoc index 04aee747c34..40ed604cd59 100644 --- a/doc/BUILDING.mdoc +++ b/doc/BUILDING.mdoc @@ -1,4 +1,4 @@ -.\" $NetBSD: BUILDING.mdoc,v 1.9 2003/01/23 16:24:08 lukem Exp $ +.\" $NetBSD: BUILDING.mdoc,v 1.10 2003/01/26 05:34:32 lukem Exp $ .\" .\" Copyright (c) 2001-2003 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -38,7 +38,7 @@ .\" NOTE: After changing this file, run "make build-docs" to generate the .\" proper plaintext versions, and check in all BUILDING.* files! .\" -.Dd January 24, 2003 +.Dd January 26, 2003 .Dt BUILDING 8 .Os NetBSD . @@ -865,6 +865,13 @@ This option implies the .Sy distribution operation. . +.It Sy makewrapper +Create the +.Sy nbmake-MACHINE +wrapper. +This operation is automatically performed for any of the other +operations. +. .It Sy obj Perform .Dq make obj . @@ -940,9 +947,17 @@ to .It Fl E Set .Sq expert -mode; +mode. +This overrides various sanity checks, and allows: .Sy DESTDIR -does not have to be set to a non-root path for builds when this is set. +does not have to be set to a non-root path for builds, +and +.Sy UNPRIVED +does not have to be set when building as a non-root user. +.Pp +.Em Note : +It is highly recommended that you know what you are doing when +you use this option. . .It Fl j Ar njob Passed through to @@ -1049,9 +1064,6 @@ Set the variable to .Ar value (which is optional). -This is useful for setting -.Sy RELEASEDIR -without actually building a release. . .It Fl w Ar wrapper Create the nbmake wrapper script (see below) in a custom location, @@ -1095,44 +1107,35 @@ This script can be symlinked into a directory listed in or called with an absolute path. . .Sh EXAMPLES -.Bl -tag -width "build.sh" -. -.It Li "./build.sh tools" -Build a new toolchain. -. -.It Li "cd ${KERNCONFDIR} ; ${TOOLDIR}/bin/nbconfig GENERIC" -Use the new version of -.Xr config 8 -to prepare to build a new GENERIC kernel. . -.It Li "cd ${KERNOBJDIR}/GENERIC ; ${TOOLDIR}/bin/nbmake-${MACHINE} dependall" -Use the new toolchain to build a new GENERIC kernel. +.Bl -tag -width "build.sh" . .It Li "./build.sh tools kernel=GENERIC" Build a new toolchain, and use the new toolchain to configure and build a new GENERIC kernel. This is a simpler way to achieve what the first three examples do. . -.It Li "./build.sh -U distribution" +.It Li "./build.sh -U -D /some/DESTDIR distribution" Using unprivileged mode, build a complete distribution in -.Sy DESTDIR . +.Pa /some/DESTDIR . . -.It Li "# ./build.sh -U installworld=/" +.It Li "# ./build.sh -U -D /some/DESTDIR installworld=/" As root, install the distribution that was built with unprivileged mode from -.Sy DESTDIR +.Pa /some/DESTDIR to .Pa / . (Even though this is run as root, .Fl U is required so that the permissions stored in -.Sy DESTDIR Ns Pa /METALOG +.Pa /some/DESTDIR/METALOG are correctly applied to the files as they're copied to .Pa / ) . . -.It Li "./build.sh -U -R /some/dir/RELEASE release" +.It Li "./build.sh -U -D /some/dir/DESTDIR -R /some/dir/RELEASE release" Using unprivileged mode, -build a complete release in the specified release directory. +build a complete release in +.Pa /some/dir/RELEASE . .El . .Sh OBSOLETE VARIABLES |
