Support multi-dash project names via ZOPEN_PROJECT_NAME and intelligent fallback#1122
Merged
IgorTodorovskiIBM merged 9 commits intomainfrom Nov 18, 2025
Merged
Support multi-dash project names via ZOPEN_PROJECT_NAME and intelligent fallback#1122IgorTodorovskiIBM merged 9 commits intomainfrom
IgorTodorovskiIBM merged 9 commits intomainfrom
Conversation
Improved the Go template to match production ports (crushport, lazygitport, gitlab-runnerport) with the following changes: - Add ZOPEN_COMP=GO setting - Add ZOPEN_CONFIGURE_MINIMAL=1 and ZOPEN_MAKE_MINIMAL=1 flags - Set ZOPEN_CHECK="skip" by default for Go projects - Add ZOPEN_CLEAN="zopen_clean" with cleanup function - Improve zopen_init() to unset CC/CXX and create bin directory - Enhance zopen_wharf() with realistic dependency management example - Simplify build functions: zopen_build() and zopen_install() - Add zopen_clean() to remove Go workspace artifacts These changes align the template with established patterns used in working Go ports and provide better guidance for new port developers.
- Add ZOPEN_PROJECT_NAME export to zopen-generate buildenv template - Update zopen-build generateMetadataJSON() to use ZOPEN_PROJECT_NAME - Update zopen-build createEnvAndSetup() to use ZOPEN_PROJECT_NAME - Update zopen-build set_install_caveats() to use ZOPEN_PROJECT_NAME - Maintain backward compatibility with fallback parsing for old ports - Fixes install directory naming for multi-dash projects like gitlab-runner
- When ZOPEN_PROJECT_NAME not set, extract version first using smart sed pattern - Derive name by removing version suffix (e.g., xcb-proto-1.17.0 -> xcb-proto) - Apply to all three functions: generateMetadataJSON, createEnvAndSetup, set_install_caveats - Fixes install directory for projects like xcb-proto without requiring ZOPEN_PROJECT_NAME - Still recommend setting ZOPEN_PROJECT_NAME for clarity
This reverts commit 4714413.
Strategy: 1. Extract version first (rightmost segment starting with digit) 2. If version found, derive name by removing -version suffix 3. If no version found, fall back to old cut method Benefits: - Handles multi-dash names: xcb-proto-1.17.0 -> xcb-proto ✅ - Handles simple names: curl-8.5.0 -> curl ✅ - Handles complex names: gitlab-runner-17.6.0 -> gitlab-runner ✅ - ZOPEN_PROJECT_NAME still recommended but not required Applied to: - generateMetadataJSON() - createEnvAndSetup() - set_install_caveats()
…dash projects Problem 1: ZOPEN_INSTALL_DIR was using cut -d'-' -f1 - xcb-proto-1.17.0 was installing to /xcb/ instead of /xcb-proto/ - Applied intelligent fallback to line 2298 Problem 2: Environment variable names had dashes (XCB-PROTO_HOME) - Shell variables cannot contain dashes - Now converts dashes to underscores: xcb-proto -> XCB_PROTO_HOME - Applied sed 's/-/_/g' before uppercase conversion Fixes: - Install dir: /home/.../zopen/xcb-proto/xcb-proto-1.17.0/ ✅ - Env variable: XCB_PROTO_HOME=... ✅
Fix: libX11-1.8.12 was creating /libX11/ instead of /libx11/ - Added awk tolower() after extracting PROJECT_NAME in fallback - Only applies to fallback (when ZOPEN_PROJECT_NAME not set) - Preserves ZOPEN_NAME case for versioned directory Result: - Parent dir: /libx11/ (lowercase) ✅ - Child dir: /libX11-1.8.12/ (preserves original case) ✅
Before: Same version extraction and name derivation logic duplicated in 4 places - generateMetadataJSON() - createEnvAndSetup() - set_install_caveats() - ZOPEN_INSTALL_DIR setting After: Single helper function getProjectName() - Centralizes logic for extracting project name from package - Uses ZOPEN_PROJECT_NAME if set - Intelligent fallback with version extraction - Falls back to old cut method if needed Benefits: - ~60 lines of duplicated code → ~20 lines in one function - Easier to maintain and update - Consistent behavior across all usages - More readable code
- Skip dependency installation when using -g (--get-source) flag - Use alias chtag=true for non-OS/390 platforms to avoid xargs errors - Fix color escape sequences: use \033 (ASCII) for Mac/Linux vs \047 (EBCDIC) for OS/390 - Update printColors() to use printf on non-OS/390 for proper escape interpretation - Add platform-specific CPU detection: - OS/390: numcpus.rexx - macOS: sysctl -n hw.ncpu - Linux: nproc or /proc/cpuinfo - Others: default to 1 - Change /bin/printf to printf for portability 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds support for projects with dashes in their names (e.g.,
xcb-proto,gitlab-runner,libX11) by introducing theZOPEN_PROJECT_NAMEvariable and implementing intelligent fallback parsing. This ensures thatzopen buildcreates the same directory structure aszopen installfor consistency.NEW: Adds cross-platform support for running
zopen buildon macOS and Linux - useful for static scanning or analysis of patches on other platforms.Problem
Previously, project names with dashes were incorrectly parsed during
zopen build:xcb-proto-1.17.0→ installed to/xcb/xcb-proto-1.17.0/instead of/xcb-proto/xcb-proto-1.17.0/❌gitlab-runner-17.6.0→ installed to/gitlab/gitlab-runner-17.6.0/instead of/gitlab-runner/gitlab-runner-17.6.0/❌XCB-PROTO_HOME(invalid shell variable name) ❌This created a mismatch with
zopen install, which correctly uses the full project name for the parent directory.Solution
1. Introduced ZOPEN_PROJECT_NAME variable
ZOPEN_PROJECT_NAME="<project-name>"in buildenv2. Intelligent fallback parsing
When
ZOPEN_PROJECT_NAMEis not set (backward compatibility):-versionsuffix3. Updated locations
generateMetadataJSON()- metadata.json creationcreateEnvAndSetup()- .env file and environment variablesset_install_caveats()- installation messagesZOPEN_INSTALL_DIRsetting (line 2298) - critical for correct install pathCross-Platform Support (NEW)
Skip dependency installation with
-gflagsetDepsEnv()when using--get-sourcemodePlatform-specific chtag handling
chtagcommandalias chtag=truestub to avoid errorsFixed color escape sequences
\047)\033)printColors()to useprintfon non-OS/390 for proper interpretationPlatform-specific CPU detection
numcpus.rexxsysctl -n hw.ncpunprocor/proc/cpuinfoPortability improvements
/bin/printftoprintffor broader compatibilityResults
✅ Aligns
zopen builddirectory structure withzopen install✅ Install directories:
/xcb-proto/xcb-proto-1.17.0/,/gitlab-runner/gitlab-runner-17.6.0/✅ Environment variables:
XCB_PROTO_HOME,GITLAB_RUNNER_HOME(valid shell names)✅ Backward compatible with existing single-dash ports
✅ NEW: Works on macOS and Linux for source download and patching with
-gflagTest Cases
xcb-proto-1.17.0/xcb-proto/xcb-proto-1.17.0/XCB_PROTO_HOMEgitlab-runner-17.6.0/gitlab-runner/gitlab-runner-17.6.0/GITLAB_RUNNER_HOMElibX11-1.8.12/libx11/libX11-1.8.12/LIBX11_HOMEcurl-8.5.0/curl/curl-8.5.0/CURL_HOMEMigration Path
New ports: zopen-generate automatically adds
ZOPEN_PROJECT_NAMEExisting ports: Will use intelligent fallback automatically, or can add
ZOPEN_PROJECT_NAMEmanually for clarity