All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCHv2] package/linux-firmware: fix special cases of symlinks
@ 2020-03-04 16:55 Yann E. MORIN
  2020-03-04 20:26 ` Antoine Tenart
  0 siblings, 1 reply; 3+ messages in thread
From: Yann E. MORIN @ 2020-03-04 16:55 UTC (permalink / raw)
  To: buildroot

From: Antoine Tenart <antoine.tenart@bootlin.com>

Some symlinks were not created correctly when installing the
Linux-firmware package. This patch fixes the support for all symlinks of
the form:

  a/foo -> bar
  a/foo -> b/bar
  a/foo -> ../b/bar

With this patch all forms of symlinks described in the WHENCE file
should be supported, whether they are in nested directories, or in
non-existing ones.

As some symlinks could be in directories that do not exist, we must
maje sure to canonicalize the path before testing the linked-to file.

We compared the symlinks installed pre-20200122 to what we have now, and
it seems we're handling all of them with this patch.

Fixes: 55df4059d24b ("package/linux-firmware: fix symlink support")
Signed-off-by: Antoine Tenart <antoine.tenart@bootlin.com>
[yann.morin.1998 at free.fr:
  - use readlink in canonicalize-missing mode, to avoid
    creating-then-removing directories
]
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
---
 package/linux-firmware/linux-firmware.mk | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/package/linux-firmware/linux-firmware.mk b/package/linux-firmware/linux-firmware.mk
index 009202d604..6d3cec1a48 100644
--- a/package/linux-firmware/linux-firmware.mk
+++ b/package/linux-firmware/linux-firmware.mk
@@ -609,12 +609,18 @@ endif
 # automatically by its copy-firmware.sh script during the installation, which
 # parses the WHENCE file where symlinks are described. We follow the same logic
 # here, adding symlink only for firmwares installed in the target directory.
-# The grep/sed parsing is taken from the script mentioned before.
+#
+# For testing the presence of firmwares in the target directory we first make
+# sure we canonicalize the pointed-to file, to cover the symlinks of the form
+# a/foo -> ../b/foo  where a/ (the directory where to put the symlink) does
+# not yet exist.
 define LINUX_FIRMWARE_CREATE_SYMLINKS
+	cd $(TARGET_DIR)/lib/firmware/ ; \
 	sed -r -e '/^Link: (.+) -> (.+)$$/!d; s//\1 \2/' $(@D)/WHENCE | \
 	while read f d; do \
-		if test -f $(TARGET_DIR)/lib/firmware/$$d; then \
-			ln -sf $$d $(TARGET_DIR)/lib/firmware/$$f || exit 1; \
+		if test -f $$(readlink -m $$(dirname $$f)/$$d); then \
+			mkdir -p $$(dirname $$f) || exit 1; \
+			ln -sf $$d $$f || exit 1; \
 		fi ; \
 	done
 endef
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [Buildroot] [PATCHv2] package/linux-firmware: fix special cases of symlinks
  2020-03-04 16:55 [Buildroot] [PATCHv2] package/linux-firmware: fix special cases of symlinks Yann E. MORIN
@ 2020-03-04 20:26 ` Antoine Tenart
  2020-03-05 17:23   ` Yann E. MORIN
  0 siblings, 1 reply; 3+ messages in thread
From: Antoine Tenart @ 2020-03-04 20:26 UTC (permalink / raw)
  To: buildroot

Hi Yann,

On Wed, Mar 04, 2020 at 05:55:32PM +0100, Yann E. MORIN wrote:
> From: Antoine Tenart <antoine.tenart@bootlin.com>
> 
> Some symlinks were not created correctly when installing the
> Linux-firmware package. This patch fixes the support for all symlinks of
> the form:
> 
>   a/foo -> bar
>   a/foo -> b/bar
>   a/foo -> ../b/bar
> 
> With this patch all forms of symlinks described in the WHENCE file
> should be supported, whether they are in nested directories, or in
> non-existing ones.
> 
> As some symlinks could be in directories that do not exist, we must
> maje sure to canonicalize the path before testing the linked-to file.
> 
> We compared the symlinks installed pre-20200122 to what we have now, and
> it seems we're handling all of them with this patch.
> 
> Fixes: 55df4059d24b ("package/linux-firmware: fix symlink support")
> Signed-off-by: Antoine Tenart <antoine.tenart@bootlin.com>
> [yann.morin.1998 at free.fr:
>   - use readlink in canonicalize-missing mode, to avoid
>     creating-then-removing directories
> ]
> Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>

I tested it and it looks good.

Thanks,
Antoine

> ---
>  package/linux-firmware/linux-firmware.mk | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/package/linux-firmware/linux-firmware.mk b/package/linux-firmware/linux-firmware.mk
> index 009202d604..6d3cec1a48 100644
> --- a/package/linux-firmware/linux-firmware.mk
> +++ b/package/linux-firmware/linux-firmware.mk
> @@ -609,12 +609,18 @@ endif
>  # automatically by its copy-firmware.sh script during the installation, which
>  # parses the WHENCE file where symlinks are described. We follow the same logic
>  # here, adding symlink only for firmwares installed in the target directory.
> -# The grep/sed parsing is taken from the script mentioned before.
> +#
> +# For testing the presence of firmwares in the target directory we first make
> +# sure we canonicalize the pointed-to file, to cover the symlinks of the form
> +# a/foo -> ../b/foo  where a/ (the directory where to put the symlink) does
> +# not yet exist.
>  define LINUX_FIRMWARE_CREATE_SYMLINKS
> +	cd $(TARGET_DIR)/lib/firmware/ ; \
>  	sed -r -e '/^Link: (.+) -> (.+)$$/!d; s//\1 \2/' $(@D)/WHENCE | \
>  	while read f d; do \
> -		if test -f $(TARGET_DIR)/lib/firmware/$$d; then \
> -			ln -sf $$d $(TARGET_DIR)/lib/firmware/$$f || exit 1; \
> +		if test -f $$(readlink -m $$(dirname $$f)/$$d); then \
> +			mkdir -p $$(dirname $$f) || exit 1; \
> +			ln -sf $$d $$f || exit 1; \
>  		fi ; \
>  	done
>  endef
> -- 
> 2.20.1
> 

-- 
Antoine T?nart, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Buildroot] [PATCHv2] package/linux-firmware: fix special cases of symlinks
  2020-03-04 20:26 ` Antoine Tenart
