From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 95197AC1763 for ; Tue, 27 Feb 2024 15:32:20 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=8ifUgupFNvrzMlMeRBEjm0ogxRhU9hypQZs5OJJS94I=; c=relaxed/simple; d=groups.io; h=Feedback-ID:Message-ID:Date:MIME-Version:User-Agent:Subject:To:Cc:References:From:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1709047939; v=1; b=OOdWLJz6JL/DuVM98luq5rXxDjZyG30+/hU6eTuxbD5KeD/0kBOJKHDcF5Lf0fDzLwnx/rYY PHWFZ2z7Nmd/KptRsMfoMqg1fIsH5G76woxRcDYi5PMCZC+D6NzgirZmvKHMuPdxMeou/0nTM6a XiBL3zvju6qPBMR5vosBFx7U= X-Received: by 127.0.0.2 with SMTP id lUPrYY7687511xcdiVftUhlb; Tue, 27 Feb 2024 07:32:19 -0800 X-Received: from wfout3-smtp.messagingengine.com (wfout3-smtp.messagingengine.com [64.147.123.146]) by mx.groups.io with SMTP id smtpd.web10.15181.1709047938209467473 for ; Tue, 27 Feb 2024 07:32:18 -0800 X-Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailfout.west.internal (Postfix) with ESMTP id 368B01C000A3; Tue, 27 Feb 2024 10:32:17 -0500 (EST) X-Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Tue, 27 Feb 2024 10:32:17 -0500 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrgeehgdehfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefkffggfgfuvfevfhfhjggtgfesthejredttddvjeenucfhrhhomheptfgvsggv tggtrgcuvehrrghnuceorhgvsggvtggtrgessghsughiohdrtghomheqnecuggftrfgrth htvghrnhephfekvdekvdfhtddvteehueeuleetjefhieehjeeuhfdtuddtvdeguddtkeev lefhnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprh gvsggvtggtrgessghsughiohdrtghomh X-ME-Proxy: Feedback-ID: i5b994698:Fastmail X-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 27 Feb 2024 10:32:15 -0500 (EST) Message-ID: <90cb7891-bb5f-49f9-9341-f55c1ca6f40d@bsdio.com> Date: Tue, 27 Feb 2024 08:32:11 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [edk2-devel] [PATCH v1 1/1] BaseTools/GenFds: Resolve absolute workspace INF paths To: mikuback@linux.microsoft.com, devel@edk2.groups.io Cc: Liming Gao , Bob Feng , Yuwei Chen References: <20240221042254.2599-1-mikuback@linux.microsoft.com> From: "Rebecca Cran" In-Reply-To: <20240221042254.2599-1-mikuback@linux.microsoft.com> Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,rebecca@bsdio.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: yqXEiaZfRPlPCAKhhXQwiPYex7686176AA= Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=OOdWLJz6; dmarc=none; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io Reviewed-by: Rebecca Cran On 2/20/2024 9:22 PM, mikuback@linux.microsoft.com wrote: > From: Michael Kubacki > > Currently, if an INF path is an absolute path on Linux (begins with > "/"), the "/" character will be removed. If the path is an absolute > system path, this creates an invalid path. > > An example of when this may be an issue is in external dependencies > where an INF is within the external dependency, the `set_build_var` > flag is set, and DSC files refer to files by its build variable > (e.g. `$(SHARED_BINARIES)/Module.inf`). INFs in a binary distribution > like this example may contain a [Binaries] section and refer to > different section files that can be used by a platform to compose an > FFS file. For example, the PE32 (.efi) and DEPEX (.depex) files. > > In this case, `$(SHARED_BINARIES)` will be an absolute path to the > ext dep directory and `FfsInfStatement.__InfParse__` will remove the > leading "/" character so the path is invalid. > > This change first checks if the absolute path will resolve into the > current workspace. If it does (as will happen in the shared crypto > ext dep example above), it modifies the path to be relative to the > workspace so later logic dependent on relative paths can operate on > it. If the absolute path is not within the current workspace, it > follows previous behavior for backward compatibility to that > scenario. > > Cc: Rebecca Cran > Cc: Liming Gao > Cc: Bob Feng > Cc: Yuwei Chen > Signed-off-by: Michael Kubacki > --- > BaseTools/Source/Python/GenFds/FfsInfStatement.py | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTool= s/Source/Python/GenFds/FfsInfStatement.py > index 568efb6d7685..6550d939d49c 100644 > --- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py > +++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py > @@ -19,6 +19,7 @@ from .GenFdsGlobalVariable import GenFdsGlobalVariable > from .Ffs import SectionSuffix,FdfFvFileTypeToFileType > import subprocess > import sys > +from pathlib import Path > from . import Section > from . import RuleSimpleFile > from . import RuleComplexFile > @@ -156,7 +157,12 @@ class FfsInfStatement(FfsInfStatementClassObject): > if len(self.InfFileName) > 1 and self.InfFileName[0] =3D=3D '\\= ' and self.InfFileName[1] =3D=3D '\\': > pass > elif self.InfFileName[0] =3D=3D '\\' or self.InfFileName[0] =3D= =3D '/' : > - self.InfFileName =3D self.InfFileName[1:] > + ws_path =3D Path(GenFdsGlobalVariable.WorkSpaceDir) > + inf_path =3D Path(self.InfFileName) > + if ws_path in inf_path.parents: > + self.InfFileName =3D str(inf_path.relative_to(ws_path)) > + else: > + self.InfFileName =3D self.InfFileName[1:] > =20 > if self.InfFileName.find('$') =3D=3D -1: > InfPath =3D NormPath(self.InfFileName) -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#116049): https://edk2.groups.io/g/devel/message/116049 Mute This Topic: https://groups.io/mt/104482915/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-