summaryrefslogtreecommitdiffstats
path: root/documentation
diff options
context:
space:
mode:
authorQuentin Schulz <quentin.schulz@cherry.de>2025-01-27 19:37:05 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2025-02-18 15:47:37 +0000
commit7ea05616697eaa20341fac0fab2fda28ddf7c18e (patch)
tree2d12d1b37db7c90d904aa6b7c1a4e16abff21c4f /documentation
parent9d7930a4e0d0566e41ad0e0cf551cab04e847d64 (diff)
downloadpoky-7ea05616697eaa20341fac0fab2fda28ddf7c18e.tar.gz
tools: add script for building documentation inside containers
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, so we simply do a sed on the scripts to add --non-interactive to the zypper commands to avoid having those in the instructions provided to our users. Somehow tzdata package in Ubuntu doesn't respect DEBIAN_FRONTEND=noninteractive hence why the timezone needs to be set by hand. (From yocto-docs rev: cefced592f1302fcb65afa9e0b1f9f5ff1570e93) Signed-off-by: Quentin Schulz <quentin.schulz@cherry.de> Reviewed-by: Antonin Godard <antonin.godard@bootlin.com> Tested-by: Antonin Godard <antonin.godard@bootlin.com> Signed-off-by: Antonin Godard <antonin.godard@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'documentation')
l---------documentation/tools/Containerfile.almalinux1
-rw-r--r--documentation/tools/Containerfile.apt26
l---------documentation/tools/Containerfile.debian1
-rw-r--r--documentation/tools/Containerfile.dnf25
l---------documentation/tools/Containerfile.fedora1
l---------documentation/tools/Containerfile.ubuntu1
-rw-r--r--documentation/tools/Containerfile.zypper32
-rwxr-xr-xdocumentation/tools/build-docs-container175
8 files changed, 262 insertions, 0 deletions
diff --git a/documentation/tools/Containerfile.almalinux b/documentation/tools/Containerfile.almalinux
new file mode 120000
index 0000000000..7237e9b99f
--- /dev/null
+++ b/documentation/tools/Containerfile.almalinux
@@ -0,0 +1 @@
Containerfile.dnf \ No newline at end of file
diff --git a/documentation/tools/Containerfile.apt b/documentation/tools/Containerfile.apt
new file mode 100644
index 0000000000..5e30b65eb8
--- /dev/null
+++ b/documentation/tools/Containerfile.apt
@@ -0,0 +1,26 @@
1ARG ARG_FROM=debian:12 # default value to avoid warning
2FROM $ARG_FROM
3
4ARG DOCS=ubuntu_docs.sh
5ARG DOCS_PDF=ubuntu_docs_pdf.sh
6
7ENV DEBIAN_FRONTEND=noninteractive
8ARG TZ=Europe/Vienna
9
10# relative to the location of the dockerfile
11COPY --chmod=777 ${DOCS} /temp/host_packages_docs.sh
12COPY --chmod=777 ${DOCS_PDF} /temp/host_packages_docs_pdf.sh
13
14RUN ln -fs "/usr/share/zoneinfo/$TZ" /etc/localtime \
15 && apt-get update \
16 && apt-get install -y sudo \
17 && yes | /temp/host_packages_docs.sh \
18 && yes | /temp/host_packages_docs_pdf.sh \
19 && apt-get --yes autoremove \
20 && apt-get clean \
21 && rm -rf /temp
22
23RUN git config --global --add safe.directory /docs
24
25ENTRYPOINT ["/usr/bin/env", "make", "-C", "documentation/"]
26CMD ["publish"]
diff --git a/documentation/tools/Containerfile.debian b/documentation/tools/Containerfile.debian
new file mode 120000
index 0000000000..5a7a425197
--- /dev/null
+++ b/documentation/tools/Containerfile.debian
@@ -0,0 +1 @@
Containerfile.apt \ No newline at end of file
diff --git a/documentation/tools/Containerfile.dnf b/documentation/tools/Containerfile.dnf
new file mode 100644
index 0000000000..3dae744455
--- /dev/null
+++ b/documentation/tools/Containerfile.dnf
@@ -0,0 +1,25 @@
1ARG ARG_FROM=fedora:40 # default value to avoid warning
2FROM $ARG_FROM
3
4ARG DOCS=fedora_docs.sh
5ARG DOCS_PDF=fedora_docs_pdf.sh
6ARG PIP3=pip3_docs.sh
7
8# relative to the location of the dockerfile
9COPY --chmod=777 ${DOCS} /temp/host_packages_docs.sh
10COPY --chmod=777 ${DOCS_PDF} /temp/host_packages_docs_pdf.sh
11COPY --chmod=777 ${PIP3} /temp/pip3_docs.sh
12
13RUN dnf update -y \
14 && dnf install -y sudo \
15 && yes | /temp/host_packages_docs.sh \
16 && yes | /temp/host_packages_docs_pdf.sh \
17 && yes | /temp/pip3_docs.sh \
18 && dnf autoremove -y \
19 && dnf clean all -y \
20 && rm -rf /temp
21
22RUN git config --global --add safe.directory /docs
23
24ENTRYPOINT ["/usr/bin/env", "make", "-C", "documentation/"]
25CMD ["publish"]
diff --git a/documentation/tools/Containerfile.fedora b/documentation/tools/Containerfile.fedora
new file mode 120000
index 0000000000..7237e9b99f
--- /dev/null
+++ b/documentation/tools/Containerfile.fedora
@@ -0,0 +1 @@
Containerfile.dnf \ No newline at end of file
diff --git a/documentation/tools/Containerfile.ubuntu b/documentation/tools/Containerfile.ubuntu
new file mode 120000
index 0000000000..5a7a425197
--- /dev/null
+++ b/documentation/tools/Containerfile.ubuntu
@@ -0,0 +1 @@
Containerfile.apt \ No newline at end of file
diff --git a/documentation/tools/Containerfile.zypper b/documentation/tools/Containerfile.zypper
new file mode 100644
index 0000000000..f27ad1b476
--- /dev/null
+++ b/documentation/tools/Containerfile.zypper
@@ -0,0 +1,32 @@
1ARG ARG_FROM=opensuse/leap:15.4 # default value to avoid warning
2FROM $ARG_FROM
3
4ARG DOCS=opensuse_docs.sh
5ARG DOCS_PDF=opensuse_docs_pdf.sh
6ARG PIP3=pip3_docs.sh
7
8# relative to the location of the dockerfile
9COPY --chmod=777 ${DOCS} /temp/host_packages_docs.sh
10COPY --chmod=777 ${DOCS_PDF} /temp/host_packages_docs_pdf.sh
11COPY --chmod=777 ${PIP3} /temp/pip3_docs.sh
12
13# Zypper doesn't have environment variables to specify whether to run in
14# non-interactive mode like Debian does with DEBIAN_FRONTEND and piping yes to
15# the scripts doesn't need to be enough as well, so let's force all zypper calls
16# to be non-interactive by adding the appropriate flag in the scripts.
17RUN for script in /temp/*.sh; do \
18 sed -i 's/zypper/zypper --non-interactive/' $script; \
19 done
20
21RUN zypper update -y \
22 && zypper install -y sudo \
23 && yes | /temp/host_packages_docs.sh \
24 && yes | /temp/host_packages_docs_pdf.sh \
25 && yes | /temp/pip3_docs.sh \
26 && zypper clean --all \
27 && rm -rf /temp
28
29RUN git config --global --add safe.directory /docs
30
31ENTRYPOINT ["/usr/bin/env", "make", "-C", "documentation/"]
32CMD ["publish"]
diff --git a/documentation/tools/build-docs-container b/documentation/tools/build-docs-container
new file mode 100755
index 0000000000..6b4d425434
--- /dev/null
+++ b/documentation/tools/build-docs-container
@@ -0,0 +1,175 @@
1#!/usr/bin/env bash
2# -*- vim: set expandtab tabstop=2 shiftwidth=2:
3#
4# Build a container ready to build the documentation be reading the dependencies
5# listed in shell scripts in documentation/tools/host_packages_scripts, and
6# start a documentation build in this container.
7#
8# Usage:
9#
10# ./documentation/tools/build-docs-container <image> [<make target>]
11#
12# e.g.:
13#
14# ./documentation/tools/build-docs-container ubuntu:24.04 html
15#
16# Will build the docs in an Ubuntu 24.04 container in html.
17#
18# The container engine can be selected by exporting CONTAINERCMD in the
19# environment. The default is docker, but podman can also be used.
20
21set -eu -o pipefail
22
23SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
24CONTAINERCMD=${CONTAINERCMD:-docker}
25DOCS_DIR="$SCRIPT_DIR/../.."
26SH_DIR="$SCRIPT_DIR/host_packages_scripts"
27
28function usage()
29{
30 echo "$0 -- script to build documentation from within a container
31
32$0 OCI_IMAGE [make arguments...]
33
34 OCI_IMAGE is an image:tag of an OCI image hosted on hub.docker.com. It is one
35 of:
36 - debian:12
37 - fedora:38
38 - fedora:39
39 - fedora:40
40 - leap:15.4
41 - leap:15.5
42 - ubuntu:22.04
43 - ubuntu:24.04
44
45 [make arguments] is one or more argument to pass to the make command of
46 documentation/Makefile, see that file for what's supported. This is typically
47 intended to be used to provide specific make targets.
48 Default: publish
49"
50}
51
52main ()
53{
54 if [ "$#" -lt 1 ]; then
55 usage
56 exit 1
57 fi
58
59 local image="$1"
60 shift
61
62 OCI=$(which "$CONTAINERCMD")
63
64 # docker build doesn't accept 2 colons, so "sanitize" the name
65 local sanitized_dockername
66 sanitized_dockername=$(echo "$image" | tr ':.' '-')
67
68 local version
69 version=$(echo "$image" | awk -F: '{print $NF}')
70
71 case $image in
72 # Missing latexmk texlive-gnu-freefont packages at the very least
73 # "almalinux:8"*|\
74 # "almalinux:9"*)
75 # containerfile=Containerfile.almalinux
76 # docs=almalinux_docs.sh
77 # docs_pdf=almalinux_docs_pdf.sh
78 # pip3=pip3_docs.sh
79 # ;;
80 # Missing python3-saneyaml
81 # "debian:11"*|\
82 "debian:12"*)
83 containerfile=Containerfile.debian
84 docs=ubuntu_docs.sh
85 docs_pdf=ubuntu_docs_pdf.sh
86 ;;
87 "fedora:38"*|\
88 "fedora:39"*|\
89 "fedora:40"*)
90 containerfile=Containerfile.fedora
91 docs=fedora_docs.sh
92 docs_pdf=fedora_docs_pdf.sh
93 pip3=pip3_docs.sh
94 ;;
95 "leap:15.4"*|\
96 "leap:15.5"*)
97 # Seems like issue with permissions package, c.f.
98 #
99 # Updating /etc/sysconfig/security ...
100 # /dev/zero: chown: Permission denied
101 # /dev/null: chown: Permission denied
102 # /dev/full: chown: Permission denied
103 # ERROR: not all operations were successful.
104 # Checking permissions and ownerships - using the permissions files
105 # /etc/permissions
106 # /etc/permissions.easy
107 # /etc/permissions.local
108 # setting / to root:root 0755. (wrong permissions 0555)
109 # setting /dev/zero to root:root 0666. (wrong owner/group 65534:65534)
110 # setting /dev/null to root:root 0666. (wrong owner/group 65534:65534)
111 # setting /dev/full to root:root 0666. (wrong owner/group 65534:65534)
112 # warning: %post(permissions-20240826-150600.10.12.1.x86_64) scriptlet failed, exit status 1
113 #
114 # "leap:15.6"*)
115 image=opensuse/leap:$version
116 containerfile=Containerfile.zypper
117 docs=opensuse_docs.sh
118 docs_pdf=opensuse_docs_pdf.sh
119 pip3=pip3_docs.sh
120 ;;
121 # Missing python3-saneyaml
122 # "ubuntu:18.04"*|\
123 # "ubuntu:20.04"*|\
124 # Cannot fetch packages anymore
125 # "ubuntu:23.04"*|\
126 "ubuntu:22.04"*|\
127 "ubuntu:24.04"*)
128 containerfile=Containerfile.ubuntu
129 docs=ubuntu_docs.sh
130 docs_pdf=ubuntu_docs_pdf.sh
131 ;;
132 *)
133 echo "$image not supported!"
134 usage
135 exit 1
136 ;;
137 esac
138
139 $OCI build \
140 --tag "yocto-docs-$sanitized_dockername:latest" \
141 --build-arg ARG_FROM="docker.io/$image" \
142 --build-arg DOCS="$docs" \
143 --build-arg DOCS_PDF="$docs_pdf" \
144 --build-arg PIP3="${pip3:-}" \
145 --file "$SCRIPT_DIR/$containerfile" \
146 "$SH_DIR/"
147
148 local -a args_run=(
149 --rm
150 --interactive
151 --tty
152 --volume="$DOCS_DIR:/docs:rw"
153 --workdir=/docs
154 --security-opt label=disable
155 )
156
157 if [ "$OCI" = "docker" ]; then
158 args_run+=(
159 --user="$(id -u)":"$(id -g)"
160 )
161 elif [ "$OCI" = "podman" ]; then
162 # we need net access to fetch bitbake terms
163 args_run+=(
164 --cap-add=NET_RAW
165 --userns=keep-id
166 )
167 fi
168
169 $OCI run \
170 "${args_run[@]}" \
171 "yocto-docs-$sanitized_dockername" \
172 "$@"
173}
174
175main "$@"