Received: by mail.netbsd.org (Postfix, from userid 605) id B43FE84DDF; Mon, 15 Feb 2021 12:56:54 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mail.netbsd.org (Postfix) with ESMTP id EB9DB84D44 for ; Mon, 15 Feb 2021 12:56:53 +0000 (UTC) X-Virus-Scanned: amavisd-new at netbsd.org Received: from mail.netbsd.org ([127.0.0.1]) by localhost (mail.netbsd.org [127.0.0.1]) (amavisd-new, port 10025) with ESMTP id 0gskyl-o3lfF for ; Mon, 15 Feb 2021 12:56:53 +0000 (UTC) Received: from cvs.NetBSD.org (ivanova.netbsd.org [199.233.217.197]) by mail.netbsd.org (Postfix) with ESMTP id 54F6E84D2F for ; Mon, 15 Feb 2021 12:56:53 +0000 (UTC) Received: by cvs.NetBSD.org (Postfix, from userid 500) id 4D3D2FA95; Mon, 15 Feb 2021 12:56:53 +0000 (UTC) Content-Transfer-Encoding: 7bit Content-Type: multipart/mixed; boundary="_----------=_161339381327240" MIME-Version: 1.0 Date: Mon, 15 Feb 2021 12:56:53 +0000 From: "Chris Pinnock" Subject: CVS commit: pkgsrc/bootstrap To: pkgsrc-changes@NetBSD.org Reply-To: cjep@netbsd.org X-Mailer: log_accum Message-Id: <20210215125653.4D3D2FA95@cvs.NetBSD.org> Sender: pkgsrc-changes-owner@NetBSD.org List-Id: Precedence: bulk List-Unsubscribe: This is a multi-part message in MIME format. --_----------=_161339381327240 Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" Module Name: pkgsrc Committed By: cjep Date: Mon Feb 15 12:56:53 UTC 2021 Modified Files: pkgsrc/bootstrap: bootstrap Log Message: 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@ To generate a diff of this commit: cvs rdiff -u -r1.296 -r1.297 pkgsrc/bootstrap/bootstrap Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. --_----------=_161339381327240 Content-Disposition: inline Content-Length: 2059 Content-Transfer-Encoding: binary Content-Type: text/x-diff; charset=us-ascii Modified files: Index: pkgsrc/bootstrap/bootstrap diff -u pkgsrc/bootstrap/bootstrap:1.296 pkgsrc/bootstrap/bootstrap:1.297 --- pkgsrc/bootstrap/bootstrap:1.296 Sat Dec 5 16:50:52 2020 +++ pkgsrc/bootstrap/bootstrap Mon Feb 15 12:56:53 2021 @@ -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 # 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" " 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= --_----------=_161339381327240--