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 BF45D9411B5 for ; Wed, 21 Feb 2024 04:23:16 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=C1vkFREFJca2A+BHyoy/8RCNLJm2EkDzA/UukByaJiA=; c=relaxed/simple; d=groups.io; h=DKIM-Filter:From:To:Cc:Subject:Date:Message-Id:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1708489395; v=1; b=Vh1ZSszd89of8e3HH0bdLbHqCHsRrsFarDFIxyh1K5OI8yNH5wtJQfQV012zlrSQk4wiQc36 uaEEXD8BJkzDqHgprlelQNYYBkO3vQ4h7UPLDzPlSyjouUomuOG+okg/0nWdy6MWjWArAKANdww 6tdDLJI4QQrqowN3E+TYhtg8= X-Received: by 127.0.0.2 with SMTP id h341YY7687511xTcrLoouCPn; Tue, 20 Feb 2024 20:23:15 -0800 X-Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mx.groups.io with SMTP id smtpd.web10.6142.1708489394447765029 for ; Tue, 20 Feb 2024 20:23:14 -0800 X-Received: from localhost.localdomain (unknown [20.39.63.11]) by linux.microsoft.com (Postfix) with ESMTPSA id 7DD4D2083EC0; Tue, 20 Feb 2024 20:23:13 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 7DD4D2083EC0 From: "Michael Kubacki" To: devel@edk2.groups.io Cc: Rebecca Cran , Liming Gao , Bob Feng , Yuwei Chen Subject: [edk2-devel] [PATCH v1 1/1] BaseTools/GenFds: Resolve absolute workspace INF paths Date: Tue, 20 Feb 2024 23:22:54 -0500 Message-Id: <20240221042254.2599-1-mikuback@linux.microsoft.com> MIME-Version: 1.0 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,mikuback@linux.microsoft.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: lsOLq8WPTmwghoyfUI9zwbzcx7686176AA= 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=Vh1ZSszd; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=linux.microsoft.com (policy=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 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) --=20 2.40.1.vfs.0.0 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#115708): https://edk2.groups.io/g/devel/message/115708 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] -=-=-=-=-=-=-=-=-=-=-=-