Skip to content

Commit

Permalink
Handle firmware files compressed with xz
Browse files Browse the repository at this point in the history
Starting from recently Arch Linux compresses the firmware files with xz [1].
Make sure we check for $firmware.xz files as well.

[1] https://archlinux.org/news/linux-firmware-202201190c6a7b3-2-requires-kernel-53-and-package-splitting/

Closes #127
  • Loading branch information
anatol committed Jan 22, 2022
1 parent e64bbb9 commit 7fcf91d
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions generator/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,14 +253,39 @@ func (img *Image) appendExtraFiles(binaries []string) error {
return nil
}

func findFwFile(fw string) (string, error) {
supportedFwExt := []string{
"",
".xz", // https://archlinux.org/news/linux-firmware-202201190c6a7b3-2-requires-kernel-53-and-package-splitting/
}

fwBasePath := firmwareDir + fw
for _, ext := range supportedFwExt {
fwPath := fwBasePath + ext
if _, err := os.Stat(fwPath); err == nil {
return fwPath, nil
} else if os.IsNotExist(err) {
continue // try the next extension
} else {
return "", err
}
}

return "", os.ErrNotExist
}

func (img *Image) appendFirmwareFiles(modName string, fws []string) error {
for _, fw := range fws {
fwPath := firmwareDir + fw
if _, err := os.Stat(fwPath); os.IsNotExist(err) {
path, err := findFwFile(fw)

if os.IsNotExist(err) {
debug("module %s depends on firmware %s but the firmware file does not exist", modName, fw)
continue
} else if err != nil {
return err
}
if err := img.AppendFile(fwPath); err != nil {

if err := img.AppendFile(path); err != nil {
return err
}
}
Expand Down

0 comments on commit 7fcf91d

Please sign in to comment.