From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp26.services.sfr.fr (smtp26.services.sfr.fr [93.17.128.215]) by mx.groups.io with SMTP id smtpd.web11.644.1669136855114290559 for ; Tue, 22 Nov 2022 09:07:35 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="no key for verify" header.i=@polynum.com header.s=202006 header.b=hyFn5wgE; spf=pass (domain: sfr.fr, ip: 93.17.128.215, mailfrom: thierry.laronde@sfr.fr) X-mail-filterd: {"version":"1.5.3","queueID":"4NGrKd0HVBz1LQN0Y","contextId": "ab056ce7-ae16-4c71-a726-5b8cec396772"} Received: from cauchy.polynum.local (20.204.0.93.rev.sfr.net [93.0.204.20]) by msfrf2639.sfr.fr (SMTP Server) with ESMTP id 4NGrKd0HVBz1LQN0Y; Tue, 22 Nov 2022 18:07:33 +0100 (CET) X-mail-filterd: {"version":"1.5.3","queueID":"4NGrKc4zrgz1LQN0K","contextId": "3ecc4f6b-e7dd-4bac-927e-0e24f3e90b73"} X-sfr-mailing: LEGIT X-sfr-spamrating: 36 X-sfr-spam: not-spam DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=polynum.com; s=202006; t=1669136853; h=Date:From:To:Cc:Subject:References:In-Reply-To; bh=0s6Qb8j0s0 42rtLIYh5dRxPQnzJmq5PLwNPTuJdkjKY=; b=hyFn5wgE1zYbAumc05M2WQEQcBRJt6NgAZaoVz UPwtgUTGBmligRswzk1UZV5wC7lNVdjyxYAOFSUttBEjj4u61NgwMNAajbUXh14Tgg91Dqidjyk0 y4o477TWkFYYGAvMUG9tHZDfk8W4ZMaIJkcHPZou/9SDnI3FJE6Gc4NcKOSGCqp4AvqvwE4AvDcX OPxxoDZUR/jy7BXxz2S5xLdCpD5DvEvT7qpFvcHwIP/jYforWJqN0Tk49+0itE/NTpKCHWAo9vmR kuoQ7B0DLL9rSHw4ZHCMtyepbozrQ4QiaffPuMNOm0mT6Veje67FdkM7fs7coRgOhq4jtjEUqpCQ == Received: from cauchy.polynum.local (20.204.0.93.rev.sfr.net [93.0.204.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: thierry.laronde@sfr.fr) by msfrf2639.sfr.fr (SMTP Server) with ESMTPSA id 4NGrKc4zrgz1LQN0K; Tue, 22 Nov 2022 18:07:32 +0100 (CET) Authentication-Results: sfr.fr; auth=pass (LOGIN) smtp.auth=thierry.laronde@sfr.fr Received: from cauchy.polynum.local (localhost [127.0.0.1]) by cauchy.polynum.local (8.15.2/8.15.2) with ESMTP id 2AMH7TQO001485; Tue, 22 Nov 2022 18:07:29 +0100 (CET) Received: (from tlaronde@localhost) by cauchy.polynum.local (8.15.2/8.14.9/Submit) id 2AMH7Tol001878; Tue, 22 Nov 2022 18:07:29 +0100 (CET) X-Authentication-Warning: cauchy.polynum.local: tlaronde set sender to thierry.laronde@sfr.fr using -f Date: Tue, 22 Nov 2022 18:07:29 +0100 From: tlaronde@polynum.com To: Pedro Falcato Cc: Rebecca Cran , devel@edk2.groups.io Subject: Re: [edk2-devel] edksetup.sh: fix for non POSIX whereis(1) Message-ID: References: <0bb285e2-ca66-f78a-7da9-ffd13473b61a@quicinc.com> MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Le Tue, Nov 22, 2022 at 04:31:14PM +0000, Pedro Falcato a =E9crit : > On Tue, Nov 22, 2022 at 4:26 PM wrote: >=20 > > Le Tue, Nov 22, 2022 at 08:40:30AM -0700, Rebecca Cran a =E9crit : > > > On 11/21/22 15:22, Pedro Falcato wrote: > > > > > > > I kind of dislike your solution. Does NetBSD ship /bin/which by > > default? > > > > I think replacing whereis with "which -a" would be a lot better. > > > > I don't think there's a 100% standard way to do this in POSIX, as= which > > > > isn't POSIX either, and your solution seems... hacky? > > > > > > > > > "command" seems to be the POSIX way to do this? > > > https://pubs.opengroup.org/onlinepubs/9699919799/ > > > > > > Though "whereis python3" shows the following on my system: > > > > > > python3: /usr/bin/python3.9-config /usr/bin/python3.9 /usr/bin/pyth= on3 > > > /usr/lib/python3.9 /usr/lib/python3 /etc/python3.9 /etc/python3 > > > /usr/local/lib/python3.9 /usr/include/python3.9 /usr/share/python3 > > > /usr/share/man/man1/python3.1.gz > > > > > > "which -a python3" returns: > > > > > > /usr/bin/python3 > > > /bin/python3 > > > > > > And "command -p -v" returns: > > > > > > /bin/python3 > > > > > > I don't know if we need all the results from "whereis"? > > > > The problem is when one does not know which exact version of python > > is here and how, exactly, the command is named. > > > > whereis(1) returns whatever command with python3 as prefix, while > > command or "which -a" will return only exactly python3. If, on the > > system, python is fully version qualified (as is the case with > > pkgsrc, the opt packages framework, used on NetBSD): > > > > which -a python3 > > > > will return nothing, since, it is python3.9 for example on the OS. > > >=20 > Sorry, what? This sounds so broken. How can a script shebang ever work? >=20 > For Sane(tm) systems, I propose command -v python3 + $(command -v pytho= n3) > -c 'import sys; print(sys.version.split(" ")[0])', > which gives us the path to the Python 3 interpreter + the path in a > relatively easy, simple way. > I think this could work mostly everywhere but apparently NetBSD since y= ou > don't provide python3? Which makes little sense in my head. >=20 NetBSD (as other OSes) does not provide python in base. It is available as an add-on. And the add-on framework on NetBSD allows to install several versions of Python (since there seems to be so many of them...) and in order to do that, the binary is not called "python", neither "python3" but "python3.9" or "python3.10". And since one can concurrently install different versions, there is no symbolic or hardlink python3 to a preferred python 3 series binary. As I have already said, edk2setup.sh allows to manipulate the environment and, for example, allows to set explicitely the env var PYTHON_COMMAND. So I know how to circumvent the problem.=20 But, since the script uses whereis(1), the Linux version, that does take "python3" as a prefix and searches for "python3*" (in more than the directories in PATH in fact), I have simply made so that the current behavior, intended(?), work on NetBSD too or on any system without whereis(1) or with a whereis(1) that does not behave as the Linux one. If you want to nuke whereis and use a POSIX2 utility instead, I'm perfectly fine: I will have to make other adjustements for NetBSD (not in edk2setup.sh) and I'm writing documentation on how-to, so I can circumvent this elsewhere. --=20 Thierry Laronde http://www.kergis.com/ http://kertex.kergis.com/ Key fingerprint =3D 0FF7 E906 FBAF FE95 FD89 250D 52B1 AE95 6006 F40C