Skip to content

interpreters/berry: Normalize CRLF before patching#3567

Open
speccy88 wants to merge 1 commit into
apache:masterfrom
speccy88:codex/fix-berry-crlf-before-patch
Open

interpreters/berry: Normalize CRLF before patching#3567
speccy88 wants to merge 1 commit into
apache:masterfrom
speccy88:codex/fix-berry-crlf-before-patch

Conversation

@speccy88

Copy link
Copy Markdown
Contributor

Berry upstream stores default/berry.c with CRLF line endings, while the local NuttX patch is LF. Fresh Make and CMake builds can therefore fail before Berry is compiled because GNU patch rejects the hunks as line-ending mismatches.

Normalize the downloaded Berry default/berry.c before applying the existing NuttX patch in both Make and CMake fetch paths.

Tested:

  • Fresh Berry archive: fix-crlf.py + patch -l -p1 applies and updates OS_NAME / optvalue.
  • ./tools/configure.sh -a ../apps sim:berry && make olddefconfig && make -j8
  • Simulator smoke: berry -v prints Berry 1.1.0; berry -e print(40+2) prints 42.
  • ./tools/testbuild.sh -m -C -N -x -j 8 -a ../apps -t /tmp/nuttx_current_berry /tmp/berry-cmake-testlist.dat
  • tools/checkpatch.sh -c -u -m -g origin/master..HEAD
  • ESP32-C3 hardware smoke on /dev/cu.usbmodem101: flashed esp32c3-devkit:usbconsole with Berry enabled; berry -v prints Berry 1.1.0; berry -e print(40+2) prints 42.

Signed-off-by: Frederick Blais fred_blais5@hotmail.com

Berry's downloaded default/berry.c uses CRLF line endings, while the local NuttX patch is stored with LF line endings. Fresh Linux and CMake builds fail when patch sees the different line endings.

Normalize the downloaded source file before applying the patch in both Make and CMake fetch paths.

Signed-off-by: Frederick Blais <fred_blais5@hotmail.com>
@simbit18

Copy link
Copy Markdown
Contributor

Hi @xiaoxiang781216, Is this related to any recent changes?

====================================================================================
Configuration/Tool: pic32mx7mmb/nsh,CONFIG_MIPS32_TOOLCHAIN_PINGUINOL
2026-06-28 16:44:34
------------------------------------------------------------------------------------
  Cleaning...
  Configuring...
  Disabling CONFIG_MIPS32_TOOLCHAIN_GNU_ELF
  Enabling CONFIG_MIPS32_TOOLCHAIN_PINGUINOL
  Building NuttX...
usbmsc_main.c: In function 'msconn_main':
Error: usbmsc_main.c:584:51: error: 'O_WROK' undeclared (first use in this function)
                            luns[num_luns].flags & O_WROK ? false : true);
                                                   ^
usbmsc_main.c:584:51: note: each undeclared identifier is reported only once for each function it appears in
make[2]: *** [/github/workspace/sources/apps/Application.mk:330: usbmsc_main.c.github.workspace.sources.apps.system.usbmsc.o] Error 1
make[2]: Target 'all' not remade because of errors.
make[1]: *** [Makefile:54: /github/workspace/sources/apps/system/usbmsc_all] Error 2
make[1]: Target 'all' not remade because of errors.
make: *** [tools/LibTargets.mk:248: /github/workspace/sources/apps/libapps.a] Error 2
make: Target 'all' not remade because of errors.
/github/workspace/sources/nuttx/tools/testbuild.sh: line 397: /github/workspace/sources/nuttx/../nuttx/nuttx.manifest: No such file or directory
  [1/1] Normalize pic32mx7mmb/nsh
/github/workspace/sources/nuttx /github/workspace/sources/nuttx
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean
/github/workspace/sources/nuttx
/github/workspace/sources/apps /github/workspace/sources/nuttx
HEAD detached at pull/3567/merge
nothing to commit, working tree clean
/github/workspace/sources/nuttx
Build Attempt 1 of 1
====================================================================================

@acassis

acassis commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

@xiaoxiang781216 there are two places where the old symbol still used:

alan@dev:~/nuttxspace/apps$ git grep O_WROK
examples/userfs/userfs_main.c:      if ((oflags & (O_WROK | O_APPEND)) == (O_WROK | O_APPEND))
system/usbmsc/usbmsc_main.c:                           luns[num_luns].flags & O_WROK ? false : true);

$(Q) unzip -q -o $(BERRY_ARCHIVE)
$(call DELDIR, $(BERRY_UNPACK))
$(Q) mv berry-$(BERRY_COMMIT_ID) $(BERRY_UNPACK)
$(Q) python3 $(BERRY_FIX_CRLF) $(BERRY_MAIN)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

but why not patch to \r\n version, or upstream the patch (convert '\r\n' to '\n' in berry.c) to the community.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I already upstreamed the Berry-side change here: berry-lang/berry#539. That PR is approved, but it has not been merged yet.

For this NuttX apps PR, I normalized the downloaded default/berry.c before applying the existing patch because the current pinned Berry archive still contains CRLF line endings, while the NuttX patch is LF. This keeps the patch file in the normal NuttX text format and makes both Make and CMake fetch paths apply it reliably.

If you prefer, I can switch this PR to a CRLF-formatted patch instead. Once berry-lang/berry#539 is merged, I can also update the pinned Berry commit and remove the local NuttX patch entirely.

@xiaoxiang781216

Copy link
Copy Markdown
Contributor

@xiaoxiang781216 there are two places where the old symbol still used:

alan@dev:~/nuttxspace/apps$ git grep O_WROK
examples/userfs/userfs_main.c:      if ((oflags & (O_WROK | O_APPEND)) == (O_WROK | O_APPEND))
system/usbmsc/usbmsc_main.c:                           luns[num_luns].flags & O_WROK ? false : true);

here is the fix: #3568

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.

4 participants