Commit 606dbc55 authored by Zen Fu's avatar Zen Fu
Browse files

[weblate] Do not serve the deps update script (tails#17377)

In its previous location, the dependencies update script was being
served in the Puppet file server, but we don't need that, as such script
is meant to be executed in the admin machine to generate Puppet code.
parent a79afcb6
Update Puppet dependencies files
================================
We choose to install packages either from Debian packages or directly from
upstream repositories, because we don't have a way to verify packages
downloaded from Pypi.
The script in this directory extracts direct requirements of Weblate from its
repository, queries Pypi for package information, traverses Weblate's full
dependency tree, and generates Puppet code for declaring all dependencies.
Usage
-----
usage: update_puppet_dependency_files.py [-h] --weblate-version WEBLATE_VERSION
--debian-suite
{stretch,buster,bullseye}
--weblate-repo WEBLATE_REPO
--config-file CONFIG_FILE
optional arguments:
-h, --help show this help message and exit
--weblate-version WEBLATE_VERSION
What Weblate version.
--debian-suite {stretch,buster,bullseye}
Debian suite.
--weblate-repo WEBLATE_REPO
Path to Weblate repository.
--config-file CONFIG_FILE
Path to configuration file.
Configuration
-------------
It accepts a YAML configuration file containing a dict with the following
entries:
'skip': A list of packages to be skipped.
'require_pip': A list of packages that must be installed with pip.
'require_debian': A list of packages that must be installed from Debian.
'pip': A dictionary indexed by pip package names in which each item is
itself a dict that may contain a 'url', a 'repo_type', and a list
of additional conditions for the package version to be installed.
Example
-------
python3 ./update_puppet_dependecy_files.py \
--weblate-version 3.5.1 \
--debian-suite stretch \
--weblate-repo ~/weblate/
#!/usr/bin/env python3
"""
update_puppet_dependency_files.py
Description
-----------
This script reads the dependency tree of a specific version of Weblate and
builds Puppet manifests that declare Debian and Python packages. Extra
requirements are not taken into account when building such dependencies lists.
It accepts a YAML configuration file containing a dict with the following
entries:
'skip': A list of packages to be skipped.
'require_pip': A list of packages that must be installed with pip.
'require_debian': A list of packages that must be installed from Debian.
'pip': A dictionary indexed by pip package names in which each item is
itself a dict that may contain a 'url', a 'repo_type', and a list
of additional conditions for the package version to be installed.
Usage
-----
usage: update_puppet_dependecy_files.py [-h] --weblate-version WEBLATE_VERSION
--debian-suite
{stretch,buster,bullseye}
--weblate-repo WEBLATE_REPO
--config-file CONFIG_FILE
optional arguments:
-h, --help show this help message and exit
--weblate-version WEBLATE_VERSION
What Weblate version.
--debian-suite {stretch,buster,bullseye}
Debian suite.
--weblate-repo WEBLATE_REPO
Path to Weblate repository.
--config-file CONFIG_FILE
Path to configuration file.
"""
from bs4 import BeautifulSoup
......@@ -467,17 +429,20 @@ def main():
# Write Puppet manifest for Debian packages
template_file = pathlib.Path(__file__).with_name("debian_packages.pp").read_text()
script_path = pathlib.Path(__file__).parent
target_path = script_path.joinpath('../../')
template_file = script_path.joinpath("debian_packages.pp.tpl").read_text()
template = Template(template_file)
debian_depends = template.substitute(
WEBLATE_DEPENDS="',\n '".join(sorted(debian_needs)),
WEBLATE_VERSION= args.weblate_version,
)
pathlib.Path("manifests/weblate/debian_packages.pp").write_text(debian_depends)
target_path.joinpath("manifests/weblate/debian_packages.pp").write_text(debian_depends)
# Write Puppet manifest for Python packages
template_file = pathlib.Path(__file__).with_name("python_modules.pp").read_text()
template_file = script_path.joinpath("python_modules.pp.tpl").read_text()
template = Template(template_file)
via_pip = set((i.name for i in pip_needs))
pip_depends = []
......@@ -491,7 +456,7 @@ def main():
PIP_DEPENDS="\n ".join(pip_depends),
WEBLATE_VERSION= args.weblate_version,
)
pathlib.Path("manifests/weblate/python_modules.pp").write_text(python_modules)
target_path.joinpath("manifests/weblate/python_modules.pp").write_text(python_modules)
if __name__ == "__main__":
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment