This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit d75d7131657d6e8af885336eeb97a3ce6ef5aff4
Author: Abhishek Mishra <[email protected]>
AuthorDate: Wed Jul 8 08:32:10 2026 +0000

    cmake/romfs: invoke passwd helper scripts via POSIX shell
    
    Run update_romfs_password.sh, check_passwd_keys.sh, and
    gen_passwd_keys.sh through an explicit sh/bash interpreter so CMake
    configure works on Linux, macOS, MSYS2, and Cygwin instead of relying
    on direct script execution.
    
    Signed-off-by: Abhishek Mishra <[email protected]>
---
 cmake/nuttx_add_romfs.cmake | 25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/cmake/nuttx_add_romfs.cmake b/cmake/nuttx_add_romfs.cmake
index 868ea4d118c..49cfc515242 100644
--- a/cmake/nuttx_add_romfs.cmake
+++ b/cmake/nuttx_add_romfs.cmake
@@ -284,8 +284,23 @@ function(process_all_directory_romfs)
 
   # Auto-generate /etc/passwd at build time if configured
   if(CONFIG_BOARD_ETC_ROMFS_PASSWD_ENABLE)
-    execute_process(COMMAND "${NUTTX_DIR}/tools/update_romfs_password.sh"
-                            "${NUTTX_DIR}/.config" RESULT_VARIABLE _cred_rc)
+    # Host tools are POSIX shell scripts (same as Make/configure.sh).  Invoke
+    # them via an explicit interpreter so CMake works on Linux, macOS, MSYS2,
+    # and Cygwin — not only when the script path is marked executable.
+    if(NOT NUTTX_POSIX_SHELL)
+      find_program(NUTTX_POSIX_SHELL NAMES sh bash)
+    endif()
+    if(NOT NUTTX_POSIX_SHELL)
+      message(
+        FATAL_ERROR
+          "ROMFS passwd generation requires a POSIX shell (sh or bash). "
+          "On Windows, configure and build from the MSYS2 or Cygwin 
environment."
+      )
+    endif()
+
+    execute_process(
+      COMMAND ${NUTTX_POSIX_SHELL} 
"${NUTTX_DIR}/tools/update_romfs_password.sh"
+              "${NUTTX_DIR}/.config" RESULT_VARIABLE _cred_rc)
     if(NOT _cred_rc EQUAL 0)
       message(FATAL_ERROR "update_romfs_password.sh failed (rc=${_cred_rc})")
     endif()
@@ -362,7 +377,8 @@ function(process_all_directory_romfs)
     # so the firmware uses the correct keys automatically.
 
     execute_process(
-      COMMAND "${NUTTX_DIR}/tools/check_passwd_keys.sh" "${NUTTX_DIR}/.config"
+      COMMAND ${NUTTX_POSIX_SHELL} "${NUTTX_DIR}/tools/check_passwd_keys.sh"
+              "${NUTTX_DIR}/.config"
       OUTPUT_VARIABLE _passwd_keys_need_setup
       OUTPUT_STRIP_TRAILING_WHITESPACE
       RESULT_VARIABLE _check_rc)
@@ -377,7 +393,8 @@ function(process_all_directory_romfs)
       if(CONFIG_BOARD_ETC_ROMFS_PASSWD_RANDOMIZE_KEYS)
         # Generate keys and write to .config (no key values printed here)
         execute_process(
-          COMMAND "${NUTTX_DIR}/tools/gen_passwd_keys.sh" 
"${NUTTX_DIR}/.config"
+          COMMAND ${NUTTX_POSIX_SHELL} "${NUTTX_DIR}/tools/gen_passwd_keys.sh"
+                  "${NUTTX_DIR}/.config"
           RESULT_VARIABLE _gen_rc
           OUTPUT_QUIET ERROR_QUIET)
         if(NOT _gen_rc EQUAL 0)

Reply via email to