Repository navigation
Expand file tree
/
Copy pathdebian.py
More file actions
52 lines (42 loc) · 1.87 KB
/
Copy pathdebian.py
File metadata and controls
52 lines (42 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from pathlib import Path
from subprocess import run
from src.common import dates
from src.common.endoflife import AutoConfig, ProductFrontmatter
from src.common.git import Git
from src.common.releasedata import ProductData
"""Fetch Debian versions by parsing news in www.debian.org source repository."""
def extract_major_versions(p: ProductData, repo_dir: Path) -> None:
child = run(
f"grep -RhE -A 1 '<define-tag pagetitle>Debian [0-9]+.+</q> released' {repo_dir}/english/News "
f"| cut -d '<' -f 2 "
f"| cut -d '>' -f 2 "
f"| grep -v -- '--'",
capture_output=True, timeout=300, check=True, shell=True)
is_release_line = True
version = None
for line in child.stdout.decode("utf-8").strip().split("\n"):
if is_release_line:
version = line.split(" ")[1]
is_release_line = False
else:
p.declare_version(version, dates.parse_date(line))
is_release_line = True
def extract_point_versions(p: ProductData, repo_dir: Path) -> None:
child = run(
f"grep -Rh -B 10 '<define-tag revision>' {repo_dir}/english/News "
"| grep -Eo '(release_date>(.*)<|revision>(.*)<)' "
"| cut -d '>' -f 2,4 "
"| tr -d '<' "
"| sed 's/[[:space:]]+/ /' "
"| paste -d ' ' - -",
capture_output=True, timeout=300, check=True, shell=True)
for line in child.stdout.decode("utf-8").strip().split("\n"):
(date, version) = line.split(' ')
p.declare_version(version, dates.parse_date(date))
def update(_product: ProductFrontmatter, config: AutoConfig) -> None:
with ProductData(config.product) as product_data:
git = Git(config.url)
git.setup()
git.checkout("master", file_list=["english/News"])
extract_major_versions(product_data, git.repo_dir)
extract_point_versions(product_data, git.repo_dir)