Skip to content

Commit 5bf9d66

Browse files
committed
Fetch from Alpine (musl) and Fedora (glibc)
Arch Linux glibc is too recent for production servers operated by LmdbJava users. Fedora 41 provides an alternative source for LMDB 0.9.33 with broader glibc compatibility. Alternatives evaluated for 0.9.33: * Rocky Linux 9: 0.9.29 * AlmaLinux 9: 0.9.29 * RHEL 9: 0.9.29 * Ubuntu 24.04: 0.9.31 * Ubuntu 22.04: 0.9.24 * Debian stable: 0.9.31 * Arch Linux: 0.9.33 (glibc too recent) * Fedora 41: 0.9.33 (selected) Reported at lmdbjava/lmdbjava#280
1 parent 3c7f0a8 commit 5bf9d66

File tree

4 files changed

+45
-13
lines changed

4 files changed

+45
-13
lines changed

.github/workflows/maven.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
uses: actions/checkout@v5
1717

1818
- name: Install dependencies
19-
run: sudo apt-get update && sudo apt-get install -y zstd
19+
run: sudo apt-get update && sudo apt-get install -y zstd rpm2cpio cpio
2020

2121
- name: Set up Java and Maven
2222
uses: actions/setup-java@v5
@@ -39,7 +39,7 @@ jobs:
3939
uses: actions/checkout@v5
4040

4141
- name: Install dependencies
42-
run: sudo apt-get update && sudo apt-get install -y zstd
42+
run: sudo apt-get update && sudo apt-get install -y zstd rpm2cpio cpio
4343

4444
- name: Set up Java and Maven
4545
uses: actions/setup-java@v5

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ secrets.tar
66
pom.xml.versionsBackup
77
pom.xml.releaseBackup
88
release.properties
9+
/src/

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
# LMDB Native Libraries
66

7-
Provides pre-compiled LMDB native libraries for Linux, macOS and Windows. These libraries are fetched from distribution package managers (Arch Linux, Homebrew, MSYS2) and packaged into a single JAR for easy dependency resolution.
7+
Provides pre-compiled LMDB native libraries for Linux, macOS and Windows. These libraries are fetched from distribution package managers (Alpine Linux, Fedora, Homebrew, MSYS2) and packaged into a single JAR for easy dependency resolution.
88

