diff options
author | cjep <cjep@pkgsrc.org> | 2021-02-15 12:56:53 +0000 |
---|---|---|
committer | cjep <cjep@pkgsrc.org> | 2021-02-15 12:56:53 +0000 |
commit | 70c7d0b4c59fd84b0b76a23490b1d0c405ae8549 (patch) | |
tree | 628f056b5baa3964baaf1ba762705487d098b8a6 /bootstrap/bootstrap | |
parent | 38cb4abcbacc40bd82cd027bdd3a39650c566972 (diff) | |
download | pkgsrc-70c7d0b4c59fd84b0b76a23490b1d0c405ae8549.tar.gz |
In the process of looking at PR#55952, we discovered something that
can catch users out with the two --prefer options. Make the parsing
of these better by checking their argument exists and is not another
command line option.
Addresses PR#55952. Reviewed with jperkin@
Diffstat (limited to 'bootstrap/bootstrap')
-rwxr-xr-x | bootstrap/bootstrap | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/bootstrap/bootstrap b/bootstrap/bootstrap index 0f610e10bfa..31836944815 100755 --- a/bootstrap/bootstrap +++ b/bootstrap/bootstrap @@ -1,6 +1,6 @@ #! /bin/sh -# $NetBSD: bootstrap,v 1.296 2020/12/05 16:50:52 js Exp $ +# $NetBSD: bootstrap,v 1.297 2021/02/15 12:56:53 cjep Exp $ # # Copyright (c) 2001-2011 Alistair Crooks <agc@NetBSD.org> # All rights reserved. @@ -323,6 +323,20 @@ get_optarg() expr "x$1" : "x[^=]*=\\(.*\\)" } +# The --prefer-pkgsrc and --prefer native options require an argument, +# but our manual getopt parser is unable to detect the difference +# between a valid argument and the next getopt option (or no option +# at all if it's the last). Ensure that the argument does not begin +# with "-" or is empty in case the user forgets to provide one. +checkarg_missing() +{ + case $1 in + -*|"") + die "ERROR: $2 takes yes, no or a list" + ;; + esac +} + checkarg_sane_absolute_path() { case "$1" in @@ -422,6 +436,11 @@ make_jobs=1 mk_fragment= quiet=no +# Set these variables so that we can test whether they have been +# correctly enabled by the user and not left empty +prefer_native=unset +prefer_pkgsrc=unset + while [ $# -gt 0 ]; do case $1 in --workdir=*) wrkdir=`get_optarg "$1"` ;; @@ -484,6 +503,9 @@ checkarg_sane_absolute_path "$varbase" "--varbase" checkarg_sane_relative_path "$pkginfodir" "--pkginfodir" checkarg_sane_relative_path "$pkgmandir" "--pkgmandir" checkarg_sane_absolute_path "$wrkdir" "--workdir" +checkarg_missing "$prefer_pkgsrc" "--prefer-pkgsrc" +checkarg_missing "$prefer_native" "--prefer-native" + # set defaults for system locations if not already set by the user wrkobjdir=${wrkdir}/pkgsrc @@ -513,6 +535,14 @@ if [ "x$preserve_path" != "xyes" ]; then PATH="$PATH:/sbin:/usr/sbin" fi +if [ "$prefer_native" = "unset" ]; then + prefer_native= +fi +if [ "$prefer_pkgsrc" = "unset" ]; then + prefer_pkgsrc= +fi + + overpath="" root_user=root bmakexargs= |