Branch 'uidmap' - pkg/cloudfs.spec.in pkg/configure.ac xlators/cluster xlators/encryption xlators/features
Jeff Darcy
jdarcy at fedoraproject.org
Tue Jun 7 19:56:52 UTC 2011
pkg/cloudfs.spec.in | 20 ++++--
pkg/configure.ac | 12 +++-
xlators/cluster/cloud/src/Makefile.am | 4 -
xlators/cluster/login/src/Makefile.am | 4 -
xlators/encryption/crypt/src/Makefile.am | 4 -
xlators/features/oplock/src/Makefile.am | 4 -
xlators/features/uidmap/src/Makefile.am | 7 +-
xlators/features/uidmap/src/uidmap.c | 93 +++++++++++++++++++------------
8 files changed, 95 insertions(+), 53 deletions(-)
New commits:
commit 9357521bdf651abd4ccf91776adf4bb4c27d8943
Author: Jeff Darcy <jdarcy at redhat.com>
Date: Tue Jun 7 15:51:07 2011 -0400
Enable building against either Gluster/Fedora RPM.
Mostly this is in the specfile, configure.ac, and makefiles. Also added
code in uidmap.c to look for plugins in the package-specific directory if
the given option is just a name rather than a path. Switching between
Fedora and Gluster packages should just be a matter of changing the
GLUSTER_LIBS line in configure.ac and some Build/BuildRequires lines in
cloudfs.spec.in; to build against a different *version* (independent of
packaging) change GLUSTER_VERSION in configure.ac instead.
diff --git a/pkg/cloudfs.spec.in b/pkg/cloudfs.spec.in
index 809a623..ee49c52 100644
--- a/pkg/cloudfs.spec.in
+++ b/pkg/cloudfs.spec.in
@@ -16,10 +16,16 @@ URL: http://cloudfs.org
Source0: http://cloudfs.org/dist/0.6/cloudfs-0.6.tgz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
+# Gluster way
+#Requires: glusterfs-core = @GLUSTER_VERSION@
+#Requires: glusterfs-fuse = @GLUSTER_VERSION@
+
+# Fedora way
Requires: glusterfs = @GLUSTER_VERSION@
+BuildRequires: glusterfs-devel = @GLUSTER_VERSION@
+
Requires: openssl
Requires: python
-BuildRequires: glusterfs-devel = @GLUSTER_VERSION@
BuildRequires: bison flex
BuildRequires: gcc make
BuildRequires: openssl-devel
@@ -43,9 +49,9 @@ with additional authentication/encryption/multi-tenancy features.
%{__make} install DESTDIR=%{buildroot}
# Remove unwanted files from all the shared libraries
-find %{buildroot}%{_libdir} -name '*.a' -delete
-find %{buildroot}%{_libdir} -name '*.la' -delete
-find %{buildroot}%{_libdir} -name '*.so.0.0.0' | xargs strip
+find %{buildroot}@GLUSTER_XLATORS@ -name '*.a' -delete
+find %{buildroot}@GLUSTER_XLATORS@ -name '*.la' -delete
+#find %{buildroot}@GLUSTER_XLATORS@ -name '*.so.0.0.0' | xargs strip
%clean
%{__rm} -rf %{buildroot}
@@ -53,9 +59,9 @@ find %{buildroot}%{_libdir} -name '*.so.0.0.0' | xargs strip
%files
%defattr(-,root,root)
%doc COPYING
-%{_libdir}/glusterfs/@GLUSTER_VERSION@/xlator/cluster/*.so*
-%{_libdir}/glusterfs/@GLUSTER_VERSION@/xlator/encryption/*.so*
-%{_libdir}/glusterfs/@GLUSTER_VERSION@/xlator/features/*.so*
+ at GLUSTER_XLATORS@/cluster/*.so*
+ at GLUSTER_XLATORS@/encryption/*.so*
+ at GLUSTER_XLATORS@/features/*.so*
%{python_sitelib}/volfilter.py*
%{_bindir}/cloudfs
diff --git a/pkg/configure.ac b/pkg/configure.ac
index c185be5..d8641ca 100644
--- a/pkg/configure.ac
+++ b/pkg/configure.ac
@@ -65,7 +65,7 @@ if test "x${have_spinlock}" = "xyes"; then
AC_DEFINE(HAVE_SPINLOCK, 1, [define if found spinlock])
fi
-GLUSTER_VERSION=3.1.3git
+GLUSTER_VERSION="3.1.3"
GF_HOST_OS=""
GF_LDFLAGS="-rdynamic"
GF_HOST_OS="GF_LINUX_HOST_OS"
@@ -74,6 +74,14 @@ GF_GLUSTERFS_CFLAGS="${GF_CFLAGS}"
GF_LDADD=""
INCLUDES=""
+# Gluster packaging puts stuff in versioned dirs under /opt
+#GLUSTER_LIBS="/opt/glusterfs/${GLUSTER_VERSION}/lib64"
+# Sane packaging puts stuff here
+GLUSTER_LIBS="/usr/lib64"
+
+# Translators specify the version again. Ick.
+GLUSTER_XLATORS="${GLUSTER_LIBS}/glusterfs/${GLUSTER_VERSION}/xlator"
+
AC_SUBST(GF_DISTRIBUTION)
AC_SUBST(GLUSTER_VERSION)
AC_SUBST(GF_HOST_OS)
@@ -83,5 +91,7 @@ AC_SUBST(GF_LDFLAGS)
AC_SUBST(GF_LDADD)
AC_SUBST(INCLUDES)
AC_SUBST(HAVE_SPINLOCK)
+AC_SUBST(GLUSTER_LIBS)
+AC_SUBST(GLUSTER_XLATORS)
AC_OUTPUT
diff --git a/xlators/cluster/cloud/src/Makefile.am b/xlators/cluster/cloud/src/Makefile.am
index 2477932..87cd919 100644
--- a/xlators/cluster/cloud/src/Makefile.am
+++ b/xlators/cluster/cloud/src/Makefile.am
@@ -1,8 +1,8 @@
xlator_LTLIBRARIES = cloud.la
-xlatordir = $(libdir)/glusterfs/$(GLUSTER_VERSION)/xlator/cluster
+xlatordir = @GLUSTER_XLATORS@/cluster
-cloud_la_LDFLAGS = -module -avoidversion -lglusterfs
+cloud_la_LDFLAGS = -module -avoidversion -L at GLUSTER_LIBS@ -lglusterfs
cloud_la_SOURCES = cloud.c
#cloud_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la
diff --git a/xlators/cluster/login/src/Makefile.am b/xlators/cluster/login/src/Makefile.am
index b3a5fdf..43bde3d 100644
--- a/xlators/cluster/login/src/Makefile.am
+++ b/xlators/cluster/login/src/Makefile.am
@@ -1,7 +1,7 @@
xlator_LTLIBRARIES = login.la
-xlatordir = $(libdir)/glusterfs/$(GLUSTER_VERSION)/xlator/cluster
+xlatordir = @GLUSTER_XLATORS@/cluster
-login_la_LDFLAGS = -module -avoidversion -lglusterfs
+login_la_LDFLAGS = -module -avoidversion -L at GLUSTER_LIBS@ -lglusterfs
login_la_SOURCES = login.c
#login_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la
diff --git a/xlators/encryption/crypt/src/Makefile.am b/xlators/encryption/crypt/src/Makefile.am
index a558228..19d8e0b 100644
--- a/xlators/encryption/crypt/src/Makefile.am
+++ b/xlators/encryption/crypt/src/Makefile.am
@@ -1,7 +1,7 @@
xlator_LTLIBRARIES = crypt.la
-xlatordir = $(libdir)/glusterfs/$(GLUSTER_VERSION)/xlator/encryption
+xlatordir = @GLUSTER_XLATORS@/encryption
-crypt_la_LDFLAGS = -module -avoidversion -lssl -lglusterfs
+crypt_la_LDFLAGS = -module -avoidversion -lssl -L at GLUSTER_LIBS@ -lglusterfs
crypt_la_SOURCES = crypt.c
#crypt_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la
diff --git a/xlators/features/oplock/src/Makefile.am b/xlators/features/oplock/src/Makefile.am
index 5122e91..74dbdef 100644
--- a/xlators/features/oplock/src/Makefile.am
+++ b/xlators/features/oplock/src/Makefile.am
@@ -1,7 +1,7 @@
xlator_LTLIBRARIES = oplock.la
-xlatordir = $(libdir)/glusterfs/$(GLUSTER_VERSION)/xlator/features
+xlatordir = @GLUSTER_XLATORS@/features
-oplock_la_LDFLAGS = -module -avoidversion -lglusterfs
+oplock_la_LDFLAGS = -module -avoidversion -L at GLUSTER_LIBS@ -lglusterfs
oplock_la_SOURCES = oplock.c
#oplock_la_LIBADD = $(top_builddir)/libglusterfs/src/libglusterfs.la
diff --git a/xlators/features/uidmap/src/Makefile.am b/xlators/features/uidmap/src/Makefile.am
index fd58a37..56d5225 100644
--- a/xlators/features/uidmap/src/Makefile.am
+++ b/xlators/features/uidmap/src/Makefile.am
@@ -1,12 +1,12 @@
xlator_LTLIBRARIES = uidmap.la libmaprbtree.la
-xlatordir = $(libdir)/glusterfs/$(GLUSTER_VERSION)/xlator/features
+xlatordir = @GLUSTER_XLATORS@/features
-uidmap_la_LDFLAGS = -module -avoidversion -lglusterfs
+uidmap_la_LDFLAGS = -module -avoidversion -L at GLUSTER_LIBS@ -lglusterfs
uidmap_la_SOURCES = uidmap.c
-libmaprbtree_la_LDFLAGS = -module -avoidversion -lglusterfs
+libmaprbtree_la_LDFLAGS = -module -avoidversion -L at GLUSTER_LIBS@ -lglusterfs
libmaprbtree_la_SOURCES = rbmap.c
@@ -16,6 +16,7 @@ GLUSTERDIR=$(includedir)/glusterfs
AM_CFLAGS = -fPIC -D_FILE_OFFSET_BITS=64 -D_GNU_SOURCE -Wall -D$(GF_HOST_OS) \
-I$(GLUSTERDIR) -I$(GLUSTERDIR)/rpc -I$(GLUSTERDIR)/server \
+ -DUIDMAP_PLUGIN_DIR=\"$(xlatordir)\" \
-shared -nostartfiles $(GF_CFLAGS)
CLEANFILES =
diff --git a/xlators/features/uidmap/src/uidmap.c b/xlators/features/uidmap/src/uidmap.c
index 9241203..d675d54 100644
--- a/xlators/features/uidmap/src/uidmap.c
+++ b/xlators/features/uidmap/src/uidmap.c
@@ -1835,41 +1835,66 @@ uidmap_lk(call_frame_t *frame, xlator_t *this, fd_t *fd,
static init_fn
uidmap_loadsharedlib(char* xltrname, char *libname)
{
- init_fn plugin_init = NULL;
- void *handle = NULL;
-
- gf_log(xltrname, CFS_LOG_LEVEL, "loading: %s", libname);
- if ((handle = dlopen(libname, RTLD_NOW|RTLD_NODELETE)) != NULL) {
- do {
- if ((uidmap_map = (map_fn) dlsym(handle, "map")) == NULL) {
- gf_log(xltrname, GF_LOG_CRITICAL,
- "plugin missing map: %s", dlerror());
- break;
- }
-
- if ((uidmap_revmap = (revmap_fn) dlsym(handle, "revmap")) == NULL) {
- gf_log(xltrname, GF_LOG_CRITICAL,
- "plugin missing revmap: %s", dlerror());
- break;
- }
-
- if ((uidmap_plugin_fini = (fini_fn) dlsym(handle, "fini")) == NULL) {
- gf_log(xltrname, GF_LOG_CRITICAL,
- "plugin missing fini: %s", dlerror());
- break;
- }
+ init_fn plugin_init = NULL;
+ void *handle = NULL;
+ char *plugin_path = NULL;
+ int ret = -1;
+
+ if (strchr(libname,'/')) {
+ plugin_path = libname;
+ }
+ else {
+ ret = gf_asprintf(plugin_path,"%s/%s",UIDMAP_PLUGIN_DIR,
+ libname);
+ if (ret < 0) {
+ gf_log(xltrname,GF_LOG_ERROR,
+ "could not construct plugin path for %s",
+ libname);
+ return NULL;
+ }
+ }
+ gf_log(xltrname, CFS_LOG_LEVEL, "loading %s (%s)", plugin_path,
+ (plugin_path == libname) ? "given" : "constructed");
+
+ handle = dlopen(plugin_path, RTLD_NOW|RTLD_NODELETE);
+ if (!handle) {
+ gf_log(xltrname, GF_LOG_ERROR, "dlopen failed (%s)", dlerror());
+ return NULL;
+ }
+
+ if ((uidmap_map = (map_fn) dlsym(handle, "map")) == NULL) {
+ gf_log(xltrname, GF_LOG_CRITICAL,
+ "plugin missing map: %s", dlerror());
+ goto close_it;
+ }
+
+ if ((uidmap_revmap = (revmap_fn) dlsym(handle, "revmap")) == NULL) {
+ gf_log(xltrname, GF_LOG_CRITICAL,
+ "plugin missing revmap: %s", dlerror());
+ goto close_it;
+ }
+
+ if ((uidmap_plugin_fini = (fini_fn) dlsym(handle, "fini")) == NULL) {
+ gf_log(xltrname, GF_LOG_CRITICAL,
+ "plugin missing fini: %s", dlerror());
+ goto close_it;
+ }
+
+ if ((plugin_init = (init_fn) dlsym(handle, "init")) == NULL) {
+ gf_log(xltrname, GF_LOG_CRITICAL,
+ "plugin missing init: %s", dlerror());
+ }
+
+close_it:
+ if (dlclose(handle)) {
+ gf_log(xltrname, CFS_LOG_LEVEL,
+ "dlclose plugin: %s", dlerror());
+ }
+
+ if (plugin_path != libname) {
+ GF_FREE(plugin_path);
+ }
- if ((plugin_init = (init_fn) dlsym(handle, "init")) == NULL) {
- gf_log(xltrname, GF_LOG_CRITICAL,
- "plugin missing init: %s", dlerror());
- }
- } while (0);
-
- if (dlclose(handle)) {
- gf_log(xltrname, CFS_LOG_LEVEL,
- "dlclose plugin: %s", dlerror());
- }
- }
return plugin_init;
}
More information about the cloudfs-devel
mailing list