Opened 3 years ago
Closed 14 months ago
#64863 closed defect (fixed)
base: (linux) invalid `os_arch` on debian-based distros
Reported by: | harens (Haren S) | Owned by: | |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | base | Version: | |
Keywords: | Cc: | mascguy (Christopher Nielsen) | |
Port: |
Description
I'm currently running MacPorts on Raspberry Pi OS with an armv7l processor. os_arch
is set to "armv7l" rather than the standard "arm" which causes breakages for ports that have a platform arm
block.
I think this is due to this code snippet from macports.tcl:
# set up platform info variables set os_arch $tcl_platform(machine) # Set os_arch to match `uname -p` if {$os_arch eq "Power Macintosh"} { set os_arch "powerpc" } elseif {$os_arch eq "i586" || $os_arch eq "i686" || $os_arch eq "x86_64"} { set os_arch "i386" } elseif {$os_arch eq "arm64"} { set os_arch "arm" }
The issue is thatuname -p
isn't defined on all linux distributions. Most notably, it's not defined on debian-based distros (excluding ubuntu and its derivatives). See here for an explanation why.
As a result, the output of uname -p
is unknown
, which doesn't match with any of the if statements. Somehow though, MacPorts sets os_arch
to armv7l, which is the output of uname -m
.
The easiest fix might be to check uname -m
if uname -p
is unknown e.g. set os_arch to arm if uname -m
begins with arm.
Change History (6)
comment:1 Changed 3 years ago by ryandesign (Ryan Carsten Schmidt)
comment:2 Changed 3 years ago by harens (Haren S)
Ah okay, thank you for explaining. That makes a lot of sense. The issue isn't to do with uname -p
, it's just that the architecture hasn't been set in MacPorts base.
Also, I really like that switch statement. I found a list of some possible uname -m
values, and thought I'd try to future proof the code a bit. Thoughts?
switch -regexp -- $os_arch { {^(Power Macintosh|ppc)} { set os_arch "powerpc" } {i[3-7]86} { set os_arch "i386" } {^(arm|aarch)} { set os_arch "arm" } }
It fixes the current problem by mapping anything that begins with arm
or aarch
to arm
comment:4 Changed 3 years ago by harens (Haren S)
Great. PR open: https://github.com/macports/macports-base/pull/268
comment:5 Changed 2 years ago by mascguy (Christopher Nielsen)
Cc: | mascguy added |
---|
comment:6 Changed 14 months ago by jmroot (Joshua Root)
Resolution: | → fixed |
---|---|
Status: | new → closed |
MacPorts doesn't use
uname
directly. As you see it uses$tcl_platform(machine)
which according to the documentation is the output ofuname -m
. But we want the equivalent ofuname -p
for which I guess Tcl doesn't offer us a variable so we turn certain known values fromuname -m
into their correspondinguname -p
-like values. As you see we have not programmed MacPorts base to know how to transform "armv7l" into "arm" here but it could easily be extended to do so. Might be a good time to change all thoseif
statements into aswitch
: