[pkg] Use sections from requires.txt to populate Recommends and Suggests
authorJérémy Bobbio <jeremy.bobbio@irq7.fr>
Wed, 19 Jun 2019 16:10:19 +0200
changeset 12656 91178bc271c7
parent 12655 5b0ce10a7046
child 12657 2856182d4628
[pkg] Use sections from requires.txt to populate Recommends and Suggests As Denis Laxalde pointed out, dh_python can also generate Recommends and Suggests from Python package names. So let's use that instead of manually populating these fields in `debian/control`. Optional dependencies are currently specified in `setup.py` grouped by feature. These dependency groups are turned into sections in `requires.txt`. Thankfully `dh_python3` has options to populate Recommends or Suggests with all package from a given section. `debian/rules` now contains a list of which sections should go to Recommends and which section should go to Suggests. Because such extra list easily gets out-of-sync, we add a third list for ignored sections, and ensure that all sections currently in `requires.txt` get a mentioned in `debian/rules`. Here are the results compared to the previous version with explicit Recommends and Suggests (only listing Python packages): |==============================================================| | only in previous | common | only in new | |==============================================================| | Recommends | |--------------------------------------------------------------| | | python3-docutils | | | python3-fyzz | | | | python3-imaging | | | | | python3-pycryptodome | | | | python3-pyramid | | | | python3-pyramid-multiauth | | | python3-pysqlite2 | | | | | python3-rdflib | | | | python3-repoze.lru | | | python3-simpletal | | | | | python3-vobject | | | | python3-waitress | | | python3-werkzeug | | | | | python3-wsgicors | | |--------------------------------------------------------------| | Suggests | |--------------------------------------------------------------| | | | python3-pil | We also lose versioned dependencies which should not really be an issue for Recommends and Suggests.
debian/control
debian/rules
--- a/debian/control	Wed Jun 19 15:44:17 2019 +0200
+++ b/debian/control	Wed Jun 19 16:10:19 2019 +0200
@@ -26,6 +26,7 @@
  python3-repoze.lru,
  python3-wsgicors,
  python3-filelock,
+ python3-pycryptodome,
  sphinx-common,
 Standards-Version: 4.3.0
 Homepage: https://www.cubicweb.org
@@ -40,30 +41,13 @@
  graphviz,
  gettext,
 Recommends:
+ ${python3:Recommends},
  cubicweb-ctl (= ${source:Version}),
  python3-cubicweb-postgresql-support (= ${source:Version})
  | sqlite3,
-# pyramid recommends
- python3-pyramid (>= 1.5.0),
- python3-pyramid-multiauth,
- python3-waitress (>= 0.8.9),
- python3-wsgicors,
- python3-repoze.lru,
-# common recommends
- python3-simpletal (>= 4.0),
- python3-pycryptodome,
-# web recommends (mostly)
- python3-docutils (>= 0.6),
- python3-vobject,
  fckeditor,
- python3-fyzz,
- python3-imaging,
- python3-rdflib,
- python3-werkzeug,
-# dev recommends
- python3-pysqlite2,
 Suggests:
- python3-zmq,
+ ${python3:Suggests},
  python3-cwclientlib (>= 0.4.0),
  python3-cubicweb-documentation (= ${source:Version}),
  w3c-dtd-xhtml,
--- a/debian/rules	Wed Jun 19 15:44:17 2019 +0200
+++ b/debian/rules	Wed Jun 19 16:10:19 2019 +0200
@@ -27,3 +27,28 @@
 override_dh_installchangelogs:
 	dh_installchangelogs -Xdoc/changes
 
+# Should extra sections in requires.txt go to Recommends, Suggests or be
+# ignored?
+#
+# All sections must be listed so we don't forget any in cases of future
+# changes.
+
+RECOMMENDS_SECTIONS = ext crypto ical pyramid rdf
+SUGGESTS_SECTIONS = captcha zmq
+# sparql currently requires fyzz which is not compatible with Python 3
+IGNORED_SECTIONS = sparql
+
+override_dh_python3:
+	@set -e && trap 'rm -f requires-sections debian-sections' EXIT && \
+		sed -n -e 's/\[\(.*\)\]/\1/p' cubicweb.egg-info/requires.txt | sort > requires-sections && \
+		printf "%s\n" $(RECOMMENDS_SECTIONS) $(SUGGESTS_SECTIONS) $(IGNORED_SECTIONS) | sort > debian-sections && \
+		FORGOTTEN_SECTIONS=$$(comm -23 requires-sections debian-sections) && \
+		if [ "$$FORGOTTEN_SECTIONS" ]; then \
+			echo "The following sections are not listed in debian/rules:" && \
+			echo "$$FORGOTTEN_SECTIONS" && \
+			echo "Please add them in either RECOMMENDS_SECTIONS, SUGGESTS_SECTIONS or IGNORED_SECTIONS" && \
+			exit 1; \
+		fi
+	dh_python3 \
+		$(foreach section,$(RECOMMENDS_SECTIONS),--recommends-section=$(section)) \
+		$(foreach section,$(SUGGESTS_SECTIONS),--suggests-section=$(section))