kernel: If 'kernel-with-firmware: false', don't assume /lib/firmware is present

Bug #1733564 reported by Paolo Pisati on 2017-11-21
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Snapcraft
High
Paolo Pisati

Bug Description

In case of 'kernel-with-firmware: false', don't assume /lib/firmware is present, and avoid referencing it later on.

snapcraft.yaml:
...
kernel-with-firmware: false

Traceback (most recent call last):
  File "/usr/lib/python3.5/shutil.py", line 538, in move
    os.rename(src, real_dst)
FileNotFoundError: [Errno 2] No such file or directory: '/home/flag/canonical/linux/snap/parts/kernel/install/lib/firmware' -> '/home/flag/canonical/lin
ux/snap/parts/kernel/install/firmware'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): [4/9271]
  File "/home/flag/canonical/snapcraft/bin/snapcraft", line 36, in <module>
    obj=dict(project=snapcraft.ProjectOptions()))
  File "/usr/lib/python3/dist-packages/click/core.py", line 716, in __call__
    return self.main(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 696, in main
    rv = self.invoke(ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 1037, in invoke
    return Command.invoke(self, ctx)
  File "/usr/lib/python3/dist-packages/click/core.py", line 889, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/lib/python3/dist-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/flag/canonical/snapcraft/snapcraft/cli/__init__.py", line 124, in run
    ctx.forward(lifecyclecli.commands['snap'])
  File "/usr/lib/python3/dist-packages/click/core.py", line 552, in forward
    return self.invoke(cmd, **kwargs)
  File "/usr/lib/python3/dist-packages/click/core.py", line 534, in invoke
    return callback(*args, **kwargs)
  File "/home/flag/canonical/snapcraft/snapcraft/cli/lifecycle.py", line 140, in snap
    project_options, directory=directory, output=output)
  File "/home/flag/canonical/snapcraft/snapcraft/internal/lifecycle/_packer.py", line 45, in snap
    execute('prime', project_options)
  File "/home/flag/canonical/snapcraft/snapcraft/internal/lifecycle/_runner.py", line 80, in execute
    _Executor(config, project_options).run(step, part_names)
  File "/home/flag/canonical/snapcraft/snapcraft/internal/lifecycle/_runner.py", line 175, in run
    self._run_step(step, part, part_names)
  File "/home/flag/canonical/snapcraft/snapcraft/internal/lifecycle/_runner.py", line 212, in _run_step
    getattr(part, step)()
  File "/home/flag/canonical/snapcraft/snapcraft/internal/pluginhandler/__init__.py", line 330, in build
    self.plugin.build()
  File "/home/flag/canonical/snapcraft/snapcraft/plugins/kbuild.py", line 258, in build
    self.do_install()
  File "/home/flag/canonical/snapcraft/snapcraft/plugins/kernel.py", line 479, in do_install
    os.path.join(self.installdir, 'lib', 'firmware'), self.installdir)
  File "/usr/lib/python3.5/shutil.py", line 552, in move
    copy_function(src, real_dst)
  File "/usr/lib/python3.5/shutil.py", line 251, in copy2
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "/usr/lib/python3.5/shutil.py", line 114, in copyfile
    with open(src, 'rb') as fsrc:
FileNotFoundError: [Errno 2] No such file or directory: '/home/flag/canonical/linux/snap/parts/kernel/install/lib/firmware'

Kyle Fazzari (kyrofa) wrote :

Hey Paolo, thanks for the bug. For the sake of those of us who aren't kernel pros, would you mind explaining exactly what the issue is, here? What is /lib/firmware, why would one have a kernel without it, and why is this only surfacing now?

Changed in snapcraft:
status: New → Incomplete
Paolo Pisati (p-pisati) wrote :

During the 4.14+ cycle, the 'make firmare_install' target was completely removed from upstream, and any invokation of that target result in an error now:

https://github.com/torvalds/linux/commit/5620a0d1aacd554ebebcff373e31107bb1ef7769

The kernel plugin, by default, invoked that step unless 'kernel-with-firmware: false' was specified, but even in that case, later on, it would blindly dereference /lib/firmware (where by default 'make firmare_install' installed the firmware binaries) resulting in the above error.

Why it surfaces only now? Because no one has used that feature in a while, but now we need it - IOW, without this feature, every recent kernel snap build is impossible.

Kyle Fazzari (kyrofa) wrote :

Exactly the info I wanted, thank you!

Changed in snapcraft:
status: Incomplete → In Progress
importance: Undecided → High
assignee: nobody → Paolo Pisati (p-pisati)
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers