Commit Graph

11 Commits

Author SHA1 Message Date
Benjamin Drung b6ea35ff6b
copy-firmware: Fix linking directories when using compression
When `copy-firmware` is called with `--xz` or `--zstd` it will create
broken symlinks for directories:

```
$ ./copy-firmware -v --zstd $dir
[...]
creating link qcom/LENOVO/21BX.zst -> ../sc8280xp/LENOVO/21BX.zst
```

The original target `../sc8280xp/LENOVO/21BX` is a directory. Adding the
compression extension to the directory name breaks the link. The
directory `qcom/sc8280xp/LENOVO/21BX` exists but
`qcom/sc8280xp/LENOVO/21BX.zst` does not exist.

The relative symlink needs to be resolved. If it points to a directory,
create the symlink without the compression extension.

Signed-off-by: Benjamin Drung <benjamin.drung@canonical.com>
Signed-off-by: Josh Boyer <jwboyer@kernel.org>
2023-07-25 06:53:30 -04:00
Benjamin Drung 0a51959c6f
copy-firmware: Fix test: unexpected operator
dash is the default /bin/sh on Debian based system.

```
dash ./copy-firmware.sh --zstd example
./copy-firmware.sh: 37: test: unexpected operator
```

`=` should be used with the test command for POSIX conformance.

Signed-off-by: Benjamin Drung <benjamin.drung@canonical.com>
Signed-off-by: Josh Boyer <jwboyer@kernel.org>
2023-07-25 06:53:21 -04:00
Emil Velikov ee91452dac
Makefile, copy-firmware: support xz/zstd compressed firmware
The kernel has supported compressed firmware for quite some time. So
let's add a couple of targets to produce that. In practical terms this
means it we'll use ~5x times less space on disk.

Reportedly the amd ucode, needs to be uncompressed _within_ the
initrd in order to work. Using compressed ucode in late load just works.
Ideally this will be addressed by the initrd generators, but considering
the files are tiny in size let's skip the compression.

v2
 - commit message, skip compression for files annotated as Raw

v3
 - rebase

[Drop extra verbose statement in zstd case, Josh Boyer
<jwboyer@kernel.org>]

Cc: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Josh Boyer <jwboyer@kernel.org>
2023-06-25 12:18:57 -04:00
Emil Velikov ad2ce8beee
copy-firmware: silence the last shellcheck warnings
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Josh Boyer <jwboyer@kernel.org>
2023-06-25 11:59:31 -04:00
Emil Velikov 67bf50e72c
copy-firmware: drop obsolete backticks, quote
As mentioned by shellcheck backticks are considered legacy. Plus we
should ensure the output is quoted, otherwise we'll get word splitting.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Signed-off-by: Josh Boyer <jwboyer@kernel.org>
2023-06-25 11:58:52 -04:00
Emil Velikov 77f31a8000
copy-firmware: tweak sed invocation
Add space between the arguments and pattern and combine patterns where
possible.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Signed-off-by: Josh Boyer <jwboyer@kernel.org>
2023-06-25 11:58:33 -04:00
Emil Velikov 40fa2b2096
copy-firmware: quote deskdir and dirname
Properly quote, otherwise we'll get word splitting. In other words:
Files might end up installed to /some/foo/, where /some path/foo bar/ is
expected.

v2:
 - rebase/split && also quote the $() output

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Signed-off-by: Josh Boyer <jwboyer@kernel.org>
2023-06-25 11:58:09 -04:00
Konrad Weihmann eaee2dacc2
Makefile: replace mkdir by install
mkdir -p creates paths that are bound to user's settings and therefore
can lead to different file mode bits of the base paths accross different
machines.
Use install instead, as this tool is not prone to such behavior.

Signed-off-by: Konrad Weihmann <kweihmann@outlook.com>
Signed-off-by: Josh Boyer <jwboyer@kernel.org>
2022-05-31 12:57:56 -04:00
Tony Nguyen c1bef9e010
copy-firmware: Always write Link: entries
File: entries in the WHENCE file overwrite existing files in the target
directory, however, Link: entries are skipped if the file exists in the
target directory. This can cause issues if the Link: entry is updated, but
the target directory contains an old symlink. Do not skip writing Link:
entries if the file exists, always create the symlink. This matches the
behavior of File: entries and ensures symlinks will contain values from
the WHENCE file.

Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Signed-off-by: Josh Boyer <jwboyer@kernel.org>
2020-10-05 08:06:02 -04:00
Thierry Reding 2de7abd480
copy-firmware: Create symlinks from WHENCE file
Rather than require symlinks to be created in the filesystem and have
duplicate Link: entries in the WHENCE file, make copy-firmware.sh create
the symlinks on the fly.

Signed-off-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Josh Boyer <jwboyer@kernel.org>
2019-10-04 18:34:02 -04:00
Takashi Iwai 07b925b450
Install only listed firmware files
The current make-install procedure leaves lots of garbage files that
aren't really firmware files in /lib/firmware.

Instead of copy-all-and-prune approach, copy only the listed files and
links in WHENCE by make-install for assuring only the proper firmware
files.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Josh Boyer <jwboyer@kernel.org>
2019-08-15 07:46:53 -04:00