cross compilation broken if part contains 'uname'

Bug #1780825 reported by Ondrej Kubik
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Snapcraft
Fix Released
Medium
Kyle Fazzari

Bug Description

Setup:
  snapcraft version: snapcraft 2.42.1 1594
  running inside lxd container on xenial
  cross compiling for armhhf
  part using nil plugin, only has stage-packages defined
  part has coreutils as stage package

Build:
  build fails when snapcraft wrongly executes uname from part instead of uname from host system

output:
Building part-name
/home/ubuntu/host/project/parts/part-name/install/bin/uname: 1: /home/ubuntu/host/project/parts/part-name/install/bin/uname: Syntax error: word unexpected (expecting ")")
Failed to run 'uname -srvmpio': Exited with code 2.

Revision history for this message
Ondrej Kubik (ondrak) wrote :

putting absolute path into snapcraft/internal/pluginhandler/__init__.py
fixes the problem

Revision history for this message
Kyle Fazzari (kyrofa) wrote :

Fix proposed here: https://github.com/snapcore/snapcraft/pull/2177 . Can you confirm that it works, Ondrej?

Changed in snapcraft:
status: New → In Progress
importance: Undecided → Medium
assignee: nobody → Kyle Fazzari (kyrofa)
Revision history for this message
Ondrej Kubik (ondrak) wrote :

hmm, more trouble with similar thing:

/home/ubuntu/host/kura/stage/bin/uname: 1: /home/ubuntu/host/kura/stage/bin/uname: Syntax error: word unexpected (expecting ")")
/home/ubuntu/host/kura/stage/bin/ls: 1: /home/ubuntu/host/kura/stage/bin/ls: Syntax error: word unexpected (expecting ")")
/home/ubuntu/host/kura/stage/usr/bin/expr: 1: /home/ubuntu/host/kura/stage/usr/bin/expr: Syntax error: word unexpected (expecting ")")
/home/ubuntu/host/kura/stage/usr/bin/expr: 1: /home/ubuntu/host/kura/stage/usr/bin/expr: Syntax error: word unexpected (expecting ")")
/home/ubuntu/host/kura/stage/usr/bin/dirname: 1: /home/ubuntu/host/kura/stage/usr/bin/dirname: Syntax error: word unexpected (expecting ")")
/home/ubuntu/host/kura/stage/usr/bin/dirname: 1: /home/ubuntu/host/kura/stage/usr/bin/dirname: Syntax error: word unexpected (expecting ")")

I'm trying to rebuild part, while there are already in stage executables from other parts. But those executables are for different architecture. Part is build with maven, so I assume maven calls those utils, and because path points to stage in first place, it picks one for wrong arch.
I guess one way around is to change order of parts here but looks like something quite fragile when cross compiling.

So as start, I'd suggest that when we cross compile, we should not populate PATH like this, as that is destined to fail

Same can happen if I will have same tools but with different behaviour in my snap...but that could be probably considered as corner case

Kyle Fazzari (kyrofa)
Changed in snapcraft:
status: In Progress → Fix Committed
Changed in snapcraft:
milestone: none → 2.43
Changed in snapcraft:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.