From ff8d137057c0593d9d15c60a6b664ecaf75078fd Mon Sep 17 00:00:00 2001 From: abraunegg Date: Sat, 28 May 2022 08:38:57 +1000 Subject: [PATCH 1/4] Update minimum compiler versions to dmd-2.088.0 and ldc-1.18.0 (#1972) * Update to dmd-2.088.0 and ldc-1.18.0 * Update documentation based on change in DMD and LDC minimum versions. Minimum DMD version now 2.088.0 and minimum LDC version now 1.18.0. * Security upgrade alpine Docker file to 3.16 --- configure | 4 +- configure.ac | 4 +- contrib/docker/Dockerfile-alpine | 2 +- contrib/docker/Dockerfile-debian | 25 +--------- contrib/docker/Dockerfile-rpi | 51 ------------------- docs/Docker.md | 4 +- docs/INSTALL.md | 84 ++++++++++---------------------- docs/ubuntu-package-install.md | 51 ++++++------------- 8 files changed, 50 insertions(+), 175 deletions(-) delete mode 100644 contrib/docker/Dockerfile-rpi diff --git a/configure b/configure index f3194930..11f900a2 100755 --- a/configure +++ b/configure @@ -2133,7 +2133,7 @@ case $(basename $DC) in # remove everthing after ): VERSION=${VERSION%%):*} # now version should be something like L.M.N - MINVERSION=1.17.0 + MINVERSION=1.18.0 ;; dmd) # DMD64 D Compiler v2.085.1\n... @@ -2141,7 +2141,7 @@ case $(basename $DC) in VERSION=${VERSION#*Compiler v} VERSION=${VERSION%% *} # now version should be something like L.M.N - MINVERSION=2.087.0 + MINVERSION=2.088.0 ;; esac diff --git a/configure.ac b/configure.ac index f5123af2..875b62d4 100644 --- a/configure.ac +++ b/configure.ac @@ -104,7 +104,7 @@ case $(basename $DC) in # remove everthing after ): VERSION=${VERSION%%):*} # now version should be something like L.M.N - MINVERSION=1.17.0 + MINVERSION=1.18.0 ;; dmd) # DMD64 D Compiler v2.085.1\n... @@ -112,7 +112,7 @@ case $(basename $DC) in VERSION=${VERSION#*Compiler v} VERSION=${VERSION%% *} # now version should be something like L.M.N - MINVERSION=2.087.0 + MINVERSION=2.088.0 ;; esac diff --git a/contrib/docker/Dockerfile-alpine b/contrib/docker/Dockerfile-alpine index 2d2dee54..296c74f1 100644 --- a/contrib/docker/Dockerfile-alpine +++ b/contrib/docker/Dockerfile-alpine @@ -1,6 +1,6 @@ # -*-Dockerfile-*- -ARG ALPINE_VERSION=3.15 +ARG ALPINE_VERSION=3.16 ARG GO_VERSION=1.17 ARG GOSU_VERSION=1.14 diff --git a/contrib/docker/Dockerfile-debian b/contrib/docker/Dockerfile-debian index d677eb94..32e52e52 100644 --- a/contrib/docker/Dockerfile-debian +++ b/contrib/docker/Dockerfile-debian @@ -1,38 +1,17 @@ # -*-Dockerfile-*- ARG DEBIAN_VERSION=bullseye -ARG LDC_VERSION_MAIN=1.28.1 FROM debian:${DEBIAN_VERSION} AS builder-onedrive -ARG LDC_VERSION_MAIN RUN apt-get update \ - && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends build-essential curl ca-certificates libcurl4-openssl-dev libsqlite3-dev libxml2-dev pkg-config git \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends build-essential curl ca-certificates libcurl4-openssl-dev libsqlite3-dev libxml2-dev pkg-config git ldc \ && rm -rf /var/lib/apt/lists/* -RUN ARCH="$(dpkg --print-architecture)" \ - && case "${ARCH}" in \ - aarch64|arm64) \ - BINARY_URL="https://github.com/ldc-developers/ldc/releases/download/v${LDC_VERSION_MAIN}/ldc2-${LDC_VERSION_MAIN}-linux-aarch64.tar.xz"; \ - ;; \ - amd64|x86-64) \ - BINARY_URL="https://github.com/ldc-developers/ldc/releases/download/v${LDC_VERSION_MAIN}/ldc2-${LDC_VERSION_MAIN}-linux-x86_64.tar.xz"; \ - ;; \ - *) \ - echo "Unsupported arch: ${ARCH}"; \ - exit 1; \ - ;; \ - esac \ - && echo ${BINARY_URL} \ - && curl -k -LfsSo /tmp/ldc.tar.xz ${BINARY_URL} \ - && mkdir -p /opt/ldc \ - && tar -xvf /tmp/ldc.tar.xz -C /opt/ldc --strip-components=1 \ - && rm -rf /tmp/ldc.tar.xz - COPY . /usr/src/onedrive WORKDIR /usr/src/onedrive -RUN ./configure DC=/opt/ldc/bin/ldmd2 \ +RUN ./configure DC=/usr/bin/ldmd2 \ && make clean \ && make \ && make install diff --git a/contrib/docker/Dockerfile-rpi b/contrib/docker/Dockerfile-rpi deleted file mode 100644 index a806a6a9..00000000 --- a/contrib/docker/Dockerfile-rpi +++ /dev/null @@ -1,51 +0,0 @@ -# -*-Dockerfile-*- - -ARG DEBIAN_VERSION=buster -ARG LDC_VERSION_MAIN=1.17.0 - -FROM debian:${DEBIAN_VERSION} AS builder-onedrive -ARG LDC_VERSION_MAIN - -RUN apt-get update \ - && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends build-essential curl ca-certificates libcurl4-openssl-dev libsqlite3-dev libxml2-dev pkg-config \ - && rm -rf /var/lib/apt/lists/* - -RUN ARCH="$(dpkg --print-architecture)" \ - && case "${ARCH}" in \ - armhf|arm) \ - BINARY_URL="https://github.com/ldc-developers/ldc/releases/download/v${LDC_VERSION_MAIN}/ldc2-${LDC_VERSION_MAIN}-linux-aarch64.tar.xz"; \ - ;; \ - *) \ - echo "Unsupported arch: ${ARCH}"; \ - exit 1; \ - ;; \ - esac \ - && echo ${BINARY_URL} \ - && curl -k -LfsSo /tmp/ldc.tar.xz ${BINARY_URL} \ - && mkdir -p /opt/ldc \ - && tar -xvf /tmp/ldc.tar.xz -C /opt/ldc --strip-components=1 \ - && rm -rf /tmp/ldc.tar.xz - -COPY . /usr/src/onedrive -WORKDIR /usr/src/onedrive - -RUN ./configure DC=/opt/ldc/bin/ldmd2 \ - && make clean \ - && make \ - && make install - -FROM debian:${DEBIAN_VERSION}-slim - -RUN apt-get update \ - && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends gosu libcurl4 libsqlite3-0 ca-certificates \ - && rm -rf /var/lib/apt/lists/* \ - # Fix bug with ssl on armhf: https://serverfault.com/a/1045189 - && /usr/bin/c_rehash \ - && mkdir -p /onedrive/conf /onedrive/data - -COPY --from=builder-onedrive /usr/local/bin/onedrive /usr/local/bin/ - -COPY contrib/docker/entrypoint.sh / -RUN chmod +x /entrypoint.sh - -ENTRYPOINT ["/entrypoint.sh"] diff --git a/docs/Docker.md b/docs/Docker.md index 5dcb3c48..d3ca97f7 100644 --- a/docs/Docker.md +++ b/docs/Docker.md @@ -277,8 +277,8 @@ Compatible with: * Raspberry Pi 3 * Raspberry Pi 4 ``` bash -docker build . -t local-onedrive-rpi -f contrib/docker/Dockerfile-rpi -docker container run -v onedrive_conf:/onedrive/conf -v "${ONEDRIVE_DATA_DIR}:/onedrive/data" local-ondrive-rpi:latest +docker build . -t local-onedrive-armhf -f contrib/docker/Dockerfile-debian +docker container run -v onedrive_conf:/onedrive/conf -v "${ONEDRIVE_DATA_DIR}:/onedrive/data" local-onedrive-armhf:latest ``` #### How to build and run a custom Docker image for AARCH64 Platforms diff --git a/docs/INSTALL.md b/docs/INSTALL.md index 05e8b3a0..ac9cf586 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -19,7 +19,7 @@ Distribution packages may be of an older release when compared to the latest rel | NixOS | [onedrive](https://search.nixos.org/packages?channel=20.09&from=0&size=50&sort=relevance&query=onedrive)|nixpkgs unstable package|❌|✔|❌|❌| Use package `onedrive` either by adding it to `configuration.nix` or by using the command `nix-env -iA .onedrive`. This does not install a service. To install a service, use unstable channel (will stabilize in 20.09) and add `services.onedrive.enable=true` in `configuration.nix`. You can also add a custom package using the `services.onedrive.package` option (recommended since package lags upstream). Enabling the service installs a default package too (based on the channel). You can also add multiple onedrive accounts trivially, see [documentation](https://github.com/NixOS/nixpkgs/pull/77734#issuecomment-575874225). | | OpenSuSE | [onedrive](https://software.opensuse.org/package/onedrive) |openSUSE Tumbleweed package|✔|✔|❌|❌| | | OpenSuSE Build Service | [onedrive](https://build.opensuse.org/package/show/home:npreining:debian-ubuntu-onedrive/onedrive) | No API Available |✔|✔|✔|✔| Package Build Service for Debian and Ubuntu | -| Raspbian | [onedrive](https://archive.raspbian.org/raspbian/pool/main/o/onedrive/) |Raspbian Stable package |❌|❌|✔|❌| **Note:** You must compile from source for Raspbian | +| Raspbian | [onedrive](https://archive.raspbian.org/raspbian/pool/main/o/onedrive/) |Raspbian Stable package |❌|❌|✔|✔| **Note:** Do not install from Raspbian Package Repositories

Install from OpenSuSE Build Service using the Debian Package Install [Instructions](ubuntu-package-install.md) | | Slackware | [onedrive](https://slackbuilds.org/result/?search=onedrive&sv=) |SlackBuilds package|✔|✔|❌|❌| | | Solus | [onedrive](https://dev.getsol.us/search/query/FB7PIf1jG9Z9/#R) |Solus package|✔|✔|❌|❌| | | Ubuntu 18.04 | [onedrive](https://packages.ubuntu.com/bionic/onedrive) |Ubuntu 18.04 package |✔|✔|✔|❌| **Note:** Do not install from Ubuntu Universe

You must compile from source for this version of Ubuntu | @@ -48,7 +48,7 @@ If you wish to change this situation so that you can just use the Universe packa * [SQLite 3](https://www.sqlite.org/) >= 3.7.15 * [Digital Mars D Compiler (DMD)](http://dlang.org/download.html) or [LDC – the LLVM-based D Compiler](https://github.com/ldc-developers/ldc) -**Note:** DMD version >= 2.087.0 or LDC version >= 1.17.0 is required to compile this application +**Note:** DMD version >= 2.088.0 or LDC version >= 1.18.0 is required to compile this application ### Example for installing DMD Compiler ```text @@ -172,43 +172,19 @@ For notifications the following is also necessary: sudo pacman -S libnotify ``` -### Dependencies: Raspbian (ARMHF) -Validated using: -* `Linux raspberrypi 5.4.79-v7+ #1373 SMP Mon Nov 23 13:22:33 GMT 2020 armv7l GNU/Linux` (2020-12-02-raspios-buster-armhf) using Raspberry Pi 2 Model B -* `Linux raspberrypi 5.4.83-v8+ #1379 SMP PREEMPT Mon Dec 14 13:15:14 GMT 2020 aarch64` (2021-01-11-raspios-buster-armhf) using Raspberry Pi 3 Model B+ +### Dependencies: Raspbian (ARMHF) and Ubuntu 22.x / Debian 11 / Raspbian (ARM64) +**Note:** The minimum LDC compiler version required to compile this application is now 1.18.0, which is not available for Debian Buster or distributions based on Debian Buster. You are advised to first upgrade your platform distribution to one that is based on Debian Bullseye (Debian 11) or later. + +These instructions were validated using: +* `Linux raspberrypi 5.10.92-v8+ #1514 SMP PREEMPT Mon Jan 17 17:39:38 GMT 2022 aarch64` (2022-01-28-raspios-bullseye-armhf-lite) using Raspberry Pi 3B (revision 1.2) +* `Linux raspberrypi 5.10.92-v8+ #1514 SMP PREEMPT Mon Jan 17 17:39:38 GMT 2022 aarch64` (2022-01-28-raspios-bullseye-arm64-lite) using Raspberry Pi 3B (revision 1.2) +* `Linux ubuntu 5.15.0-1005-raspi #5-Ubuntu SMP PREEMPT Mon Apr 4 12:21:48 UTC 2022 aarch64 aarch64 aarch64 GNU/Linux` (ubuntu-22.04-preinstalled-server-arm64+raspi) using Raspberry Pi 3B (revision 1.2) **Note:** Build environment must have at least 1GB of memory & 1GB swap space. Check with `swapon`. ```text sudo apt install build-essential -sudo apt install libcurl4-openssl-dev -sudo apt install libsqlite3-dev -sudo apt install pkg-config -sudo apt install git -sudo apt install curl -wget https://github.com/ldc-developers/ldc/releases/download/v1.17.0/ldc2-1.17.0-linux-armhf.tar.xz -tar -xvf ldc2-1.17.0-linux-armhf.tar.xz -``` -For notifications the following is also necessary: -```text -sudo apt install libnotify-dev -``` - -### Dependencies: Ubuntu 20.x / Debian 10 (ARM64) -Validated using: -* `Ubuntu 20.04.2 LTS (GNU/Linux 5.4.0-1028-raspi aarch64)` (ubuntu-20.04.2-preinstalled-server-arm64+raspi) using Raspberry Pi 3 Model B+ - -**Note:** Build environment must have at least 1GB of memory & 1GB swap space. Check with `swapon`. - -```text -sudo apt install build-essential -sudo apt install libcurl4-openssl-dev -sudo apt install libsqlite3-dev -sudo apt install pkg-config -sudo apt install git -sudo apt install curl -wget https://github.com/ldc-developers/ldc/releases/download/v1.25.1/ldc2-1.25.1-linux-aarch64.tar.xz -tar -xvf ldc2-1.25.1-linux-aarch64.tar.xz +sudo apt install libcurl4-openssl-dev libsqlite3-dev pkg-config git curl ldc ``` For notifications the following is also necessary: ```text @@ -269,13 +245,13 @@ sudo zypper install libnotify-devel ### Building using DMD Reference Compiler Before cloning and compiling, if you have installed DMD via curl for your OS, you will need to activate DMD as per example below: ```text -Run `source ~/dlang/dmd-2.087.0/activate` in your shell to use dmd-2.087.0. +Run `source ~/dlang/dmd-2.088.0/activate` in your shell to use dmd-2.088.0. This will setup PATH, LIBRARY_PATH, LD_LIBRARY_PATH, DMD, DC, and PS1. Run `deactivate` later on to restore your environment. ``` Without performing this step, the compilation process will fail. -**Note:** Depending on your DMD version, substitute `2.087.0` above with your DMD version that is installed. +**Note:** Depending on your DMD version, substitute `2.088.0` above with your DMD version that is installed. ```text git clone https://github.com/abraunegg/onedrive.git @@ -305,27 +281,30 @@ as far as possible automatically, but can be overridden by passing `--with-fish-completion-dir=` to `configure`. ### Building using a different compiler (for example [LDC](https://wiki.dlang.org/LDC)) -#### ARMHF Architecture (Raspbian etc) +#### ARMHF Architecture (Raspbian) and ARM64 Architecture (Ubuntu 22.x / Debian 11 / Raspbian) +**Note:** The minimum LDC compiler version required to compile this application is now 1.18.0, which is not available for Debian Buster or distributions based on Debian Buster. You are advised to first upgrade your platform distribution to one that is based on Debian Bullseye (Debian 11) or later. + **Note:** Build environment must have at least 1GB of memory & 1GB swap space. Check with `swapon`. ```text git clone https://github.com/abraunegg/onedrive.git cd onedrive -./configure DC=~/ldc2-1.17.0-linux-armhf/bin/ldmd2 +./configure DC=/usr/bin/ldmd2 make clean; make sudo make install ``` -#### ARM64 Architecture -**Note:** Build environment must have at least 1GB of memory & 1GB swap space. Check with `swapon` -```text -git clone https://github.com/abraunegg/onedrive.git -cd onedrive -./configure DC=~/ldc2-1.25.1-linux-aarch64/bin/ldmd2 -make clean; make -sudo make install -``` +## Upgrading the client +If you have installed the client from a distribution package, the client will be updated when the distribution package is updated by the package maintainer and will be updated to the new application version when you perform your package update. + +If you have built the client from source, to upgrade your client, you must first uninstall your existing 'onedrive' binary (see above), then re-install the client by re-cloning, re-compiling and re-installing the client again to install the new version. + +To confirm you have the new version installed, use `onedrive --version` to determine the version that is now installed. ## Uninstalling the client +### Uninstalling the client if installed from distribution package +Follow your distribution documentation to uninstall the package that you installed + +### Uninstalling the client if installed and built from source From within your GitHub repository clone, perform the following to remove the 'onedrive' binary: ```text sudo make uninstall @@ -340,13 +319,4 @@ rm -rf ~/.config/onedrive If you want to just delete the application key, but keep the items database: ```text rm -f ~/.config/onedrive/refresh_token -``` - -## Upgrading the client -If you have installed the client from a distribution package, the client will be updated when the distribution package is updated by the package maintainer and will be updated to the new application version when you perform your package update. - -If you have built the client from source, to upgrade your client, you must first uninstall your existing 'onedrive' binary (see above), then re-install the client by re-cloning, re-compiling and re-installing the client again to install the new version. - -To confirm you have the new version installed, use `onedrive --version` to determine the version that is now installed. - - +``` \ No newline at end of file diff --git a/docs/ubuntu-package-install.md b/docs/ubuntu-package-install.md index b26c01df..8a4623d8 100644 --- a/docs/ubuntu-package-install.md +++ b/docs/ubuntu-package-install.md @@ -4,11 +4,13 @@ This document covers the appropriate steps to install the 'onedrive' client usin #### Important information for all Ubuntu and Ubuntu based distribution users: This information is specifically for the following platforms and distributions: -* Ubuntu + * Lubuntu * Linux Mint * POP OS * Peppermint OS +* Raspbian +* Ubuntu Whilst there are [onedrive](https://packages.ubuntu.com/search?keywords=onedrive&searchon=names&suite=all§ion=all) Universe packages available for Ubuntu, do not install 'onedrive' from these Universe packages. The default Ubuntu Universe packages are out-of-date and are not supported and should not be used. @@ -113,45 +115,20 @@ If required, review the table below based on your 'lsb_release' information to p | Release & Codename | Instructions to use | |--------------------|---------------------| -| Ubuntu 18.x / bionic | You must build from source or upgrade your Operating System Ubuntu 22.x | -| Linux Mint 19.x / tina | You must build from source or upgrade your Operating System Linux Mint 20.x | -| Linux Mint 20.x / ulyana | Use [Ubuntu 20.04](#distribution-ubuntu-2004) instructions below | -| Debian 10 | Use [Debian 10](#distribution-debian-10) instructions below | -| Debian 11 | Use [Debian 11](#distribution-debian-11) instructions below | -| Ubuntu 20.04 | Use [Ubuntu 20.04](#distribution-ubuntu-2004) instructions below | -| Ubuntu 21.04 | Use [Ubuntu 21.04](#distribution-ubuntu-2104) instructions below | -| Ubuntu 21.10 | Use [Ubuntu 21.10](#distribution-ubuntu-2110) instructions below | -| Ubuntu 22.04 | Use [Ubuntu 22.04](#distribution-ubuntu-2204) instructions below | +| Ubuntu 18.x / bionic | You must build from source or upgrade your Operating System Ubuntu 22.x | +| Linux Mint 19.x / tina | You must build from source or upgrade your Operating System Linux Mint 20.x | +| Linux Mint 20.x / ulyana | Use [Ubuntu 20.04](#distribution-ubuntu-2004) instructions below | +| Debian 10 | You must build from source or upgrade your Operating System Debian 11 | +| Debian 11 | Use [Debian 11](#distribution-debian-11) instructions below | +| Raspbian GNU/Linux 10 | You must build from source or upgrade your Operating System Debian 11 | +| Raspbian GNU/Linux 11 | Use [Debian 11](#distribution-debian-11) instructions below | +| Ubuntu 20.04 | Use [Ubuntu 20.04](#distribution-ubuntu-2004) instructions below | +| Ubuntu 21.04 | Use [Ubuntu 21.04](#distribution-ubuntu-2104) instructions below | +| Ubuntu 21.10 | Use [Ubuntu 21.10](#distribution-ubuntu-2110) instructions below | +| Ubuntu 22.04 | Use [Ubuntu 22.04](#distribution-ubuntu-2204) instructions below | ## Distribution Package Install Instructions -### Distribution: Debian 10 -The packages support the following platform architectures: -|  i686  | x86_64 | ARMHF | AARCH64 | -|:----:|:------:|:-----:|:-------:| -|✔|✔|✔|✔| | - -#### Step 1: Add the OpenSuSE Build Service repository release key -Add the OpenSuSE Build Service repository release key using the following command: -```text -wget -qO - https://download.opensuse.org/repositories/home:/npreining:/debian-ubuntu-onedrive/Debian_10/Release.key | sudo apt-key add - -``` - -#### Step 2: Add the OpenSuSE Build Service repository -Add the OpenSuSE Build Service repository using the following command: -```text -echo 'deb https://download.opensuse.org/repositories/home:/npreining:/debian-ubuntu-onedrive/Debian_10/ ./' | sudo tee /etc/apt/sources.list.d/onedrive.list -``` - -#### Step 3: Update your apt package cache -Run: `sudo apt-get update` - -#### Step 4: Install 'onedrive' -Run: `sudo apt install onedrive` - -#### Step 5: Read 'Known Issues' with these packages -Read and understand the known issues with these packages below, taking any action that is needed. - ### Distribution: Debian 11 The packages support the following platform architectures: |  i686  | x86_64 | ARMHF | AARCH64 | From b6fee40939c4e010fc749594bc55ee920682e564 Mon Sep 17 00:00:00 2001 From: abraunegg Date: Mon, 30 May 2022 10:28:59 +1000 Subject: [PATCH 2/4] Update ubuntu-package-install.md * Update doc --- docs/ubuntu-package-install.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/ubuntu-package-install.md b/docs/ubuntu-package-install.md index 8a4623d8..1bf5ad64 100644 --- a/docs/ubuntu-package-install.md +++ b/docs/ubuntu-package-install.md @@ -115,17 +115,17 @@ If required, review the table below based on your 'lsb_release' information to p | Release & Codename | Instructions to use | |--------------------|---------------------| -| Ubuntu 18.x / bionic | You must build from source or upgrade your Operating System Ubuntu 22.x | -| Linux Mint 19.x / tina | You must build from source or upgrade your Operating System Linux Mint 20.x | -| Linux Mint 20.x / ulyana | Use [Ubuntu 20.04](#distribution-ubuntu-2004) instructions below | -| Debian 10 | You must build from source or upgrade your Operating System Debian 11 | -| Debian 11 | Use [Debian 11](#distribution-debian-11) instructions below | -| Raspbian GNU/Linux 10 | You must build from source or upgrade your Operating System Debian 11 | -| Raspbian GNU/Linux 11 | Use [Debian 11](#distribution-debian-11) instructions below | -| Ubuntu 20.04 | Use [Ubuntu 20.04](#distribution-ubuntu-2004) instructions below | -| Ubuntu 21.04 | Use [Ubuntu 21.04](#distribution-ubuntu-2104) instructions below | -| Ubuntu 21.10 | Use [Ubuntu 21.10](#distribution-ubuntu-2110) instructions below | -| Ubuntu 22.04 | Use [Ubuntu 22.04](#distribution-ubuntu-2204) instructions below | +| Ubuntu 18.x / bionic | You must build from source or upgrade your Operating System to Ubuntu 22.x | +| Linux Mint 19.x / tina | You must build from source or upgrade your Operating System to Linux Mint 20.x | +| Linux Mint 20.x / ulyana | Use [Ubuntu 20.04](#distribution-ubuntu-2004) instructions below | +| Debian 10 | You must build from source or upgrade your Operating System to Debian 11 | +| Debian 11 | Use [Debian 11](#distribution-debian-11) instructions below | +| Raspbian GNU/Linux 10 | You must build from source or upgrade your Operating System to Raspbian GNU/Linux 11 | +| Raspbian GNU/Linux 11 | Use [Debian 11](#distribution-debian-11) instructions below | +| Ubuntu 20.04 | Use [Ubuntu 20.04](#distribution-ubuntu-2004) instructions below | +| Ubuntu 21.04 | Use [Ubuntu 21.04](#distribution-ubuntu-2104) instructions below | +| Ubuntu 21.10 | Use [Ubuntu 21.10](#distribution-ubuntu-2110) instructions below | +| Ubuntu 22.04 | Use [Ubuntu 22.04](#distribution-ubuntu-2204) instructions below | ## Distribution Package Install Instructions From 767352686f72bd0b6179b6e4d01d345d02d06adc Mon Sep 17 00:00:00 2001 From: ticteam <38141953+ticteam@users.noreply.github.com> Date: Tue, 31 May 2022 21:45:06 +0200 Subject: [PATCH 3/4] Add libphobos2-ldc-shared94 to Dockerfile-debian (#1975) * Add libphobos2-ldc-shared94 to Dockerfile-debian --- contrib/docker/Dockerfile-debian | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/docker/Dockerfile-debian b/contrib/docker/Dockerfile-debian index 32e52e52..9c0dd8f8 100644 --- a/contrib/docker/Dockerfile-debian +++ b/contrib/docker/Dockerfile-debian @@ -19,7 +19,7 @@ RUN ./configure DC=/usr/bin/ldmd2 \ FROM debian:${DEBIAN_VERSION}-slim RUN apt-get update \ - && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends gosu libcurl4 libsqlite3-0 ca-certificates \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends gosu libcurl4 libsqlite3-0 ca-certificates libphobos2-ldc-shared94 \ && rm -rf /var/lib/apt/lists/* \ # Fix bug with ssl on armhf: https://serverfault.com/a/1045189 && /usr/bin/c_rehash \ From 0fffb8fbc0f7a1033ceaf26ef49c37676315a38d Mon Sep 17 00:00:00 2001 From: abraunegg Date: Wed, 1 Jun 2022 05:57:05 +1000 Subject: [PATCH 4/4] Implement a check to validate local filesystem available space before attempting file download (#1971) * Implement a check to validate local filesystem available space before attempting file download * Implement 'space_reservation' config option with a default value of 50 MB * Prevent the original run-away logging error message 'Failed initialization on handle XXXX' from occurring if the system is out of space * Update documentation and man page --- config | 1 + docs/USAGE.md | 27 +++++++++++++++++++++++++++ onedrive.1.in | 4 +++- src/config.d | 19 +++++++++++++++++-- src/main.d | 1 + src/onedrive.d | 10 ++++++++++ src/sync.d | 24 +++++++++++++++++++++++- src/util.d | 11 +++++++++-- 8 files changed, 91 insertions(+), 6 deletions(-) diff --git a/config b/config index 98d61cfb..0514a86d 100644 --- a/config +++ b/config @@ -50,3 +50,4 @@ # webhook_listening_port = "8888" # webhook_expiration_interval = "86400" # webhook_renewal_interval = "43200" +# space_reservation = "50" \ No newline at end of file diff --git a/docs/USAGE.md b/docs/USAGE.md index 86373094..2d498c06 100644 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -35,6 +35,7 @@ * [Configuring the client to use older 'skilion' application identifier](#configuring-the-client-to-use-older-skilion-application-identifier) * [How to 'skip' directories from syncing?](#how-to-skip-directories-from-syncing) * [How to 'rate limit' the application to control bandwidth consumed for upload & download operations](#how-to-rate-limit-the-application-to-control-bandwidth-consumed-for-upload--download-operations) + * [Preventing your local disk from filling up](#preventing-your-local-disk-from-filling-up) * [Shared folders (OneDrive Personal)](#shared-folders-onedrive-personal) * [Shared folders (OneDrive Business or Office 365)](#shared-folders-onedrive-business-or-office-365) * [SharePoint / Office 365 Shared Libraries](#sharepoint--office-365-shared-libraries) @@ -382,6 +383,7 @@ See the [config](https://raw.githubusercontent.com/abraunegg/onedrive/master/con # webhook_listening_port = "8888" # webhook_expiration_interval = "86400" # webhook_renewal_interval = "43200" +# space_reservation = "50" ``` ### 'config' file configuration examples: @@ -765,6 +767,29 @@ rate_limit = "131072" **Note:** A number greater than '131072' is a valid value, with '104857600' being tested as an upper limit. +### Preventing your local disk from filling up +By default, the application will reserve 50MB of disk space to prevent your filesystem to run out of disk space. This value can be modified by adding the following to your config file: + +Example: +```text +... +# webhook_expiration_interval = "86400" +# webhook_renewal_interval = "43200" +space_reservation = "10" +``` + +The value entered is in MB (Mega Bytes). In this example, a value of 10MB is being used, and will be converted to bytes by the application. The value being used can be reviewed when using `--display-config`: +``` +Config option 'sync_dir_permissions' = 700 +Config option 'sync_file_permissions' = 600 +Config option 'space_reservation' = 10485760 +Config option 'application_id' = +Config option 'azure_ad_endpoint' = +Config option 'azure_tenant_id' = common +``` + +Any value is valid here, however, if you use a value of '0' a value of '1' will actually be used, so that you actually do not run out of disk space. + ### Shared folders (OneDrive Personal) Folders shared with you can be synced by adding them to your OneDrive. To do that open your Onedrive, go to the Shared files list, right click on the folder you want to sync and then click on "Add to my OneDrive". @@ -1202,6 +1227,8 @@ Options: Skip syncing of symlinks --source-directory ARG Source directory to rename or move on OneDrive - no sync will be performed. + --space-reservation ARG + The amount of disk space to reserve (in MB) to avoid 100% disk space utilisation --sync-root-files Sync all files in sync_dir root when using sync_list. --sync-shared-folders diff --git a/onedrive.1.in b/onedrive.1.in index 6c5fd3ea..e06568fe 100644 --- a/onedrive.1.in +++ b/onedrive.1.in @@ -219,9 +219,11 @@ Configuration file key: \fBskip_symlinks\fP (default: \fBfalse\fP) \fB\-\-source\-directory\fP ARG Source directory to rename or move on OneDrive \- no sync will be performed. .TP +\fB\-\-space\-reservation\fP ARG +The amount of disk space to reserve (in MB) to avoid 100% disk space utilisation +.TP \fB\-\-sync\-root\-files\fP Sync all files in sync_dir root when using sync_list. - .TP \fB\-\-sync\-shared\-folders\fP Sync OneDrive Business Shared Folders diff --git a/src/config.d b/src/config.d index 14301614..4c23538e 100644 --- a/src/config.d +++ b/src/config.d @@ -124,8 +124,9 @@ final class Config longValues["rate_limit"] = 0; // maximum time an operation is allowed to take // This includes dns resolution, connecting, data transfer, etc. - longValues["operation_timeout"] = 3600; - + longValues["operation_timeout"] = 3600; + // To ensure we do not fill up the load disk, how much disk space should be reserved by default + longValues["space_reservation"] = 50 * 2^^20; // 50 MB as Bytes // Webhook options boolValues["webhook_enabled"] = false; stringValues["webhook_public_url"] = ""; @@ -457,6 +458,9 @@ final class Config "source-directory", "Source directory to rename or move on OneDrive - no sync will be performed.", &stringValues["source_directory"], + "space-reservation", + "The amount of disk space to reserve (in MB) to avoid 100% disk space utilisation", + &longValues["space_reservation"], "syncdir", "Specify the local directory used for synchronization to OneDrive", &stringValues["sync_dir"], @@ -661,6 +665,16 @@ final class Config if (ppp) { c.popFront(); setValueLong(key, to!long(c.front.dup)); + // if key is space_reservation we have to calculate MB -> bytes + if (key == "space_reservation") { + // temp value + ulong tempValue = to!long(c.front.dup); + // a value of 0 needs to be made at least 1MB .. + if (tempValue == 0) { + tempValue = 1; + } + setValueLong("space_reservation", to!long(tempValue * 2^^20)); + } } else { log.log("Unknown key in config file: ", key); return false; @@ -766,6 +780,7 @@ void outputLongHelp(Option[] opt) "--skip-file", "--skip-size", "--source-directory", + "--space-reservation", "--syncdir", "--user-agent" ]; writeln(`OneDrive - a client for OneDrive Cloud Services diff --git a/src/main.d b/src/main.d index f2d9620d..cdc6ce01 100644 --- a/src/main.d +++ b/src/main.d @@ -672,6 +672,7 @@ int main(string[] args) writeln("Config option 'remove_source_files' = ", cfg.getValueBool("remove_source_files")); writeln("Config option 'sync_dir_permissions' = ", cfg.getValueLong("sync_dir_permissions")); writeln("Config option 'sync_file_permissions' = ", cfg.getValueLong("sync_file_permissions")); + writeln("Config option 'space_reservation' = ", cfg.getValueLong("space_reservation")); // curl operations writeln("Config option 'application_id' = ", cfg.getValueString("application_id")); diff --git a/src/onedrive.d b/src/onedrive.d index b4e29190..b22b5cda 100644 --- a/src/onedrive.d +++ b/src/onedrive.d @@ -1472,6 +1472,16 @@ final class OneDriveApi // Some other error was returned log.error(" Error Message: ", errorMessage); log.error(" Calling Function: ", getFunctionName!({})); + + // Was this a curl initialization error? + if (canFind(errorMessage, "Failed initialization on handle")) { + // initialization error ... prevent a run-away process if we have zero disk space + ulong localActualFreeSpace = to!ulong(getAvailableDiskSpace(".")); + if (localActualFreeSpace == 0) { + // force exit + exit(-1); + } + } } // return an empty JSON for handling return json; diff --git a/src/sync.d b/src/sync.d index c5bcb4e7..ee563771 100644 --- a/src/sync.d +++ b/src/sync.d @@ -269,7 +269,7 @@ final class SyncEngine private bool nationalCloudDeployment = false; // array of all OneDrive driveId's for use with OneDrive Business Folders private string[] driveIDsArray; - + this(Config cfg, OneDriveApi onedrive, ItemDatabase itemdb, SelectiveSync selectiveSync) { assert(onedrive && itemdb && selectiveSync); @@ -2822,6 +2822,28 @@ final class SyncEngine log.vdebug("WARNING: fileDetails['file']['hashes'] is missing - unable to compare file hash after download"); } + // Is there enough free space locally to download the file + // - We can use '.' here as we change the current working directory to the configured 'sync_dir' + ulong localActualFreeSpace = to!ulong(getAvailableDiskSpace(".")); + // So that we are not responsible in making the disk 100% full if we can download the file, compare the current available space against the reservation set and file size + // The reservation value is user configurable in the config file, 50MB by default + ulong freeSpaceReservation = cfg.getValueLong("space_reservation"); + // debug output + log.vdebug("Local Disk Space Actual: ", localActualFreeSpace); + log.vdebug("Free Space Reservation: ", freeSpaceReservation); + log.vdebug("File Size to Download: ", fileSize); + + // calculate if we can download file + if ((localActualFreeSpace < freeSpaceReservation) || (fileSize > localActualFreeSpace)) { + // localActualFreeSpace is less than freeSpaceReservation .. insufficient free space + // fileSize is greater than localActualFreeSpace .. insufficient free space + writeln("failed!"); + log.log("Insufficient local disk space to download file"); + downloadFailed = true; + return; + } + + // Attempt to download the file try { onedrive.downloadById(item.driveId, item.id, path, fileSize); } catch (OneDriveException e) { diff --git a/src/util.d b/src/util.d index 8e666fbc..efcbd5ae 100644 --- a/src/util.d +++ b/src/util.d @@ -14,6 +14,7 @@ import std.uri; import std.json; import std.traits; import qxor; +import core.stdc.stdlib; static import log; shared string deviceName; @@ -332,7 +333,7 @@ void displayOneDriveErrorMessage(string message, string callingFunction) } // Where in the code was this error generated - log.error(" Calling Function: ", callingFunction); + log.vlog(" Calling Function: ", callingFunction); } // Parse and display error message received from the local file system @@ -343,7 +344,13 @@ void displayFileSystemErrorMessage(string message, string callingFunction) // What was the error message log.error(" Error Message: ", errorArray[0]); // Where in the code was this error generated - log.error(" Calling Function: ", callingFunction); + log.vlog(" Calling Function: ", callingFunction); + // If we are out of disk space (despite download reservations) we need to exit the application + ulong localActualFreeSpace = to!ulong(getAvailableDiskSpace(".")); + if (localActualFreeSpace == 0) { + // force exit + exit(-1); + } } // Get the function name that is being called to assist with identifying where an error is being generated