pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/mk/bulk Added basic checks to make sure the values fro...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/28acb7bdb4a4
branches:  trunk
changeset: 502564:28acb7bdb4a4
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sun Nov 06 17:12:55 2005 +0000

description:
Added basic checks to make sure the values from the configuration file are
somewhat sane. If a check fails, the bulk build is terminated. Removed the
conditional under which MAKECONF is exported, as it is not needed anymore.

diffstat:

 mk/bulk/build           |    3 +-
 mk/bulk/post-build-conf |  140 ++++++++++++++++++++++++++++++++++++++++++-----
 2 files changed, 126 insertions(+), 17 deletions(-)

diffs (194 lines):

diff -r b8930a64d271 -r 28acb7bdb4a4 mk/bulk/build
--- a/mk/bulk/build     Sun Nov 06 16:57:56 2005 +0000
+++ b/mk/bulk/build     Sun Nov 06 17:12:55 2005 +0000
@@ -1,5 +1,5 @@
 #!/bin/sh
-# $NetBSD: build,v 1.69 2005/11/06 10:27:57 seb Exp $
+# $NetBSD: build,v 1.70 2005/11/06 17:12:55 rillig Exp $
 
 #
 # Copyright (c) 1999, 2000 Hubert Feyrer <hubertf%NetBSD.org@localhost>
@@ -181,6 +181,7 @@
 { test -f "${BULK_BUILD_CONF}" \
   && . "${BULK_BUILD_CONF}" \
   && . "${scriptdir}/post-build-conf" \
+  && check_config_vars \
   && export_config_vars
 } || die "Cannot load config file ${BULK_BUILD_CONF}, aborting."
 
diff -r b8930a64d271 -r 28acb7bdb4a4 mk/bulk/post-build-conf
--- a/mk/bulk/post-build-conf   Sun Nov 06 16:57:56 2005 +0000
+++ b/mk/bulk/post-build-conf   Sun Nov 06 17:12:55 2005 +0000
@@ -1,14 +1,17 @@
-# $NetBSD: post-build-conf,v 1.2 2005/11/06 10:32:58 seb Exp $
+# $NetBSD: post-build-conf,v 1.3 2005/11/06 17:12:55 rillig Exp $
 #
 
 # This file is included after the build.conf file by the "build" and
-# "pre-build" scripts. It provides two functions for printing and
+# "pre-build" scripts. It provides functions for printing, checking and
 # exporting the configuration variables.
 
-# usage: show_variable varname
-show_variable() {
-       eval "fnv_isset=\${$1+set}"
-       case $fnv_isset in
+# Note: All function whose name start with "pbc_" are considered private
+# to this file. The "pbc" prefix is an abbreviation for "post-build-conf".
+
+# usage: pbc_showvar varname
+pbc_showvar() {
+       eval "pbc_isset=\${$1+set}"
+       case $pbc_isset in
        "set")  eval "fnv_val=\${$1-}"
                printf "   %-25s = %s\\n" "$1" "${fnv_val}"
                ;;
@@ -17,27 +20,27 @@
        esac
 }
 
