diff --git a/pkgs/development/compilers/open-watcom-bin/default.nix b/pkgs/development/compilers/open-watcom-bin/default.nix index 0cd80b6e1df3..a9c6b221065c 100644 --- a/pkgs/development/compilers/open-watcom-bin/default.nix +++ b/pkgs/development/compilers/open-watcom-bin/default.nix @@ -1,15 +1,62 @@ -{ stdenvNoCC, fetchurl, qemu, expect, writeScript, ncurses }: +{ stdenvNoCC, fetchurl, qemu, expect, writeScript, writeScriptBin, ncurses, bash, coreutils }: let - # We execute the installer in qemu-user, because otherwise the - # installer fails to open itself due to a failed stat() call. This - # seems like an incompatibility of new Linux kernels to run this - # ancient binary. - performInstall = writeScript "perform-ow-install" '' + # We execute all OpenWatcom binaries in qemu-user, because otherwise + # some binaries (most notably the installer itself and wlib) fail to + # use the stat() systemcall. The failure mode is that it returns + # EOVERFLOW for completely legitimate requests. This seems like an + # incompatibility of new Linux kernels to run this ancient binary. + wrapLegacyBinary = writeScript "wrapLegacyBinary" '' + #!${bash}/bin/bash + + set -eu + + if [ $# -ne 2 ]; then + echo "Usage: $0 unwrapped-binary wrapped-binary" + exit 1 + fi + + IN="$(${coreutils}/bin/realpath $1)" + OUT="$2" + ARGV0="$(basename $2)" + + cat > "$OUT" <