Index: head/net-mgmt/seafile/Makefile =================================================================== --- head/net-mgmt/seafile/Makefile (revision 374801) +++ head/net-mgmt/seafile/Makefile (revision 374802) @@ -1,83 +1,83 @@ # $FreeBSD$ PORTNAME= seafile PORTVERSION= 3.1.4 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= net-mgmt devel MAINTAINER= yan_jingfeng@yahoo.com COMMENT= Framework for writing networked applications LICENSE= GPLv3 BUILD_DEPENDS= valac:${PORTSDIR}/lang/vala LIB_DEPENDS= libsearpc.so:${PORTSDIR}/devel/libsearpc \ libevhtp.so:${PORTSDIR}/www/libevhtp \ libzdb.so:${PORTSDIR}/databases/libzdb \ libcrypto.so:${PORTSDIR}/security/openssl \ libarchive.so.13:${PORTSDIR}/archivers/libarchive \ libinotify.so:${PORTSDIR}/devel/libinotify \ libccnet.so:${PORTSDIR}/net-mgmt/ccnet RUN_DEPENDS= ${PYTHON_PKGNAMEPREFIX}eggtestinfo>0:${PORTSDIR}/devel/py-eggtestinfo \ ${PYTHON_SITELIBDIR}/PIL/__init__.py:${PORTSDIR}/graphics/py-imaging \ ${PYTHON_PKGNAMEPREFIX}sqlite3>0:${PORTSDIR}/databases/py-sqlite3 \ bash:${PORTSDIR}/shells/bash USE_GITHUB= yes GH_ACCOUNT= haiwen GH_TAGNAME= v3.1.4 GH_COMMIT= ac58109 USES= autoreconf iconv libtool pathfix pkgconfig python:2 shebangfix GNU_CONFIGURE= yes USE_OPENSSL= yes USE_LDCONFIG= yes WITH_OPENSSL_PORT= yes PATHFIX_MAKEFILEIN= Makefile.am CONFIGURE_ARGS= --enable-server INSTALL_TARGET= install-strip WWWDIR= ${PREFIX}/www/haiwen/seafile-server SEABIN= ${STAGEDIR}${WWWDIR}/seafile/bin CPPFLAGS+= -I${LOCALBASE}/include 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 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] \ ${STAGEDIR}${WWWDIR}/upgrade ${INSTALL_DATA} ${WRKSRC}/doc/seafile-tutorial.doc \ ${STAGEDIR}${WWWDIR}/seafile/share/doc/seafile/ (cd ${WRKSRC}/scripts/upgrade && \ ${COPYTREE_SHARE} sql ${STAGEDIR}${WWWDIR}/upgrade) .include Index: head/net-mgmt/seafile/files/patch-lib_utils.c =================================================================== --- head/net-mgmt/seafile/files/patch-lib_utils.c (revision 374801) +++ head/net-mgmt/seafile/files/patch-lib_utils.c (revision 374802) @@ -1,195 +1,194 @@ --- 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 +#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__) +#include +#include +#include +#include +#include +#include +#endif + extern int inet_pton(int af, const char *src, void *dst); @@ -1756,14 +1765,19 @@ #endif /* ifdef WIN32 */ -#ifdef __linux__ /* 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) { char path[512]; /* fisrst construct a path like /proc/123/exe */ +#ifdef __linux__ if (sprintf (path, "/proc/%s/exe", dir->d_name) < 0) { +#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)) ++ (!kthreads && ((kp)->kp_flags & P_SYSTEM) != 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) ++#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) {