WolfgangFahl / pymediawikidocker

Python controlled mediawiki docker image installation
Apache License 2.0
6 stars 1 forks source link

Bash scripts on windows can't be executed in container #73

Closed Kusko25 closed 2 months ago

Kusko25 commented 3 months ago

If you build a container on Windows (used mw version 1.41.1, which bypasses the template issue), the bash scripts initdb.sh, installExtensions.sh etc. are generated with \r\n line endings before being copied into the container. That leads to docker exec producing file not found errors (because ?) when called on files that are very much there.

I confirmed this by installing dos2unix in the container and applying it to /root/installExtensions.sh after which the exec command worked.

From a bit of experimentation that can be fixed by adding newline="" in docker.py in line 511 in optionalWrite() like this:
with open(targetPath, "w", newline="") as targetFile: That prevents Python from automatically replacing newline characters.

WolfgangFahl commented 3 months ago

@Kusko25 - thank you for reporting. It is a pitty how Bill Gates decisions of the 80th to be non standard compliant still hit us some 40+ years later.

Kusko25 commented 3 months ago

True, though Windows these days can handle just \n perfectly fine, so I put a lot of the blame on all those 'helpful' systems that make sure to sneak \r in where it is absolutely not needed.