@ 2020-03-05 17:23   ` Yann E. MORIN
  0 siblings, 0 replies; 3+ messages in thread
From: Yann E. MORIN @ 2020-03-05 17:23 UTC (permalink / raw)
  To: buildroot

Antoine, All,

On 2020-03-04 21:26 +0100, Antoine Tenart spake thusly:
> On Wed, Mar 04, 2020 at 05:55:32PM +0100, Yann E. MORIN wrote:
> > From: Antoine Tenart <antoine.tenart@bootlin.com>
> > 
> > Some symlinks were not created correctly when installing the
> > Linux-firmware package. This patch fixes the support for all symlinks of
> > the form:
> > 
> >   a/foo -> bar
> >   a/foo -> b/bar
> >   a/foo -> ../b/bar
> > 
> > With this patch all forms of symlinks described in the WHENCE file
> > should be supported, whether they are in nested directories, or in
> > non-existing ones.
> > 
> > As some symlinks could be in directories that do not exist, we must
> > maje sure to canonicalize the path before testing the linked-to file.
> > 
> > We compared the symlinks installed pre-20200122 to what we have now, and
> > it seems we're handling all of them with this patch.
> > 
> > Fixes: 55df4059d24b ("package/linux-firmware: fix symlink support")
> > Signed-off-by: Antoine Tenart <antoine.tenart@bootlin.com>
> > [yann.morin.1998 at free.fr:
> >   - use readlink in canonicalize-missing mode, to avoid
> >     creating-then-removing directories
> > ]
> > Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
> 
> I tested it and it looks good.

I took that as a hint to add your Tested-by: and Reviewed-by: tags to
the commit.

Applied to next. Thanks!

Regards,
Yann E. MORIN.

> Thanks,
> Antoine
> 
> > ---
> >  package/linux-firmware/linux-firmware.mk | 12 +++++++++---
> >  1 file changed, 9 insertions(+), 3 deletions(-)
> > 
> > diff --git a/package/linux-firmware/linux-firmware.mk b/package/linux-firmware/linux-firmware.mk
> > index 009202d604..6d3cec1a48 100644
> > --- a/package/linux-firmware/linux-firmware.mk
> > +++ b/package/linux-firmware/linux-firmware.mk
> > @@ -609,12 +609,18 @@ endif
> >  # automatically by its copy-firmware.sh script during the installation, which
> >  # parses the WHENCE file where symlinks are described. We follow the same logic
> >  # here, adding symlink only for firmwares installed in the target directory.
> > -# The grep/sed parsing is taken from the script mentioned before.
> > +#
> > +# For testing the presence of firmwares in the target directory we first make
> > +# sure we canonicalize the pointed-to file, to cover the symlinks of the form
> > +# a/foo -> ../b/foo  where a/ (the directory where to put the symlink) does
> > +# not yet exist.
> >  define LINUX_FIRMWARE_CREATE_SYMLINKS
> > +	cd $(TARGET_DIR)/lib/firmware/ ; \
> >  	sed -r -e '/^Link: (.+) -> (.+)$$/!d; s//\1 \2/' $(@D)/WHENCE | \
> >  	while read f d; do \
> > -		if test -f $(TARGET_DIR)/lib/firmware/$$d; then \
> > -			ln -sf $$d $(TARGET_DIR)/lib/firmware/$$f || exit 1; \
> > +		if test -f $$(readlink -m $$(dirname $$f)/$$d); then \
> > +			mkdir -p $$(dirname $$f) || exit 1; \
> > +			ln -sf $$d $$f || exit 1; \
> >  		fi ; \
> >  	done
> >  endef
> > -- 
> > 2.20.1
> > 
> 
> -- 
> Antoine T?nart, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-03-05 17:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-04 16:55 [Buildroot] [PATCHv2] package/linux-firmware: fix special cases of symlinks Yann E. MORIN
2020-03-04 20:26 ` Antoine Tenart
2020-03-05 17:23   ` Yann E. MORIN

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.