99
**If you are using LMDB from Java, use the [LmdbJava](https://github.com/lmdbjava/lmdbjava) project instead.** This artifact is a dependency of LmdbJava.
1010

fetch-native-libs.sh

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,56 @@ set -euo pipefail
77
LMDB_VERSION="0.9.33"
88
#######################################################################
99

10+
# Check required tools
11+
missing_tools=()
12+
command -v curl >/dev/null 2>&1 || missing_tools+=("curl")
13+
command -v tar >/dev/null 2>&1 || missing_tools+=("tar")
14+
command -v zstd >/dev/null 2>&1 || missing_tools+=("zstd")
15+
command -v rpm2cpio >/dev/null 2>&1 || missing_tools+=("rpm2cpio")
16+
command -v cpio >/dev/null 2>&1 || missing_tools+=("cpio")
17+
18+
if [ ${#missing_tools[@]} -ne 0 ]; then
19+
echo "Error: Missing required tools: ${missing_tools[*]}"
20+
echo ""
21+
echo "Install them with:"
22+
echo " Ubuntu/Debian: sudo apt-get install ${missing_tools[*]}"
23+
echo " Arch Linux: sudo pacman -S ${missing_tools[*]//rpm2cpio/rpm-tools}"
24+
echo " macOS: brew install ${missing_tools[*]}"
25+
exit 1
26+
fi
27+
1028
DEST="${DEST:-src/main/resources/org/lmdbjava/native}"
1129
TMP=$(mktemp -d)
1230
trap "rm -rf $TMP" EXIT
1331

1432
mkdir -p "$DEST"
1533

16-
# Arch Linux x86_64
34+
# Alpine Linux x86_64 (musl)
35+
if [ ! -f "$DEST/x86_64-linux-musl.so" ]; then
36+
curl -sL "https://dl-cdn.alpinelinux.org/alpine/v3.21/main/x86_64/lmdb-${LMDB_VERSION}-r0.apk" -o "$TMP/x64-musl.apk"
37+
tar xzf "$TMP/x64-musl.apk" -C "$TMP" usr/lib/liblmdb.so.0.0.0 --strip-components=2 2>/dev/null
38+
mv -f "$TMP/liblmdb.so.0.0.0" "$DEST/x86_64-linux-musl.so"
39+
fi
40+
41+
# Alpine Linux aarch64 (musl)
42+
if [ ! -f "$DEST/aarch64-linux-musl.so" ]; then
43+
curl -sL "https://dl-cdn.alpinelinux.org/alpine/v3.21/main/aarch64/lmdb-${LMDB_VERSION}-r0.apk" -o "$TMP/arm64-musl.apk"
44+
tar xzf "$TMP/arm64-musl.apk" -C "$TMP" usr/lib/liblmdb.so.0.0.0 --strip-components=2 2>/dev/null
45+
mv -f "$TMP/liblmdb.so.0.0.0" "$DEST/aarch64-linux-musl.so"
46+
fi
47+
48+
# Fedora x86_64 (glibc)
1749
if [ ! -f "$DEST/x86_64-linux-gnu.so" ]; then
18-
curl -sL "https://archive.archlinux.org/packages/l/lmdb/lmdb-${LMDB_VERSION}-1-x86_64.pkg.tar.zst" -o "$TMP/x64.tar.zst"
19-
zstd -d "$TMP/x64.tar.zst" -o "$TMP/x64.tar"
20-
tar xf "$TMP/x64.tar" -C "$TMP" usr/lib/liblmdb.so --strip-components=2
21-
mv -f "$TMP/liblmdb.so" "$DEST/x86_64-linux-gnu.so"
50+
curl -sL "https://dl.fedoraproject.org/pub/fedora/linux/releases/41/Everything/x86_64/os/Packages/l/lmdb-libs-${LMDB_VERSION}-2.fc41.x86_64.rpm" -o "$TMP/x64-glibc.rpm"
51+
(cd "$TMP" && rpm2cpio x64-glibc.rpm | cpio -idm) >/dev/null 2>&1
52+
mv -f "$TMP/usr/lib64/liblmdb.so.0.0.0" "$DEST/x86_64-linux-gnu.so"
2253
fi
2354

24-
# Arch Linux ARM aarch64
55+
# Fedora aarch64 (glibc)
2556
if [ ! -f "$DEST/aarch64-linux-gnu.so" ]; then
26-
curl -sL "http://mirror.archlinuxarm.org/aarch64/extra/lmdb-${LMDB_VERSION}-1-aarch64.pkg.tar.xz" -o "$TMP/arm64.tar.xz"
27-
tar xf "$TMP/arm64.tar.xz" -C "$TMP" usr/lib/liblmdb.so --strip-components=2
28-
mv -f "$TMP/liblmdb.so" "$DEST/aarch64-linux-gnu.so"
57+
curl -sL "https://dl.fedoraproject.org/pub/fedora/linux/releases/41/Everything/aarch64/os/Packages/l/lmdb-libs-${LMDB_VERSION}-2.fc41.aarch64.rpm" -o "$TMP/arm64-glibc.rpm"
58+
(cd "$TMP" && rpm2cpio arm64-glibc.rpm | cpio -idm) >/dev/null 2>&1
59+
mv -f "$TMP/usr/lib64/liblmdb.so.0.0.0" "$DEST/aarch64-linux-gnu.so"
2960
fi
3061

3162
# Homebrew macOS x86_64
@@ -45,7 +76,7 @@ fi
4576
# MSYS2 Windows x86_64
4677
if [ ! -f "$DEST/x86_64-windows-gnu.dll" ]; then
4778
curl -sL "https://repo.msys2.org/mingw/mingw64/mingw-w64-x86_64-lmdb-${LMDB_VERSION}-1-any.pkg.tar.zst" -o "$TMP/win.tar.zst"
48-
zstd -d "$TMP/win.tar.zst" -o "$TMP/win.tar"
79+
zstd -d "$TMP/win.tar.zst" -o "$TMP/win.tar" -q
4980
tar xf "$TMP/win.tar" -C "$TMP" mingw64/bin/liblmdb.dll --strip-components=2
5081
mv -f "$TMP/liblmdb.dll" "$DEST/x86_64-windows-gnu.dll"
5182
fi

0 commit comments

Comments
 (0)