ci: `.gitattributes` - Ensure `eol=lf` for shell scripts by polarathene · Pull Request #3755 · docker-mailserver/docker-mailserver · GitHub
Skip to content

ci: .gitattributes - Ensure eol=lf for shell scripts#3755

Merged
polarathene merged 2 commits into
masterfrom
ci/ensure-lf-for-shellscript-content
Jan 7, 2024
Merged

ci: .gitattributes - Ensure eol=lf for shell scripts#3755
polarathene merged 2 commits into
masterfrom
ci/ensure-lf-for-shellscript-content

Conversation

@polarathene

@polarathene polarathene commented Jan 7, 2024

Copy link
Copy Markdown
Member

Description

  • These files should always use LF for line endings.
  • Dockerfile does not like building with HereDoc RUN scripts that expect LF.

Cloned on Windows, but ran Docker build from WSL2 which failed as Windows checkout used CRLF:

 => [stage-base 2/6] COPY target/bin/sedfile /usr/local/bin/sedfile                                                                                                                                               0.0s
 => ERROR [stage-base 3/6] RUN <<EOF (chmod +x /usr/local/bin/sedfile...)                                                                                                                                         0.4s
------
 > [stage-base 3/6] RUN <<EOF (chmod +x /usr/local/bin/sedfile...):
0.372 chmod: cannot access '/usr/local/bin/sedfile'$'\r': No such file or directory
------
Dockerfile:23
--------------------
  22 |     COPY target/bin/sedfile /usr/local/bin/sedfile
  23 | >>> RUN <<EOF
  24 | >>>   chmod +x /usr/local/bin/sedfile
  25 | >>>   adduser --quiet --system --group --disabled-password --home /var/lib/clamav --no-create-home --uid 200 clamav
  26 | >>> EOF
  27 |
--------------------
ERROR: failed to solve: process "/bin/bash -e -o pipefail -c   chmod +x /usr/local/bin/sedfile\r\n  adduser --quiet --system --group --disabled-password --home /var/lib/clamav --no-create-home --uid 200 clamav\r\n" did not complete successfully: exit code: 1
make: *** [Makefile:21: build] Error 1

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Improvement (non-breaking change that does improve existing functionality)

Checklist:

  • New and existing unit tests pass locally with my changes
  • I have added information about changes made in this PR to CHANGELOG.md

- These files should always use LF for line endings.
- `Dockerfile` does not like building with HereDoc `RUN` scripts that expect LF.
@polarathene polarathene added area/ci kind/bug/fix A fix (PR) for a confirmed bug labels Jan 7, 2024
@polarathene polarathene added this to the v14.0.0 milestone Jan 7, 2024
@polarathene polarathene self-assigned this Jan 7, 2024
@casperklein

Copy link
Copy Markdown
Member

@polarathene

polarathene commented Jan 7, 2024

Copy link
Copy Markdown
Member Author

Shouldn't this take care of all file types, not explicitly configured?

It does in the sense of the text attribute but that is regarding check-in.

eol=lf affects check-out. By default on git a clone on Windows will checkout as CRLF unless we explicitly configure it to be LF. Certain files expect to have LF line endings (notably scripts, python included apparently), or at least they do when running on Linux 😅

Until I can switch back to linux or use VMs again, this is my lazy way of addressing the issue when I hit failure due to line endings being incorrect.


Technically, we probably could do * text=auto eol=lf, assuming eol=lf only applies to files detected as text 🤷‍♂️

Not sure if there would be any files in the project that would actually need eol=crlf 🤔

@polarathene polarathene merged commit 6d66651 into master Jan 7, 2024
@polarathene polarathene deleted the ci/ensure-lf-for-shellscript-content branch January 7, 2024 20:34
@casperklein

Copy link
Copy Markdown
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/ci kind/bug/fix A fix (PR) for a confirmed bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants