mapbox / node-pre-gyp

Node.js tool for easy binary deployment of C++ addons
BSD 3-Clause "New" or "Revised" License
1.11k stars 260 forks source link

Node.js (and by extension node-pre-gyp) doesn't differentiate between AIX and IBM i #592

Open markdirish opened 3 years ago

markdirish commented 3 years ago

IBM i is a business operating system that includes an AIX-like environment called PASE. Until recently, Python on IBM i identified the operating system as aix. Python is used when building the Node.js binary to determine the operating system, so the Node.js process.platform on when called on IBM i returns aix.

The problem arises when node-pre-gyp uses process.platform in the creation of published package names. This means binaries built on IBM i for IBM i have names that identify the platform as aix like so: odbc-v2.4.0-aix-ppc64-napi-v6.tar.gz. IBM i binaries won't run on AIX, and vice-versa, so anyone using AIX to download these packages will get binaries not built for their systems.

Extra logic should be added to lib/util/versioning.js to check the return value of os.type() when the platform is identified as AIX. os.type() on IBM i will return 'OS400' (the historical name for the operating system), which will allow node-pre-gyp to differentiate between AIX and IBM i. If op.type() returns 'OS400', then the platform and target_platform should be changed to ibmi.

kadler commented 3 years ago

I think we need to check to see what process.platform() will return when Node.js itself is built with a Python which no longer claims to be AIX. I suspect building Node.js this way will cause process.platform() to return "os400", but I'm not sure. In that case, we would want everything to be consistent. Additionally, we'd probably want to be tagged with "os400" for consistency with output of uname, process.platfform(), os.type(), etc... (as much as it would be nice to use the newer marketing name, lots of other platforms have similar baggage eg. mvs, sunos, win32, ...)

markdirish commented 3 years ago

Output from our Python 3.9 build:

bash-5.1$ python --version
Python 3.9.6
bash-5.1$ python
Python 3.9.6 (default, Jul  7 2021, 13:29:52) 
[GCC 6.3.0] on os400
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.name
'posix'
>>> import platform
>>> platform.system()
'OS400'