domains / / ollama/ollama
Use portable path configurations
Build and configuration scripts should use portable path handling techniques to ensure they work correctly across different environments and installations.
Build and configuration scripts should use portable path handling techniques to ensure they work correctly across different environments and installations.
Key practices:
- Use wildcards when copying library files to include all version suffixes:
# Correct - captures all version suffixes cp ${VULKAN_ROOT}/libvulkan.so* "${BUILD_DIR}/bin/" # Incorrect - only copies the base library file cp "${VULKAN_ROOT}/libvulkan.so" "${BUILD_DIR}/bin/" - Avoid hardcoded absolute paths in configuration variables. When default paths are needed, make them overridable:
# Better approach - allows overriding with environment variables if [ -z "${VULKAN_ROOT}" ]; then # Default only used if not explicitly set VULKAN_ROOT=/usr/lib/ fi - Use relative paths with
$ORIGINfor runtime library paths instead of absolute paths that assume specific installation locations:# Better - uses relative paths from binary location EXTRA_LIBS="-Wl,-rpath,'$ORIGIN'" # Avoid - assumes specific installation location EXTRA_LIBS="-Wl,-rpath,/opt/intel/oneapi/compiler/latest/lib" - Be careful with string formatting in configuration variables to prevent command execution errors:
# Correct - no space after equals DNF_COMPATIBILITY_FMT="addrepo --from-repofile=" # Incorrect - space will cause command parsing issues DNF_COMPATIBILITY_FMT="addrepo --from-repofile= "
Following these practices ensures build scripts and configurations work reliably across different environments, making software more portable and easier to install for end users.