Add some help2man for man pages
authorStuart Prescott <stuart@debian.org>
Mon, 16 Feb 2026 07:54:52 +0000 (18:54 +1100)
committerStuart Prescott <stuart@debian.org>
Mon, 16 Feb 2026 07:54:52 +0000 (18:54 +1100)
debian/control
debian/make-manpages [new file with mode: 0755]
debian/pyside6-tools.manpages [new file with mode: 0644]
debian/rules

index 9042db5c188a8f02c759f6ce311832eb47ac5025..625bf2ca0ada481884ea936b98e7afe35c359c40 100644 (file)
@@ -13,6 +13,7 @@ Build-Depends:
  dh-sequence-python3,
  dh-sequence-sphinxdoc,
  furo <!nodoc>,
+ help2man,
  libclang-dev,
  libxml2-dev,
  libxslt1-dev,
diff --git a/debian/make-manpages b/debian/make-manpages
new file mode 100755 (executable)
index 0000000..b0eea78
--- /dev/null
@@ -0,0 +1,101 @@
+#!/usr/bin/python3
+
+import os
+from pathlib import Path
+import subprocess
+import textwrap
+
+
+skip_tools = [
+    "android-deploy",
+    "assistant",
+    "balsamui",
+    "designer",
+    "linguist",
+    "qmlimportscanner",
+]
+
+
+def help2man(tool):
+    toolname = str(tool.stem).replace("pyside6-", "")
+    if toolname in skip_tools:
+        print(f"I: skipping {toolname} as configured")
+        return
+
+    print(f"I: attempting to make man page for {toolname} ({tool})")
+    _run_help2man(tool, toolname, "--help")
+
+
+def _run_help2man(tool, toolname, help_opt):
+    cmd = [
+        "xvfb-run",
+        "--auto-servernum",
+        "help2man",
+        "--name",
+        toolname,
+        "--section",
+        "1",
+        "--manual",
+        "PySide6 tools",
+        "--help-option",
+        help_opt,
+        "--version-string",
+        pyside_version,
+        "--no-info",  # suppress "see info pages" footer
+        "--output",
+        str(mandir / (tool.stem + ".1")),
+        str(tool),
+    ]
+    cmd_summary = [
+        f"LD_LIBRARY_PATH={env["LD_LIBRARY_PATH"]} ",
+        f"PYTHONPATH={env["PYTHONPATH"]} ",
+        "'",
+        "' '".join(cmd),
+        "'",
+    ]
+    print(f"I: {''.join(cmd_summary)}")
+
+    # Run the tool
+    ret = subprocess.run(cmd, capture_output=True, timeout=10, encoding="UTF-8", env=env)
+    if ret.returncode != 0:
+        print(f"W: returned: {ret.returncode}:\n")
+        print(textwrap.indent(ret.stdout, "W: "))
+        print(textwrap.indent(ret.stderr, "W: "))
+
+
+# PATH CONFIG FOR TOOL
+wd = Path.cwd()
+
+# In preparation for debhelper, debian/tmp will be used for most operations
+# except for the list of tools, which we get from those installed into the
+# pyside6-tools package
+tmppath = wd / "debian" / "tmp"
+modpath = list((tmppath / "usr" / "lib").glob("python*"))[0] / "dist-packages"
+bindir = wd / "debian" / "pyside6-tools" / "usr" / "bin"
+mandir = tmppath  # dh_installman will sort this out for us
+
+# help2man needs to run the tools but that means that the tools have to be
+# able to find libraries / python modules.
+libpaths = [
+    str(modpath / "shiboken6"),
+    str(modpath / "PySide6"),
+]
+if "LD_LIBRARY_PATH" in os.environ:
+    libpaths.append(os.environ["LD_LIBRARY_PATH"])
+env = {
+    "LD_LIBRARY_PATH": ":".join(libpaths),
+    "PYTHONPATH": str(modpath),
+}
+
+# Override the version in all pages (lots of tools don't have a --version
+# option to extract the version)
+pyside_version = os.environ.get("PYSIDE_MAJOR")
+if not pyside_version:
+    print("W: PySide6 version not available, this should be set in d/rules")
+    pyside_version = "6"
+
+
+mandir.mkdir(exist_ok=True, parents=True)
+
+for tool in sorted(bindir.iterdir()):
+    help2man(tool)
diff --git a/debian/pyside6-tools.manpages b/debian/pyside6-tools.manpages
new file mode 100644 (file)
index 0000000..623f89e
--- /dev/null
@@ -0,0 +1,19 @@
+pyside6-balsam.1
+pyside6-deploy.1
+pyside6-genpyi.1
+pyside6-lrelease.1
+pyside6-lupdate.1
+pyside6-metaobjectdump.1
+pyside6-project.1
+pyside6-qml.1
+pyside6-qmlcachegen.1
+pyside6-qmlformat.1
+pyside6-qmllint.1
+pyside6-qmlls.1
+pyside6-qmltyperegistrar.1
+pyside6-qsb.1
+pyside6-qtpy2cpp.1
+pyside6-rcc.1
+pyside6-svgtoqml.1
+pyside6-uic.1
+shiboken6-genpyi.1
index 5d3e488c9b10594fe8e6a17e4d4d58d1301bd499..f0bd780fa2ddae586490ddd3493467018348c978 100755 (executable)
@@ -3,7 +3,7 @@
 include /usr/share/dpkg/default.mk
 
 # Safety measure to ensure package names match SONAMEs
-PYSIDE_MAJOR := $(shell echo $(DEB_VERSION_UPSTREAM) | cut -d. -f1-2)
+export PYSIDE_MAJOR := $(shell echo $(DEB_VERSION_UPSTREAM) | cut -d. -f1-2)
 ifeq ($(shell awk '/Package:/ {print $$2}' debian/control | grep -- -$(PYSIDE_MAJOR)$$),)
     $(error Please update package names for major version $(PYSIDE_MAJOR))
 endif
@@ -120,6 +120,9 @@ execute_after_dh_install-arch:
        # fix up various paths in .pc, cmake and __init__.py
        debian/set-paths
 
+       # Make man pages for tools
+       ./debian/make-manpages
+
 override_dh_auto_test:
 ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
 ifeq (mips64el,$(DEB_HOST_ARCH))