open-watcom / open-watcom-v2

Open Watcom V2.0 - Source code repository, Wiki, Latest Binary build, Archived builds including all installers for download.
Other
989 stars 162 forks source link

Open Watcom v2 installer can't be run in a Dockerfile (as part of building a Docker image) #1192

Closed volkertb closed 10 months ago

volkertb commented 10 months ago

I know that a workaround exists for the Floating point exception (core dumped) issue in the Open Watcom v2 installer, but I can't for the love of me seem to get it to work in a Dockerfile:

# SPDX-License-Identifier: Apache-2.0
FROM debian:12.2-slim

ARG OW2_RELEASE_VERSION=2023-12-01-Build
ARG OW2_INSTALLER_NAME=open-watcom-2_0-c-linux-x64
ARG OW2_INSTALLER_SHA256=1781635c1cf76d3e7232b4de137372dccf00b166b1271359f969c50dda7dde61

# Download, verify and run the prebuilt Open Watcom v2 installer for Linux
RUN apt -y update
RUN apt -y install wget
RUN wget -P /tmp https://github.com/open-watcom/open-watcom-v2/releases/download/${OW2_RELEASE_VERSION}/${OW2_INSTALLER_NAME}
RUN echo "${OW2_INSTALLER_SHA256}  /tmp/${OW2_INSTALLER_NAME}" | sha256sum --check
RUN chmod +x /tmp/${OW2_INSTALLER_NAME}

# Workaround(s), see https://github.com/open-watcom/open-watcom-v2/wiki/Notes#core-dump-in-linux-installer

# Doesn't work
ARG TERMINFO=/lib/terminfo

# Doesn't work either (even when I try other values such as `xterm`, `xterm-256color`, etc.)
ARG TERM=vt100

# This one keeps failing with `Floating point exception (core dumped)`
RUN /tmp/${OW2_INSTALLER_NAME} -i

When I run docker run -i -t --rm debian:12.2-slim and then consecutively enter the commands behind each RUN statement manually, it works fine. But of course that's because this results in docker run running in interactive mode, and thus with a valid TTY, while the installer is run.

I tried various workarounds, such as GNU Screen (in detached mode), script, unbuffer (part of the expect package), but all those did was hide the error without the installer running successfully. I know this, since the directory /usr/bin/watcom didn't exist afterwards, which is where Open Watcom should have been installed, had the installer in silent mode (with the -i option) worked and completed successfully.

Here is a StackOverflow answer with some suggestions I tried, none of them which worked, at least when builing a Dockerfile in which the Open Watcom v2 installer is run, even in silent mode with the -i option.

This is really unfortunate, because I'm trying to set up a project that automatically takes Open Watcom v2 releases, and builds Docker images around them, for use in GitHub Actions for projects that require the Open Watcom toolchain. I don't want to have to figure out how to perform all the actions of the installers (where to copy each file, how to create the owsetenv script, etc) by myself. Also, that would be redundant, since the installer is already supposed to take care of all of that for us.

At the end of the day, the installer should not even try to initialize any of the terminal-dependent ncurses stuff when -i (silent mode) or -? (usage help) is specified. Instead of relying on the aforementioned TERMINFO workaround (which doesn't work during docker build), can this maybe be fixed in the installer?

Thank you kindly for considering. :pray:

Seems related to https://github.com/open-watcom/open-watcom-v2/issues/556, but not the same.

jmalak commented 10 months ago

the problem could be with old OW ncurses port (I think version 5.3) due to compatibility problem with newer Linux distributions. I checked version 6 but it has complete new configuration system which requires Unix/Posix host system for configuration and not support most of OW platforms. I was not able to create installation for non-Linux system as DOS, Windows, OS/2 etc.

jmalak commented 10 months ago

You can create installation from OW snapshot without installer. Snapshot is tar file which contains OW installation for all hosts and targets that you can put it into any directory and create or modify startup script owsetenv.sh to refere this directory. It is what installer do. Next possibility is to use OW setup

jmalak commented 10 months ago

Anyway I tried last OW installer on Ubuntu 22 and it works without problem. No hacks are needed.

volkertb commented 10 months ago

@jmalak To clarify, this issue only occurs while running the OW2 installer as part of a docker build. So by creating a file called Dockerfile with the contents I shared above and then running the command docker build . in the same directory (the dot at the end it not a typo).

I just tried replacing FROM debian:12.2-slim with FROM ubuntu:22.04, so that the official Ubuntu 22.04 Docker base image is used instead of the Debian (slim) one. Unfortunately that didn't help, and the Docker build failed with the same Floating point exception (core dumped) error. Again, this probably has something to do with the lack of an actual TTY during the Docker build.

Thanks for pointing out OW snapshot and OW setup.

However, OW snapshot only allows me to build the latest snapshot, whereas I'd like to build specific versions of Docker images that correspond to specific versions (or dated builds) of Open Watcom v2.

If I tell OW setup to download and install version 2.0 of Open Watcom, exactly which build will it end up installing? Open Watcom v2.0 has been a moving target for years, right?

Long story short, I need a simple way to check out a specific (dated, non-snapshot) build of Open Watcom 2, and install it or at least unpack it in the same way the installer would, as part of a Docker build, without having to recreate the installation steps (which files to copy where, creating the owsetenv script, and whatever else needs to happen as part of the installation). There's already an installer for that, and if the installation procedure ever gets changed in the installer, I would have to manually adapt the installation logic in the Dockerfile (or in some kind of self-maintained script) manually to keep it up-to-date with the installer. That would add a maintenance burden and a possible human point of failure, so I prefer not to do that.

Thanks again for whatever help you can provide me towards achieving this goal.

volkertb commented 10 months ago

It took me quite some effort and trial and error, but I finally found a reasonable workaround:

# Run the installer with `script` as a workaround for `Floating point exception (core dumped)`
# See also https://github.com/open-watcom/open-watcom-v2/wiki/Notes#core-dump-in-linux-installer
ARG TERM=vt100
RUN script -c "/tmp/${OW2_INSTALLER_NAME} -i -dDstDir=${OW2_DESTINATION_DIR} -dFullInstall=1"

So I had to do two things: set a TERM environment variable to something that ncurses supports (vt100 is a safe lowest common denominator) and and use the script command (part of util-linux) to run the installer, which allows "interactive" applications (expecting a terminal session) to run in environments without one.

With this workaround, the GitHub Actions in my project are now passing.

I'll close this issue now that this workaround is documented here for whomever runs into the same problem. But it would be nice to eventually have the installer improved in a way that it could run as a command-line tool as well as an interactive application with a text UI.

I'll also reach out to the OW setup project, since there is definitely some overlap between what they have been doing and what I'm currently doing.

Thanks again!

jmalak commented 10 months ago

only notes: