From 8d3e9aaede03f3615e5afb82df4d9b530a06a5f0 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Fri, 18 Mar 2022 13:05:06 +0000 Subject: Makefile/set_versions: Allow poky.yaml to be autogenerated Use a script to generate the branch/tag information inside poky.yaml. If the branch isn't a known release branch, include git magic to find the closest matching release branch we know about. (From yocto-docs rev: 841e2df0e2e544b82fff9ddd0339a4e775148e3a) Signed-off-by: Richard Purdie --- documentation/.gitignore | 1 + documentation/Makefile | 1 + documentation/poky.yaml | 45 ---------------- documentation/poky.yaml.in | 45 ++++++++++++++++ documentation/set_versions.py | 120 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 167 insertions(+), 45 deletions(-) delete mode 100644 documentation/poky.yaml create mode 100644 documentation/poky.yaml.in create mode 100755 documentation/set_versions.py (limited to 'documentation') diff --git a/documentation/.gitignore b/documentation/.gitignore index 35ead8af66..e5e2c1708d 100644 --- a/documentation/.gitignore +++ b/documentation/.gitignore @@ -1,5 +1,6 @@ _build/ Pipfile.lock +poky.yaml .vscode/ */svg/*.png */svg/*.pdf diff --git a/documentation/Makefile b/documentation/Makefile index f04f381bd2..bec53399c0 100644 --- a/documentation/Makefile +++ b/documentation/Makefile @@ -57,4 +57,5 @@ all: html epub latexpdf # Catch-all target: route all unknown targets to Sphinx using the new # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). %: + $(SOURCEDIR)/set_versions.py @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/documentation/poky.yaml b/documentation/poky.yaml deleted file mode 100644 index 89a059ef1a..0000000000 --- a/documentation/poky.yaml +++ /dev/null @@ -1,45 +0,0 @@ -DISTRO : "3.4.2" -DISTRO_NAME_NO_CAP : "honister" -DISTRO_NAME : "Honister" -DISTRO_NAME_NO_CAP_MINUS_ONE : "hardknott" -DISTRO_NAME_NO_CAP_LTS : "dunfell" -YOCTO_DOC_VERSION : "3.4.2" -DISTRO_REL_TAG : "yocto-3.4.2" -YOCTO_DL_URL : "https://downloads.yoctoproject.org" -YOCTO_AB_URL : "https://autobuilder.yoctoproject.org" -YOCTO_RELEASE_DL_URL : "&YOCTO_DL_URL;/releases/yocto/yocto-&DISTRO;" -UBUNTU_HOST_PACKAGES_ESSENTIAL : "gawk wget git diffstat unzip texinfo gcc \ - build-essential chrpath socat cpio python3 python3-pip python3-pexpect \ - xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev \ - pylint3 xterm python3-subunit mesa-common-dev zstd liblz4-tool" -FEDORA_HOST_PACKAGES_ESSENTIAL : "gawk make wget tar bzip2 gzip python3 unzip perl patch \ - diffutils diffstat git cpp gcc gcc-c++ glibc-devel texinfo chrpath \ - ccache perl-Data-Dumper perl-Text-ParseWords perl-Thread-Queue perl-bignum socat \ - python3-pexpect findutils which file cpio python python3-pip xz python3-GitPython \ - python3-jinja2 SDL-devel xterm rpcgen mesa-libGL-devel perl-FindBin perl-File-Compare \ - perl-File-Copy perl-locale zstd lz4" -OPENSUSE_HOST_PACKAGES_ESSENTIAL : "python gcc gcc-c++ git chrpath make wget python-xml \ - diffstat makeinfo python-curses patch socat python3 python3-curses tar python3-pip \ - python3-pexpect xz which python3-Jinja2 Mesa-libEGL1 libSDL-devel xterm rpcgen Mesa-dri-devel \ - zstd lz4 - \n\ $ sudo pip3 install GitPython" -CENTOS7_HOST_PACKAGES_ESSENTIAL : "-y epel-release - \n\ $ sudo yum makecache - \n\ $ sudo yum install gawk make wget tar bzip2 gzip python3 unzip perl patch \ - diffutils diffstat git cpp gcc gcc-c++ glibc-devel texinfo chrpath socat \ - perl-Data-Dumper perl-Text-ParseWords perl-Thread-Queue python3-pip xz \ - which SDL-devel xterm mesa-libGL-devel zstd lz4 - \n\ $ sudo pip3 install GitPython jinja2" -CENTOS8_HOST_PACKAGES_ESSENTIAL : "-y epel-release - \n\ $ sudo dnf config-manager --set-enabled PowerTools - \n\ $ sudo dnf makecache - \n\ $ sudo dnf install gawk make wget tar bzip2 gzip python3 unzip perl patch \ - diffutils diffstat git cpp gcc gcc-c++ glibc-devel texinfo chrpath ccache \ - socat perl-Data-Dumper perl-Text-ParseWords perl-Thread-Queue python3-pip \ - python3-GitPython python3-jinja2 python3-pexpect xz which SDL-devel xterm \ - rpcgen mesa-libGL-devel zstd lz4" -PIP3_HOST_PACKAGES_DOC : "$ sudo pip3 install sphinx sphinx_rtd_theme pyyaml" -MIN_PYTHON_VERSION : "3.6.0" -MIN_TAR_VERSION : "1.28" -MIN_GIT_VERSION : "1.8.3.1" -MIN_GCC_VERSION : "5.0" diff --git a/documentation/poky.yaml.in b/documentation/poky.yaml.in new file mode 100644 index 0000000000..89a059ef1a --- /dev/null +++ b/documentation/poky.yaml.in @@ -0,0 +1,45 @@ +DISTRO : "3.4.2" +DISTRO_NAME_NO_CAP : "honister" +DISTRO_NAME : "Honister" +DISTRO_NAME_NO_CAP_MINUS_ONE : "hardknott" +DISTRO_NAME_NO_CAP_LTS : "dunfell" +YOCTO_DOC_VERSION : "3.4.2" +DISTRO_REL_TAG : "yocto-3.4.2" +YOCTO_DL_URL : "https://downloads.yoctoproject.org" +YOCTO_AB_URL : "https://autobuilder.yoctoproject.org" +YOCTO_RELEASE_DL_URL : "&YOCTO_DL_URL;/releases/yocto/yocto-&DISTRO;" +UBUNTU_HOST_PACKAGES_ESSENTIAL : "gawk wget git diffstat unzip texinfo gcc \ + build-essential chrpath socat cpio python3 python3-pip python3-pexpect \ + xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev \ + pylint3 xterm python3-subunit mesa-common-dev zstd liblz4-tool" +FEDORA_HOST_PACKAGES_ESSENTIAL : "gawk make wget tar bzip2 gzip python3 unzip perl patch \ + diffutils diffstat git cpp gcc gcc-c++ glibc-devel texinfo chrpath \ + ccache perl-Data-Dumper perl-Text-ParseWords perl-Thread-Queue perl-bignum socat \ + python3-pexpect findutils which file cpio python python3-pip xz python3-GitPython \ + python3-jinja2 SDL-devel xterm rpcgen mesa-libGL-devel perl-FindBin perl-File-Compare \ + perl-File-Copy perl-locale zstd lz4" +OPENSUSE_HOST_PACKAGES_ESSENTIAL : "python gcc gcc-c++ git chrpath make wget python-xml \ + diffstat makeinfo python-curses patch socat python3 python3-curses tar python3-pip \ + python3-pexpect xz which python3-Jinja2 Mesa-libEGL1 libSDL-devel xterm rpcgen Mesa-dri-devel \ + zstd lz4 + \n\ $ sudo pip3 install GitPython" +CENTOS7_HOST_PACKAGES_ESSENTIAL : "-y epel-release + \n\ $ sudo yum makecache + \n\ $ sudo yum install gawk make wget tar bzip2 gzip python3 unzip perl patch \ + diffutils diffstat git cpp gcc gcc-c++ glibc-devel texinfo chrpath socat \ + perl-Data-Dumper perl-Text-ParseWords perl-Thread-Queue python3-pip xz \ + which SDL-devel xterm mesa-libGL-devel zstd lz4 + \n\ $ sudo pip3 install GitPython jinja2" +CENTOS8_HOST_PACKAGES_ESSENTIAL : "-y epel-release + \n\ $ sudo dnf config-manager --set-enabled PowerTools + \n\ $ sudo dnf makecache + \n\ $ sudo dnf install gawk make wget tar bzip2 gzip python3 unzip perl patch \ + diffutils diffstat git cpp gcc gcc-c++ glibc-devel texinfo chrpath ccache \ + socat perl-Data-Dumper perl-Text-ParseWords perl-Thread-Queue python3-pip \ + python3-GitPython python3-jinja2 python3-pexpect xz which SDL-devel xterm \ + rpcgen mesa-libGL-devel zstd lz4" +PIP3_HOST_PACKAGES_DOC : "$ sudo pip3 install sphinx sphinx_rtd_theme pyyaml" +MIN_PYTHON_VERSION : "3.6.0" +MIN_TAR_VERSION : "1.28" +MIN_GIT_VERSION : "1.8.3.1" +MIN_GCC_VERSION : "5.0" diff --git a/documentation/set_versions.py b/documentation/set_versions.py new file mode 100755 index 0000000000..d48b8b74c7 --- /dev/null +++ b/documentation/set_versions.py @@ -0,0 +1,120 @@ +#!/usr/bin/env python3 +# +# Add version information to poky.yaml based upon current git branch/tags +# +# Copyright Linux Foundation +# Author: Richard Purdie +# +# SPDX-License-Identifier: MIT +# + + +import subprocess +import collections +import sys + +ourversion = None +if len(sys.argv) == 2: + ourversion = sys.argv[1] + +activereleases = ["honister", "hardknott", "gatesgarth", "dunfell", "zeus", "warrior"] +#devbranch = "langdale" +devbranch = "kirkstone" +ltsseries = ["kirkstone", "dunfell"] + +release_series = collections.OrderedDict() +#release_series["langdale"] = "4.1" +release_series["kirkstone"] = "4.0" +release_series["honister"] = "3.4" +release_series["hardknott"] = "3.3" +release_series["gatesgarth"] = "3.2" +release_series["dunfell"] = "3.1" + +ourversion = None +ourseries = None +ourbranch = None + +# Test tags exist and inform the user to fetch if not +try: + subprocess.run(["git", "show", "yocto-3.4.2"], capture_output=True, check=True) +except subprocess.CalledProcessError: + sys.exit("Please run 'git fetch --tags' before building the documentation") + +# Try and figure out what we are +tags = subprocess.run(["git", "tag", "--points-at", "HEAD"], capture_output=True, text=True).stdout +for t in tags.split(): + if t.startswith("yocto-"): + ourversion = t[6:] + +if ourversion: + # We're a tagged release + components = ourversion.split(".") + baseversion = components[0] + "." + components[1] + for i in release_series: + if release_series[i] == baseversion: + ourseries = i + ourbranch = i +else: + # We're floating on a branch + branch = subprocess.run(["git", "branch", "--show-current"], capture_output=True, text=True).stdout.strip() + ourbranch = branch + if branch != "master" and branch not in release_series: + possible_branches = [] + for b in release_series.keys(): + result = subprocess.run(["git", "show-ref", "heads/" + b], capture_output=True, text=True) + if result.returncode == 0: + possible_branches.append(b) + continue + result = subprocess.run(["git", "show-ref", "origin/" + b], capture_output=True, text=True) + if result.returncode == 0: + possible_branches.append("origin/" + b) + nearestbranch = subprocess.run('git show-branch master ' + ' '.join(possible_branches) + ' | grep "*" | grep -v "$(git rev-parse --abbrev-ref HEAD)" | head -n1', shell=True, capture_output=True, text=True).stdout + branch = nearestbranch.split('[')[1].split('~')[0] + print("Nearest release branch esimtated to be %s" % branch) + if branch == "master": + ourseries = devbranch + elif branch in release_series: + ourseries = branch + else: + sys.exit("Unknown series for branch %s" % branch) + + previoustags = subprocess.run(["git", "tag", "--merged", "HEAD"], capture_output=True, text=True).stdout + previoustags = [t[6:] for t in previoustags.split() if t.startswith("yocto-" + release_series[ourseries])] + futuretags = subprocess.run(["git", "tag", "--merged", ourbranch], capture_output=True, text=True).stdout + futuretags = [t[6:] for t in futuretags.split() if t.startswith("yocto-" + release_series[ourseries])] + + # Append .999 against the last known version + if len(previoustags) != len(futuretags): + ourversion = previoustags[-1] + ".999" + else: + ourversion = release_series[ourseries] + ".999" + +series = [k for k in release_series] +previousseries = series[series.index(ourseries)+1:] +lastlts = [k for k in previousseries if k in ltsseries] + +print("Version calculated to be %s" % ourversion) +print("Release series calculated to be %s" % ourseries) + +replacements = { + "DISTRO" : ourversion, + "DISTRO_NAME_NO_CAP" : ourseries, + "DISTRO_NAME" : ourseries.capitalize(), + "DISTRO_NAME_NO_CAP_MINUS_ONE" : previousseries[0], + "DISTRO_NAME_NO_CAP_LTS" : lastlts[0], + "YOCTO_DOC_VERSION" : ourversion, + "DISTRO_REL_TAG" : "yocto-" + ourversion, +} + +with open("poky.yaml.in", "r") as r, open("poky.yaml", "w") as w: + lines = r.readlines() + for line in lines: + data = line.split(":") + k = data[0].strip() + if k in replacements: + w.write("%s : \"%s\"\n" % (k, replacements[k])) + else: + w.write(line) + +print("poky.yaml generated from poky.yaml.in") + -- cgit v1.2.3-54-g00ecf