Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion debian/configure
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
96 changes: 96 additions & 0 deletions scripts/inkscape
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#!/bin/bash
# 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

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 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|-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
;;
*)
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

# 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 "$@"
fi
Loading