summaryrefslogtreecommitdiffstats
path: root/documentation/tools/build-docs-container
diff options
context:
space:
mode:
Diffstat (limited to 'documentation/tools/build-docs-container')
-rwxr-xr-xdocumentation/tools/build-docs-container175
1 files changed, 0 insertions, 175 deletions
diff --git a/documentation/tools/build-docs-container b/documentation/tools/build-docs-container
deleted file mode 100755
index f97cfc4025..0000000000
--- a/documentation/tools/build-docs-container
+++ /dev/null
@@ -1,175 +0,0 @@
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"
27INCLUDE_ESSENTIAL_PACKAGES=${INCLUDE_ESSENTIAL_PACKAGES:-0}
28
29function usage()
30{
31 echo "$0 -- script to build documentation from within a container
32
33$0 OCI_IMAGE [make arguments...]
34
35 OCI_IMAGE is an image:tag of an OCI image hosted on hub.docker.com. It is one
36 of:
37 - debian:12
38 - debian:13
39 - fedora:39
40 - fedora:40
41 - fedora:41
42 - fedora:42
43 - leap:15.5
44 - leap:15.6
45 - ubuntu:22.04
46 - ubuntu:24.04
47 - ubuntu:25.04
48
49 [make arguments] is one or more argument to pass to the make command of
50 documentation/Makefile, see that file for what's supported. This is typically
51 intended to be used to provide specific make targets.
52 Default: publish
53
54 Environment variables:
55
56 - CONTAINERCMD can be set to 'docker' or 'podman' to select the
57 container engine (default: 'docker').
58
59 - INCLUDE_ESSENTIAL_PACKAGES can be set to 0 or 1 to also include essential
60 packages listed in documentation/tools/host_packages_scripts/*_essential.sh.
61 This is not required to build the documentation but can be useful to validate
62 the installation of packages listed in these files (default: 0).
63"
64}
65
66main ()
67{
68 if [ "$#" -lt 1 ]; then
69 usage
70 exit 1
71 fi
72
73 local image="$1"
74 shift
75
76 OCI=$(which "$CONTAINERCMD")
77
78 # docker build doesn't accept 2 colons, so "sanitize" the name
79 local sanitized_dockername
80 sanitized_dockername=$(echo "$image" | tr ':.' '-')
81
82 local version
83 version=$(echo "$image" | awk -F: '{print $NF}')
84
85 case $image in
86 # Missing latexmk texlive-gnu-freefont packages at the very least
87 # "almalinux:8"*|\
88 # "almalinux:9"*)
89 # containerfile=Containerfile.almalinux
90 # docs=almalinux_docs.sh
91 # docs_pdf=almalinux_docs_pdf.sh
92 # pip3=pip3_docs.sh
93 # ;;
94 # Missing python3-saneyaml
95 # "debian:11"*|\
96 "debian:12"*|\
97 "debian:13"*)
98 containerfile=Containerfile.debian
99 essential=ubuntu_essential.sh
100 docs=ubuntu_docs.sh
101 docs_pdf=ubuntu_docs_pdf.sh
102 ;;
103 "fedora:39"*|\
104 "fedora:40"*|\
105 "fedora:41"*|\
106 "fedora:42"*)
107 containerfile=Containerfile.fedora
108 essential=fedora_essential.sh
109 docs=fedora_docs.sh
110 docs_pdf=fedora_docs_pdf.sh
111 pip3=pip3_docs.sh
112 ;;
113 "leap:15.5"*|\
114 "leap:15.6"*)
115 image=opensuse/leap:$version
116 containerfile=Containerfile.zypper
117 essential=opensuse_essential.sh
118 docs=opensuse_docs.sh
119 docs_pdf=opensuse_docs_pdf.sh
120 pip3=pip3_docs.sh
121 ;;
122 "ubuntu:22.04"*|\
123 "ubuntu:24.04"*|\
124 "ubuntu:25.04"*)
125 containerfile=Containerfile.ubuntu
126 essential=ubuntu_essential.sh
127 docs=ubuntu_docs.sh
128 docs_pdf=ubuntu_docs_pdf.sh
129 ;;
130 *)
131 echo "$image not supported!"
132 usage
133 exit 1
134 ;;
135 esac
136
137 $OCI build \
138 --tag "yocto-docs-$sanitized_dockername:latest" \
139 --build-arg ARG_FROM="docker.io/$image" \
140 --build-arg INCLUDE_ESSENTIAL_PACKAGES="${INCLUDE_ESSENTIAL_PACKAGES}" \
141 --build-arg ESSENTIAL="$essential" \
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 [ "$(basename "$OCI")" = "docker" ]; then
158 args_run+=(
159 --user="$(id -u)":"$(id -g)"
160 )
161 elif [ "$(basename "$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 "$@"