add script for containers building the documentation
v2 cover add script for containers building the documentation
Based on initial work done by Antonin Godard[1].
This does two things:
- move all the installation steps to fulfil the system requirements for each distro into separate files,
- add a script for using those separate files for building a container which allows to build the documentation within,
Note that only instructions for Debian Bookworm (12), Ubuntu 22.04 and 24.04, and Fedora 38, 39 and 40, currently work.
openSUSE seems to be running the sphinx build from a 3.6 Python interpreter which has an incompatible API with the Python calls used in Sphinx for our documentation. This is fixed/worked-around with this patch from Antonin:
https://lore.kernel.org/yocto-docs/[email protected]/
15.4, 15.5 and 15.6 tested with that patch applied.
Almalinux instructions are missing a bunch of packages and I reached a point where I couldn't find a package providing everysel.sty though texlive-ms seems to be providing it according to pkgs.org.
How far I went:
"""
diff --git a/documentation/tools/almalinux_host_packages_docs_pdf.sh b/documentation/tools/almalinux_host_packages_docs_pdf.sh
index 8341eb8c2..19f45312b 100644
--- a/documentation/tools/almalinux_host_packages_docs_pdf.sh
+++ b/documentation/tools/almalinux_host_packages_docs_pdf.sh
@@ -1 +1,5 @@
-sudo dnf install latexmk texlive-collection-fontsrecommended texlive-collection-latex texlive-collection-latexrecommended texlive-collection-xetex texlive-fncychap texlive-gnu-freefont texlive-tex-gyre texlive-xetex
+sudo dnf install -y epel-release
+sudo yum install dnf-plugins-core
+sudo dnf config-manager --set-enabled crb
+sudo dnf makecache
+sudo dnf install -y latexmk texlive-capt-of texlive-collection-fontsrecommended texlive-collection-latex texlive-collection-latexrecommended texlive-collection-xetex texlive-ctex texlive-fncychap texlive-framed texlive-gnu-freefont texlive-ms texlive-needspace texlive-tabulary texlive-tex-gyre texlive-upquote texlive-wrapfig texlive-xetex
"""
Note the dnf install -y for the packages is required for installing the GPG key of one of the repos noninteractively.
Older Debian and Ubuntu both lack python3-saneyaml and similar Python packages in their packagefeed.
Ubuntu 23.04 package feed isn't accessible anymore.
Note that this script cannot be run in parallel right now as all containers would be sharing the same build directory. This could be mitigated by allowing BUILDDIR to be overridden from the environment before being used by make and have it overridden by the script to a different location. There are probably other corner cases not handled (likely concurrent set_versions.py for example?).
[1] https://lore.kernel.org/yocto-docs/[email protected]/
[2] https://lore.kernel.org/yocto-docs/[email protected]/
---
Changes in v2:
- rebase on master,
- fix issues for recent Ubuntu by setting the timezone,
- add support for building pdf docs from within container,
- fix support for passing multiple make targets to the script
- have all pip3-packages-requiring-distros use one file to make it easier to maintain,
- put scripts into a dedicated repo,
- rename variables and filenames to remove host_packages/packages from them to make things a bit more digest,
- fix incorrect comment in script about reading poky.yaml.in,
- Link to v1: https://lore.kernel.org/r/20241210-instructions-shell-container-v1-0-6a7cdc404ff4@cherry.de
---
Quentin Schulz (2):
docs: use literalinclude for system requirements
tools: add script for building documentation inside containers
documentation/poky.yaml.in | 234 --------------------- documentation/ref-manual/system-requirements.rst | 82 +++++--- documentation/tools/Containerfile.almalinux | 1 + documentation/tools/Containerfile.apt | 26 +++ documentation/tools/Containerfile.debian | 1 + documentation/tools/Containerfile.dnf | 25 +++ documentation/tools/Containerfile.fedora | 1 + documentation/tools/Containerfile.ubuntu | 1 + documentation/tools/Containerfile.zypper | 24 +++ documentation/tools/build-docs-container | 113 ++++++++++ .../tools/host_packages_scripts/almalinux_docs.sh | 1 + .../host_packages_scripts/almalinux_docs_pdf.sh | 1 + .../host_packages_scripts/almalinux_essential.sh | 5 + .../tools/host_packages_scripts/fedora_docs.sh | 1 + .../tools/host_packages_scripts/fedora_docs_pdf.sh | 1 + .../host_packages_scripts/fedora_essential.sh | 1 + .../tools/host_packages_scripts/opensuse_docs.sh | 1 + .../host_packages_scripts/opensuse_docs_pdf.sh | 1 + .../host_packages_scripts/opensuse_essential.sh | 2 + .../tools/host_packages_scripts/pip3_docs.sh | 1 + .../tools/host_packages_scripts/ubuntu_docs.sh | 1 + .../tools/host_packages_scripts/ubuntu_docs_pdf.sh | 1 + .../host_packages_scripts/ubuntu_essential.sh | 1 + 23 files changed, 257 insertions(+), 269 deletions(-)
---
base-commit: 02c090718ac602f7d4760dd28dadbf0631668d49
change-id: 20241210-instructions-shell-container-c5a84c043a35
Best regards,
Signature · 1 line
Quentin Schulz <[email protected]>
RFC PATCH v2 1/2 docs: use literalinclude for system requirements
From: Quentin Schulz <[email protected]>
The YAML variables for the host dependencies are updated by hand and actually only used inside code blocks.
Let's migrate all instructions into separate shell scripts that are then literalinclude'd into the Sphinx documentation.
This allows a few things:
- ability to run shellcheck on the scripts if we ever want to
- manually calling the appropriate script from a supported distro to build stuff (distro or bitbake/yocto stuff)
- use this script to create containers to do CI of documentation on different distros, to make sure our instructions are all up to date,
--- documentation/poky.yaml.in | 234 --------------------- documentation/ref-manual/system-requirements.rst | 82 +++++--- .../tools/host_packages_scripts/almalinux_docs.sh | 1 + .../host_packages_scripts/almalinux_docs_pdf.sh | 1 + .../host_packages_scripts/almalinux_essential.sh | 5 + .../tools/host_packages_scripts/fedora_docs.sh | 1 + .../tools/host_packages_scripts/fedora_docs_pdf.sh | 1 + .../host_packages_scripts/fedora_essential.sh | 1 + .../tools/host_packages_scripts/opensuse_docs.sh | 1 + .../host_packages_scripts/opensuse_docs_pdf.sh | 1 + .../host_packages_scripts/opensuse_essential.sh | 2 + .../tools/host_packages_scripts/pip3_docs.sh | 1 + .../tools/host_packages_scripts/ubuntu_docs.sh | 1 + .../tools/host_packages_scripts/ubuntu_docs_pdf.sh | 1 + .../host_packages_scripts/ubuntu_essential.sh | 1 + 15 files changed, 65 insertions(+), 269 deletions(-)
documentation/poky.yaml.in +0 -234
@@ -25,237 +25,3 @@ MIN_DISK_SPACE : "90" MIN_DISK_SPACE_RM_WORK : "40" # RAM (Gbytes) needed to generate qemux86-64 core-image-sato on Ubuntu 22.04 (x86-64) on a 4 core system MIN_RAM : "8" - -# -# Dependencies -# - -# Shared between distros -PIP3_HOST_PACKAGES_DOC: sphinx sphinx_rtd_theme pyyaml - -UBUNTU_DEBIAN_HOST_PACKAGES_ESSENTIAL: >- - build-essential - chrpath - cpio - debianutils - diffstat - file - gawk - gcc - git - iputils-ping - libacl1 - liblz4-tool - locales - python3 - python3-git - python3-jinja2 - python3-pexpect - python3-pip - python3-subunit - socat - texinfo - unzip - wget - xz-utils - zstd - -UBUNTU_DEBIAN_HOST_PACKAGES_DOC: >- - git - librsvg2-bin - locales - make - python3-saneyaml - python3-sphinx-rtd-theme - sphinx - -UBUNTU_DEBIAN_HOST_PACKAGES_DOC_PDF: >- - fonts-freefont-otf - latexmk - tex-gyre - texlive-fonts-extra - texlive-fonts-recommended - texlive-lang-all - texlive-latex-extra - texlive-latex-recommended - texlive-xetex - -FEDORA_HOST_PACKAGES_ESSENTIAL: >- - bzip2 - ccache - chrpath - cpio - cpp - diffstat - diffutils - file - findutils - gawk - gcc - gcc-c++ - git - glibc-devel - glibc-langpack-en - gzip - hostname - libacl - lz4 - make - patch - perl - perl-Data-Dumper - perl-File-Compare - perl-File-Copy - perl-FindBin - perl-Text-ParseWords - perl-Thread-Queue - perl-bignum - perl-locale - python - python3 - python3-GitPython - python3-jinja2 - python3-pexpect - python3-pip - rpcgen - socat - tar - texinfo - unzip - wget - which - xz - zstd - -FEDORA_HOST_PACKAGES_DOC: >- - git - glibc-locale-source - librsvg2-tools - make - python3-pip - which - -FEDORA_HOST_PACKAGES_DOC_PDF: >- - 'texlive-collection-lang*' - latexmk - texlive-collection-fontsextra - texlive-collection-fontsrecommended - texlive-collection-latex - texlive-collection-latexextra - texlive-collection-latexrecommended - texlive-collection-xetex - texlive-fncychap - texlive-gnu-freefont - texlive-tex-gyre - texlive-xetex - -OPENSUSE_HOST_PACKAGES_ESSENTIAL: >- - bzip2 - chrpath - diffstat - gcc - gcc-c++ - git - gzip - hostname - libacl1 - lz4 - make - makeinfo - patch - python - python-curses - python-xml - python3 - python3-Jinja2 - python3-curses - python3-pexpect - python3-pip - rpcgen - socat - tar - wget - which - xz - zstd - -OPENSUSE_PIP3_HOST_PACKAGES_ESSENTIAL: GitPython - -OPENSUSE_HOST_PACKAGES_DOC: >- - git - glibc-i18ndata - make - python3-pip - rsvg-convert - which - -OPENSUSE_HOST_PACKAGES_DOC_PDF: >- - 'texlive-collection-lang*' - texlive-collection-fontsextra - texlive-collection-fontsrecommended - texlive-collection-latex - texlive-collection-latexextra - texlive-collection-latexrecommended - texlive-collection-xetex - texlive-fncychap - texlive-gnu-freefont - texlive-latexmk - texlive-tex-gyre - texlive-xetex - -ALMALINUX_HOST_PACKAGES_ESSENTIAL: >- - bzip2 - ccache - chrpath - cpio - cpp - diffstat - diffutils - gawk - gcc - gcc-c++ - git - glibc-devel - glibc-langpack-en - gzip - libacl - lz4 - make - patch - perl - perl-Data-Dumper - perl-Text-ParseWords - perl-Thread-Queue - python3 - python3-GitPython - python3-jinja2 - python3-pexpect - python3-pip - rpcgen - socat - tar - texinfo - unzip - wget - which - xz - zstd - -ALMALINUX_HOST_PACKAGES_DOC: >- - git - glibc-locale-source - librsvg2-tools - make - python3-pip - which - -ALMALINUX_HOST_PACKAGES_DOC_PDF: >- - latexmk - texlive-collection-fontsrecommended - texlive-collection-latex - texlive-collection-latexrecommended - texlive-collection-xetex - texlive-fncychap - texlive-gnu-freefont - texlive-tex-gyre - texlive-xetex
documentation/ref-manual/system-requirements.rst +47 -35
141 lines not on this page · raw message
documentation/tools/host_packages_scripts/almalinux_docs.sh new file +1 -0
@@ -0,0 +1 @@ +sudo dnf install git glibc-locale-source librsvg2-tools make python3-pip which
documentation/tools/host_packages_scripts/almalinux_docs_pdf.sh new file +1 -0
@@ -0,0 +1 @@ +sudo dnf install latexmk texlive-collection-fontsrecommended texlive-collection-latex texlive-collection-latexrecommended texlive-collection-xetex texlive-fncychap texlive-gnu-freefont texlive-tex-gyre texlive-xetex
documentation/tools/host_packages_scripts/almalinux_essential.sh new file +5 -0
@@ -0,0 +1,5 @@ +sudo dnf install -y epel-release +sudo yum install dnf-plugins-core +sudo dnf config-manager --set-enabled crb +sudo dnf makecache +sudo dnf install bzip2 ccache chrpath cpio cpp diffstat diffutils gawk gcc gcc-c++ git glibc-devel glibc-langpack-en gzip libacl lz4 make patch perl perl-Data-Dumper perl-Text-ParseWords perl-Thread-Queue python3 python3-GitPython python3-jinja2 python3-pexpect python3-pip rpcgen socat tar texinfo unzip wget which xz zstd
documentation/tools/host_packages_scripts/fedora_docs.sh new file +1 -0
@@ -0,0 +1 @@ +sudo dnf install git glibc-locale-source librsvg2-tools make python3-pip which
documentation/tools/host_packages_scripts/fedora_docs_pdf.sh new file +1 -0
@@ -0,0 +1 @@ +sudo dnf install 'texlive-collection-lang*' latexmk texlive-collection-fontsextra texlive-collection-fontsrecommended texlive-collection-latex texlive-collection-latexextra texlive-collection-latexrecommended texlive-collection-xetex texlive-fncychap texlive-gnu-freefont texlive-tex-gyre texlive-xetex
documentation/tools/host_packages_scripts/fedora_essential.sh new file +1 -0
@@ -0,0 +1 @@ +sudo dnf install bzip2 ccache chrpath cpio cpp diffstat diffutils file findutils gawk gcc gcc-c++ git glibc-devel glibc-langpack-en gzip hostname libacl lz4 make patch perl perl-Data-Dumper perl-File-Compare perl-File-Copy perl-FindBin perl-Text-ParseWords perl-Thread-Queue perl-bignum perl-locale python python3 python3-GitPython python3-jinja2 python3-pexpect python3-pip rpcgen socat tar texinfo unzip wget which xz zstd
documentation/tools/host_packages_scripts/opensuse_docs.sh new file +1 -0
@@ -0,0 +1 @@ +sudo zypper install git glibc-i18ndata make python3-pip rsvg-convert which
documentation/tools/host_packages_scripts/opensuse_docs_pdf.sh new file +1 -0
@@ -0,0 +1 @@ +sudo zypper install 'texlive-collection-lang*' texlive-collection-fontsextra texlive-collection-fontsrecommended texlive-collection-latex texlive-collection-latexextra texlive-collection-latexrecommended texlive-collection-xetex texlive-fncychap texlive-gnu-freefont texlive-latexmk texlive-tex-gyre texlive-xetex
documentation/tools/host_packages_scripts/opensuse_essential.sh new file +2 -0
@@ -0,0 +1,2 @@ +sudo zypper install bzip2 chrpath diffstat gcc gcc-c++ git gzip hostname libacl1 lz4 make makeinfo patch python python-curses python-xml python3 python3-Jinja2 python3-curses python3-pexpect python3-pip rpcgen socat tar wget which xz zstd +sudo pip3 install GitPython
documentation/tools/host_packages_scripts/pip3_docs.sh new file +1 -0
@@ -0,0 +1 @@ +sudo pip3 install sphinx sphinx_rtd_theme pyyaml
documentation/tools/host_packages_scripts/ubuntu_docs.sh new file +1 -0
@@ -0,0 +1 @@ +sudo apt install git librsvg2-bin locales make python3-saneyaml python3-saneyaml python3-sphinx-rtd-theme sphinx
documentation/tools/host_packages_scripts/ubuntu_docs_pdf.sh new file +1 -0
@@ -0,0 +1 @@ +sudo apt install fonts-freefont-otf latexmk tex-gyre texlive-fonts-extra texlive-fonts-recommended texlive-lang-all texlive-latex-extra texlive-latex-recommended texlive-xetex
documentation/tools/host_packages_scripts/ubuntu_essential.sh new file +1 -0
@@ -0,0 +1 @@ +sudo apt-get install build-essential chrpath cpio debianutils diffstat file gawk gcc git iputils-ping libacl1 liblz4-tool locales python3 python3-git python3-jinja2 python3-pexpect python3-pip python3-subunit socat texinfo unzip wget xz-utils zstd
Signature · 1 line
2.47.1
RFC PATCH v2 2/2 tools: add script for building documentation inside containers
In reply to Quentin SchulzFrom: Quentin Schulz <[email protected]>
This adds a script for building a container and building the documentation within that new container image.
The openSUSE instructions now require a --non-interactive flag otherwise they fail to run. Sadly there doesn't seem to be a way to have this in an environment variable à-la DEBIAN_FRONTEND=noninteractive.
Somehow tzdata package in Ubuntu doesn't respect DEBIAN_FRONTEND=noninteractive hence why the timezone needs to be set by hand.
Note that only instructions for Debian Bookworm (12), Ubuntu 22.04 and 24.04, and Fedora 38, 39 and 40, currently work.
--- documentation/tools/Containerfile.almalinux | 1 + documentation/tools/Containerfile.apt | 26 +++++ documentation/tools/Containerfile.debian | 1 + documentation/tools/Containerfile.dnf | 25 +++++ documentation/tools/Containerfile.fedora | 1 + documentation/tools/Containerfile.ubuntu | 1 + documentation/tools/Containerfile.zypper | 24 +++++ documentation/tools/build-docs-container | 113 +++++++++++++++++++++ .../tools/host_packages_scripts/opensuse_docs.sh | 2 +- .../host_packages_scripts/opensuse_docs_pdf.sh | 2 +- .../host_packages_scripts/opensuse_essential.sh | 2 +- 11 files changed, 195 insertions(+), 3 deletions(-)
documentation/tools/Containerfile.almalinux new file +1 -0
@@ -0,0 +1 @@ +Containerfile.dnf
documentation/tools/Containerfile.apt new file +26 -0
@@ -0,0 +1,26 @@ +ARG ARG_FROM=debian:12 # default value to avoid warning +FROM $ARG_FROM + +ARG DOCS=ubuntu_docs.sh +ARG DOCS_PDF=ubuntu_docs_pdf.sh + +ENV DEBIAN_FRONTEND=noninteractive +ARG TZ=Europe/Vienna + +# relative to the location of the dockerfile +COPY --chmod=777 ${DOCS} /temp/host_packages_docs.sh +COPY --chmod=777 ${DOCS_PDF} /temp/host_packages_docs_pdf.sh + +RUN ln -fs "/usr/share/zoneinfo/$TZ" /etc/localtime \ + && apt-get update \ + && apt-get install -y sudo \ + && yes | /temp/host_packages_docs.sh \ + && yes | /temp/host_packages_docs_pdf.sh \ + && apt-get --yes autoremove \ + && apt-get clean \ + && rm -rf /temp + +RUN git config --global --add safe.directory /docs + +ENTRYPOINT ["/usr/bin/env", "make", "-C", "documentation/"] +CMD ["publish"]
documentation/tools/Containerfile.debian new file +1 -0
@@ -0,0 +1 @@ +Containerfile.apt
documentation/tools/Containerfile.dnf new file +25 -0
@@ -0,0 +1,25 @@ +ARG ARG_FROM=fedora:40 # default value to avoid warning +FROM $ARG_FROM + +ARG DOCS=fedora_docs.sh +ARG DOCS_PDF=fedora_docs_pdf.sh +ARG PIP3=pip3_docs.sh + +# relative to the location of the dockerfile +COPY --chmod=777 ${DOCS} /temp/host_packages_docs.sh +COPY --chmod=777 ${DOCS_PDF} /temp/host_packages_docs_pdf.sh +COPY --chmod=777 ${PIP3} /temp/pip3_docs.sh + +RUN dnf update -y \ + && dnf install -y sudo \ + && yes | /temp/host_packages_docs.sh \ + && yes | /temp/host_packages_docs_pdf.sh \ + && yes | /temp/pip3_docs.sh \ + && dnf autoremove -y \ + && dnf clean all -y \ + && rm -rf /temp + +RUN git config --global --add safe.directory /docs + +ENTRYPOINT ["/usr/bin/env", "make", "-C", "documentation/"] +CMD ["publish"]
documentation/tools/Containerfile.fedora new file +1 -0
@@ -0,0 +1 @@ +Containerfile.dnf
documentation/tools/Containerfile.ubuntu new file +1 -0
@@ -0,0 +1 @@ +Containerfile.apt
documentation/tools/Containerfile.zypper new file +24 -0
@@ -0,0 +1,24 @@ +ARG ARG_FROM=opensuse/leap:15.4 # default value to avoid warning +FROM $ARG_FROM + +ARG DOCS=opensuse_docs.sh +ARG DOCS_PDF=opensuse_docs_pdf.sh +ARG PIP3=pip3_docs.sh + +# relative to the location of the dockerfile +COPY --chmod=777 ${DOCS} /temp/host_packages_docs.sh +COPY --chmod=777 ${DOCS_PDF} /temp/host_packages_docs_pdf.sh +COPY --chmod=777 ${PIP3} /temp/pip3_docs.sh + +RUN zypper update -y \ + && zypper install -y sudo \ + && yes | /temp/host_packages_docs.sh \ + && yes | /temp/host_packages_docs_pdf.sh \ + && yes | /temp/pip3_docs.sh \ + && zypper clean --all \ + && rm -rf /temp + +RUN git config --global --add safe.directory /docs + +ENTRYPOINT ["/usr/bin/env", "make", "-C", "documentation/"] +CMD ["publish"]
documentation/tools/build-docs-container new file +113 -0
113 lines not on this page · raw message
documentation/tools/host_packages_scripts/opensuse_docs.sh +1 -1
@@ -1 +1 @@ -sudo zypper install git glibc-i18ndata make python3-pip rsvg-convert which +sudo zypper --non-interactive install git glibc-i18ndata make python3-pip rsvg-convert which
documentation/tools/host_packages_scripts/opensuse_docs_pdf.sh +1 -1
@@ -1 +1 @@ -sudo zypper install 'texlive-collection-lang*' texlive-collection-fontsextra texlive-collection-fontsrecommended texlive-collection-latex texlive-collection-latexextra texlive-collection-latexrecommended texlive-collection-xetex texlive-fncychap texlive-gnu-freefont texlive-latexmk texlive-tex-gyre texlive-xetex +sudo zypper --non-interactive install 'texlive-collection-lang*' texlive-collection-fontsextra texlive-collection-fontsrecommended texlive-collection-latex texlive-collection-latexextra texlive-collection-latexrecommended texlive-collection-xetex texlive-fncychap texlive-gnu-freefont texlive-latexmk texlive-tex-gyre texlive-xetex
documentation/tools/host_packages_scripts/opensuse_essential.sh +1 -1
@@ -1,2 +1,2 @@ -sudo zypper install bzip2 chrpath diffstat gcc gcc-c++ git gzip hostname libacl1 lz4 make makeinfo patch python python-curses python-xml python3 python3-Jinja2 python3-curses python3-pexpect python3-pip rpcgen socat tar wget which xz zstd +sudo zypper --non-interactive install bzip2 chrpath diffstat gcc gcc-c++ git gzip hostname libacl1 lz4 make makeinfo patch python python-curses python-xml python3 python3-Jinja2 python3-curses python3-pexpect python3-pip rpcgen socat tar wget which xz zstd sudo pip3 install GitPython
Signature · 1 line
2.47.1
Re: [docs] [PATCH RFC v2 2/2] tools: add script for building documentation inside containers
Hi Quentin,
Quoted 8 lines · Quentin Schulz
From: Quentin Schulz <[email protected]>
This adds a script for building a container and building the documentation within that new container image.
The openSUSE instructions now require a --non-interactive flag otherwise they fail to run. Sadly there doesn't seem to be a way to have this in an environment variable à-la DEBIAN_FRONTEND=noninteractive.
Hmm, this means that we end up instructing to pass "--non-interactive" in the docs? That's not ideal :/ I suggested a workaround below.
I hope there won't be too many cases where we have to do things differently in the context of a containerfile in the future. Apart from this case I cannot think of anything else that could happen. Anything comes to mind for you?
Quoted 124 lines
Somehow tzdata package in Ubuntu doesn't respect DEBIAN_FRONTEND=noninteractive hence why the timezone needs to be set by hand.
Note that only instructions for Debian Bookworm (12), Ubuntu 22.04 and 24.04, and Fedora 38, 39 and 40, currently work.
Signed-off-by Quentin Schulz <[email protected]>--- documentation/tools/Containerfile.almalinux | 1 + documentation/tools/Containerfile.apt | 26 +++++ documentation/tools/Containerfile.debian | 1 + documentation/tools/Containerfile.dnf | 25 +++++ documentation/tools/Containerfile.fedora | 1 + documentation/tools/Containerfile.ubuntu | 1 + documentation/tools/Containerfile.zypper | 24 +++++ documentation/tools/build-docs-container | 113 +++++++++++++++++++++ .../tools/host_packages_scripts/opensuse_docs.sh | 2 +- .../host_packages_scripts/opensuse_docs_pdf.sh | 2 +- .../host_packages_scripts/opensuse_essential.sh | 2 +- 11 files changed, 195 insertions(+), 3 deletions(-)documentation/tools/Containerfile.almalinux new file +1
-0@@ -0,0 +1 @@ +Containerfile.dnfdocumentation/tools/Containerfile.apt new file +26
-0@@ -0,0 +1,26 @@ +ARG ARG_FROM=debian:12 # default value to avoid warning +FROM $ARG_FROM + +ARG DOCS=ubuntu_docs.sh +ARG DOCS_PDF=ubuntu_docs_pdf.sh + +ENV DEBIAN_FRONTEND=noninteractive +ARG TZ=Europe/Vienna + +# relative to the location of the dockerfile +COPY --chmod=777 ${DOCS} /temp/host_packages_docs.sh +COPY --chmod=777 ${DOCS_PDF} /temp/host_packages_docs_pdf.sh + +RUN ln -fs "/usr/share/zoneinfo/$TZ" /etc/localtime \ + && apt-get update \ + && apt-get install -y sudo \ + && yes | /temp/host_packages_docs.sh \ + && yes | /temp/host_packages_docs_pdf.sh \ + && apt-get --yes autoremove \ + && apt-get clean \ + && rm -rf /temp + +RUN git config --global --add safe.directory /docs + +ENTRYPOINT ["/usr/bin/env", "make", "-C", "documentation/"] +CMD ["publish"]documentation/tools/Containerfile.debian new file +1
-0@@ -0,0 +1 @@ +Containerfile.aptdocumentation/tools/Containerfile.dnf new file +25
-0@@ -0,0 +1,25 @@ +ARG ARG_FROM=fedora:40 # default value to avoid warning +FROM $ARG_FROM + +ARG DOCS=fedora_docs.sh +ARG DOCS_PDF=fedora_docs_pdf.sh +ARG PIP3=pip3_docs.sh + +# relative to the location of the dockerfile +COPY --chmod=777 ${DOCS} /temp/host_packages_docs.sh +COPY --chmod=777 ${DOCS_PDF} /temp/host_packages_docs_pdf.sh +COPY --chmod=777 ${PIP3} /temp/pip3_docs.sh + +RUN dnf update -y \ + && dnf install -y sudo \ + && yes | /temp/host_packages_docs.sh \ + && yes | /temp/host_packages_docs_pdf.sh \ + && yes | /temp/pip3_docs.sh \ + && dnf autoremove -y \ + && dnf clean all -y \ + && rm -rf /temp + +RUN git config --global --add safe.directory /docs + +ENTRYPOINT ["/usr/bin/env", "make", "-C", "documentation/"] +CMD ["publish"]documentation/tools/Containerfile.fedora new file +1
-0@@ -0,0 +1 @@ +Containerfile.dnfdocumentation/tools/Containerfile.ubuntu new file +1
-0@@ -0,0 +1 @@ +Containerfile.aptdocumentation/tools/Containerfile.zypper new file +1
-0@@ -0,0 +1,24 @@ +ARG ARG_FROM=opensuse/leap:15.4 # default value to avoid warning
documentation/tools/Containerfile.zypper line 11
Quoted 10 lines
documentation/tools/Containerfile.zypper new file +10
-0+FROM $ARG_FROM + +ARG DOCS=opensuse_docs.sh +ARG DOCS_PDF=opensuse_docs_pdf.sh +ARG PIP3=pip3_docs.sh + +# relative to the location of the dockerfile +COPY --chmod=777 ${DOCS} /temp/host_packages_docs.sh +COPY --chmod=777 ${DOCS_PDF} /temp/host_packages_docs_pdf.sh +COPY --chmod=777 ${PIP3} /temp/pip3_docs.sh
A bit of a hacky workaround, but maybe here run
sed -i 's/zypper/zypper --non-interactive/ ...' on the scripts? So we don't need to provide this option in the doc.
Quoted 37 lines
documentation/tools/Containerfile.zypper new file +13
-0+ +RUN zypper update -y \ + && zypper install -y sudo \ + && yes | /temp/host_packages_docs.sh \ + && yes | /temp/host_packages_docs_pdf.sh \ + && yes | /temp/pip3_docs.sh \ + && zypper clean --all \ + && rm -rf /temp + +RUN git config --global --add safe.directory /docs + +ENTRYPOINT ["/usr/bin/env", "make", "-C", "documentation/"] +CMD ["publish"]documentation/tools/build-docs-container new file +18
-0@@ -0,0 +1,113 @@ +#!/usr/bin/env bash +# +# Build a container ready to build the documentation be reading the dependencies +# listed in shell scripts in documentation/tools/host_packages_scripts, and +# start a documentation build in this container. +# +# Usage: +# +# ./documentation/tools/build-docs-container <image> [<make target>] +# +# e.g.: +# +# ./documentation/tools/build-docs-container ubuntu:24.04 html +# +# Will build the docs in an Ubuntu 24.04 container in html. +# +# The container engine can be selected by exporting CONTAINERCMD in the +# environment. The default is docker, but podman can also be used.
documentation/tools/build-docs-container line 28
Quoted 10 lines
documentation/tools/build-docs-container new file +10
-0+ +set -eu -o pipefail + +SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) +CONTAINERCMD=${CONTAINERCMD:-docker} +DOCS_DIR="$SCRIPT_DIR/../.." +SH_DIR="$SCRIPT_DIR/host_packages_scripts" + +main () +{
I would be good to have a check here to avoid
$ ./tools/build-docs-container ./tools/build-docs-container: line 29: $1: unbound variable
You could probably copypaste what I did in my version of the script.
Quoted 34 lines
documentation/tools/build-docs-container new file +34
-0+ local image="$1" + shift + + OCI=$(which "$CONTAINERCMD") + + # docker build doesn't accept 2 colons, so "sanitize" the name + local sanitized_dockername + sanitized_dockername=$(echo "$image" | tr ':.' '-') + + local version + version=$(echo "$image" | awk -F: '{print $NF}') + + case $image in + almalinux*) + containerfile=Containerfile.almalinux + docs=almalinux_docs.sh + docs_pdf=almalinux_docs_pdf.sh + pip3=pip3_docs.sh + ;; + debian*) + containerfile=Containerfile.debian + docs=ubuntu_docs.sh + docs_pdf=ubuntu_docs_pdf.sh + ;; + fedora*) + containerfile=Containerfile.fedora + docs=fedora_docs.sh + docs_pdf=fedora_docs_pdf.sh + pip3=pip3_docs.sh + ;; + opensuse* | leap*) + image=opensuse/leap:$version + containerfile=Containerfile.zypper + docs=opensuse_docs.sh
documentation/tools/build-docs-container line 72
Quoted 10 lines
documentation/tools/build-docs-container new file +10
-0+ docs_pdf=opensuse_docs_pdf.sh + pip3=pip3_docs.sh + ;; + ubuntu*) + containerfile=Containerfile.ubuntu + docs=ubuntu_docs.sh + docs_pdf=ubuntu_docs_pdf.sh + ;; + *) + echo "$image not supported"
Can we have a way of listing images here so a user doesn't need to read the script and guess which one to use?
Quoted 60 lines
documentation/tools/build-docs-container new file +41
-0+ exit 1 + ;; + esac + + $OCI build \ + --tag "yocto-docs-$sanitized_dockername:latest" \ + --build-arg ARG_FROM="docker.io/$image" \ + --build-arg DOCS="$docs" \ + --build-arg DOCS_PDF="$docs_pdf" \ + --build-arg PIP3="${pip3:-}" \ + --file "$SCRIPT_DIR/$containerfile" \ + "$SH_DIR/" + + local -a args_run=( + --rm + --interactive + --tty + --volume="$DOCS_DIR:/docs:rw" + --workdir=/docs + --security-opt label=disable + ) + + if [ "$OCI" = "docker" ]; then + args_run+=( + --user="$(id -u)":"$(id -g)" + ) + elif [ "$OCI" = "podman" ]; then + # we need net access to fetch bitbake terms + args_run+=( + --cap-add=NET_RAW + --userns=keep-id + ) + fi + + $OCI run \ + "${args_run[@]}" \ + "yocto-docs-$sanitized_dockername" \ + "$@" +} + +main "$@"documentation/tools/host_packages_scripts/opensuse_docs.sh +1
-1@@ -1 +1 @@ -sudo zypper install git glibc-i18ndata make python3-pip rsvg-convert which +sudo zypper --non-interactive install git glibc-i18ndata make python3-pip rsvg-convert whichdocumentation/tools/host_packages_scripts/opensuse_docs_pdf.sh +1
-1@@ -1 +1 @@ -sudo zypper install 'texlive-collection-lang*' texlive-collection-fontsextra texlive-collection-fontsrecommended texlive-collection-latex texlive-collection-latexextra texlive-collection-latexrecommended texlive-collection-xetex texlive-fncychap texlive-gnu-freefont texlive-latexmk texlive-tex-gyre texlive-xetex +sudo zypper --non-interactive install 'texlive-collection-lang*' texlive-collection-fontsextra texlive-collection-fontsrecommended texlive-collection-latex texlive-collection-latexextra texlive-collection-latexrecommended texlive-collection-xetex texlive-fncychap texlive-gnu-freefont texlive-latexmk texlive-tex-gyre texlive-xetexdocumentation/tools/host_packages_scripts/opensuse_essential.sh +0
-0
documentation/tools/host_packages_scripts/opensuse_essential.sh line 2
Quoted 3 lines
documentation/tools/host_packages_scripts/opensuse_essential.sh +1
-1@@ -1,2 +1,2 @@ -sudo zypper install bzip2 chrpath diffstat gcc gcc-c++ git gzip hostname libacl1 lz4 make makeinfo patch python python-curses python-xml python3 python3-Jinja2 python3-curses python3-pexpect python3-pip rpcgen socat tar wget which xz zstd +sudo zypper --non-interactive install bzip2 chrpath diffstat gcc gcc-c++ git gzip hostname libacl1 lz4 make makeinfo patch python python-curses python-xml python3 python3-Jinja2 python3-curses python3-pexpect python3-pip rpcgen socat tar wget which xz zstd sudo pip3 install GitPython
Thanks,
Antonin
Signature · 3 lines
Antonin Godard, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Re: [docs] [PATCH RFC v2 2/2] tools: add script for building documentation inside containers
Hi Antonin,
Quoted 12 lines · Antonin Godard
Hi Quentin,
Quoted 8 lines · Quentin Schulz
From: Quentin Schulz <[email protected]>
This adds a script for building a container and building the documentation within that new container image.
The openSUSE instructions now require a --non-interactive flag otherwise they fail to run. Sadly there doesn't seem to be a way to have this in an environment variable à-la DEBIAN_FRONTEND=noninteractive.
Quoted 7 lines
Hmm, this means that we end up instructing to pass "--non-interactive" in the docs? That's not ideal :/ I suggested a workaround below.
I hope there won't be too many cases where we have to do things differently in the context of a containerfile in the future. Apart from this case I cannot think of anything else that could happen. Anything comes to mind for you?
There are always interesting corner cases in unattended CI :)
Quoted 130 lines
Quoted 130 lines
Somehow tzdata package in Ubuntu doesn't respect DEBIAN_FRONTEND=noninteractive hence why the timezone needs to be set by hand.
Note that only instructions for Debian Bookworm (12), Ubuntu 22.04 and 24.04, and Fedora 38, 39 and 40, currently work.
Signed-off-by Quentin Schulz <[email protected]>--- documentation/tools/Containerfile.almalinux | 1 + documentation/tools/Containerfile.apt | 26 +++++ documentation/tools/Containerfile.debian | 1 + documentation/tools/Containerfile.dnf | 25 +++++ documentation/tools/Containerfile.fedora | 1 + documentation/tools/Containerfile.ubuntu | 1 + documentation/tools/Containerfile.zypper | 24 +++++ documentation/tools/build-docs-container | 113 +++++++++++++++++++++ .../tools/host_packages_scripts/opensuse_docs.sh | 2 +- .../host_packages_scripts/opensuse_docs_pdf.sh | 2 +- .../host_packages_scripts/opensuse_essential.sh | 2 +- 11 files changed, 195 insertions(+), 3 deletions(-)documentation/tools/Containerfile.almalinux new file +1
-0@@ -0,0 +1 @@ +Containerfile.dnfdocumentation/tools/Containerfile.apt new file +26
-0@@ -0,0 +1,26 @@ +ARG ARG_FROM=debian:12 # default value to avoid warning +FROM $ARG_FROM + +ARG DOCS=ubuntu_docs.sh +ARG DOCS_PDF=ubuntu_docs_pdf.sh + +ENV DEBIAN_FRONTEND=noninteractive +ARG TZ=Europe/Vienna + +# relative to the location of the dockerfile +COPY --chmod=777 ${DOCS} /temp/host_packages_docs.sh +COPY --chmod=777 ${DOCS_PDF} /temp/host_packages_docs_pdf.sh + +RUN ln -fs "/usr/share/zoneinfo/$TZ" /etc/localtime \ + && apt-get update \ + && apt-get install -y sudo \ + && yes | /temp/host_packages_docs.sh \ + && yes | /temp/host_packages_docs_pdf.sh \ + && apt-get --yes autoremove \ + && apt-get clean \ + && rm -rf /temp + +RUN git config --global --add safe.directory /docs + +ENTRYPOINT ["/usr/bin/env", "make", "-C", "documentation/"] +CMD ["publish"]documentation/tools/Containerfile.debian new file +1
-0@@ -0,0 +1 @@ +Containerfile.aptdocumentation/tools/Containerfile.dnf new file +25
-0@@ -0,0 +1,25 @@ +ARG ARG_FROM=fedora:40 # default value to avoid warning +FROM $ARG_FROM + +ARG DOCS=fedora_docs.sh +ARG DOCS_PDF=fedora_docs_pdf.sh +ARG PIP3=pip3_docs.sh + +# relative to the location of the dockerfile +COPY --chmod=777 ${DOCS} /temp/host_packages_docs.sh +COPY --chmod=777 ${DOCS_PDF} /temp/host_packages_docs_pdf.sh +COPY --chmod=777 ${PIP3} /temp/pip3_docs.sh + +RUN dnf update -y \ + && dnf install -y sudo \ + && yes | /temp/host_packages_docs.sh \ + && yes | /temp/host_packages_docs_pdf.sh \ + && yes | /temp/pip3_docs.sh \ + && dnf autoremove -y \ + && dnf clean all -y \ + && rm -rf /temp + +RUN git config --global --add safe.directory /docs + +ENTRYPOINT ["/usr/bin/env", "make", "-C", "documentation/"] +CMD ["publish"]documentation/tools/Containerfile.fedora new file +1
-0@@ -0,0 +1 @@ +Containerfile.dnfdocumentation/tools/Containerfile.ubuntu new file +1
-0@@ -0,0 +1 @@ +Containerfile.aptdocumentation/tools/Containerfile.zypper new file +7
-0@@ -0,0 +1,24 @@ +ARG ARG_FROM=opensuse/leap:15.4 # default value to avoid warning +FROM $ARG_FROM + +ARG DOCS=opensuse_docs.sh +ARG DOCS_PDF=opensuse_docs_pdf.sh +ARG PIP3=pip3_docs.sh +
Quoted 9 lines
documentation/tools/Containerfile.zypper line 11
Quoted 4 lines
documentation/tools/Containerfile.zypper new file +4
-0+# relative to the location of the dockerfile +COPY --chmod=777 ${DOCS} /temp/host_packages_docs.sh +COPY --chmod=777 ${DOCS_PDF} /temp/host_packages_docs_pdf.sh +COPY --chmod=777 ${PIP3} /temp/pip3_docs.shA bit of a hacky workaround, but maybe here run
sed -i 's/zypper/zypper --non-interactive/ ...' on the scripts? So we don't need to provide this option in the doc.
Another dirty hack is to have a shell zypper wrapper that calls /usr/bin/zypper --non-interactive.
Up to you.
Quoted 50 lines
Quoted 37 lines
documentation/tools/Containerfile.zypper new file +13
-0+ +RUN zypper update -y \ + && zypper install -y sudo \ + && yes | /temp/host_packages_docs.sh \ + && yes | /temp/host_packages_docs_pdf.sh \ + && yes | /temp/pip3_docs.sh \ + && zypper clean --all \ + && rm -rf /temp + +RUN git config --global --add safe.directory /docs + +ENTRYPOINT ["/usr/bin/env", "make", "-C", "documentation/"] +CMD ["publish"]documentation/tools/build-docs-container new file +18
-0@@ -0,0 +1,113 @@ +#!/usr/bin/env bash +# +# Build a container ready to build the documentation be reading the dependencies +# listed in shell scripts in documentation/tools/host_packages_scripts, and +# start a documentation build in this container. +# +# Usage: +# +# ./documentation/tools/build-docs-container <image> [<make target>] +# +# e.g.: +# +# ./documentation/tools/build-docs-container ubuntu:24.04 html +# +# Will build the docs in an Ubuntu 24.04 container in html. +# +# The container engine can be selected by exporting CONTAINERCMD in the +# environment. The default is docker, but podman can also be used.documentation/tools/build-docs-container line 28
Quoted 10 lines
documentation/tools/build-docs-container new file +10
-0+ +set -eu -o pipefail + +SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) +CONTAINERCMD=${CONTAINERCMD:-docker} +DOCS_DIR="$SCRIPT_DIR/../.." +SH_DIR="$SCRIPT_DIR/host_packages_scripts" + +main () +{I would be good to have a check here to avoid
Quoted 5 lines
$ ./tools/build-docs-container ./tools/build-docs-container: line 29: $1: unbound variableYou could probably copypaste what I did in my version of the script.
Will do.
Quoted 39 lines
Quoted 39 lines
documentation/tools/build-docs-container new file +39
-0+ local image="$1" + shift + + OCI=$(which "$CONTAINERCMD") + + # docker build doesn't accept 2 colons, so "sanitize" the name + local sanitized_dockername + sanitized_dockername=$(echo "$image" | tr ':.' '-') + + local version + version=$(echo "$image" | awk -F: '{print $NF}') + + case $image in + almalinux*) + containerfile=Containerfile.almalinux + docs=almalinux_docs.sh + docs_pdf=almalinux_docs_pdf.sh + pip3=pip3_docs.sh + ;; + debian*) + containerfile=Containerfile.debian + docs=ubuntu_docs.sh + docs_pdf=ubuntu_docs_pdf.sh + ;; + fedora*) + containerfile=Containerfile.fedora + docs=fedora_docs.sh + docs_pdf=fedora_docs_pdf.sh + pip3=pip3_docs.sh + ;; + opensuse* | leap*) + image=opensuse/leap:$version + containerfile=Containerfile.zypper + docs=opensuse_docs.sh + docs_pdf=opensuse_docs_pdf.sh + pip3=pip3_docs.sh + ;; + ubuntu*) + containerfile=Containerfile.ubuntu
Quoted 9 lines
documentation/tools/build-docs-container line 72
Quoted 5 lines
documentation/tools/build-docs-container new file +5
-0+ docs=ubuntu_docs.sh + docs_pdf=ubuntu_docs_pdf.sh + ;; + *) + echo "$image not supported"Can we have a way of listing images here so a user doesn't need to read the script and guess which one to use?
The ones in https://docs.yoctoproject.org/ref-manual/system-requirements.html#supported-linux-distributions? Though I guess Rocky and CentOS are still missing. Do we want the name of the distro or the name + the version? Basically we can end up with two places where this information will be, in the docs and in the container.
Cheers,
Quentin
Re: [docs] [PATCH RFC v2 2/2] tools: add script for building documentation inside containers
Hi Quentin,
On Mon Jan 13, 2025 at 5:43 PM CET, Quentin Schulz wrote:
[...]
Quoted 10 lines
Quoted 9 lines
documentation/tools/Containerfile.dnf line 11
Quoted 4 lines
documentation/tools/Containerfile.dnf new file +4
-0+# relative to the location of the dockerfile +COPY --chmod=777 ${DOCS} /temp/host_packages_docs.sh +COPY --chmod=777 ${DOCS_PDF} /temp/host_packages_docs_pdf.sh +COPY --chmod=777 ${PIP3} /temp/pip3_docs.shA bit of a hacky workaround, but maybe here run
sed -i 's/zypper/zypper --non-interactive/ ...' on the scripts? So we don't need to provide this option in the doc.
Quoted 4 lines
Another dirty hack is to have a shell zypper wrapper that calls
/usr/bin/zypper--non-interactive.Up to you.
Let's go for a sed in the Containerfile.
[...]
Quoted 10 lines
Quoted 4 lines
Can we have a way of listing images here so a user doesn't need to read the script and guess which one to use?
The ones in
https://docs.yoctoproject.org/ref-manual/system-requirements.html#supported-linux-distributions?
Though I guess Rocky and CentOS are still missing. Do we want the name of the distro or the name + the version? Basically we can end up with two places where this information will be, in the docs and in the container.
I was thinking of just listing what the script supports, not from the docs. I did that in my version of the script. Something like ./build-docs-container list. In your case, it would probably extract that information from the Containerfiles.
Antonin
Signature · 3 lines
Antonin Godard, Bootlin Embedded Linux and Kernel engineering https://bootlin.com