Skip to content

Commit

Permalink
Remove Tails 3.x admin virtualenv when upgrading to Tails 4.x
Browse files Browse the repository at this point in the history
Fixes #4910
  • Loading branch information
emkll committed Oct 16, 2019
1 parent b6c6d93 commit 7af7dba
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions admin/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import argparse
import logging
import os
import shutil
import subprocess
import sys

Expand Down Expand Up @@ -75,6 +76,32 @@ def is_tails():
return id == 'Tails'


def clean_up_tails3_venv():
"""
Tails 3.x, based on debian stretch uses libpython3.5, whereas Tails 4.x is
based on Debian Buster and uses libpython3.7. This means that the Tails 3.x
virtualenv will not work under Tails 4.x, and will need to be destroyed and
rebuilt. We can detect if the version of libpython is 3.5 in the
admin/.venv3/ folder, and delete it if that's the case. This will ensure a
smooth upgrade from Tails 3.x to Tails 4.x.
"""
if is_tails():
try:
dist = subprocess.check_output('lsb_release --codename --short',
shell=True).strip()
except subprocess.CalledProcessError:
dist = None

# tails4 is based on buster
if dist == 'buster':
python_lib_path = os.path.join(VENV_DIR, "lib/python3.5")
if os.path.exists(os.path.join(python_lib_path)):
sdlog.info("Tails 3 Python 3 virtualenv detected.")
shutil.rmtree(VENV_DIR)
sdlog.info("Tails 3 Python 3 virtualenv deleted. It will be "
"rebuilt to complete migration to Tails 4.x")


def maybe_torify():
if is_tails():
return ['torify']
Expand Down Expand Up @@ -130,6 +157,9 @@ def envsetup(args):
Ansible is available to the Admin on subsequent boots without requiring
installation of packages again.
"""
# clean up tails 3.x venv when migrating to tails 4.x
clean_up_tails3_venv()

# virtualenv doesnt exist? Install dependencies and create
if not os.path.exists(VENV_DIR):

Expand Down

0 comments on commit 7af7dba

Please sign in to comment.