From 5a804b421f2499a324c3f23592fd6ef8613897a6 Mon Sep 17 00:00:00 2001 From: Luca Toniolo <10792599+grandixximo@users.noreply.github.com> Date: Tue, 19 May 2026 19:24:00 +0800 Subject: [PATCH 1/3] docs: shim inkscape calls from dblatex to rsvg-convert dblatex hardcodes 'inkscape -D --export-filename=OUT IN' for SVG conversion, which spams the build log with Pango/GtkRecentManager warnings on headless runs (issue #4040). Drop a small shim named 'inkscape' in scripts/ (already on the docs build PATH per docs/src/Submakefile:7) that translates the dblatex call into rsvg-convert. Falls back to the real inkscape if args do not match the expected pattern, if rsvg-convert is missing, or if LINUXCNC_DOCS_NO_RSVG=1 is set. Add librsvg2-bin to DOC_DEPENDS; inkscape stays as fallback. Measured: Master_Documentation PDF build 51.5s -> 46.8s (9%), zero pixel diff across all 1055 pages. Per-SVG conversion ~6x faster in isolation. --- debian/configure | 2 +- scripts/inkscape | 71 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 scripts/inkscape diff --git a/debian/configure b/debian/configure index fd30bca95fe..b157af7f09e 100755 --- a/debian/configure +++ b/debian/configure @@ -110,7 +110,7 @@ elif [ -f /etc/lsb-release ]; then fi if [ -n "$ENABLE_BUILD_DOCUMENTATION" ]; then - DOC_DEPENDS="dblatex (>= 0.2.12),\n dvipng,\n fonts-dejavu,\n graphviz,\n groff,\n inkscape,\n python3-lxml,\n source-highlight,\n texlive-extra-utils,\n texlive-font-utils,\n texlive-fonts-recommended,\n texlive-lang-cyrillic,\n texlive-lang-european,\n texlive-lang-french,\n texlive-lang-german,\n texlive-lang-polish,\n texlive-lang-spanish,\n texlive-latex-recommended,\n w3c-linkchecker,\n xsltproc" + DOC_DEPENDS="dblatex (>= 0.2.12),\n dvipng,\n fonts-dejavu,\n graphviz,\n groff,\n inkscape,\n librsvg2-bin,\n python3-lxml,\n source-highlight,\n texlive-extra-utils,\n texlive-font-utils,\n texlive-fonts-recommended,\n texlive-lang-cyrillic,\n texlive-lang-european,\n texlive-lang-french,\n texlive-lang-german,\n texlive-lang-polish,\n texlive-lang-spanish,\n texlive-latex-recommended,\n w3c-linkchecker,\n xsltproc" case $DISTRIB_NAME in diff --git a/scripts/inkscape b/scripts/inkscape new file mode 100644 index 00000000000..8a4cf342f5f --- /dev/null +++ b/scripts/inkscape @@ -0,0 +1,71 @@ +#!/bin/bash +# Shim that intercepts the `inkscape -D --export-filename=OUT IN` calls made +# by dblatex during the LinuxCNC docs build and forwards them to rsvg-convert. +# Avoids the noisy Pango/GtkRecentManager warnings that headless Inkscape +# prints on every SVG conversion (see issue #4040). Falls back to the real +# inkscape whenever the args do not match the expected pattern, when +# rsvg-convert is missing, or when LINUXCNC_DOCS_NO_RSVG is set. + +set -u + +real_inkscape() { + # Find the next `inkscape` on PATH after stripping the directory holding + # this shim, so we do not recurse into ourselves. + local self_dir + self_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd) + local stripped_path + stripped_path=$(printf '%s' "$PATH" | tr ':' '\n' \ + | grep -vxF "$self_dir" | paste -sd:) + PATH="$stripped_path" exec inkscape "$@" +} + +# Escape hatch. +if [ -n "${LINUXCNC_DOCS_NO_RSVG:-}" ]; then + real_inkscape "$@" +fi + +# rsvg-convert must be available. +if ! command -v rsvg-convert >/dev/null 2>&1; then + real_inkscape "$@" +fi + +# Parse just the dblatex call pattern: optional -D, --export-filename=OUT, +# one positional input. Anything else falls through. +out="" +in="" +saw_unknown=0 +for arg in "$@"; do + case "$arg" in + -D|-d) + ;; + --export-filename=*) + out="${arg#--export-filename=}" + ;; + -*) + saw_unknown=1 + ;; + *) + if [ -n "$in" ]; then + saw_unknown=1 + else + in="$arg" + fi + ;; + esac +done + +if [ "$saw_unknown" = 1 ] || [ -z "$in" ] || [ -z "$out" ]; then + real_inkscape "$@" +fi + +case "$out" in + *.pdf) fmt=pdf ;; + *.png) fmt=png ;; + *.eps) fmt=eps ;; + *.svg) fmt=svg ;; + *) real_inkscape "$@" ;; +esac + +if ! rsvg-convert -f "$fmt" -o "$out" "$in"; then + real_inkscape "$@" +fi From 0e9988015e21b53212b05cf07b7b2dd459390c91 Mon Sep 17 00:00:00 2001 From: Luca Toniolo <10792599+grandixximo@users.noreply.github.com> Date: Tue, 19 May 2026 20:43:38 +0800 Subject: [PATCH 2/3] docs: handle Inkscape 0.x syntax in shim (CI uses old dblatex) CI runners on debian bookworm/trixie/sid use an older dblatex variant that invokes inkscape with the 0.x syntax: inkscape -z -D --export-png=OUT IN inkscape -z -D --export-pdf=OUT IN inkscape -z -D --export-eps=OUT IN The shim only matched the 1.x --export-filename= form, so on those runners every call fell through to the real Inkscape and the GtkRecentManager warnings persisted. Accept -z and --without-gui as no-ops, parse --export-{png,pdf,eps}= with explicit format, and keep extension inference for the 1.x form. --- scripts/inkscape | 57 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 16 deletions(-) diff --git a/scripts/inkscape b/scripts/inkscape index 8a4cf342f5f..44cdc1c119c 100644 --- a/scripts/inkscape +++ b/scripts/inkscape @@ -1,10 +1,14 @@ #!/bin/bash -# Shim that intercepts the `inkscape -D --export-filename=OUT IN` calls made -# by dblatex during the LinuxCNC docs build and forwards them to rsvg-convert. -# Avoids the noisy Pango/GtkRecentManager warnings that headless Inkscape -# prints on every SVG conversion (see issue #4040). Falls back to the real -# inkscape whenever the args do not match the expected pattern, when -# rsvg-convert is missing, or when LINUXCNC_DOCS_NO_RSVG is set. +# Shim that intercepts the inkscape calls made by dblatex during the +# LinuxCNC docs build and forwards them to rsvg-convert. Avoids the noisy +# Pango/GtkRecentManager warnings that headless Inkscape prints on every +# SVG conversion (see issue #4040). Handles both dblatex syntaxes: +# new (Inkscape 1.x): inkscape -D --export-filename=OUT IN +# old (Inkscape 0.x): inkscape -z -D --export-png=OUT IN +# (also --export-pdf=, --export-eps=) +# Falls back to the real inkscape whenever the args do not match the +# expected pattern, when rsvg-convert is missing, or when +# LINUXCNC_DOCS_NO_RSVG is set. set -u @@ -29,18 +33,36 @@ if ! command -v rsvg-convert >/dev/null 2>&1; then real_inkscape "$@" fi -# Parse just the dblatex call pattern: optional -D, --export-filename=OUT, -# one positional input. Anything else falls through. +# Parse the dblatex call pattern. Accepted flags: +# -D, -d, -z, --without-gui (ignored: pose/area/legacy GUI suppression) +# --export-filename=OUT (Inkscape 1.x) +# --export-png=OUT (Inkscape 0.x) +# --export-pdf=OUT (Inkscape 0.x) +# --export-eps=OUT (Inkscape 0.x) +# One positional input. Anything else falls through to real inkscape. out="" in="" +fmt="" saw_unknown=0 for arg in "$@"; do case "$arg" in - -D|-d) + -D|-d|-z|--without-gui) ;; --export-filename=*) out="${arg#--export-filename=}" ;; + --export-png=*) + out="${arg#--export-png=}" + fmt=png + ;; + --export-pdf=*) + out="${arg#--export-pdf=}" + fmt=pdf + ;; + --export-eps=*) + out="${arg#--export-eps=}" + fmt=eps + ;; -*) saw_unknown=1 ;; @@ -58,13 +80,16 @@ if [ "$saw_unknown" = 1 ] || [ -z "$in" ] || [ -z "$out" ]; then real_inkscape "$@" fi -case "$out" in - *.pdf) fmt=pdf ;; - *.png) fmt=png ;; - *.eps) fmt=eps ;; - *.svg) fmt=svg ;; - *) real_inkscape "$@" ;; -esac +# If format not yet set (new-syntax --export-filename), infer from extension. +if [ -z "$fmt" ]; then + case "$out" in + *.pdf) fmt=pdf ;; + *.png) fmt=png ;; + *.eps) fmt=eps ;; + *.svg) fmt=svg ;; + *) real_inkscape "$@" ;; + esac +fi if ! rsvg-convert -f "$fmt" -o "$out" "$in"; then real_inkscape "$@" From c1b2cc75cf150558ff3e48cba27d4df69b23bdcc Mon Sep 17 00:00:00 2001 From: Luca Toniolo <10792599+grandixximo@users.noreply.github.com> Date: Tue, 19 May 2026 21:15:31 +0800 Subject: [PATCH 3/3] docs: make scripts/inkscape executable git index had mode 100644 from initial commit (core.fileMode=false locally masked the +x bit). On CI the file was checked out as non-executable and inkscape calls fell through to /usr/bin/inkscape on every system, leaving the warnings in place. Set the executable bit in the index. --- scripts/inkscape | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 scripts/inkscape diff --git a/scripts/inkscape b/scripts/inkscape old mode 100644 new mode 100755