Compare commits

...

3 commits

Author SHA1 Message Date
Alex Pyrgiotis
0cfa86bf58
WIP: Everything works 2024-11-29 17:48:27 +02:00
Alex Pyrgiotis
f55607eb63
WIP: Don't clean git 2024-11-29 15:46:34 +02:00
Alex Pyrgiotis
b353b6c262
WIP: Fedora RPM works 2024-11-29 15:43:40 +02:00

217
dodo.py
View file

@ -31,22 +31,29 @@ PARAM_APPLE_ID = {
} }
def list_files(path): def list_files(path, recursive=False):
filepaths = [] filepaths = []
for root, _, files in os.walk(path): for root, _, files in os.walk(path):
for f in files: for f in files:
if f.endswith(".pyc"): if f.endswith(".pyc"):
continue continue
filepaths.append(Path(root) / f) filepaths.append(Path(root) / f)
if not recursive:
break
return filepaths return filepaths
def copy_dz_dir(src, dst): def copy_dz_dir(src, dst):
shutil.rmtree(dst) shutil.rmtree(dst, ignore_errors=True)
dst.mkdir(exist_ok=True)
shutil.copytree(src, dst) shutil.copytree(src, dst)
def create_release_dir():
RELEASE_DIR.mkdir(parents=True, exist_ok=True)
(RELEASE_DIR / "assets").mkdir(exist_ok=True)
(RELEASE_DIR / "tmp").mkdir(exist_ok=True)
def cmd_build_linux_pkg(distro, version, cwd, qubes=False): def cmd_build_linux_pkg(distro, version, cwd, qubes=False):
pkg = "rpm" if distro == "fedora" else "deb" pkg = "rpm" if distro == "fedora" else "deb"
cmd = [ cmd = [
@ -57,12 +64,13 @@ def cmd_build_linux_pkg(distro, version, cwd, qubes=False):
"--version", "--version",
version, version,
"run", "run",
"--dev" "--no-gui",
"--dev",
f"./dangerzone/install/linux/build-{pkg}.py" f"./dangerzone/install/linux/build-{pkg}.py"
] ]
if qubes: if qubes:
cmd += ["--qubes"] cmd += ["--qubes"]
return CmdAction(cmd, cwd=cwd) return CmdAction(" ".join(cmd), cwd=cwd)
def task_clean_container_runtime(): def task_clean_container_runtime():
@ -70,35 +78,24 @@ def task_clean_container_runtime():
return { return {
"actions": None, "actions": None,
"clean": [ "clean": [
[CONTAINER_RUNTIME, "system", "prune", "-f"], [CONTAINER_RUNTIME, "system", "prune", "-a", "-f"],
], ],
} }
def task_clean_git(): #def task_check_python():
"""Clean the Git repo.""" # """Check that the latest supported Python version is installed (WIP).
return { #
"actions": None, # This task does not work yet, and is currently short-circuited.
"clean": [ # """
"git clean -fdx", # def check_python_updated():
"git checkout -f", # # FIXME: Check that the latest supported Python release is installed. Use the
], # # same logic as we do in dev_scripts/qa.py.
} # return True
#
# return {
def task_check_python(): # "actions": [check_python_updated],
"""Check that the latest supported Python version is installed (WIP). # }
This task does not work yet, and is currently short-circuited.
"""
def check_python():
# FIXME: Check that the latest supported Python release is installed. Use the
# same logic as we do in dev_scripts/qa.py.
return True
return {
"actions": [check_python],
}
def task_check_container_runtime(): def task_check_container_runtime():
@ -116,7 +113,7 @@ def task_check_system():
return { return {
"actions": None, "actions": None,
"task_dep": [ "task_dep": [
"check_python", #"check_python",
"check_container_runtime", "check_container_runtime",
], ],
} }
@ -132,26 +129,26 @@ def task_macos_check_cert():
} }
def task_macos_check_docker_containerd(): #def task_macos_check_docker_containerd():
"""Test that Docker uses the containard image store.""" # """Test that Docker uses the containard image store."""
def check_containerd_store(): # def check_containerd_store():
cmd = ["docker", "info", "-f", "{{ .DriverStatus }}"] # cmd = ["docker", "info", "-f", "{{ .DriverStatus }}"]
driver = subprocess.check_output(cmd, text=True).strip() # driver = subprocess.check_output(cmd, text=True).strip()
if driver != "[[driver-type io.containerd.snapshotter.v1]]": # if driver != "[[driver-type io.containerd.snapshotter.v1]]":
raise RuntimeError( # raise RuntimeError(
f"Probing the Docker image store with {cmd} returned {driver}." # f"Probing the Docker image store with {cmd} returned {driver}."
" Switch to Docker's containerd image store from the Docker Desktop" # " Switch to Docker's containerd image store from the Docker Desktop"
" settings." # " settings."
) # )
#
return { # return {
"actions": [ # "actions": [
"which docker", # "which docker",
"docker ps", # "docker ps",
check_containerd_store, # check_containerd_store,
], # ],
"params": [PARAM_APPLE_ID], # "params": [PARAM_APPLE_ID],
} # }
def task_macos_check_system(): def task_macos_check_system():
@ -161,18 +158,13 @@ def task_macos_check_system():
"task_dep": [ "task_dep": [
"check_system", "check_system",
"macos_check_cert", "macos_check_cert",
"macos_check_docker_containerd", #"macos_check_docker_containerd",
], ],
} }
def task_init_release_dir(): def task_init_release_dir():
"""Create a directory for release artifacts.""" """Create a directory for release artifacts."""
def create_release_dir():
RELEASE_DIR.mkdir(parents=True, exist_ok=True)
(RELEASE_DIR / "assets").mkdir(exist_ok=True)
(RELEASE_DIR / "tmp").mkdir(exist_ok=True)
return { return {
"actions": [create_release_dir], "actions": [create_release_dir],
"clean": [f"rm -rf {RELEASE_DIR}"], "clean": [f"rm -rf {RELEASE_DIR}"],
@ -263,20 +255,21 @@ def task_macos_build_dmg():
f" --keychain-profile dz-notarytool-release-key {dmg_src}"), f" --keychain-profile dz-notarytool-release-key {dmg_src}"),
f"xcrun stapler staple {dmg_src}", f"xcrun stapler staple {dmg_src}",
["cp", "-r", dmg_src, dmg_dst], ["cp", "-r", dmg_src, dmg_dst],
["rm", "-r", dz_dir], ["rm", "-rf", dz_dir],
], ],
"params": [PARAM_APPLE_ID], "params": [PARAM_APPLE_ID],
"file_dep": [ "file_dep": [
"poetry.lock", "poetry.lock",
"install/macos/build.app.py", "install/macos/build-app.py",
*list_files("assets"), *list_files("assets"),
*list_files("share"), *list_files("share", recursive=True),
*list_files("dangerzone"), *list_files("dangerzone", recursive=True),
f"share/container-{VERSION}.tar.gz", f"share/container-{VERSION}.tar.gz",
], ],
"task_dep": [ "task_dep": [
"init_release_dir", "init_release_dir",
"poetry_install" "poetry_install",
"download_tessdata",
], ],
"targets": [dmg_dst], "targets": [dmg_dst],
"clean": True, "clean": True,
@ -314,6 +307,7 @@ def task_debian_env():
"build-dev", "build-dev",
] ]
], ],
"task_dep": ["check_container_runtime"],
} }
@ -328,14 +322,14 @@ def task_debian_deb():
(copy_dz_dir, [".", dz_dir]), (copy_dz_dir, [".", dz_dir]),
cmd_build_linux_pkg("debian", "bookworm", cwd=dz_dir), cmd_build_linux_pkg("debian", "bookworm", cwd=dz_dir),
["cp", deb_src, deb_dst], ["cp", deb_src, deb_dst],
["rm", "-r", dz_dir], ["rm", "-rf", dz_dir],
], ],
"file_dep": [ "file_dep": [
"poetry.lock", "poetry.lock",
"install/linux/build-deb.py", "install/linux/build-deb.py",
*list_files("assets"), *list_files("assets"),
*list_files("share"), *list_files("share"),
*list_files("dangerzone"), *list_files("dangerzone", recursive=True),
f"share/container-{VERSION}.tar.gz", f"share/container-{VERSION}.tar.gz",
], ],
"task_dep": [ "task_dep": [
@ -363,35 +357,35 @@ def task_fedora_env():
"build-dev", "build-dev",
], ],
], ],
"task_dep": ["check_container_runtime"],
} }
def task_fedora_rpm(): def task_fedora_rpm():
for version in FEDORA_VERSIONS: for version in FEDORA_VERSIONS:
dz_dir = RELEASE_DIR / "tmp" / f"f{version}" for qubes in (True, False):
qubes_ident = "-qubes" if qubes else ""
dz_dir = RELEASE_DIR / "tmp" / f"f{version}{qubes_ident}"
rpm_names = [ rpm_names = [
f"dangerzone-{VERSION}-1.fc{version}.x86_64.rpm", f"dangerzone{qubes_ident}-{VERSION}-1.fc{version}.x86_64.rpm",
f"dangerzone-{VERSION}-1.fc{version}.src.rpm", f"dangerzone{qubes_ident}-{VERSION}-1.fc{version}.src.rpm",
f"dangerzone-qubes-{VERSION}-1.fc{version}.x86_64.rpm",
f"dangerzone-qubes-{VERSION}-1.fc{version}.src.rpm",
] ]
rpm_src = [dz_dir / "dist" / rpm_name for rpm_name in rpm_names] rpm_src = [dz_dir / "dist" / rpm_name for rpm_name in rpm_names]
rpm_dst = [RELEASE_DIR / rpm_name for rpm_name in rpm_names] rpm_dst = [RELEASE_DIR / rpm_name for rpm_name in rpm_names]
yield { yield {
"name": version, "name": version + qubes_ident,
"actions": [ "actions": [
(copy_dz_dir, [".", dz_dir]), (copy_dz_dir, [".", dz_dir]),
cmd_build_linux_pkg("fedora", version, cwd=dz_dir), cmd_build_linux_pkg("fedora", version, cwd=dz_dir, qubes=qubes),
cmd_build_linux_pkg("fedora", version, cwd=dz_dir, qubes=True),
["cp", *rpm_src, RELEASE_DIR], ["cp", *rpm_src, RELEASE_DIR],
["rm", "-r", dz_dir], ["rm", "-rf", dz_dir],
], ],
"file_dep": [ "file_dep": [
"poetry.lock", "poetry.lock",
"install/linux/build-rpm.py", "install/linux/build-rpm.py",
*list_files("assets"), *list_files("assets"),
*list_files("share"), *list_files("share"),
*list_files("dangerzone"), *list_files("dangerzone", recursive=True),
f"share/container-{VERSION}.tar.gz", f"share/container-{VERSION}.tar.gz",
], ],
"task_dep": [ "task_dep": [
@ -403,40 +397,41 @@ def task_fedora_rpm():
} }
@task_params([{ #def copy_files(dz_dir, apt_dir, src, bookworm_deb, other_debs):
"name": "apt_tools_prod_dir", # # Delete previous Dangerzone files.
"default": "~/release/apt-tools-prod" # old_files = dz_dir.rglob("dangerzone_*j")
}]) # for f in old_files:
def task_apt_tools_prod_prep(apt_tools_prod_dir): # f.unlink()
apt_dir = Path(apt_tools_prod_dir).expanduser() #
dz_dir = apt_dir / "dangerzone" # # Delete DB entries.
# shutil.rmtree(apt_dir / "db")
src = task_debian_deb()["targets"][0] # shutil.rmtree(apt_dir / "public" / "dists")
deb_name = src.name # shutil.rmtree(apt_dir / "public" / "pool")
bookworm_deb = dz_dir / "bookworm" / deb_name #
other_debs = [dz_dir / version / deb_name for version in DEBIAN_VERSIONS] # # Copy .deb to bookworm folder.
# shutil.copy2(src, bookworm_deb)
def copy_files(): #
# Delete previous Dangerzone files. # # Create the necessary symlinks
old_files = dz_dir.rglob("dangerzone_*j") # for deb in other_debs:
for f in old_files: # deb.symlink_to(f"../bookworm/{deb_name}")
f.unlink() #
#
# Delete DB entries. #@task_params([{
shutil.rmtree(apt_dir / "db") # "name": "apt_tools_prod_dir",
shutil.rmtree(apt_dir / "public" / "dists") # "default": "~/release/apt-tools-prod"
shutil.rmtree(apt_dir / "public" / "pool") #}])
#def task_apt_tools_prod_prep(apt_tools_prod_dir):
# Copy .deb to bookworm folder. # apt_dir = Path(apt_tools_prod_dir).expanduser()
shutil.copy2(src, bookworm_deb) # dz_dir = apt_dir / "dangerzone"
#
# Create the necessary symlinks # src = task_debian_deb()["targets"][0]
for deb in other_debs: # deb_name = src.name
deb.symlink_to(f"../bookworm/{deb_name}") # bookworm_deb = dz_dir / "bookworm" / deb_name
# other_debs = [dz_dir / version / deb_name for version in DEBIAN_VERSIONS]
return { #
"actions": [copy_files], # return {
"file_dep": [src], # "actions": [(copy_files, [dz_dir, apt_dir, src, bookworm_deb, other_debs])],
"targets": [bookworm_deb, *other_debs], # "file_dep": [src],
"clean": True, # "targets": [bookworm_deb, *other_debs],
} # "clean": True,
# }