Remove archivemount stuff (#491)

This commit is contained in:
Alexandre Aubin 2018-06-15 15:29:05 +02:00 committed by GitHub
parent 07b4ec49aa
commit 898d665900
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 39 additions and 148 deletions

2
debian/control vendored
View file

@ -33,7 +33,7 @@ Recommends: yunohost-admin
, python-pip
, unattended-upgrades
, libdbd-ldap-perl, libnet-dns-perl
Suggests: htop, vim, rsync, acpi-support-base, udisks2, archivemount
Suggests: htop, vim, rsync, acpi-support-base, udisks2
Conflicts: iptables-persistent
, moulinette-yunohost, yunohost-config
, yunohost-config-others, yunohost-config-postfix

View file

@ -1316,9 +1316,7 @@ class BackupMethod(object):
TarBackupMethod
---------------
This method compresses all files to backup in a .tar.gz archive. When
restoring, it tries to mount the archive using archivemount/fuse instead
of untaring the archive. Some systems don't support fuse (for these,
it automatically falls back to untaring the required parts).
restoring, it untars the required parts.
CustomBackupMethod
------------------
@ -1687,8 +1685,7 @@ class CopyBackupMethod(BackupMethod):
class TarBackupMethod(BackupMethod):
"""
This class compress all files to backup in archive. To restore it try to
mount the archive with archivemount (fuse). Some system don't support fuse.
This class compress all files to backup in archive.
"""
def __init__(self, repo=None):
@ -1760,8 +1757,6 @@ class TarBackupMethod(BackupMethod):
Exceptions:
backup_archive_open_failed -- Raised if the archive can't be open
backup_archive_mount_failed -- Raised if the system don't support
archivemount
"""
super(TarBackupMethod, self).mount(restore_manager)
@ -1776,16 +1771,6 @@ class TarBackupMethod(BackupMethod):
tar.close()
# Mount the tarball
try:
ret = subprocess.call(['archivemount', '-o', 'readonly',
self._archive_file, self.work_dir])
except:
ret = -1
# If archivemount failed, extract the archive
if ret != 0:
logger.warning(m18n.n('backup_archive_mount_failed'))
logger.debug(m18n.n("restore_extracting"))
tar = tarfile.open(self._archive_file, "r:gz")
tar.extract('info.json', path=self.work_dir)

View file

@ -101,9 +101,6 @@ def app_is_installed(app):
def backup_test_dependencies_are_met():
# We need archivemount installed for the backup features to work
assert os.system("which archivemount >/dev/null") == 0
# Dummy test apps (or backup archives)
assert os.path.exists("./tests/apps/backup_wordpress_from_2p4")
assert os.path.exists("./tests/apps/backup_legacy_app_ynh")
@ -250,42 +247,6 @@ def test_backup_and_restore_all_sys():
assert os.path.exists("/etc/ssowat/conf.json")
def test_backup_and_restore_archivemount_failure(monkeypatch, mocker):
# Create the backup
backup_create(ignore_system=False, ignore_apps=True)
archives = backup_list()["archives"]
assert len(archives) == 1
archives_info = backup_info(archives[0], with_details=True)
assert archives_info["apps"] == {}
assert (len(archives_info["system"].keys()) ==
len(os.listdir("/usr/share/yunohost/hooks/backup/")))
# Remove ssowat conf
assert os.path.exists("/etc/ssowat/conf.json")
os.system("rm -rf /etc/ssowat/")
assert not os.path.exists("/etc/ssowat/conf.json")
def custom_subprocess_call(*args, **kwargs):
import subprocess as subprocess2
if args[0] and args[0][0]=="archivemount":
monkeypatch.undo()
return 1
return subprocess.call(*args, **kwargs)
monkeypatch.setattr("subprocess.call", custom_subprocess_call)
mocker.spy(m18n, "n")
# Restore the backup
backup_restore(auth, name=archives[0], force=True,
ignore_system=False, ignore_apps=True)
# Check ssowat conf is back
assert os.path.exists("/etc/ssowat/conf.json")
###############################################################################
# System restore from 2.4 #
###############################################################################
@ -311,38 +272,6 @@ def test_restore_system_from_Ynh2p4(monkeypatch, mocker):
ignore_apps=True,
force=True)
@pytest.mark.with_system_archive_from_2p4
def test_restore_system_from_Ynh2p4_archivemount_failure(monkeypatch, mocker):
# Backup current system
backup_create(ignore_system=False, ignore_apps=True)
archives = backup_list()["archives"]
assert len(archives) == 2
def custom_subprocess_call(*args, **kwargs):
import subprocess as subprocess2
if args[0] and args[0][0]=="archivemount":
monkeypatch.undo()
return 1
return subprocess.call(*args, **kwargs)
monkeypatch.setattr("subprocess.call", custom_subprocess_call)
try:
# Restore system from 2.4
backup_restore(auth, name=backup_list()["archives"][1],
ignore_system=False,
ignore_apps=True,
force=True)
finally:
# Restore system as it was
backup_restore(auth, name=backup_list()["archives"][0],
ignore_system=False,
ignore_apps=True,
force=True)
###############################################################################
# App backup #
###############################################################################
@ -545,29 +474,6 @@ def test_restore_app_not_in_backup(mocker):
assert not _is_installed("yoloswag")
@pytest.mark.with_wordpress_archive_from_2p4
def test_restore_app_archivemount_failure(monkeypatch, mocker):
def custom_subprocess_call(*args, **kwargs):
import subprocess as subprocess2
if args[0] and args[0][0]=="archivemount":
monkeypatch.undo()
return 1
return subprocess.call(*args, **kwargs)
monkeypatch.setattr("subprocess.call", custom_subprocess_call)
mocker.spy(m18n, "n")
assert not _is_installed("wordpress")
backup_restore(auth, name=backup_list()["archives"][0],
ignore_system=True,
ignore_apps=False,
apps=["wordpress"])
assert _is_installed("wordpress")
@pytest.mark.with_wordpress_archive_from_2p4
def test_restore_app_already_installed(mocker):