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 <hiroo.ono+freebsd@gmail.com>
This commit is contained in:
Kurt Jaeger 2019-03-17 13:28:57 +00:00
parent fda98ed059
commit 2d6c7fb27b
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=496060
9 changed files with 193 additions and 0 deletions

View file

@ -545,6 +545,7 @@
SUBDIR += ocserv
SUBDIR += olsrd
SUBDIR += omnitty
SUBDIR += onedrive
SUBDIR += onenetd
SUBDIR += onioncat
SUBDIR += opal

45
net/onedrive/Makefile Normal file
View file

@ -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 <bsd.port.pre.mk>
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 <bsd.port.post.mk>

3
net/onedrive/distinfo Normal file
View file

@ -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

View file

@ -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);

View file

@ -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

View file

@ -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

View file

@ -0,0 +1 @@
1.1.3

15
net/onedrive/pkg-descr Normal file
View file

@ -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

3
net/onedrive/pkg-plist Normal file
View file

@ -0,0 +1,3 @@
bin/onedrive
%%DOCSDIR%%/README.md
%%EXAMPLESDIR%%/config