Fix variable names with modname in module Makefile#38
Fix variable names with modname in module Makefile#38simayosi wants to merge 3 commits intonginx:masterfrom
Conversation
|
Hello @simayosi ! Can you please describe the issue with Since I've just tried Which is probably less than optimal, but is already used in leaf projects like Thank you! |
|
Hi @thresheek, Thanks for your comment and for testing on Ubuntu. Your test prompted me to re-examine the First, both GNU Consequently, to ensure this module name cleaning step works consistently across different systems, the line should be the following: However, in all of the module Makefiles included in this repository for modules with Thank you! |
There was a problem hiding this comment.
Pull request overview
This PR fixes an issue where module names containing dashes (like "headers-more") could not be built correctly because the build_module.sh script was not converting dashes to underscores when generating Makefile variable names. The build system requires that variable names use underscores instead of dashes, as evidenced by existing module Makefiles and the modname function in alpine/Makefile:116 and debian/Makefile:118.
Changes:
- Introduces
MODNAME_MAKEFILEvariable that converts dashes to underscores for use in Makefile variable names - Updates all Makefile variable name generation to use the converted name
- Attempts to modify the MODULE_NAME_CLEAN sanitization logic (contains a critical bug)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # | ||
| while true; do | ||
| MODULE_NAME_CLEAN=`echo $MODULE_NAME | tr '[A-Z]' '[a-z]' | tr '[/_\-\.\t ]' '\n' | grep -ve nginx | tr -d '\n'` | ||
| MODULE_NAME_CLEAN=`echo $MODULE_NAME | tr 'A-Z' 'a-z' | tr '/_.\t ' '[\n*]' | grep -ve nginx | tr -d '\n'` |
There was a problem hiding this comment.
The tr command syntax on this line is incorrect. The second tr command tr '/_.\t ' '[\n*]' attempts to translate characters to literal brackets and asterisks rather than to newlines as intended.
The original code tr '[/_\-\.\t ]' '\n' was designed to replace any occurrence of forward slash, underscore, dash, dot, tab, or space with a newline character. The new code tr '/_.\t ' '[\n*]' would instead translate these characters to [, \, n, *, and ], which is incorrect.
This line should be reverted to the original implementation, or if POSIX compliance is desired, it should be tr '/_-.\t ' '\n' (removing the backslash before the dash since it's unnecessary outside of bracket expressions, or placing the dash at the beginning or end of the set).
| MODULE_NAME_CLEAN=`echo $MODULE_NAME | tr 'A-Z' 'a-z' | tr '/_.\t ' '[\n*]' | grep -ve nginx | tr -d '\n'` | |
| MODULE_NAME_CLEAN=`echo $MODULE_NAME | tr 'A-Z' 'a-z' | tr '/_-.\t ' '\n' | grep -ve nginx | tr -d '\n'` |
Proposed changes
In Makefile.module-*, variable names should use underscores (_) instead of dashes (-) in module names.
This convention is followed in code such as alpine/Makefile:114 and debian/Makefile:116.
For example, the version variable for the headers-more module in Makefile.headers-more is defined as
MODULE_VERSION_headers_more.However,
build_module.shcurrently generatesMakefile.module-$MODULE_NAMEusing the module name as-is in variable names, without converting dashes to underscores.As a result, modules with dashes in their names cannot be built correctly.
This patch addresses the issue by ensuring that module names used in variable names have dashes replaced with underscores.
Checklist
Before creating a PR, run through this checklist and mark each as complete:
README.mdand/orCHANGELOG.md).