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
This commit is contained in:
abraunegg 2019-01-19 13:01:01 +11:00 committed by GitHub
parent 83cc2e419b
commit c27ff936fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 37 additions and 10 deletions

View file

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

View file

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

View file

@ -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 $?
exit $?

View file

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