[debian] Refactor script (#221)
Make the script more readable, mostly by: - using the endoflife.Product class, - a little bit of renaming and documentation.
This commit is contained in:
@@ -1,63 +1,53 @@
|
||||
import subprocess
|
||||
from common import dates
|
||||
from common import endoflife
|
||||
from common.git import Git
|
||||
from subprocess import run
|
||||
|
||||
"""Fetch Debian versions with their dates from www.debian.org source repository.
|
||||
"""
|
||||
|
||||
PRODUCT = "debian"
|
||||
REPO_URL = "https://salsa.debian.org/webmaster-team/webwml.git"
|
||||
"""Fetch Debian versions by parsing news in www.debian.org source repository."""
|
||||
|
||||
|
||||
def extract_major_releases(releases, repo_dir):
|
||||
child = subprocess.Popen(
|
||||
def extract_major_versions(product, repo_dir):
|
||||
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 -- '--'",
|
||||
shell=True, stdout=subprocess.PIPE)
|
||||
output = child.communicate()[0].decode('utf-8')
|
||||
capture_output=True, timeout=300, check=True, shell=True)
|
||||
|
||||
is_release_line = True
|
||||
version = None
|
||||
for line in output.split('\n'):
|
||||
if line:
|
||||
if is_release_line:
|
||||
version = line.split(" ")[1]
|
||||
is_release_line = False
|
||||
else:
|
||||
date = line
|
||||
releases[version] = date
|
||||
print(f"{version}: {date}")
|
||||
is_release_line = True
|
||||
for line in child.stdout.decode("utf-8").strip().split("\n"):
|
||||
if is_release_line:
|
||||
version = line.split(" ")[1]
|
||||
is_release_line = False
|
||||
else:
|
||||
product.declare_version(version, dates.parse_date(line))
|
||||
is_release_line = True
|
||||
|
||||
|
||||
def extract_point_releases(releases, repo_dir):
|
||||
child = subprocess.Popen(
|
||||
def extract_point_versions(product, repo_dir):
|
||||
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 ' ' - -",
|
||||
shell=True, stdout=subprocess.PIPE)
|
||||
output = child.communicate()[0].decode('utf-8')
|
||||
capture_output=True, timeout=300, check=True, shell=True)
|
||||
|
||||
for line in output.split('\n'):
|
||||
if line:
|
||||
parts = line.split(' ')
|
||||
date = parts[0]
|
||||
version = parts[1]
|
||||
print(f"{version}: {date}")
|
||||
releases[version] = date
|
||||
for line in child.stdout.decode("utf-8").strip().split("\n"):
|
||||
(date, version) = line.split(' ')
|
||||
product.declare_version(version, dates.parse_date(date))
|
||||
|
||||
print(f"::group::{PRODUCT}")
|
||||
git = Git(REPO_URL)
|
||||
|
||||
product = endoflife.Product("debian")
|
||||
print(f"::group::{product.name}")
|
||||
git = Git("https://salsa.debian.org/webmaster-team/webwml.git")
|
||||
git.setup()
|
||||
git.checkout("master", file_list=["english/News"])
|
||||
|
||||
all_versions = {}
|
||||
extract_major_releases(all_versions, git.repo_dir)
|
||||
extract_point_releases(all_versions, git.repo_dir)
|
||||
endoflife.write_releases(PRODUCT, all_versions)
|
||||
extract_major_versions(product, git.repo_dir)
|
||||
extract_point_versions(product, git.repo_dir)
|
||||
|
||||
product.write()
|
||||
print("::endgroup::")
|
||||
|
||||
Reference in New Issue
Block a user