[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1035505: firmware-nonfree: debian/bin/gencontrol.py fails on spaces and backslashes



Cyril Brulebois <kibi@debian.org> (2023-05-04):
> The problem is the next stage, distributing the relevant files into the
> appropriate binary packages. That part is controlled by the defines, and
> that's what needs to be adjusted (file format and/or how it's used).
> 
> A quick look suggests files_orig isn't set properly, with each part of
> the path being considered a path on its own. I'm not familiar with the
> config object yet, but if that's indeed the correct thing, that can't
> work as it is:
> 
>     class SchemaItemList(object):
>         def __init__(self, type=r"\s+"):
>             self.type = type
>     
>         def __call__(self, i):
>             i = i.strip()
>             if not i:
>                 return []
>             return [j.strip() for j in re.split(self.type, i)]

Side-stepping that one with the dumb patch attached confirms that
there's an issue reading from the config, but it's not the only issue:
while the immediate one goes away (file lookup that used to fail), the
next one happens after copying all files into place, when the symlinking
begins:

    ln -s brcmfmac43430-sdio.AP6212.txt debian/firmware-brcm80211/lib/firmware/brcm/brcmfmac43430-sdio.sinovoip,bpi-m2-plus.txt
    ln -s brcmfmac43430-sdio.AP6212.txt debian/firmware-brcm80211/lib/firmware/brcm/brcmfmac43430-sdio.sinovoip,bpi-m2-ultra.txt
    ln -s brcmfmac43430-sdio.AP6212.txt debian/firmware-brcm80211/lib/firmware/brcm/brcmfmac43430-sdio.sinovoip,bpi-m2-zero.txt
    ln -s brcmfmac43430-sdio.AP6212.txt debian/firmware-brcm80211/lib/firmware/brcm/brcmfmac43430-sdio.sinovoip,bpi-m3.txt
    ln -s brcm/brcmfmac43455-sdio.Raspberry debian/firmware-brcm80211/lib/firmware/brcm/brcmfmac43455-sdio.Raspberry
    ln -s Pi debian/firmware-brcm80211/lib/firmware/Pi
    ln -s Foundation-Raspberry debian/firmware-brcm80211/lib/firmware/Foundation-Raspberry
    ln -s Pi debian/firmware-brcm80211/lib/firmware/Pi
    ln: failed to create symbolic link 'debian/firmware-brcm80211/lib/firmware/Pi': File exists
    make[2]: *** [debian/rules.real:17: install] Error 1

This is due to the way the debian/rules.gen file is built, leading to
such a line:

    $(MAKE) -f debian/rules.real binary-indep FILES='[…]' LINKS='[…] brcm/brcmfmac43455-sdio.Raspberry Pi Foundation-Raspberry Pi 4 Model B.txt:brcmfmac43455-sdio.raspberrypi,4-model-b.txt […]' PACKAGE='brcm80211'

and of course the spaces are going to be problemating here as well…

Applying another dumb patch (using a lambda to make it clear which
transformation is happening and to give me one single thing to update if
the first attempt didn't work, using it on both source and destination)
gave me a symlink…

    $ dpkg --contents ../firmware-brcm80211_20230210-5_all.deb | grep Foundation
    lrwxrwxrwx root/root         0 2023-05-01 19:30 ./lib/firmware/brcm/brcmfmac43455-sdio.Raspberry Pi Foundation-Raspberry Pi 4 Model B.txt -> brcmfmac43455-sdio.raspberrypi,4-model-b.txt

Attaching both patches for illustration only (and therefore not tagging
with “patch”). I didn't check for possible fallouts in other packages,
I stopped the build once the firmware-brcm80211 package has been built,
and I only checked the one bit I cared about, the presence of the
symlink (via the aforementioned dpkg|grep command).

Note that the second patch doesn't really on the specifics of the first
patch (using a specific character to avoid the splitting issue, then
getting rid of it). There might be more similar fun depending on the
characters being embedded in firmware files or symlinks, the way both
source and destination are passed together as a single word, with the
':' separator, via the LINKS command.

I suppose the same problem could happen for the FILES variable, and a
similar trick might help there too.


I don't plan on spending more time on this, I just wanted to see if I
could explore the issues at hand and provide some heads-up. I'll be on
stand-by for the hw-detect side once the symlinks are available in a
fixed package.


Cheers,
-- 
Cyril Brulebois (kibi@debian.org)            <https://debamax.com/>
D-I release manager -- Release team member -- Freelance Consultant
From ca3ece1a1dd45bbe349bd14809ffca4e704ee588 Mon Sep 17 00:00:00 2001
From: Cyril Brulebois <kibi@debian.org>
Date: Thu, 4 May 2023 19:09:29 +0000
Subject: [PATCH 1/2] do you wanna build a snowman?

---
 debian/config/brcm80211/defines | 1 +
 debian/lib/python/config.py     | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/debian/config/brcm80211/defines b/debian/config/brcm80211/defines
index 80041d5..f5a4430 100644
--- a/debian/config/brcm80211/defines
+++ b/debian/config/brcm80211/defines
@@ -48,6 +48,7 @@ files:
  brcm/brcmfmac43455-sdio.raspberrypi,3-model-a-plus.txt
  brcm/brcmfmac43455-sdio.raspberrypi,3-model-b-plus.txt
  brcm/brcmfmac43455-sdio.raspberrypi,4-model-b.txt
+ brcm/brcmfmac43455-sdio.Raspberry☃Pi☃Foundation-Raspberry☃Pi☃4☃Model☃B.txt
  brcm/brcmfmac4350c2-pcie.bin
  brcm/brcmfmac4350-pcie.bin
  brcm/brcmfmac4354-sdio.bin
diff --git a/debian/lib/python/config.py b/debian/lib/python/config.py
index 46cc324..ac32665 100644
--- a/debian/lib/python/config.py
+++ b/debian/lib/python/config.py
@@ -43,4 +43,6 @@ class Config(dict):
                 real = (section[-1], package)
             s = self.get(real, {})
             s.update(config[section])
+            if 'files' in s:
+                s['files'] = [x.replace('☃', ' ') for x in s['files']]
             self[real] = s
-- 
2.40.1

From e0b70ed1ba961527b7e979993d054978d819305d Mon Sep 17 00:00:00 2001
From: Cyril Brulebois <kibi@debian.org>
Date: Thu, 4 May 2023 19:25:59 +0000
Subject: [PATCH 2/2] more cheating

---
 debian/bin/gencontrol.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/debian/bin/gencontrol.py b/debian/bin/gencontrol.py
index 293432b..eef667c 100755
--- a/debian/bin/gencontrol.py
+++ b/debian/bin/gencontrol.py
@@ -207,7 +207,8 @@ class GenControl(debian_linux.gencontrol.Gencontrol):
         makeflags['FILES'] = ' '.join(["%s:%s" % (i[1], i[0]) for i in sorted(files_real.values())])
         vars['files_real'] = ' '.join(["/lib/firmware/%s" % i for i in config_entry['files']])
 
-        makeflags['LINKS'] = ' '.join(["%s:%s" % (link, target)
+        quote = lambda x: x.replace(' ', '\ ')
+        makeflags['LINKS'] = ' '.join(["%s:%s" % (quote(link), quote(target))
                                        for link, target in sorted(links.items())])
 
         files_desc = ["Contents:"]
-- 
2.40.1

Attachment: signature.asc
Description: PGP signature


Reply to: