Package: debhelper
Version: 12.4
Severity: wishlist
Packages containing a GSettings schema currently generate a dependency
on "dconf-gsettings-backend | gsettings-backend", so that whenever an
application or library has settings, they actually get stored on disk
(rather than only existing in memory, with a warning, which is GLib's
fallback behaviour if no GSettings backend is available).
Some participants in a recent thread on -devel assert that this is too
strong, either for GSettings schemas associated with libraries or for all
GSettings schemas, and should be a Recommends or even a Suggests. Without
taking a position on the correct balance between "weaken non-essential
Depends to Recommends to make the system more flexible" and "don't
lose user configuration", this is not currently possible, because
dh_installgsettings always generates a hard dependency.
If it is desirable to make it possible to weaken dependencies on a
GSettings backend to Recommends or Suggests, without accidentally
weakening other dependencies that happen to go via ${misc:Depends}
and are more important, then dh_installgsettings should have an option
analogous to "dpkg-shlibdeps -dRecommends", perhaps something like the
attached patch.
Looking at the other dh scripts for other mentions of misc:Depends:
* dh_gconf is in the same situation as dh_installgsettings, but GConf is
obsolete anyway, and nobody seems to have objected to the dependency
in the 15 years since it was added, so I think that one can be ignored.
* dh_installcatalogs adds a dependency on sgml-base, so that its triggers
will be run. Is this essential to the functionality of SGML stuff or
could a maintainer have valid reasons to weaken it?
* dh_installdebconf adds a dependency on a debconf implementation, but the
man page only says it "probably" needs to depend on debconf, so perhaps
this one should be possible to weaken?
* dh_installdocs adds a dependency on the package with linked documentation,
which Policy ยง12.5 says has to be a hard dependency, so this is correct.
* dh_installinit and dh_installsystemduser add a versioned dependency on
init-system-helpers, which is used from maintainer scripts (so it's
correct to be a hard dependency) and is Essential anyway.
* dh_installxfonts adds a dependency on xfonts-utils, again for the
maintainer script. This is guarded by `which` so maybe it should be
possible to weaken? (I don't know.)
* dh_ucf unconditionally uses ucf in the maintainer scripts, so a hard
dependency is certainly correct.
Regards,
smcv
>From a80dd94cf062fbcd6fb0e675d714556f6f68d3d9 Mon Sep 17 00:00:00 2001
From: Simon McVittie <[email protected]>
Date: Fri, 16 Aug 2019 09:42:00 +0100
Subject: [PATCH] dh_installgsettings: Allow dependency to be weakened
Signed-off-by: Simon McVittie <[email protected]>
---
dh_installgsettings | 18 ++++++-
t/dh_installgsettings/debian/changelog | 5 ++
t/dh_installgsettings/debian/control | 25 +++++++++
t/dh_installgsettings/dh_installgsettings.t | 59 +++++++++++++++++++++
4 files changed, 106 insertions(+), 1 deletion(-)
create mode 100644 t/dh_installgsettings/debian/changelog
create mode 100644 t/dh_installgsettings/debian/control
create mode 100755 t/dh_installgsettings/dh_installgsettings.t
diff --git a/dh_installgsettings b/dh_installgsettings
index 45b228eb..3198929e 100755
--- a/dh_installgsettings
+++ b/dh_installgsettings
@@ -53,9 +53,20 @@ priority instead of 10. Higher values than ten can be used by
derived distributions (20), blend distributions (50), or site-specific
packages (90).
+=item B<--field> I<field>
+
+If the package contains GSettings schemas, add a suitable GSettings
+backend to the substvar B<misc:>I<field> instead of B<misc:Depends>.
+For example, if the settings described in a package's schemas are
+considered to be non-critical and it would be acceptable to fall back
+to the in-memory backend on unusually minimal systems, the maintainer
+could use B<dh_installgsettings --field Recommends>, and add
+B<Recommends: ${misc:Recommends}> in F<debian/control>.
+
=cut
init(options => {
+ "field=s" => \$dh{FIELD},
"priority=s" => \$dh{PRIORITY},
});
@@ -64,6 +75,11 @@ if (defined $dh{PRIORITY}) {
$priority=$dh{PRIORITY};
}
+my $field='Depends';
+if (defined $dh{FIELD}) {
+ $field=$dh{FIELD};
+}
+
# PROMISE: DH NOOP WITHOUT gsettings-override tmp(usr/share/glib-2.0/schemas) cli-options()
foreach my $package (@{$dh{DOPACKAGES}}) {
@@ -84,7 +100,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
'(', '-name', '*.xml', '-o', '-name', '*.override',
')', '-printf', '%P');
if ($schemas ne '') {
- addsubstvar($package, "misc:Depends", "dconf-gsettings-backend | gsettings-backend");
+ addsubstvar($package, "misc:$field", "dconf-gsettings-backend | gsettings-backend");
}
}
}
diff --git a/t/dh_installgsettings/debian/changelog b/t/dh_installgsettings/debian/changelog
new file mode 100644
index 00000000..5850f0e2
--- /dev/null
+++ b/t/dh_installgsettings/debian/changelog
@@ -0,0 +1,5 @@
+foo (1.0-1) unstable; urgency=low
+
+ * Initial release. (Closes: #XXXXXX)
+
+ -- Test <testing@nowhere> Mon, 11 Jul 2016 18:10:59 +0200
diff --git a/t/dh_installgsettings/debian/control b/t/dh_installgsettings/debian/control
new file mode 100644
index 00000000..b402ff69
--- /dev/null
+++ b/t/dh_installgsettings/debian/control
@@ -0,0 +1,25 @@
+Source: foo
+Section: misc
+Priority: optional
+Maintainer: Test <testing@nowhere>
+Standards-Version: 3.9.8
+
+Package: has-settings
+Architecture: all
+Depends: ${misc:Depends}
+Description: package has-settings
+ This package has a GSettings schema.
+
+Package: has-unimportant-settings
+Architecture: all
+Depends: ${misc:Depends}
+Recommends: ${misc:Recommends}
+Description: package has-unimportant-settings
+ This package has a GSettings schema but it represents unimportant
+ settings.
+
+Package: no-settings
+Architecture: all
+Depends: ${misc:Depends}
+Description: package no-settings
+ This package doesn't have a GSettings schema.
diff --git a/t/dh_installgsettings/dh_installgsettings.t b/t/dh_installgsettings/dh_installgsettings.t
new file mode 100755
index 00000000..36953d95
--- /dev/null
+++ b/t/dh_installgsettings/dh_installgsettings.t
@@ -0,0 +1,59 @@
+#!/usr/bin/perl
+use strict;
+use Test::More;
+
+use autodie;
+use File::Basename qw(dirname);
+use lib dirname(dirname(__FILE__));
+use Test::DH;
+use File::Path qw(remove_tree make_path);
+use Debian::Debhelper::Dh_Lib qw(!dirname);
+
+our @TEST_DH_EXTRA_TEMPLATE_FILES = (qw(
+ debian/changelog
+ debian/control
+));
+
+my $SCHEMAS = 'usr/share/glib-2.0/schemas';
+
+sub touch {
+ my $path = shift;
+ open(my $fh, '>>', $path);
+ close $fh;
+}
+
+sub slurp {
+ my $path = shift;
+ local $/ = undef;
+ open(my $fh, '<', $path);
+ my $contents = <$fh>;
+ close $fh;
+ return $contents;
+}
+
+each_compat_subtest {
+ make_path("debian/has-settings/$SCHEMAS");
+ touch("debian/has-settings/$SCHEMAS/com.example.HasSettings.xml");
+ make_path("debian/has-unimportant-settings/$SCHEMAS");
+ touch("debian/has-unimportant-settings/$SCHEMAS/com.example.HasUnimportantSettings.xml");
+ touch("debian/no-settings.substvars");
+ ok(run_dh_tool('dh_installgsettings', '-phas-settings'), 'run for has-settings');
+ ok(run_dh_tool('dh_installgsettings', '-phas-unimportant-settings', '--field=Recommends'),
+ 'run for has-unimportant-settings');
+ ok(run_dh_tool('dh_installgsettings', '-pno-settings'), 'run for no-settings');
+ remove_tree(qw(debian/has-settings debian/has-unimportant-settings));
+ like(slurp('debian/has-settings.substvars'),
+ qr{^misc:Depends=dconf-gsettings-backend \| gsettings-backend$}m,
+ 'has-settings should depend on a backend');
+ like(slurp('debian/has-unimportant-settings.substvars'),
+ qr{^misc:Recommends=dconf-gsettings-backend \| gsettings-backend$}m,
+ 'has-unimportant-settings should Recommend a backend');
+ unlike(slurp('debian/has-unimportant-settings.substvars'),
+ qr{^misc:Depends=dconf-gsettings-backend \| gsettings-backend$}m,
+ 'has-unimportant-settings should not depend on a backend');
+ unlike(slurp('debian/no-settings.substvars'),
+ qr{^misc:Depends=dconf-gsettings-backend \| gsettings-backend$}m,
+ 'no-settings should not depend on a backend');
+};
+
+done_testing;
--
2.23.0.rc1