|
| 1 | +os="$(uname -s)" |
| 2 | +os_lower=$(echo "$os" | tr '[:upper:]' '[:lower:]') |
| 3 | +os_capital=$(echo "$os" | tr '[:lower:]' '[:upper:]') |
| 4 | + |
1 | 5 | # Function to parse extension environment variables |
2 | 6 | parse_args() { |
3 | 7 | local extension=${1%-*} |
@@ -36,7 +40,7 @@ add_lib_log() { |
36 | 40 | # Function to check if a library is installed |
37 | 41 | check_lib() { |
38 | 42 | local lib=$1 |
39 | | - if [ "$(uname -s)" = "Linux" ]; then |
| 43 | + if [ "$os" = "Linux" ]; then |
40 | 44 | [ "x$(dpkg -s "$lib" 2>/dev/null | grep Status)" != "x" ] |
41 | 45 | else |
42 | 46 | [ "x$(find "${brew_prefix:?}"/Cellar -maxdepth 1 -name "$lib")" != "x" ] |
@@ -68,14 +72,27 @@ add_darwin_libs() { |
68 | 72 | add_libs() { |
69 | 73 | local all_libs=("$@") |
70 | 74 | for lib in "${all_libs[@]}"; do |
71 | | - if [ "$(uname -s)" = "Linux" ]; then |
| 75 | + if [ "$os" = "Linux" ]; then |
72 | 76 | add_linux_libs "$lib" |
73 | 77 | else |
74 | 78 | add_darwin_libs "$lib" |
75 | 79 | fi |
76 | 80 | done |
77 | 81 | } |
78 | 82 |
|
| 83 | +# Function to get required libraries for an extension |
| 84 | +get_libraries() { |
| 85 | + local extension=$1 |
| 86 | + { |
| 87 | + parse_args "$extension" LIBS |
| 88 | + parse_args "$extension" "$os_capital"_LIBS |
| 89 | + [ -r "${src:?}/configs/${os_lower}_libs" ] && \ |
| 90 | + grep -E "^[[:space:]]*${extension}[[:space:]]*=" "${src:?}/configs/${os_lower}_libs" | \ |
| 91 | + head -n1 | \ |
| 92 | + sed -E "s/^[[:space:]]*${extension}[[:space:]]*=[[:space:]]*//" |
| 93 | + } | xargs -n 1 2>/dev/null | sort -u | xargs 2>/dev/null |
| 94 | +} |
| 95 | + |
79 | 96 | # Function to run command in a group |
80 | 97 | run_group() { |
81 | 98 | local command=$1 |
@@ -137,7 +154,7 @@ add_extension_from_source() { |
137 | 154 | local fetch=${7:-clone} |
138 | 155 | slug="$extension-$release" |
139 | 156 | source="$url/$org/$repo" |
140 | | - libraries="$(parse_args "$extension" LIBS) $(parse_args "$extension" "$(uname -s)"_LIBS)" |
| 157 | + libraries="$(get_libraries "$extension")" |
141 | 158 | opts="$(parse_args "$extension" CONFIGURE_OPTS)" |
142 | 159 | prefix_opts="$(parse_args "$extension" CONFIGURE_PREFIX_OPTS)" |
143 | 160 | suffix_opts="$(parse_args "$extension" CONFIGURE_SUFFIX_OPTS)" |
|
0 commit comments