From b375a7e96e51b7d429a01d3a6b9611656393edb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexis=20M=C3=A9taireau?= Date: Fri, 6 Sep 2024 10:50:56 +0200 Subject: [PATCH] dev_scripts: store `env` data in the user's data dir. Previously, these files where stored inside the repository (under `dev_scripts/env/`), which could lead to conflicts with some tooling (black, debian-helper). (Linux only): as a convenience, here is how to move data to the new location: ```bash mkdir -p ~/.local/share/dangerzone-dev mv dev_scripts/envs/ ~/.local/share/dangerzone-dev/. ``` --- dev_scripts/env.py | 28 ++++++++++++++++++++++++---- dev_scripts/envs/.gitignore | 2 -- 2 files changed, 24 insertions(+), 6 deletions(-) delete mode 100644 dev_scripts/envs/.gitignore diff --git a/dev_scripts/env.py b/dev_scripts/env.py index 71c005b..61ba881 100755 --- a/dev_scripts/env.py +++ b/dev_scripts/env.py @@ -3,6 +3,7 @@ import argparse import os import pathlib +import platform import shutil import subprocess import sys @@ -272,9 +273,27 @@ def git_root(): return pathlib.Path(path) +def user_data(): + """Get the user data dir in (which differs on different OSes)""" + home = pathlib.Path.home() + system = platform.system() + + if system == "Windows": + return home / "AppData" / "Local" + elif system == "Linux": + return home / ".local" / "share" + elif system == "Darwin": + return home / "Library" / "Application Support" + + +def dz_dev_root(): + """Get the directory where we will store dangerzone-dev related files""" + return user_data() / "dangerzone-dev" + + def distro_root(distro, version): """Get the root directory for the specific Linux environment.""" - return git_root() / f"dev_scripts/envs/{distro}/{version}" + return dz_dev_root() / "envs" / distro / version def distro_state(distro, version): @@ -357,9 +376,10 @@ class PySide6Manager: file=sys.stderr, ) try: - with urllib.request.urlopen(self.rpm_url) as r, open( - self.rpm_local_path, "wb" - ) as f: + with ( + urllib.request.urlopen(self.rpm_url) as r, + open(self.rpm_local_path, "wb") as f, + ): shutil.copyfileobj(r, f) except: # NOTE: We purposefully catch all exceptions, since we want to catch Ctrl-C diff --git a/dev_scripts/envs/.gitignore b/dev_scripts/envs/.gitignore deleted file mode 100644 index d6b7ef3..0000000 --- a/dev_scripts/envs/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore