[PATCH v2 2/4] erofs-utils: introduce build support for libcurl, openssl and libxml2 library
Yifan Zhao
zhaoyifan28 at huawei.com
Fri Aug 1 17:30:44 AEST 2025
From: zhaoyifan <zhaoyifan28 at huawei.com>
This patch adds additional dependencies on libcurl, openssl and libxml2 library
for the upcoming S3 data source support, with libcurl to interact with S3 API,
openssl to generate S3 auth signature and libxml2 to parse response body.
The newly introduced dependencies are optional, controlled by the `--enable-s3`
configure option.
Signed-off-by: Yifan Zhao <zhaoyifan28 at huawei.com>
---
change since v1:
- rebase on the latest `experimental` branch
- rename: lib/s3.c => lib/remotes/s3.c
- configure.ac: introduce `subdir-objects` option as s3.c in a subdir
- move include/erofs/s3.h in the following patch
configure.ac | 43 ++++++++++++++++++++++++++++++++++++++++++-
lib/Makefile.am | 4 ++++
lib/remotes/s3.c | 6 ++++++
mkfs/Makefile.am | 3 ++-
4 files changed, 54 insertions(+), 2 deletions(-)
create mode 100644 lib/remotes/s3.c
diff --git a/configure.ac b/configure.ac
index 2d42b1f..82ff98e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -24,7 +24,7 @@ esac
# OS-specific treatment
AM_CONDITIONAL([OS_LINUX], [test "$build_linux" = "yes"])
-AM_INIT_AUTOMAKE([foreign -Wall])
+AM_INIT_AUTOMAKE([foreign subdir-objects -Wall])
# Checks for programs.
AM_PROG_AR
@@ -165,6 +165,10 @@ AC_ARG_WITH(xxhash,
[AS_HELP_STRING([--with-xxhash],
[Enable and build with libxxhash support @<:@default=auto@:>@])])
+AC_ARG_ENABLE(s3,
+ [AS_HELP_STRING([--enable-s3], [enable s3 image generation support @<:@default=no@:>@])],
+ [enable_s3="$enableval"], [enable_s3="no"])
+
AC_ARG_ENABLE(fuse,
[AS_HELP_STRING([--enable-fuse], [enable erofsfuse @<:@default=no@:>@])],
[enable_fuse="$enableval"], [enable_fuse="no"])
@@ -578,6 +582,32 @@ AS_IF([test "x$with_xxhash" != "xno"], [
])
])
+AS_IF([test "x$enable_s3" != "xno"], [
+ # Paranoia: don't trust the result reported by pkgconfig before trying out
+ saved_LIBS="$LIBS"
+ saved_CPPFLAGS=${CPPFLAGS}
+ PKG_CHECK_MODULES([libcurl], [libcurl])
+ PKG_CHECK_MODULES([openssl], [openssl])
+ PKG_CHECK_MODULES([libxml2], [libxml-2.0])
+ CPPFLAGS="${libcurl_CFLAGS} ${openssl_CFLAGS} ${libxml2_CFLAGS} ${CPPFLAGS}"
+ LIBS="${libcurl_LIBS} ${openssl_LIBS} ${libxml2_LIBS} $LIBS"
+ s3_deps_ok="yes"
+ AC_CHECK_LIB(curl, curl_multi_perform, [], [
+ AC_MSG_ERROR([libcurl doesn't work properly])
+ s3_deps_ok="no"
+ ])
+ AC_CHECK_LIB(ssl, EVP_sha1, [], [
+ AC_MSG_ERROR([openssl doesn't work properly])
+ s3_deps_ok="no"
+ ])
+ AC_CHECK_LIB(xml2, xmlReadMemory, [], [
+ AC_MSG_ERROR([libxml-2.0 doesn't work properly])
+ s3_deps_ok="no"
+ ])
+ AS_IF([test "x$s3_deps_ok" = "xyes"], [have_s3="yes"], [have_s3="no"])
+ LIBS="${saved_LIBS}"
+ CPPFLAGS="${saved_CPPFLAGS}"], [have_s3="no"])
+
# Enable 64-bit off_t
CFLAGS+=" -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
@@ -601,6 +631,7 @@ AM_CONDITIONAL([ENABLE_LIBDEFLATE], [test "x${have_libdeflate}" = "xyes"])
AM_CONDITIONAL([ENABLE_LIBZSTD], [test "x${have_libzstd}" = "xyes"])
AM_CONDITIONAL([ENABLE_QPL], [test "x${have_qpl}" = "xyes"])
AM_CONDITIONAL([ENABLE_XXHASH], [test "x${have_xxhash}" = "xyes"])
+AM_CONDITIONAL([ENABLE_S3], [test "x${have_s3}" = "xyes"])
AM_CONDITIONAL([ENABLE_STATIC_FUSE], [test "x${enable_static_fuse}" = "xyes"])
if test "x$have_uuid" = "xyes"; then
@@ -652,6 +683,16 @@ if test "x$have_xxhash" = "xyes"; then
AC_DEFINE([HAVE_XXHASH], 1, [Define to 1 if xxhash is found])
fi
+if test "x$have_s3" = "xyes"; then
+ AC_DEFINE([HAVE_S3], 1, [Define to 1 if s3 is enabled])
+ AC_SUBST([libcurl_LIBS])
+ AC_SUBST([libcurl_CFLAGS])
+ AC_SUBST([openssl_LIBS])
+ AC_SUBST([openssl_CFLAGS])
+ AC_SUBST([libxml2_LIBS])
+ AC_SUBST([libxml2_CFLAGS])
+fi
+
# Dump maximum block size
AS_IF([test "x$erofs_cv_max_block_size" = "x"],
[$erofs_cv_max_block_size = 4096], [])
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 0db81df..2d04149 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -66,6 +66,10 @@ liberofs_la_CFLAGS += ${libxxhash_CFLAGS}
else
liberofs_la_SOURCES += xxhash.c
endif
+if ENABLE_S3
+liberofs_la_CFLAGS += ${libcurl_CFLAGS} ${openssl_CFLAGS} ${libxml2_CFLAGS}
+liberofs_la_SOURCES += remotes/s3.c
+endif
if ENABLE_EROFS_MT
liberofs_la_LDFLAGS = -lpthread
liberofs_la_SOURCES += workqueue.c
diff --git a/lib/remotes/s3.c b/lib/remotes/s3.c
new file mode 100644
index 0000000..ed2b023
--- /dev/null
+++ b/lib/remotes/s3.c
@@ -0,0 +1,6 @@
+/* SPDX-License-Identifier: GPL-2.0+ OR Apache-2.0 */
+/*
+ * Copyright (C) 2025 HUAWEI, Inc.
+ * http://www.huawei.com/
+ * Created by Yifan Zhao <zhaoyifan28 at huawei.com>
+ */
\ No newline at end of file
diff --git a/mkfs/Makefile.am b/mkfs/Makefile.am
index 2499242..b84b4c1 100644
--- a/mkfs/Makefile.am
+++ b/mkfs/Makefile.am
@@ -7,4 +7,5 @@ mkfs_erofs_SOURCES = main.c
mkfs_erofs_CFLAGS = -Wall -I$(top_srcdir)/include
mkfs_erofs_LDADD = $(top_builddir)/lib/liberofs.la ${libselinux_LIBS} \
${libuuid_LIBS} ${liblz4_LIBS} ${liblzma_LIBS} ${zlib_LIBS} \
- ${libdeflate_LIBS} ${libzstd_LIBS} ${libqpl_LIBS} ${libxxhash_LIBS}
+ ${libdeflate_LIBS} ${libzstd_LIBS} ${libqpl_LIBS} ${libxxhash_LIBS} \
+ ${libcurl_LIBS} ${openssl_LIBS} ${libxml2_LIBS}
--
2.46.0
More information about the Linux-erofs
mailing list