Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix highly embarrassing mistake in patch transformation #6182

Merged
merged 2 commits into from
Aug 28, 2024

Conversation

dra27
Copy link
Member

@dra27 dra27 commented Aug 27, 2024

Backport in 2.2 with #6183

This has sadly been wrong since #3349 was fixed in #3449 (which equates to "it's always been wrong", as that was during 2.0.0's dev cycle).

Patches require transformation to deal with line-endings - patch can cope with patching CRLF files, but the diff needs to have the same line-endings as the files. Prior to applying a patch, OpamSystem.translate_patch checks the files to which the diff is being applied and transforms the patch. If no transformations are needed (which is pretty much always - most release tarballs use Unix line-endings, even on Windows), then the patch is simply copied.

The process works fine, except for a teeny detail. Owing to a badly made logging transformation in #3449, the transformation was only written to the patch file if debugging mode was enabled 🤦

On Windows, while working on compiler packaging, this manifested itself as:

∗ installed ocaml-env-mingw64.1
∗ installed system-mingw.1
⬇ retrieved ocaml-compiler.4.08.1  (cached)
∗ installed mingw-w64-shims.0.2.0

#=== ERROR while compiling ocaml-compiler.4.08.1 ==============================#
Sys_error("C:\\Users\\DRA\\AppData\\Local\\opam\\log\\processed-patch-25204-bf7b21: Permission denied")


<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><>  🐫
┌─ The following actions failed
│ λ build ocaml-compiler 4.08.1

but the patch is successfully transformed when running with --debug. What was happening was the the patch file is opened (ch_out); nothing is written to it so the patch of course "applies" perfectly but because ch_out was never closed, the removal fails after trying to apply the patch (as it happens, the removal is skipped when debugging, but would in fact succeed).

Indicate at level 1 whether a patch has been copied or transformed.
OpamSystem.translate_patch embarrassingly only transformed patches when
--debug was in effect.
Copy link
Collaborator

@rjbou rjbou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@rjbou rjbou merged commit 9985053 into ocaml:master Aug 28, 2024
29 checks passed
@rjbou rjbou modified the milestones: 2.2.2, 2.3.0~alpha Aug 28, 2024
@dra27 dra27 deleted the processing-patches branch August 28, 2024 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants