From a4cd27b0fbe2ad5001a9b8a19172b3e04497b5a7 Mon Sep 17 00:00:00 2001 From: "ljf (zamentur)" Date: Tue, 21 May 2019 16:48:54 +0200 Subject: [PATCH 1/2] [fix] Remove backports (#9) * [fix] Remove backports * [fix] Upgrade don't forget to install pip borg package --- manifest.json | 2 +- scripts/_common.sh | 4 ---- scripts/install | 17 +++++++++-------- scripts/restore | 15 ++++++++------- scripts/upgrade | 12 ++++++++++++ 5 files changed, 30 insertions(+), 20 deletions(-) diff --git a/manifest.json b/manifest.json index 395997e..9ff44db 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "Offer backup storage to a friend.", "fr": "Offrez un espace de stockage à un⋅e ami⋅e." }, - "version": "1.0.1", + "version": "1.1.10~ynh1", "url": "https://borgbackup.readthedocs.io", "license": "BSD-3-Clause", "maintainer": { diff --git a/scripts/_common.sh b/scripts/_common.sh index c8c1531..8557b43 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -116,10 +116,6 @@ ynh_check_app_version_changed () { } -ynh_install_backports () { - echo "deb http://httpredir.debian.org/debian stretch-backports main" > /etc/apt/sources.list.d/$app-stretch-backports.list -} - ynh_remove_backports () { rm /etc/apt/sources.list.d/$app-stretch-backports.list } diff --git a/scripts/install b/scripts/install index 4d4bd66..d93e0bf 100755 --- a/scripts/install +++ b/scripts/install @@ -30,16 +30,17 @@ ynh_export ssh_user public_key quota ynh_save_args ssh_user public_key quota #================================================= -# CONFIGURE BACKPORTS -#================================================= -# We need borg 1.1+ available only in backports -ynh_install_backports - -#================================================= -# STORE SETTINGS FROM MANIFEST +# INSTALL DEPENDENCIES #================================================= ynh_install_app_dependencies $pkg_dependencies -ynh_package_install -t stretch-backports borgbackup + +if [ ! -d /opt/borg-env ]; then + virtualenv --python=python3 /opt/borg-env + /opt/borg-env/bin/python /opt/borg-env/bin/pip install borgbackup + echo "#!/bin/bash +/opt/borg-env/bin/python /opt/borg-env/bin/borg \"\$@\"" > /usr/local/bin/borg + chmod u+x /usr/local/bin/borg +fi #================================================= # CREATE SSH USER USED BY BORG diff --git a/scripts/restore b/scripts/restore index a7ee0e5..7046fb1 100755 --- a/scripts/restore +++ b/scripts/restore @@ -31,17 +31,18 @@ export ssh_user=$(ynh_app_setting_get $app ssh_user) export public_key=$(ynh_app_setting_get $app public_key) export quota=$(ynh_app_setting_get $app quota) -#================================================= -# CONFIGURE BACKPORTS -#================================================= -# We need borg 1.1+ available only in backports -ynh_install_backports - #================================================= # INSTALL DEPENDENCIES #================================================= ynh_install_app_dependencies $pkg_dependencies -ynh_package_install -t stretch-backports borgbackup + +if [ ! -d /opt/borg-env ]; then + virtualenv --python=python3 /opt/borg-env + /opt/borg-env/bin/python /opt/borg-env/bin/pip install borgbackup + echo "#!/bin/bash +/opt/borg-env/bin/python /opt/borg-env/bin/borg \"\$@\"" > /usr/local/bin/borg + chmod u+x /usr/local/bin/borg +fi #================================================= # CREATE SSH USER USED BY BORG diff --git a/scripts/upgrade b/scripts/upgrade index a2f1c92..056774f 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -33,3 +33,15 @@ ynh_clean_setup () { # Exit if an error occurs during the execution of the script ynh_abort_if_errors +# Replace backports with pip +if is_stretch; then + ynh_remove_backports + + if [ ! -d /opt/borg-env ]; then + virtualenv --python=python3 /opt/borg-env + /opt/borg-env/bin/python /opt/borg-env/bin/pip install borgbackup + echo "#!/bin/bash +/opt/borg-env/bin/python /opt/borg-env/bin/borg \"\$@\"" > /usr/local/bin/borg + chmod u+x /usr/local/bin/borg + fi +fi From b1cf03191e24eaf907feceb73e23189399556d1c Mon Sep 17 00:00:00 2001 From: ljf Date: Tue, 21 May 2019 17:05:24 +0200 Subject: [PATCH 2/2] [enh] Pin the borg version to 1.1.10 --- scripts/_common.sh | 11 +++++++++++ scripts/install | 9 +-------- scripts/restore | 9 +-------- scripts/upgrade | 8 +------- 4 files changed, 14 insertions(+), 23 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 8557b43..2d0cda9 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -8,6 +8,17 @@ PKG_DIR=$(cd ../; pwd) pkg_dependencies="python3-pip python3-dev libacl1-dev libssl-dev liblz4-dev python-jinja2" +# Install borg with pip if borg is not here +install_borg_with_pip () { + if [ ! -d /opt/borg-env ]; then + virtualenv --python=python3 /opt/borg-env + /opt/borg-env/bin/python /opt/borg-env/bin/pip install borgbackup=1.1.10 + echo "#!/bin/bash + /opt/borg-env/bin/python /opt/borg-env/bin/borg \"\$@\"" > /usr/local/bin/borg + chmod u+x /usr/local/bin/borg + fi +} + #================================================= # COMMON HELPERS #================================================= diff --git a/scripts/install b/scripts/install index d93e0bf..331f924 100755 --- a/scripts/install +++ b/scripts/install @@ -33,14 +33,7 @@ ynh_save_args ssh_user public_key quota # INSTALL DEPENDENCIES #================================================= ynh_install_app_dependencies $pkg_dependencies - -if [ ! -d /opt/borg-env ]; then - virtualenv --python=python3 /opt/borg-env - /opt/borg-env/bin/python /opt/borg-env/bin/pip install borgbackup - echo "#!/bin/bash -/opt/borg-env/bin/python /opt/borg-env/bin/borg \"\$@\"" > /usr/local/bin/borg - chmod u+x /usr/local/bin/borg -fi +install_borg_with_pip #================================================= # CREATE SSH USER USED BY BORG diff --git a/scripts/restore b/scripts/restore index 7046fb1..b83184d 100755 --- a/scripts/restore +++ b/scripts/restore @@ -35,14 +35,7 @@ export quota=$(ynh_app_setting_get $app quota) # INSTALL DEPENDENCIES #================================================= ynh_install_app_dependencies $pkg_dependencies - -if [ ! -d /opt/borg-env ]; then - virtualenv --python=python3 /opt/borg-env - /opt/borg-env/bin/python /opt/borg-env/bin/pip install borgbackup - echo "#!/bin/bash -/opt/borg-env/bin/python /opt/borg-env/bin/borg \"\$@\"" > /usr/local/bin/borg - chmod u+x /usr/local/bin/borg -fi +install_borg_with_pip #================================================= # CREATE SSH USER USED BY BORG diff --git a/scripts/upgrade b/scripts/upgrade index 056774f..02caf8e 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -37,11 +37,5 @@ ynh_abort_if_errors if is_stretch; then ynh_remove_backports - if [ ! -d /opt/borg-env ]; then - virtualenv --python=python3 /opt/borg-env - /opt/borg-env/bin/python /opt/borg-env/bin/pip install borgbackup - echo "#!/bin/bash -/opt/borg-env/bin/python /opt/borg-env/bin/borg \"\$@\"" > /usr/local/bin/borg - chmod u+x /usr/local/bin/borg - fi + install_borg_with_pip fi