This is an automated email from the ASF dual-hosted git repository.
adoroszlai pushed a commit to branch HDDS-10685
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/HDDS-10685 by this push:
new 277737474cd HDDS-15559. Add libhadoop to DYLD_LIBRARY_PATH or
LD_LIBRARY_PATH (#10513)
277737474cd is described below
commit 277737474cdaa2ddb573a292303469a207d9ef11
Author: Sammi Chen <[email protected]>
AuthorDate: Fri Jul 17 15:36:49 2026 +0800
HDDS-15559. Add libhadoop to DYLD_LIBRARY_PATH or LD_LIBRARY_PATH (#10513)
---
hadoop-hdds/rocks-native/pom.xml | 6 +--
.../dist/src/shell/ozone/ozone-functions.sh | 42 ++++++++++++++++
pom.xml | 56 +++++++++++++++-------
3 files changed, 85 insertions(+), 19 deletions(-)
diff --git a/hadoop-hdds/rocks-native/pom.xml b/hadoop-hdds/rocks-native/pom.xml
index 9837aae92db..acd8dbefc85 100644
--- a/hadoop-hdds/rocks-native/pom.xml
+++ b/hadoop-hdds/rocks-native/pom.xml
@@ -152,7 +152,7 @@
<goals>
<goal>java</goal>
</goals>
- <phase>initialize</phase>
+ <phase>generate-resources</phase>
<configuration>
<mainClass>org.apache.hadoop.hdds.utils.db.managed.JniLibNamePropertyWriter</mainClass>
<arguments>
@@ -171,7 +171,7 @@
<goals>
<goal>read-project-properties</goal>
</goals>
- <phase>initialize</phase>
+ <phase>generate-resources</phase>
<configuration>
<files>
<file>${project.build.directory}/propertyFile.txt</file>
@@ -214,7 +214,7 @@
<goals>
<goal>wget</goal>
</goals>
- <phase>generate-sources</phase>
+ <phase>initialize</phase>
<configuration>
<url>https://github.com/facebook/rocksdb/archive/refs/tags/v${rocksdb.source.version}.tar.gz</url>
<outputFileName>rocksdb-v${rocksdb.source.version}.tar.gz</outputFileName>
diff --git a/hadoop-ozone/dist/src/shell/ozone/ozone-functions.sh
b/hadoop-ozone/dist/src/shell/ozone/ozone-functions.sh
index ce364d1cdec..2edab9725b2 100755
--- a/hadoop-ozone/dist/src/shell/ozone/ozone-functions.sh
+++ b/hadoop-ozone/dist/src/shell/ozone/ozone-functions.sh
@@ -1337,6 +1337,7 @@ function ozone_os_tricks
local bindv6only
OZONE_IS_CYGWIN=false
+ ARCH_TYPE=$(uname -m)
case ${OZONE_OS_TYPE} in
Darwin)
if [[ -z "${JAVA_HOME}" ]]; then
@@ -1348,6 +1349,25 @@ function ozone_os_tricks
export JAVA_HOME
fi
fi
+
+ if [ "$ARCH_TYPE" = "arm64" ]; then
+ TARGET_FILE="libhadoop_osx_aarch_64.dylib"
+ fi
+
+ pushd lib/native > /dev/null
+ # If no matching file variant was found for the current environment
+ if [ -z "$TARGET_FILE" ]; then
+ echo "Error: libhadoop doesn't support platform combination ($OS_TYPE
/ $ARCH_TYPE)." >&2
+ else
+ LINK_FILE="libhadoop.dylib"
+ # Check if it already exists but points to the wrong target
+ if [ -L "$LINK_FILE" ] && [ "$(readlink "$LINK_FILE")" !=
"$TARGET_FILE" ]; then
+ # Forcefully recreate it so it points to the correct target file
+ ln -sf "$TARGET_FILE" "$LINK_FILE" > /dev/null 2>&1
+ fi
+ export DYLD_LIBRARY_PATH=$OZONE_HOME/lib/native:$DYLD_LIBRARY_PATH
+ fi
+ popd > /dev/null
;;
Linux)
@@ -1375,6 +1395,28 @@ function ozone_os_tricks
ozone_error "ERROR: For more info:
http://wiki.apache.org/hadoop/HadoopIPv6"
exit 1
fi
+
+ if [ "$ARCH_TYPE" = "aarch64" ]; then
+ TARGET_FILE="libhadoop_linux_aarch_64.so"
+ elif [ "$ARCH_TYPE" = "x86_64" ]; then
+ TARGET_FILE="libhadoop_linux_x86_64.so"
+ fi
+
+ pushd . > /dev/null && cd lib/native
+ # If no matching file variant was found for the current environment
+ if [ -z "$TARGET_FILE" ]; then
+ echo "Error: libhadoop doesn't support platform combination ($OS_TYPE
/ $ARCH_TYPE)." >&2
+ else
+ LINK_FILE="libhadoop.so"
+
+ # Check if it already exists but points to the wrong target
+ if [ -L "$LINK_FILE" ] && [ "$(readlink "$LINK_FILE")" !=
"$TARGET_FILE" ]; then
+ # Forcefully recreate it so it points to the correct target file
+ ln -sf "$TARGET_FILE" "$LINK_FILE" > /dev/null 2>&1
+ fi
+ export LD_LIBRARY_PATH=$OZONE_HOME/lib/native:$LD_LIBRARY_PATH
+ fi
+ popd > /dev/null
;;
CYGWIN*)
# Flag that we're running on Cygwin to trigger path translation later.
diff --git a/pom.xml b/pom.xml
index fd87ad45424..524e506a144 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2624,7 +2624,7 @@
<inherited>false</inherited>
<executions>
<execution>
- <id>fetch-linux-library</id>
+ <id>fetch-linux-x86_64-library</id>
<goals>
<goal>wget</goal>
</goals>
@@ -2637,7 +2637,20 @@
</configuration>
</execution>
<execution>
- <id>fetch-mac-library</id>
+ <id>fetch-linux-aarch64-library</id>
+ <goals>
+ <goal>wget</goal>
+ </goals>
+ <phase>generate-resources</phase>
+ <configuration>
+
<url>https://raw.githubusercontent.com/apache/ozone-thirdparty/master/hadoop-native-lib/${hadoop.version}/libhadoop_linux_aarch_64.so</url>
+ <unpack>false</unpack>
+
<outputDirectory>${project.build.directory}/native-lib</outputDirectory>
+ <skipCache>false</skipCache>
+ </configuration>
+ </execution>
+ <execution>
+ <id>fetch-darwin-aarch64-library</id>
<goals>
<goal>wget</goal>
</goals>
@@ -2655,14 +2668,14 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>${maven-antrun-plugin.version}</version>
+ <inherited>false</inherited>
<executions>
<execution>
- <id>extract-linux-library</id>
+ <id>extract-linux-x86_64-library</id>
<goals>
<goal>run</goal>
</goals>
- <phase>prepare-package</phase>
- <inherited>false</inherited>
+ <phase>generate-resources</phase>
<configuration>
<target>
<exec dir="${project.build.directory}/native-lib"
executable="bash" failonerror="true">
@@ -2673,12 +2686,11 @@
</configuration>
</execution>
<execution>
- <id>extract-mac-library</id>
+ <id>extract-darwin-aarch64-library</id>
<goals>
<goal>run</goal>
</goals>
- <phase>prepare-package</phase>
- <inherited>false</inherited>
+ <phase>generate-resources</phase>
<configuration>
<target>
<exec dir="${project.build.directory}/native-lib"
executable="bash" failonerror="true">
@@ -2995,7 +3007,7 @@
<inherited>false</inherited>
<executions>
<execution>
- <id>fetch-linux-library</id>
+ <id>fetch-linux-x86_64-library</id>
<goals>
<goal>wget</goal>
</goals>
@@ -3008,7 +3020,20 @@
</configuration>
</execution>
<execution>
- <id>fetch-mac-library</id>
+ <id>fetch-linux-aarch64-library</id>
+ <goals>
+ <goal>wget</goal>
+ </goals>
+ <phase>generate-resources</phase>
+ <configuration>
+
<url>https://raw.githubusercontent.com/apache/ozone-thirdparty/master/hadoop-native-lib/${hadoop.version}/libhadoop_linux_aarch_64.so</url>
+ <unpack>false</unpack>
+
<outputDirectory>${project.build.directory}/native-lib</outputDirectory>
+ <skipCache>false</skipCache>
+ </configuration>
+ </execution>
+ <execution>
+ <id>fetch-darwin-aarch64-library</id>
<goals>
<goal>wget</goal>
</goals>
@@ -3026,14 +3051,14 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>${maven-antrun-plugin.version}</version>
+ <inherited>false</inherited>
<executions>
<execution>
- <id>extract-linux-library</id>
+ <id>extract-linux-x86_64-library</id>
<goals>
<goal>run</goal>
</goals>
- <phase>prepare-package</phase>
- <inherited>false</inherited>
+ <phase>generate-resources</phase>
<configuration>
<target>
<exec dir="${project.build.directory}/native-lib"
executable="bash" failonerror="true">
@@ -3044,12 +3069,11 @@
</configuration>
</execution>
<execution>
- <id>extract-mac-library</id>
+ <id>extract-darwin-aarch64-library</id>
<goals>
<goal>run</goal>
</goals>
- <phase>prepare-package</phase>
- <inherited>false</inherited>
+ <phase>generate-resources</phase>
<configuration>
<target>
<exec dir="${project.build.directory}/native-lib"
executable="bash" failonerror="true">
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]