From 2d6c7fb27b3c31a83501a661aba9f333933f16ce Mon Sep 17 00:00:00 2001 From: Kurt Jaeger Date: Sun, 17 Mar 2019 13:28:57 +0000 Subject: [PATCH] New port: net/onedrive: Microsoft OneDrive client A complete tool to interact with OneDrive on Linux. Built following the UNIX philosophy. Features: State caching Real-Time file monitoring with Inotify Resumable uploads Support OneDrive for Business (part of Office 365) Shared folders (not Business) What's missing: While local changes are uploaded right away, remote changes are delayed No GUI WWW: https://github.com/skilion/onedrive PR: 236573 Submitted by: Hiroo Ono --- net/Makefile | 1 + net/onedrive/Makefile | 45 +++++++++++++++++ net/onedrive/distinfo | 3 ++ net/onedrive/files/freebsd_inotify.d | 67 ++++++++++++++++++++++++++ net/onedrive/files/patch-Makefile | 43 +++++++++++++++++ net/onedrive/files/patch-src_monitor.d | 15 ++++++ net/onedrive/files/version | 1 + net/onedrive/pkg-descr | 15 ++++++ net/onedrive/pkg-plist | 3 ++ 9 files changed, 193 insertions(+) create mode 100644 net/onedrive/Makefile create mode 100644 net/onedrive/distinfo create mode 100644 net/onedrive/files/freebsd_inotify.d create mode 100644 net/onedrive/files/patch-Makefile create mode 100644 net/onedrive/files/patch-src_monitor.d create mode 100644 net/onedrive/files/version create mode 100644 net/onedrive/pkg-descr create mode 100644 net/onedrive/pkg-plist diff --git a/net/Makefile b/net/Makefile index b1338e869c92..ce0b561df03a 100644 --- a/net/Makefile +++ b/net/Makefile @@ -545,6 +545,7 @@ SUBDIR += ocserv SUBDIR += olsrd SUBDIR += omnitty + SUBDIR += onedrive SUBDIR += onenetd SUBDIR += onioncat SUBDIR += opal diff --git a/net/onedrive/Makefile b/net/onedrive/Makefile new file mode 100644 index 000000000000..b85a5aa3ff1c --- /dev/null +++ b/net/onedrive/Makefile @@ -0,0 +1,45 @@ +# $FreeBSD$ + +PORTNAME= onedrive +DISTVERSIONPREFIX= v +DISTVERSION= 1.1.3 +CATEGORIES= net + +MAINTAINER= hiroo.ono+freebsd@gmail.com +COMMENT= Microsoft OneDrive client + +LICENSE= GPLv3 + +BUILD_DEPENDS= ldmd2:lang/ldc +LIB_DEPENDS= libcurl.so:ftp/curl \ + libinotify.so:devel/libinotify + +USES= sqlite +USE_GITHUB= yes +GH_ACCOUNT= skilion + +OPTIONS_DEFAULT= LDC +OPTIONS_SINGLE= DLANG +OPTIONS_SINGLE_DLANG= DMD1 DMD2 LDC + +DMD1_DESC= Use lang/dmd1 as D compiler +DMD2_DESC= Use lang/dmd2 as D compiler +LDC_DESC= Use lang/ldc as D compiler + +DMD1_MAKE_ARGS= DC=dmd1 +DMD2_MAKE_ARGS= DC=dmd +LDC_MAKE_ARGS= DC=ldmd2 + +.include + +post-extract: + ${CP} ${FILESDIR}/freebsd_inotify.d ${WRKSRC}/src + ${CP} ${FILESDIR}/version ${WRKSRC} + +do-install: + ${INSTALL_PROGRAM} ${WRKSRC}/onedrive ${STAGEDIR}${PREFIX}/bin + ${MKDIR} ${STAGEDIR}${EXAMPLESDIR} ${STAGEDIR}${DOCSDIR} + ${INSTALL_DATA} ${WRKSRC}/config ${STAGEDIR}${EXAMPLESDIR} + ${INSTALL_DATA} ${WRKSRC}/README.md ${STAGEDIR}${DOCSDIR} + +.include diff --git a/net/onedrive/distinfo b/net/onedrive/distinfo new file mode 100644 index 000000000000..cdb8d270675b --- /dev/null +++ b/net/onedrive/distinfo @@ -0,0 +1,3 @@ +TIMESTAMP = 1552643961 +SHA256 (skilion-onedrive-v1.1.3_GH0.tar.gz) = fb12235a73919b3374b8f27785b834a690fba1c6e70c6e6f1f5da3e51eb471a0 +SIZE (skilion-onedrive-v1.1.3_GH0.tar.gz) = 35281 diff --git a/net/onedrive/files/freebsd_inotify.d b/net/onedrive/files/freebsd_inotify.d new file mode 100644 index 000000000000..cb3c3c4036b7 --- /dev/null +++ b/net/onedrive/files/freebsd_inotify.d @@ -0,0 +1,67 @@ +/** + * D header file for libinotify (incomplete) + */ + +module freebsd_inotify; + +import core.stdc.stdint; + +struct inotify_event +{ + int wd; /* Watch descriptor. */ + uint32_t mask; /* Watch mask. */ + uint32_t cookie; /* Cookie to synchronize two events. */ + uint32_t len; /* Length (including NULLs) of name. */ + char[] name; /* Name. */ +}; + + +/* Supported events suitable for MASK parameter of INOTIFY_ADD_WATCH. */ +enum IN_ACCESS = 0x00000001; /* File was accessed. */ +enum IN_MODIFY = 0x00000002; /* File was modified. */ +enum IN_ATTRIB = 0x00000004; /* Metadata changed. */ +enum IN_CLOSE_WRITE = 0x00000008; /* Writtable file was closed. */ +enum IN_CLOSE_NOWRITE = 0x00000010; /* Unwrittable file closed. */ +enum IN_CLOSE = (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE); /* Close. */ +enum IN_OPEN = 0x00000020; /* File was opened. */ +enum IN_MOVED_FROM = 0x00000040; /* File was moved from X. */ +enum IN_MOVED_TO = 0x00000080; /* File was moved to Y. */ +enum IN_MOVE = (IN_MOVED_FROM | IN_MOVED_TO); /* Moves. */ +enum IN_CREATE = 0x00000100; /* Subfile was created. */ +enum IN_DELETE = 0x00000200; /* Subfile was deleted. */ +enum IN_DELETE_SELF = 0x00000400; /* Self was deleted. */ +enum IN_MOVE_SELF = 0x00000800; /* Self was moved. */ + +/* Additional events and flags. Some of these flags are unsupported, + but still should be present */ +enum IN_UNMOUNT = 0x00002000; /* Backing fs was unmounted. */ +enum IN_Q_OVERFLOW = 0x00004000; /* Event queued overflowed. */ +enum IN_IGNORED = 0x00008000; /* File was ignored. */ + +enum IN_ONLYDIR = 0x01000000; /* Only watch the path if it is a + directory. */ +enum IN_DONT_FOLLOW = 0x02000000; /* Do not follow a sym link. */ +enum IN_EXCL_UNLINK = 0x04000000; /* Exclude events on unlinked + objects. */ +enum IN_MASK_ADD = 0x20000000; /* Add to the mask of an already + existing watch. */ +enum IN_ISDIR = 0x40000000; /* Event occurred against dir. */ +enum IN_ONESHOT = 0x80000000; /* Only send event once. */ + + +/* Create and initialize inotify-kqueue instance. */ +extern (C) int inotify_init (); + +/* Create and initialize inotify-kqueue instance. */ +extern (C) int inotify_init1 (int flags); + +/* Add watch of object NAME to inotify-kqueue instance FD. Notify about + events specified by MASK. */ +extern (C) int inotify_add_watch (int fd, const char *name, uint32_t mask); + +/* Remove the watch specified by WD from the inotify instance FD. */ +extern (C) int inotify_rm_watch (int fd, int wd); + +/* Libinotify specific. Set inotify instance parameter. */ +extern (C) int inotify_set_param (int fd, int param, intptr_t value); + diff --git a/net/onedrive/files/patch-Makefile b/net/onedrive/files/patch-Makefile new file mode 100644 index 000000000000..3dc33fad0627 --- /dev/null +++ b/net/onedrive/files/patch-Makefile @@ -0,0 +1,43 @@ +--- Makefile.orig 2018-09-09 20:14:01 UTC ++++ Makefile +@@ -1,5 +1,5 @@ + DC = dmd +-DFLAGS = -g -ofonedrive -O -L-lcurl -L-lsqlite3 -L-ldl -J. ++DFLAGS = -g -ofonedrive -O -L-lcurl -L-lsqlite3 -L-ldl -L-linotify -J. + PREFIX = /usr/local + + SOURCES = \ +@@ -14,26 +14,19 @@ SOURCES = \ + src/sqlite.d \ + src/sync.d \ + src/upload.d \ +- src/util.d ++ src/util.d \ ++ src/freebsd_inotify.d + +-all: onedrive onedrive.service ++all: onedrive + + clean: +- rm -f onedrive onedrive.o onedrive.service ++ rm -f onedrive onedrive.o + +-install: all +- install -D onedrive $(DESTDIR)$(PREFIX)/bin/onedrive +- install -D -m 644 onedrive.service $(DESTDIR)/usr/lib/systemd/user/onedrive.service ++# install: all ++# install -D onedrive $(DESTDIR)$(PREFIX)/bin/onedrive + + onedrive: version $(SOURCES) + $(DC) $(DFLAGS) $(SOURCES) + +-onedrive.service: +- sed "s|@PREFIX@|$(PREFIX)|g" onedrive.service.in > onedrive.service +- + uninstall: + rm -f $(DESTDIR)$(PREFIX)/bin/onedrive +- rm -f $(DESTDIR)/usr/lib/systemd/user/onedrive.service +- +-version: .git/HEAD .git/index +- echo $(shell git describe --tags) >version +\ No newline at end of file diff --git a/net/onedrive/files/patch-src_monitor.d b/net/onedrive/files/patch-src_monitor.d new file mode 100644 index 000000000000..451dd720d547 --- /dev/null +++ b/net/onedrive/files/patch-src_monitor.d @@ -0,0 +1,15 @@ +--- src/monitor.d.orig 2019-03-16 11:55:35 UTC ++++ src/monitor.d +@@ -1,10 +1,11 @@ +-import core.sys.linux.sys.inotify; ++// import core.sys.linux.sys.inotify; + import core.stdc.errno; + import core.sys.posix.poll, core.sys.posix.unistd; + import std.exception, std.file, std.path, std.regex, std.stdio, std.string; + import config; + import selective; + import util; ++import freebsd_inotify; + static import log; + + // relevant inotify events diff --git a/net/onedrive/files/version b/net/onedrive/files/version new file mode 100644 index 000000000000..781dcb07cd80 --- /dev/null +++ b/net/onedrive/files/version @@ -0,0 +1 @@ +1.1.3 diff --git a/net/onedrive/pkg-descr b/net/onedrive/pkg-descr new file mode 100644 index 000000000000..aaad10c73fd9 --- /dev/null +++ b/net/onedrive/pkg-descr @@ -0,0 +1,15 @@ +A complete tool to interact with OneDrive on Linux. +Built following the UNIX philosophy. + +Features: + State caching + Real-Time file monitoring with Inotify + Resumable uploads + Support OneDrive for Business (part of Office 365) + Shared folders (not Business) + +What's missing: + While local changes are uploaded right away, remote changes are delayed + No GUI + +WWW: https://github.com/skilion/onedrive diff --git a/net/onedrive/pkg-plist b/net/onedrive/pkg-plist new file mode 100644 index 000000000000..f3ed01570d77 --- /dev/null +++ b/net/onedrive/pkg-plist @@ -0,0 +1,3 @@ +bin/onedrive +%%DOCSDIR%%/README.md +%%EXAMPLESDIR%%/config