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/.
```
This commit is contained in:
Alexis Métaireau 2024-09-06 10:50:56 +02:00
parent 396c3b56c8
commit b375a7e96e
No known key found for this signature in database
GPG key ID: C65C7A89A8FFC56E
2 changed files with 24 additions and 6 deletions

View file

@ -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

View file

@ -1,2 +0,0 @@
*
!.gitignore