-# usage: section title varname...
-section() {
+# usage: pbc_section title varname...
+pbc_section() {
        printf "%s\\n" "$1"
        shift
-       for i in "$@"; do
-               show_variable "$i"
+       for pbc_var in "$@"; do
+               pbc_showvar "${pbc_var}"
        done
        printf "\\n"
 }
 
 # usage: show_config_vars
 show_config_vars() {
-       section "System information" \
+       pbc_section "System information" \
                osrev arch BULK_BUILD_CONF USR_PKGSRC MAKECONF
-       section "Keeping pkgsrc up-to-date" \
+       pbc_section "Keeping pkgsrc up-to-date" \
                CVS_USER CVS_FLAGS
-       section "Getting distfiles" \
+       pbc_section "Getting distfiles" \
                PRUNEDISTFILES ftp_proxy http_proxy
-       section "Building packages" \
+       pbc_section "Building packages" \
                PKGLIST NICE_LEVEL ADMIN ADMINSIG
-       section "Uploading binary packages" \
+       pbc_section "Uploading binary packages" \
                UPDATE_VULNERABILITY_LIST PRUNEPACKAGES MKSUMS SIGN_AS \
                RSYNC_DST RSYNC_OPTS FTPHOST FTP
 }
@@ -50,5 +53,110 @@
        export PKGLIST NICE_LEVEL ADMIN ADMINSIG
        export UPDATE_VULNERABILITY_LIST PRUNEPACKAGES MKSUMS SIGN_AS
        export RSYNC_DST RSYNC_OPTS FTPHOST FTP
-       if [ -n "$MAKECONF" ]; then export MAKECONF; fi 
+}
+
+# usage: pbc_die error-message
+pbc_die() {
+       exec 1>&2
+       printf "error: %s\\n" "$1"
+       printf "       Please check your bulk build configuration file:\\n"
+       case ${BULK_BUILD_CONF+set} in
+       "set")  printf "       %s\\n" "${BULK_BUILD_CONF}"
+       esac
+       exit 1
+}
+
+# usage: pbc_checkyesno varname
+pbc_checkyesno() {
+       eval "pbc_val=\${$1-}"
+       case $pbc_val in
+       [Yy][Ee][Ss]|[Nn][Oo]) ;;
+       *)      pbc_die "$1 must be set to one of YES, yes, NO, no.";;
+       esac
+}
+
+# usage: pbc_checkexistingfile varname
+pbc_checkexistingfile() {
+       eval "pbc_val=\${$1-}"
+
+       case $pbc_val in
+       /*)     ;;
+       *)      pbc_die "$1 must be an absolute pathname.";;
+       esac
+
+       test -f "${pbc_val}" \
+       || pbc_die "$1 must be the name of an existing file."
+}
+
+# usage: pbc_checkexistingdir varname
+pbc_checkexistingdir() {
+       eval "pbc_val=\${$1-}"
+
+       case $pbc_val in
+       /*)     ;;
+       *)      pbc_die "$1 must be an absolute pathname.";;
+       esac
+
+       test -d "${pbc_val}" \
+       || pbc_die "$1 must be the name of an existing directory."
 }
+
+# usage: pbc_checknonempty varname
+pbc_checknonempty() {
+       eval "pbc_isset=\${$1+set}"
+       eval "pbc_val=\${$1-}"
+
+       case $pbc_isset in
+       "set")  case $pbc_val in
+               "")     pbc_die "$1 must be non-empty.";;
+               esac;;
+       *)      pbc_die "$1 must be defined and non-empty.";;
+       esac
+}
+
+# usage: pbc_checkdefined varname
+pbc_checkdefined() {
+       eval "pbc_val=\${$1+set}"
+
+       case $pbc_val in
+       "set")  ;;
+       *)      pbc_die "$1 must be defined.";;
+       esac
+}
+
+# usage: check_config_vars
+check_config_vars() {
+       # section "System information"
+       pbc_checknonempty osrev
+       pbc_checknonempty arch
+       pbc_checkexistingfile BULK_BUILD_CONF
+       pbc_checkexistingdir USR_PKGSRC
+       case ${MAKECONF+set} in set)
+               pbc_checkexistingfile MAKECONF;;
+       esac
+
+       # section "Keeping pkgsrc up-to-date"
+       # no checks for CVS_USER
+       # no checks for CVS_FLAGS
+
+       # section "Getting distfiles"
+       pbc_checkyesno PRUNEDISTFILES
+       # no checks for ftp_proxy
+       # no checks for http_proxy
+
+       # section "Building packages"
+       # no checks for PKGLIST
+       # no checks for NICE_LEVEL
+       # no checks for ADMIN
+       # no checks for ADMINSIG
+
+       # section "Uploading binary packages"
+       pbc_checkyesno UPDATE_VULNERABILITY_LIST
+       pbc_checkyesno PRUNEPACKAGES
+       pbc_checkyesno MKSUMS
+       # no checks for SIGN_AS
+       # no checks for RSYNC_DST
+       # no checks for RSYNC_OPTS
+       # no checks for FTPHOST
+       # no checks for FTP
+}



Home | Main Index | Thread Index | Old Index