aclemons / slackware-dockerfiles

Unofficial Slackware Linux Docker Images
MIT License
7 stars 1 forks source link

Documentation: How to install the gcc toolchain? (i386) #149

Closed nilstoedtmann closed 2 months ago

nilstoedtmann commented 7 months ago

(Disclaimer: Apologies for opening a ticket for a simple question. Feel free to direct me to more appropriate places.)

How do I install the the gcc toolchain in slackware:latest (i386) so I can build a Python3 virtualenv?

I managed to install Python3:

docker run  --platform "linux/386"  --rm -it   aclemons/slackware:latest
slackpkg update
slackpkg search python
slackpkg install python3-3.9.18-i586-1_slack15.0
# python -V
Python 3.9.18

However, I can't find gcc:

# slackpkg search gcc

Looking for gcc in package list. Please wait... DONE

No package name matches the pattern.

Apologies for being new to Slackware and slackpkg. I am proficient with Debian/Ubuntu and if I have to RH-based distros.


Background: For very peculiar and historical reasons, I need to run some modern Python3 software on old x32 i586 hardware running some very old Debian version. I am somewhat successful with taking a x32 docker image of a less old Debian version, and (because Docker doesn't run here) flatten that out as a Linux chroot, where I can run more recent software than on the old host Debian.

But Debian no longer support the i586 instruction set since Debian11.

So I thought I'll give Slackware a try, and I found your helpful docker images!

aclemons commented 6 months ago

Sorry, I missed this ticket in the stream of daily github pings.

I'm not actually sure of what the best practice for 386 docker images is, but the issue here is with slackpkg and how it filters packaged on the architecture. The 386 container still returns x86_64 as the arch from uname, so it is filtering out most things in your search. That's why you are seeing no results in your search.

I noticed before this is not the case with ubuntu / debian x32 images, but I don't actually know why. I had considered changing the ENTRYPOINT for the 386 images to default to linux32 but wasn't sure if this is actually "correct", so left it for the user to decide.

Anyway, for my purposes when I use the 386 images, I always start them with something like this:

docker run  --platform "linux/386" --entrypoint linux32 --rm -it   aclemons/slackware:latest

After that, you should be able to install all your package. You probably already know, but the package manager will not handle any dependencies for you, so you'll need to make sure to install the things that python3 and gcc need - a bit of trial and error might be needed.

Good luck!

nilstoedtmann commented 6 months ago

Hi @aclemons , thank you for taking the time!

--entrypoint linux32 does indeed help, I can now e.g. slackpkg install gcc-11.2.0-i586-2.

Obviously I am used to package managers like APT or YUM that resolve dependencies conveniently (but also can descend down into dependency hell), but I'll figure it out. Any pointers to best practises resolving dependency issues would be welcome though.

For example, trying to make a Python Venv fails because of

ImportError: /usr/lib/python3.9/lib-dynload/pyexpat.cpython-39-i386-linux-gnu.so: undefined symbol: XML_SetReparseDeferralEnabled 

which I suspect is some missing library. Details below:

# ...
Package python3-3.9.19-i586-1_slack15.0.txz installed.

# python3 -V
Python 3.9.19

# mkdir /opt/venvs

# python3 -m venv /opt/venvs/test
Error: Command '['/opt/venvs/test/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.

# /opt/venvs/test/bin/python3 -I -m ensurepip --upgrade --default-pip
Traceback (most recent call last):
  File "<string>", line 6, in <module>
  File "/usr/lib/python3.9/runpy.py", line 225, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib/python3.9/runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/tmp/tmpn1jcssjo/pip-23.0.1-py3-none-any.whl/pip/__main__.py", line 31, in <module>
  File "/tmp/tmpn1jcssjo/pip-23.0.1-py3-none-any.whl/pip/_internal/cli/main.py", line 68, in main
  File "/tmp/tmpn1jcssjo/pip-23.0.1-py3-none-any.whl/pip/_internal/commands/__init__.py", line 114, in create_command
  File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 627, in _load_backward_compatible
  File "<frozen zipimport>", line 259, in load_module
  File "/tmp/tmpn1jcssjo/pip-23.0.1-py3-none-any.whl/pip/_internal/commands/install.py", line 16, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "/tmp/tmpn1jcssjo/pip-23.0.1-py3-none-any.whl/pip/_internal/cli/req_command.py", line 21, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "/tmp/tmpn1jcssjo/pip-23.0.1-py3-none-any.whl/pip/_internal/index/package_finder.py", line 30, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "/tmp/tmpn1jcssjo/pip-23.0.1-py3-none-any.whl/pip/_internal/req/__init__.py", line 8, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "/tmp/tmpn1jcssjo/pip-23.0.1-py3-none-any.whl/pip/_internal/req/req_install.py", line 44, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "/tmp/tmpn1jcssjo/pip-23.0.1-py3-none-any.whl/pip/_internal/operations/install/wheel.py", line 39, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "/tmp/tmpn1jcssjo/pip-23.0.1-py3-none-any.whl/pip/_vendor/distlib/scripts.py", line 16, in <module>
  File "<frozen zipimport>", line 259, in load_module
  File "/tmp/tmpn1jcssjo/pip-23.0.1-py3-none-any.whl/pip/_vendor/distlib/compat.py", line 83, in <module>
  File "/usr/lib/python3.9/xmlrpc/client.py", line 138, in <module>
    from xml.parsers import expat
  File "/usr/lib/python3.9/xml/parsers/expat.py", line 4, in <module>
    from pyexpat import *
ImportError: /usr/lib/python3.9/lib-dynload/pyexpat.cpython-39-i386-linux-gnu.so: undefined symbol: XML_SetReparseDeferralEnabled
Traceback (most recent call last):
  File "/usr/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/usr/lib/python3.9/ensurepip/__main__.py", line 5, in <module>
    sys.exit(ensurepip._main())
  File "/usr/lib/python3.9/ensurepip/__init__.py", line 211, in _main
    return _bootstrap(
  File "/usr/lib/python3.9/ensurepip/__init__.py", line 130, in _bootstrap
    return _run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
  File "/usr/lib/python3.9/ensurepip/__init__.py", line 39, in _run_pip
    return subprocess.run(cmd, check=True).returncode
  File "/usr/lib/python3.9/subprocess.py", line 528, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['/opt/venvs/test/bin/python3', '-I', '-c', '\nimport runpy\nimport sys\nsys.path = [\'/tmp/tmpn1jcssjo/setuptools-58.1.0-py3-none-any.whl\', \'/tmp/tmpn1jcssjo/pip-23.0.1-py3-none-any.whl\'] + sys.path\nsys.argv[1:] = [\'install\', \'--ignore-installed\', \'--no-cache-dir\', \'--no-index\', \'--find-links\', \'/tmp/tmpn1jcssjo\', \'--upgrade\', \'setuptools\', \'pip\']\nrunpy.run_module("pip", run_name="__main__", alter_sys=True)\n']' returned non-zero exit status 1.
aclemons commented 6 months ago

Here is a dockerfile I use for running a small python lambda using slackware -current as a base (the unreleased development version of the next slackware release). I would not recommend using it since it is constantly changing, but the dependencies for use with 15.0/latest should be about the same:

https://github.com/aclemons/sbo-bot/blob/f697204e2973a96c2042618c575ea78351f89e2e/gitlab/Dockerfile#L9-L17

Specifically for your case, it looks like you need to install expat so that pyexpat can find the things it is linked to.