From 1fedc314b3a005a4d4d53dd4ba1ca3a0e6592e25 Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Sun, 27 Nov 2022 18:47:43 -0600 Subject: [PATCH] Add pyfuse3 support for backup (borg) app --- rattail_fabric2/backup.py | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/rattail_fabric2/backup.py b/rattail_fabric2/backup.py index c2feab0..4fedaf8 100644 --- a/rattail_fabric2/backup.py +++ b/rattail_fabric2/backup.py @@ -2,7 +2,7 @@ ################################################################################ # # Rattail -- Retail Software Framework -# Copyright © 2010-2019 Lance Edgar +# Copyright © 2010-2022 Lance Edgar # # This file is part of Rattail. # @@ -55,6 +55,7 @@ def deploy_backup_everything(c, **context): def deploy_backup_app(c, deploy, envname, mkvirtualenv=True, user='rattail', python_exe='/usr/bin/python3', install_borg=False, + pyfuse3=False, link_borg_to_bin=True, install_luigi=False, luigi_history_db=None, @@ -91,11 +92,11 @@ def deploy_backup_app(c, deploy, envname, mkvirtualenv=True, user='rattail', envpath = '/srv/envs/{}'.format(envname) if mkvirtualenv and not exists(c, envpath): python.mkvirtualenv(c, envname, python=python_exe, runas_user=user) - # TODO: this should not be necessary, right? - c.sudo('chown -R {}: {}'.format(user, envpath)) + # TODO: this should not be necessary, right? + c.sudo('chown -R {}: {}'.format(user, envpath)) + c.sudo("bash -c 'PIP_CONFIG_FILE={0}/pip.conf {0}/bin/pip install -U pip setuptools wheel'".format(envpath), + user=user) mkdir(c, os.path.join(envpath, 'src'), use_sudo=True, runas_user=user) - c.sudo("bash -c 'PIP_CONFIG_FILE={0}/pip.conf {0}/bin/pip install -U pip setuptools wheel'".format(envpath), - user=user) if install_rattail: @@ -131,17 +132,19 @@ def deploy_backup_app(c, deploy, envname, mkvirtualenv=True, user='rattail', # borg if install_borg: - if install_rattail: - packages = [ - 'rattail[backup]', - ] + if isinstance(install_borg, list): + packages = install_borg + elif isinstance(install_borg, str): + packages = [install_borg] else: - # TODO: these should be same as rattail[backup] - packages = [ - 'msgpack', - 'borgbackup[fuse]', - ] - c.sudo("bash -c 'PIP_CONFIG_FILE={0}/pip.conf {0}/bin/pip install {1}'".format(envpath, ' '.join(packages)), + packages = ['msgpack'] + if pyfuse3: + apt.install(c, 'libfuse3-dev') + packages.append('borgbackup[pyfuse3]') + else: + # TODO: this is legacy and should stop being default + packages.append('borgbackup[fuse]') + c.sudo("bash -c 'PIP_CONFIG_FILE={0}/pip.conf {0}/bin/pip install {1}'".format(envpath, ' '.join(packages)), user=user) if link_borg_to_bin: c.sudo("ln -sf {}/bin/borg /usr/local/bin/borg".format(envpath))