diff mbox series

fetch2/npm: evaluate PATH before patching HOME

Message ID 94c18370-5149-8d5a-32ad-8c72a76e38e0@astro-kom.de
State Accepted, archived
Commit 893f3b116b628457fe0bfaf4b8394b1cd05a90a5
Headers show
Series fetch2/npm: evaluate PATH before patching HOME | expand

Commit Message

Arno Baumfalk May 16, 2023, 4:07 p.m. UTC
From acafbccb32510bca036894287afbe83765bc2d30 Mon Sep 17 00:00:00 2001
From: Arno Baumfalk <a.baumfalk@astro-kom.de>
Date: Tue, 16 May 2023 17:18:26 +0200
Subject: [PATCH] fetch2/npm: evaluate PATH before patching HOME

When the user configures the TMPDIR variable in a way that it contains 
$HOME (in local.conf), the DataSmart (d) object's PATH variable will 
also contain $HOME.

As the NpmEnvironment patches HOME with a temporary directory, further 
evaluation of PATH will become invalid an the build breaks with an error 
(npm not found).

As countermeasure PATH is evaluated *before* patching HOME.

Signed-off-by: Arno Baumfalk <a.baumfalk@astro-kom.de>
---
  bitbake/lib/bb/fetch2/npm.py | 1 +
  1 file changed, 1 insertion(+)

              if not workdir:

Comments

Alexandre Belloni May 23, 2023, 9:04 p.m. UTC | #1
Hello,

On 16/05/2023 18:07:08+0200, Arno Baumfalk wrote:
> From acafbccb32510bca036894287afbe83765bc2d30 Mon Sep 17 00:00:00 2001
> From: Arno Baumfalk <a.baumfalk@astro-kom.de>
> Date: Tue, 16 May 2023 17:18:26 +0200
> Subject: [PATCH] fetch2/npm: evaluate PATH before patching HOME
> 
> When the user configures the TMPDIR variable in a way that it contains $HOME
> (in local.conf), the DataSmart (d) object's PATH variable will also contain
> $HOME.
> 
> As the NpmEnvironment patches HOME with a temporary directory, further
> evaluation of PATH will become invalid an the build breaks with an error
> (npm not found).
> 
> As countermeasure PATH is evaluated *before* patching HOME.
> 
> Signed-off-by: Arno Baumfalk <a.baumfalk@astro-kom.de>
> ---
> �bitbake/lib/bb/fetch2/npm.py | 1 +
> �1 file changed, 1 insertion(+)
> 
> diff --git a/bitbake/lib/bb/fetch2/npm.py b/bitbake/lib/bb/fetch2/npm.py
> index 8a179a339a..e6d0598f5d 100644
> --- a/bitbake/lib/bb/fetch2/npm.py
> +++ b/bitbake/lib/bb/fetch2/npm.py
> @@ -103,6 +103,7 @@ class NpmEnvironment(object):
> �������� """Run npm command in a controlled environment"""
> �������� with tempfile.TemporaryDirectory() as tmpdir:
> ������������ d = bb.data.createCopy(self.d)
> +����������� d.setVar("PATH", d.getVar("PATH"))� # PATH might contain $HOME
> - evaluate it before patching

It seems your mailer is mangling your patch and it does not apply.

> ������������ d.setVar("HOME", tmpdir)
> 
> ������������ if not workdir:
> -- 
> 2.26.2
> -- 
> 
> Mit freundlichen Gr��en
> 
> *ASTRO Strobel **
> *Kommunikationssysteme GmbH
> 
> Dr. Arno Baumfalk
> Entwicklung
> 
> 	
> 
> 
> Telefon: 	+49�(0) 2204 405 228
> Fax: 	+49�(0) 2204 405 220
> eMail 	a.baumfalk@astro-kom.de <3D"mailto:a.ba=>
> Internet: 	www.astro-kom.de <3D"http://www.=>
> 
> 
> Folgen Sie uns<https://www.facebook.com/astrostrobel/>
> 
> ASTRO Strobel Kommunikationssysteme GmbH
> Olefant 1-3 � 51427 Bergisch Gladbach
> Gesch�ftsf�hrer: Herbert Strobel
> Registergericht K�ln HRB 46271
> Steuer-Nr. 204/5710/0569 � USt.ID-Nr. DE 121980384
> 
> Die Informationen in dieser eMail zusammen mit allen Anlagen sind streng
> vertraulich. Sie sind ausschlie�lich f�r den Gebrauch des rechtm��igen
> Empf�ngers bestimmt. Jegliche Weitergabe ohne unsere ausdr�ckliche
> Genehmigung ist verboten und kann strafrechtlich verfolgt werden. Sollten
> Sie nicht der vorgesehene Empf�nger dieser E-Mail sein, informieren Sie�uns
> bitte unter 02204/405-0 oder leiten Sie die Mail an uns zur�ck
> _a.baumfalk@astro-kom.de_. L�schen Sie bitte die E-Mail von Ihrem System.
> Die ASTRO Strobel Kommunikationssysteme GmbH tr�gt weder die Verantwortung
> f�r die richtige und vollst�ndige �bertragung dieser E-Mail noch f�r die
> Verz�gerungen in der �bertragung.
> 
> The information and attachments in this e-mail are strictly confidential.
> They are for the exclusive use of the legitimate recipient. Any transfer
> without our express approval is prohibited and can be prosecuted. If you are
> not the destined recipient of this e-mail, please inform us by phone number
> +49 2204 405 0 or send the e-mail back to a.baumfalk@astro-kom.de. Please
> delete this e-mail from your system. The ASTRO Strobel Kommunikationssysteme
> GmbH is neither responsible for the complete transmission of this e-mail nor
> for transmission delays.

> 
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#14790): https://lists.openembedded.org/g/bitbake-devel/message/14790
> Mute This Topic: https://lists.openembedded.org/mt/98929768/3617179
> Group Owner: bitbake-devel+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub [alexandre.belloni@bootlin.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
diff mbox series

Patch

diff --git a/bitbake/lib/bb/fetch2/npm.py b/bitbake/lib/bb/fetch2/npm.py
index 8a179a339a..e6d0598f5d 100644
--- a/bitbake/lib/bb/fetch2/npm.py
+++ b/bitbake/lib/bb/fetch2/npm.py
@@ -103,6 +103,7 @@  class NpmEnvironment(object):
          """Run npm command in a controlled environment"""
          with tempfile.TemporaryDirectory() as tmpdir:
              d = bb.data.createCopy(self.d)
+            d.setVar("PATH", d.getVar("PATH"))  # PATH might contain 
$HOME - evaluate it before patching
              d.setVar("HOME", tmpdir)