diff options
author | marino <marino@FreeBSD.org> | 2014-11-28 16:11:11 +0800 |
---|---|---|
committer | marino <marino@FreeBSD.org> | 2014-11-28 16:11:11 +0800 |
commit | 78edfdcd01722a0b48e2ff9344380e64739442ac (patch) | |
tree | 143687866870d6a63c95a1b96d8201d93f710877 /net-mgmt | |
parent | 730177615650301da449cbc602a1e9bbea5fbf8c (diff) | |
download | freebsd-ports-gnome-78edfdcd01722a0b48e2ff9344380e64739442ac.tar.gz freebsd-ports-gnome-78edfdcd01722a0b48e2ff9344380e64739442ac.tar.zst freebsd-ports-gnome-78edfdcd01722a0b48e2ff9344380e64739442ac.zip |
net-mgmt/seafile: Remove use of /proc and make FUSE optional
DragonFly has not implemented FUSE, so it's not reqired by default.
PR: 195024
submitted by: maintainer
Diffstat (limited to 'net-mgmt')
-rw-r--r-- | net-mgmt/seafile/Makefile | 23 | ||||
-rw-r--r-- | net-mgmt/seafile/files/patch-configure.ac | 17 | ||||
-rw-r--r-- | net-mgmt/seafile/files/patch-controller_seafile-controller.c | 91 | ||||
-rw-r--r-- | net-mgmt/seafile/files/patch-lib_Makfile.am | 13 | ||||
-rw-r--r-- | net-mgmt/seafile/files/patch-lib_utils.c | 184 | ||||
-rw-r--r-- | net-mgmt/seafile/files/patch-lib_utils.h | 15 | ||||
-rw-r--r-- | net-mgmt/seafile/pkg-plist | 4 |
7 files changed, 325 insertions, 22 deletions
diff --git a/net-mgmt/seafile/Makefile b/net-mgmt/seafile/Makefile index 519fd2dcbf36..00ca8e45ea73 100644 --- a/net-mgmt/seafile/Makefile +++ b/net-mgmt/seafile/Makefile @@ -2,6 +2,7 @@ PORTNAME= seafile PORTVERSION= 3.1.4 +PORTREVISION= 1 CATEGORIES= net-mgmt devel MAINTAINER= yan_jingfeng@yahoo.com @@ -15,7 +16,6 @@ LIB_DEPENDS= libsearpc.so:${PORTSDIR}/devel/libsearpc \ libzdb.so:${PORTSDIR}/databases/libzdb \ libcrypto.so:${PORTSDIR}/security/openssl \ libarchive.so.13:${PORTSDIR}/archivers/libarchive \ - libfuse.so:${PORTSDIR}/sysutils/fusefs-libs \ libinotify.so:${PORTSDIR}/devel/libinotify \ libccnet.so:${PORTSDIR}/net-mgmt/ccnet RUN_DEPENDS= ${PYTHON_PKGNAMEPREFIX}eggtestinfo>0:${PORTSDIR}/devel/py-eggtestinfo \ @@ -45,13 +45,32 @@ LDFLAGS+= -L${LOCALBASE}/lib MAKE_JOBS_UNSAFE= yes +OPTIONS_DEFINE= FUSE RIAK +OPTIONS_SUB= yes + +FUSE_DESC= Use file system in userspace +RIAK_DESC= Use distributed noSQL database + +FUSE_CONFIGURE_ENABLE= fuse +FUSE_LIB_DEPENDS= libfuse.so:${PORTSDIR}/sysutils/fusefs-libs + +RIAK_CONFIGURE_ENABLE= riak +RIAK_RUN_DEPENDS= riak:${PORTSDIR}/databases/riak + +OPTIONS_DEFAULT=FUSE +.if defined(DFLYVERSION) +OPTIONS_DEFAULT= +.endif + post-install: @${MKDIR} ${SEABIN} \ ${STAGEDIR}${WWWDIR}/seafile/share/doc/seafile \ ${STAGEDIR}${WWWDIR}/upgrade .for SERVPROG in fileserver seaf-fsck seafserv-gc seaf-fuse seaf-migrate \ seaf-server seaf-server-init seafile-controller seafserv-tool - ${LN} ${STAGEDIR}${PREFIX}/bin/${SERVPROG} ${SEABIN} + if [ -e "${STAGEDIR}${PREFIX}/bin/${SERVPROG}" ]; then \ + ${LN} ${STAGEDIR}${PREFIX}/bin/${SERVPROG} ${SEABIN}; \ + fi .endfor ${INSTALL_SCRIPT} ${WRKSRC}/scripts/*.[ps][yh] ${STAGEDIR}${WWWDIR} ${INSTALL_SCRIPT} ${WRKSRC}/scripts/upgrade/*.[ps][yh] \ diff --git a/net-mgmt/seafile/files/patch-configure.ac b/net-mgmt/seafile/files/patch-configure.ac index 5596aaba7e4b..8ad6d5e350ab 100644 --- a/net-mgmt/seafile/files/patch-configure.ac +++ b/net-mgmt/seafile/files/patch-configure.ac @@ -1,5 +1,14 @@ ---- configure.ac.orig 2014-06-05 02:25:50.000000000 -0400 -+++ configure.ac 2014-07-21 12:43:12.000000000 -0400 +--- configure.ac.orig 2014-08-05 01:28:35.000000000 -0400 ++++ configure.ac 2014-11-22 13:34:26.927863521 -0500 +@@ -88,7 +88,7 @@ + [compile_riak=$enableval],[compile_riak="no"]) + + AC_ARG_ENABLE(fuse, AC_HELP_STRING([--enable-fuse], [enable fuse virtual file system]), +- [compile_fuse=$enableval],[compile_fuse="yes"]) ++ [compile_fuse=$enableval],[compile_fuse="no"]) + fi + + AC_ARG_ENABLE(client, AC_HELP_STRING([--enable-client], [enable client]), @@ -199,25 +199,28 @@ LIB_GDI32= LIB_RT= @@ -40,7 +49,7 @@ AC_SUBST(MSVC_CFLAGS) -@@ -241,7 +246,6 @@ +@@ -242,7 +247,6 @@ #LIBNAUTILUS_EXTENSION_REQUIRED=2.30.1 CURL_REQUIRED=7.17 FUSE_REQUIRED=2.8.6 @@ -48,7 +57,7 @@ PKG_CHECK_MODULES(GLIB2, [glib-2.0 >= $GLIB_REQUIRED]) AC_SUBST(GLIB2_CFLAGS) -@@ -263,10 +267,6 @@ +@@ -268,10 +272,6 @@ AC_SUBST(LIBEVENT_CFLAGS) AC_SUBST(LIBEVENT_LIBS) diff --git a/net-mgmt/seafile/files/patch-controller_seafile-controller.c b/net-mgmt/seafile/files/patch-controller_seafile-controller.c index 7e49b061ce61..ca5bdd3a48e4 100644 --- a/net-mgmt/seafile/files/patch-controller_seafile-controller.c +++ b/net-mgmt/seafile/files/patch-controller_seafile-controller.c @@ -1,25 +1,108 @@ --- controller/seafile-controller.c.orig 2014-08-05 01:28:35.000000000 -0400 -+++ controller/seafile-controller.c 2014-08-30 09:11:34.868400091 -0400 -@@ -18,6 +18,10 @@ ++++ controller/seafile-controller.c 2014-11-22 22:00:58.614945337 -0500 +@@ -18,10 +18,23 @@ #include "log.h" #include "seafile-controller.h" +#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__) +#include <sys/sysctl.h> ++#include <sys/types.h> ++#include <sys/user.h> ++#include <limits.h> ++ ++#ifndef WITH_PROC_FS ++#define WITH_PROC_FS g_file_test("/proc/curproc", G_FILE_TEST_EXISTS) ++#endif ++ +#endif + #define CHECK_PROCESS_INTERVAL 10 /* every 10 seconds */ SeafileController *ctl; -@@ -273,7 +277,11 @@ + ++static char *command_name = NULL; + static char *controller_pidfile = NULL; + + char *bin_dir = NULL; +@@ -273,7 +286,20 @@ init_seafile_path () { GError *error = NULL; +#if defined(__linux__) char *executable = g_file_read_link ("/proc/self/exe", &error); +#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__) -+ char *executable = g_file_read_link ("/proc/curproc/file", &error); ++ /* ++ * seafile.sh starts the process using abs path ++ */ ++ char executable[_POSIX_PATH_MAX]; ++ memset(executable, 0, _POSIX_PATH_MAX); ++ char * rc = realpath(command_name, executable); ++ if (!rc) { ++ seaf_warning ("failed to readpath: %s\n", executable); ++ return; ++ } +#endif char *tmp = NULL; if (error != NULL) { seaf_warning ("failed to readlink: %s\n", error->message); +@@ -287,7 +313,9 @@ + + topdir = g_path_get_dirname (installpath); + ++#if defined(__linux__) + g_free (executable); ++#endif + g_free (tmp); + } + +@@ -427,12 +455,41 @@ + return FALSE; + } else { + char buf[256]; ++ gboolean with_procfs; ++#if defined(__linux__) ++ with_procfs = g_file_test("/proc/self", G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR); ++#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) ++ with_procfs = g_file_test("/proc/curproc", G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR); ++#else ++ with_procfs = FALSE; ++#endif ++ if (with_procfs) { + snprintf (buf, sizeof(buf), "/proc/%d", pid); + if (g_file_test (buf, G_FILE_TEST_IS_DIR)) { + return FALSE; + } else { + return TRUE; +- } ++ } ++ ++ } else { ++#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__) ++#ifdef __OpenBSD__ ++ int min[6] = {CTL_KERN, KERN_PROC, KERN_PROC_PID, pid, sizeof(struct kinfo_proc), 1}; ++#else ++ int mib[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PID, pid}; ++#endif ++ size_t len = sizeof(struct kinfo_proc); ++ struct kinfo_proc kp; ++ if (sysctl(mib, sizeof(mib)/sizeof(mib[0]), &kp, &len, NULL, 0) != -1 && ++ len == sizeof(struct kinfo_proc)) { ++ return FALSE; ++ } else { ++ return TRUE; ++ } ++#else ++ return FALSE; ++#endif ++ } + } + } + +@@ -892,6 +949,7 @@ + exit (1); + } + ++ command_name = argv[0]; + char *config_dir = DEFAULT_CONFIG_DIR; + char *seafile_dir = NULL; + char *logdir = NULL; diff --git a/net-mgmt/seafile/files/patch-lib_Makfile.am b/net-mgmt/seafile/files/patch-lib_Makfile.am index 7873fbdcb92b..3b9b881e62c8 100644 --- a/net-mgmt/seafile/files/patch-lib_Makfile.am +++ b/net-mgmt/seafile/files/patch-lib_Makfile.am @@ -1,5 +1,14 @@ ---- lib/Makefile.am.orig 2014-08-30 02:00:00.097346044 -0400 -+++ lib/Makefile.am 2014-08-30 02:00:10.951213463 -0400 +--- lib/Makefile.am.orig 2014-11-11 10:47:33.631976054 -0500 ++++ lib/Makefile.am 2014-11-11 11:40:14.030311321 -0500 +@@ -55,7 +55,7 @@ + libseafile_common_la_LDFLAGS = -no-undefined + libseafile_common_la_LIBADD = @GLIB2_LIBS@ @GOBJECT_LIBS@ -lssl -lcrypto @LIB_GDI32@ \ + @LIB_UUID@ @LIB_WS32@ @LIB_PSAPI@ -lsqlite3 \ +- -levent @SEARPC_LIBS@ @LIB_SHELL32@ \ ++ -levent -lkvm @SEARPC_LIBS@ @LIB_SHELL32@ \ + @ZLIB_LIBS@ + + searpc_gen = searpc-signature.h searpc-marshal.h @@ -72,8 +72,4 @@ rm -f $(top_srcdir)/lib/rpc_table.pyc diff --git a/net-mgmt/seafile/files/patch-lib_utils.c b/net-mgmt/seafile/files/patch-lib_utils.c index c1c3c4f645d3..4ae52bcbfccc 100644 --- a/net-mgmt/seafile/files/patch-lib_utils.c +++ b/net-mgmt/seafile/files/patch-lib_utils.c @@ -1,11 +1,26 @@ ---- lib/utils.c.orig 2014-06-05 02:25:50.000000000 -0400 -+++ lib/utils.c 2014-07-30 22:56:37.000000000 -0400 -@@ -1756,14 +1756,19 @@ +--- lib/utils.c.orig 2014-08-05 01:28:35.000000000 -0400 ++++ lib/utils.c 2014-11-22 20:17:13.543784891 -0500 +@@ -46,6 +46,15 @@ + + #include <zlib.h> + ++#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__) ++#include <stdlib.h> ++#include <kvm.h> ++#include <paths.h> ++#include <sys/param.h> ++#include <sys/sysctl.h> ++#include <sys/user.h> ++#endif ++ + extern int inet_pton(int af, const char *src, void *dst); + + +@@ -1756,14 +1765,19 @@ #endif /* ifdef WIN32 */ -#ifdef __linux__ -+#if defined(__linux__) || defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__) /* read the link of /proc/123/exe and compare with `process_name' */ static int find_process_in_dirent(struct dirent *dir, const char *process_name) @@ -14,10 +29,167 @@ /* fisrst construct a path like /proc/123/exe */ +#ifdef __linux__ if (sprintf (path, "/proc/%s/exe", dir->d_name) < 0) { -+#endif -+#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__) ++#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) + if (sprintf (path, "/proc/%s/file", dir->d_name) < 0) { ++#else ++ if (TRUE) { +#endif return -1; } +@@ -1787,7 +1801,8 @@ + } + + /* read the /proc fs to determine whether some process is running */ +-gboolean process_is_running (const char *process_name) ++static gboolean ++process_is_running_procfs (const char *process_name) + { + DIR *proc_dir = opendir("/proc"); + if (!proc_dir) { +@@ -1812,7 +1827,8 @@ + return FALSE; + } + +-int count_process(const char *process_name) ++static int ++count_process_procfs(const char *process_name) + { + int count = 0; + DIR *proc_dir = opendir("/proc"); +@@ -1836,6 +1852,14 @@ + return count; + } + ++#ifdef __linux__ ++gboolean process_is_running (const char *process_name) { ++ return process_is_running_procfs(process_name); ++} ++ ++int count_process(const char *process_name) { ++ return count_process_procfs(process_name); ++} + #endif + + #ifdef __APPLE__ +@@ -1846,6 +1870,120 @@ + } + #endif + ++#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__) ++#if defined(__FreeBSD__) ++#define PSKIP(kp) ((kp)->ki_pid == mypid || \ ++ (!kthreads && ((kp)->ki_flag & P_KTHREAD) != 0)) ++#define KVM_OPENFILES(exec, coref, buf) \ ++ kvm_openfiles(exec, coref, NULL, O_RDONLY, buf) ++#define KVM_GETPROCS(kd, plist, nproc) \ ++ kvm_getprocs(kd, KERN_PROC_PROC, 0, &nproc) ++ ++#elif defined(__DragonFly__) ++#define PSKIP(kp) ((kp)->kp_pid == mypid || \ ++ (!kthreads && ((kp)->kp_flags & P_KTHREADP) != 0)) ++#define KVM_OPENFILES(exec, coref, buf) \ ++ kvm_openfiles(exec, coref, NULL, O_RDONLY, buf) ++#define KVM_GETPROCS(kd, plist, nproc) \ ++ kvm_getprocs(kd, KERN_PROC_ALL, 0, &nproc) ++ ++#elif defined(__NetBSD__) ++#define PSKIP(kp) ((kp)->kp_pid == mypid || \ ++ ((kp)->p_flag & P_SYSTEM) != 0) ++#define KVM_OPENFILES(exec, coref, buf) \ ++ kvm_openfiles(exec, coref, NULL, KVM_NO_FILES, buf) ++#define KVM_GETPROCS(kd, plist, nproc) \ ++ kvm_getprocs(kd, KERN_PROC_ALL, 0, sizeof(*plist), &nproc) ++ ++#elif defined(__OpenBSD__) ++#define PSKIP(kp) ((kp)->kp_pid == mypid || \ ++ ((kp)->p_flag & (P_SYSTEM | P_THREAD)) != 0) ++#define KVM_OPENFILES(exec, coref, buf) \ ++ kvm_openfiles(exec, coref, NULL, KVM_NO_FILES, buf) ++#define KVM_GETPROCS(kd, plist, nproc) \ ++ kvm_getprocs(kd, KERN_PROC_ALL, 0, sizeof(*plist), &nproc) ++ ++#else ++#define PSKIP(kp) 0 ++#define KVM_OPENFILES(exec, coref, buf) 0 ++#define KVM_GETPROCS(kd, plist, nproc) 0 ++#endif ++ ++#ifndef WITH_PROC_FS ++#define WITH_PROC_FS g_file_test("/proc/curproc", G_FILE_TEST_EXISTS) ++#endif ++ ++static int ++count_running_process_kvm(const char *process_name) { ++ ++ ++ static kvm_t *kd; ++ static struct kinfo_proc *plist; ++ static int nproc; ++ static pid_t mypid; ++ static int kthreads; ++ ++ char buf[_POSIX2_LINE_MAX]; ++ const char * execf, *coref; ++ char **pargv; ++ int i, selected_nproc; ++ struct kinfo_proc *kp; ++ ++ selected_nproc = 0; ++ execf = NULL; ++ coref = _PATH_DEVNULL; ++ ++ mypid = getpid(); ++ kd = KVM_OPENFILES(execf, coref, buf); ++ if (kd == NULL) { ++ fprintf(stderr, "Error: Cannot open kernel files (%s)", buf); ++ exit(1); ++ } ++ ++ plist = KVM_GETPROCS(kd, plist, nproc); ++ if (plist == NULL) { ++ fprintf(stderr, "Error: Cannot get process list (%s)", kvm_geterr(kd)); ++ exit(1); ++ } ++ ++ for(i = 0, kp = plist; i < nproc; i++, kp++) { ++ if (PSKIP(kp)) { ++ continue; ++ } ++ if ((pargv = kvm_getargv(kd, kp, 0)) != NULL) { ++ if (strstr(pargv[0], process_name) != NULL) { ++ selected_nproc += 1; ++ } ++ } ++ } ++ kvm_close(kd); ++ kvm_close(kd); ++ ++ return selected_nproc; ++} ++ ++gboolean ++process_is_running(const char * process_name) { ++ if (WITH_PROC_FS) { ++ return process_is_running_procfs(process_name); ++ } ++ if (count_running_process_kvm(process_name) > 0) { ++ return TRUE; ++ } else { ++ return FALSE; ++ } ++} ++ ++int ++count_process(const char * process_name) { ++ if (WITH_PROC_FS) { ++ return count_process_procfs(process_name); ++ } ++ return count_running_process_kvm(process_name); ++} ++#endif ++ ++ + char* + ccnet_object_type_from_id (const char *object_id) + { diff --git a/net-mgmt/seafile/files/patch-lib_utils.h b/net-mgmt/seafile/files/patch-lib_utils.h index eaf1dfeed44c..576b8854377f 100644 --- a/net-mgmt/seafile/files/patch-lib_utils.h +++ b/net-mgmt/seafile/files/patch-lib_utils.h @@ -1,5 +1,5 @@ ---- lib/utils.h.orig 2014-06-05 02:25:50.000000000 -0400 -+++ lib/utils.h 2014-07-27 01:48:52.000000000 -0400 +--- lib/utils.h.orig 2014-08-05 01:28:35.000000000 -0400 ++++ lib/utils.h 2014-11-11 11:30:51.843637061 -0500 @@ -3,6 +3,9 @@ #ifndef CCNET_UTILS_H #define CCNET_UTILS_H @@ -10,3 +10,14 @@ #include <sys/time.h> #include <time.h> #include <stdint.h> +@@ -13,7 +16,9 @@ + #include <stdlib.h> + #include <sys/stat.h> + +-#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) ++#if defined(__FreeBSD__) || defined(__DragonFly__) ++#include <evutil.h> ++#elif (__NetBSD__) || defined(__OpenBSD__) + #include <event2/util.h> + #else + #include <evutil.h> diff --git a/net-mgmt/seafile/pkg-plist b/net-mgmt/seafile/pkg-plist index 4c12664f0cc5..d65a8b017f80 100644 --- a/net-mgmt/seafile/pkg-plist +++ b/net-mgmt/seafile/pkg-plist @@ -2,7 +2,7 @@ bin/fileserver bin/seaf-cli bin/seaf-daemon bin/seaf-fsck -bin/seaf-fuse +%%FUSE%%bin/seaf-fuse bin/seaf-migrate bin/seaf-server bin/seaf-server-init @@ -47,7 +47,7 @@ man/man1/seafile-applet.1.gz %%WWWDIR%%/seafile.sh %%WWWDIR%%/seafile/bin/fileserver %%WWWDIR%%/seafile/bin/seaf-fsck -%%WWWDIR%%/seafile/bin/seaf-fuse +%%FUSE%%%%WWWDIR%%/seafile/bin/seaf-fuse %%WWWDIR%%/seafile/bin/seaf-migrate %%WWWDIR%%/seafile/bin/seaf-server %%WWWDIR%%/seafile/bin/seaf-server-init |