From c27ff936fb917cb9b23ce87c0622fc54b5b514c8 Mon Sep 17 00:00:00 2001 From: abraunegg Date: Sat, 19 Jan 2019 13:01:01 +1100 Subject: [PATCH] Resolve build warning & support CentOS 6.x for installation (Issue #350) (#353) * Support install on CentOS / RHEL 6.x * Support uninstall on CentOS / RHEL 6.x * Add /usr/local/bin/ to search path when starting init.d service * Fix dmd-2.084.0 deprecation warning: loop index implicitly converted from size_t to int * Update readme based on CentOS 6 / RHEL 6 additional dependencies * Resolve warnings about "bashisms" in init.d script (Issue #349) - fixed here as we are updating the init file already, rather than have multiple PR's --- Makefile | 20 +++++++++++++++++--- README.md | 13 ++++++++++++- init.d/onedrive.init | 9 +++++---- src/sqlite.d | 5 +++-- 4 files changed, 37 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 5d1827cb..871400fd 100644 --- a/Makefile +++ b/Makefile @@ -31,9 +31,11 @@ MANDIR ?= $(PREFIX)/share/man/man1 DOCFILES = README.md README.Office365.md config LICENSE CHANGELOG.md ifneq ("$(wildcard /etc/redhat-release)","") -RHEL = $(shell cat /etc/redhat-release | grep -E "(Red Hat Enterprise Linux Server|CentOS Linux)" | wc -l) +RHEL = $(shell cat /etc/redhat-release | grep -E "(Red Hat Enterprise Linux Server|CentOS)" | wc -l) +RHEL_VERSION = $(shell rpm --eval "%{centos_ver}") else RHEL = 0 +RHEL_VERSION = 0 endif SOURCES = \ @@ -74,10 +76,17 @@ install.noservice: onedrive onedrive.1 install: all install.noservice for i in $(DOCFILES) ; do install -D -m 644 $$i $(DESTDIR)$(DOCDIR)/$$i ; done ifeq ($(RHEL),1) +ifeq ($(RHEL_VERSION),6) + mkdir -p $(DESTDIR)/etc/init.d/ + chown root.root $(DESTDIR)/etc/init.d/ + install -D init.d/onedrive.init $(DESTDIR)/etc/init.d/onedrive + install -D init.d/onedrive_service.sh $(DESTDIR)$(PREFIX)/bin/onedrive_service.sh +else mkdir -p $(DESTDIR)/usr/lib/systemd/system/ chown root.root $(DESTDIR)/usr/lib/systemd/system/ chmod 0755 $(DESTDIR)/usr/lib/systemd/system/ install -D -m 644 *.service $(DESTDIR)/usr/lib/systemd/system/ +endif else mkdir -p $(DESTDIR)/usr/lib/systemd/user/ chown root.root $(DESTDIR)/usr/lib/systemd/user/ @@ -87,8 +96,8 @@ else chown root.root $(DESTDIR)/usr/lib/systemd/system/ chmod 0755 $(DESTDIR)/usr/lib/systemd/system/ install -D -m 644 onedrive@.service $(DESTDIR)/usr/lib/systemd/system/ -endif install -D -m 644 onedrive.service $(DESTDIR)/usr/lib/systemd/user/onedrive.service +endif onedrive.service: sed "s|@PREFIX@|$(PREFIX)|g" systemd.units/onedrive.service.in > onedrive.service @@ -101,7 +110,12 @@ uninstall: rm -f $(DESTDIR)$(PREFIX)/bin/onedrive rm -f $(DESTDIR)/etc/logrotate.d/onedrive ifeq ($(RHEL),1) +ifeq ($(RHEL_VERSION),6) + rm -f $(DESTDIR)/etc/init.d/onedrive + rm -f $(DESTDIR)$(PREFIX)/bin/onedrive_service.sh +else rm -f $(DESTDIR)/usr/lib/systemd/system/onedrive*.service +endif else rm -f $(DESTDIR)/usr/lib/systemd/user/onedrive.service rm -f $(DESTDIR)/usr/lib/systemd/system/onedrive@.service @@ -110,4 +124,4 @@ endif rm -f $(DESTDIR)$(MANDIR)/onedrive.1 version: .git/HEAD .git/index - echo $(shell git describe --tags) >version + echo $(shell git describe --tags) > version diff --git a/README.md b/README.md index b45a6973..28e9b9e4 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ A complete tool to interact with OneDrive on Linux. Built following the UNIX phi ## Build Requirements * Build environment must have at least 1GB of memory & 1GB swap space * [libcurl](http://curl.haxx.se/libcurl/) -* [SQLite 3](https://www.sqlite.org/) +* [SQLite 3](https://www.sqlite.org/) >= 3.7.15 * [Digital Mars D Compiler (DMD)](http://dlang.org/download.html) ### Dependencies: Ubuntu/Debian - x86_64 @@ -82,6 +82,17 @@ For notifications the following is necessary: sudo yum install libnotify-devel ``` +### Dependencies: CentOS 6.x / RHEL 6.x +In addition to the above requirements, the `sqlite` version used on CentOS 6.x / RHEL 6.x needs to be upgraded. Use the following instructions to update your version of `sqlite` so that it can support the client: +```text +sudo yum -y update +sudo yum -y install epel-release, wget +sudo yum -y install mock +wget https://kojipkgs.fedoraproject.org//packages/sqlite/3.7.15.2/2.fc19/src/sqlite-3.7.15.2-2.fc19.src.rpm +sudo mock --rebuild sqlite-3.7.15.2-2.fc19.src.rpm +sudo yum -y upgrade /var/lib/mock/epel-6-{arch}/result/sqlite-* +``` + ### Dependencies: Fedora > Version 18 ```text sudo dnf groupinstall 'Development Tools' diff --git a/init.d/onedrive.init b/init.d/onedrive.init index cb892a68..a249954e 100644 --- a/init.d/onedrive.init +++ b/init.d/onedrive.init @@ -24,7 +24,8 @@ STOP_TIMEOUT=${STOP_TIMEOUT-5} RETVAL=0 start() { - echo -n $"Starting $APP_NAME: " + export PATH=/usr/local/bin/:$PATH + echo -n "Starting $APP_NAME: " daemon --user root onedrive_service.sh RETVAL=$? echo @@ -34,7 +35,7 @@ start() { } stop() { - echo -n $"Shutting down $APP_NAME: " + echo -n "Shutting down $APP_NAME: " killproc onedrive RETVAL=$? echo @@ -74,8 +75,8 @@ case "$1" in rhstatus ;; *) - echo $"Usage: $0 {start|stop|restart|reload|status}" + echo "Usage: $0 {start|stop|restart|reload|status}" exit 2 esac -exit $? \ No newline at end of file +exit $? diff --git a/src/sqlite.d b/src/sqlite.d index ff8cffa2..6b299517 100644 --- a/src/sqlite.d +++ b/src/sqlite.d @@ -3,6 +3,7 @@ import std.stdio; import etc.c.sqlite3; import std.string: fromStringz, toStringz; import core.stdc.stdlib; +import std.conv; static import log; extern (C) immutable(char)* sqlite3_errstr(int); // missing from the std library @@ -176,9 +177,9 @@ struct Statement // https://www.sqlite.org/c3ref/data_count.html int count = sqlite3_data_count(pStmt); row = new const(char)[][count]; - foreach (int i, ref column; row) { + foreach (size_t i, ref column; row) { // https://www.sqlite.org/c3ref/column_blob.html - column = fromStringz(sqlite3_column_text(pStmt, i)); + column = fromStringz(sqlite3_column_text(pStmt, to!int(i))); } } else { string errorMessage = ifromStringz(sqlite3_errmsg(sqlite3_db_handle(pStmt)));