pkgsrc-Changes-HG archive

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

[pkgsrc/trunk]: pkgsrc/bootstrap In the process of looking at PR#55952, we di...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/2a67c2726400
branches:  trunk
changeset: 447058:2a67c2726400
user:      cjep <cjep%pkgsrc.org@localhost>
date:      Mon Feb 15 12:56:53 2021 +0000

description:
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:

 bootstrap/bootstrap |  32 +++++++++++++++++++++++++++++++-
 1 files changed, 31 insertions(+), 1 deletions(-)

diffs (69 lines):

diff -r e1fc7ef97c5c -r 2a67c2726400 bootstrap/bootstrap
--- a/bootstrap/bootstrap       Mon Feb 15 12:50:44 2021 +0000
+++ b/bootstrap/bootstrap       Mon Feb 15 12:56:53 2021 +0000
@@ -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@localhost>
 # All rights reserved.
@@ -323,6 +323,20 @@
        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 @@
 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_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 @@
        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=



Home | Main Index | Thread Index | Old Index