Package: dh-octave
Severity: wishlist
Tags: patch

Hello.
The attached suggestions may simplify the use of dh-octave, especially
for source packages building several binary packages.
>From 8f56b92d51e122a8c50e12c0c14da0c37bba6acb Mon Sep 17 00:00:00 2001
From: Nicolas Boulenguez <nico...@debian.org>
Date: Tue, 24 May 2022 21:13:45 +0200
Subject: [PATCH 1/4] d/control: let dh-octave provide dh-sequence-octave

Debhelper recognizes this special formal packages in Build-Depends and
adds --with=octave to the dh parameters.

This is quite convenient when the dependency is restricted to
architecture-independent builds or by profiles.  In such scenarios,
several non-trivial conditionals can be avoided in debian/rules.
---
 debian/control | 1 +
 1 file changed, 1 insertion(+)

diff --git a/debian/control b/debian/control
index 8cc3d4a..280752f 100644
--- a/debian/control
+++ b/debian/control
@@ -16,6 +16,7 @@ Vcs-Git: https://salsa.debian.org/pkg-octave-team/dh-octave.git
 Rules-Requires-Root: no
 
 Package: dh-octave
+Provides: dh-sequence-octave
 Architecture: all
 Depends: octave-dev,
          debhelper-compat (= 13),
-- 
2.30.2

>From e67ffe5ff0858c3722e8c100bd71b1ffed975b09 Mon Sep 17 00:00:00 2001
From: Nicolas Boulenguez <nico...@debian.org>
Date: Tue, 24 May 2022 22:13:54 +0200
Subject: [PATCH 2/4] =?UTF-8?q?install-pkg.m:=20implement=20non-octave=20p?=
 =?UTF-8?q?arts=20with=20perl=E2=80=99s=20Dh=5FLib?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The effect should be equivalent, with a slight improvement when
debhelper verbose option is enabled.
---
 buildsystem.pm | 22 +++++++++++++++++++++-
 install-pkg.m  | 23 +----------------------
 2 files changed, 22 insertions(+), 23 deletions(-)

diff --git a/buildsystem.pm b/buildsystem.pm
index 974b275..ffd3dab 100644
--- a/buildsystem.pm
+++ b/buildsystem.pm
@@ -10,13 +10,33 @@ sub DESCRIPTION {
 
 sub install {
     my $this = shift;
+    my $destdir = "debian/" . sourcepackage();
+    my $arch = dpkg_architecture_value("DEB_HOST_MULTIARCH");
+    my $mpath = "$destdir/usr/share/octave/packages";
+    my $bpath = "$destdir/usr/lib/$arch/octave/packages";
+
     $this->doit_in_sourcedir ("octave",
                               "--no-gui",
                               "--no-history",
                               "--silent",
                               "--no-init-file",
                               "--no-window-system",
-                              "/usr/share/dh-octave/install-pkg.m")
+                              "/usr/share/dh-octave/install-pkg.m",
+                              $mpath, $bpath);
+
+    doit ("rmdir", "--ignore-fail-on-non-empty", "-p", "$mpath", "$bpath");
+
+    # Remove unnecessary documentation files
+    doit ("rm", "-fr", "$mpath/*/doc");
+    doit ("rm", "-f", "$mpath/*/packinfo/COPYING");
+
+    # Fix permission of installed *.oct and *.mex files, as per FHS 3.0
+    # sections 4.6 and 4.7 (see Bug#954149)
+    doit ("chmod", "-x", "$bpath/*/*/*.oct");
+    doit ("chmod", "-x", "$bpath/*/*/*.mex");
+
+    # Remove left over files *-tst
+    doit ("rm", "-f", "$bpath/*/*/*-tst");
 }
 
 sub clean {
diff --git a/install-pkg.m b/install-pkg.m
index 0a343ad..d586c13 100644
--- a/install-pkg.m
+++ b/install-pkg.m
@@ -24,12 +24,7 @@ if (exist ("./PKG_ADD") == 2)
     movefile ("PKG_ADD", "PKG_ADD.bak");
 endif
 
-package = sysout ("grep ^Source: debian/control | cut -f2 -d\\ ");
-debpkg = [pwd(), "/debian/", package];
-mpath = [debpkg, "/usr/share/octave/packages"];
-arch = sysout ("dpkg-architecture -qDEB_HOST_MULTIARCH");
-bpath = [debpkg, "/usr/lib/", arch, "/octave/packages"];
-pkg ("prefix", mpath, bpath);
+pkg ("prefix", argv(){1}, argv(){2});
 
 pkg ("local_list", fullfile (pwd (), "local-list"));
 pkg ("global_list", fullfile (pwd (), "global-list"));
@@ -41,19 +36,3 @@ if (exist ("PKG_ADD.bak") == 2)
 endif
 
 pkg -verbose -nodeps install .
-
-system (sprintf ("rmdir --ignore-fail-on-non-empty -p %s %s",
-                 mpath, bpath));
-
-### Remove unnecessary documentation files
-pkgdir = "debian/*/usr/share/octave/packages/*";
-system (sprintf ("rm -rf %s/doc", pkgdir));
-system (sprintf ("rm -f %s/packinfo/COPYING", pkgdir));
-
-### Fix permission of installed *.oct and *.mex files, as per FHS 3.0
-### sections 4.6 and 4.7 (see Bug#954149)
-system ("chmod -x debian/*/usr/lib/*/octave/packages/*/*/*.oct");
-system ("chmod -x debian/*/usr/lib/*/octave/packages/*/*/*.mex");
-
-### Remove left over files *-tst
-system ("rm -f debian/*/usr/lib/*/octave/packages/*/*/*-tst");
-- 
2.30.2

>From 215fc37d39001e56833b20e80a7c23bc0511af16 Mon Sep 17 00:00:00 2001
From: Nicolas Boulenguez <nico...@debian.org>
Date: Tue, 24 May 2022 22:17:02 +0200
Subject: [PATCH 3/4] =?UTF-8?q?buildsystem.pm:=20use=20debhelper=E2=80=99s?=
 =?UTF-8?q?=20tmpdir=20instead=20of=20debian/sourcepackage?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This change is intrusive, but may simplify source packages building
several binary packages, for example libraries providing binding for
multiple languages including octave.

Nothing should change when an octave-foo source package produces one
binary package with the same name.

When a source package produces several binary packages, the
destination directory for dh_auto_install is debian/tmp (and may be
overridden on the debhelper command line).  The dh_install* tools are
then in charge of dispatching to binary packages.
---
 buildsystem.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/buildsystem.pm b/buildsystem.pm
index ffd3dab..779adb3 100644
--- a/buildsystem.pm
+++ b/buildsystem.pm
@@ -10,7 +10,7 @@ sub DESCRIPTION {
 
 sub install {
     my $this = shift;
-    my $destdir = "debian/" . sourcepackage();
+    my $destdir = shift;
     my $arch = dpkg_architecture_value("DEB_HOST_MULTIARCH");
     my $mpath = "$destdir/usr/share/octave/packages";
     my $bpath = "$destdir/usr/lib/$arch/octave/packages";
-- 
2.30.2

>From dc00e8c88774acba37a652d0793663d024a2a20c Mon Sep 17 00:00:00 2001
From: Nicolas Boulenguez <nico...@debian.org>
Date: Tue, 24 May 2022 23:07:49 +0200
Subject: [PATCH 4/4] dh scripts: document how which script is enabled

---
 dh_octave_changelogs | 6 ++++++
 dh_octave_check      | 7 +++++++
 dh_octave_clean      | 3 +++
 dh_octave_examples   | 7 +++++++
 dh_octave_substvar   | 7 +++++++
 dh_octave_version    | 7 +++++++
 6 files changed, 37 insertions(+)

diff --git a/dh_octave_changelogs b/dh_octave_changelogs
index b9ac072..a615af2 100755
--- a/dh_octave_changelogs
+++ b/dh_octave_changelogs
@@ -40,6 +40,12 @@ L<dh_octave_examples(1)>
 
 This program is meant to be used together with debhelper for Debian
 packages derived from Octave-Forge packages.
+It is recommended to enable it by adding the dh-sequence-octave
+virtual package to Build-Depends, Build-Depends-Arch or
+Build-Depends-Indep.
+This is equivalent to adding dh-octave to the same field and adding
+--with=octave to the dh sequencer in debian/rules, except that only
+-arch/-indep/profiled builds are affected.
 
 =head1 AUTHOR
 
diff --git a/dh_octave_check b/dh_octave_check
index a5a8c9b..170a112 100755
--- a/dh_octave_check
+++ b/dh_octave_check
@@ -83,6 +83,13 @@ L<dh_octave_version(1)>, L<dh_octave_changelogs(1)>, L<dh_octave_examples(1)>
 
 This program is meant to be used together with debhelper for Debian
 packages derived from Octave-Forge packages.
+It is recommended to enable it by adding the dh-sequence-octave
+virtual package to Build-Depends, Build-Depends-Arch or
+Build-Depends-Indep.
+This is equivalent to adding dh-octave to the same field and adding
+--with=octave to the dh sequencer in debian/rules, except that only
+-arch/-indep/profiled builds are affected.
+This is also slightly more simple in the most common case.
 
 =head1 AUTHOR
 
diff --git a/dh_octave_clean b/dh_octave_clean
index 19dda4f..085f650 100755
--- a/dh_octave_clean
+++ b/dh_octave_clean
@@ -72,6 +72,9 @@ L<dh_octave_version(1)>, L<dh_octave_changelogs(1)>, L<dh_octave_examples(1)>
 
 This program is meant to be used together with debhelper for Debian
 packages derived from Octave-Forge packages.
+It is part of the Debhelper octave build system, enabled by the
+--buildsystem option to dh_auto_clean (or globally).
+It is NOT enabled by the dh sequence provided by the same package.
 
 =head1 AUTHOR
 
diff --git a/dh_octave_examples b/dh_octave_examples
index fcd56d6..9603f3c 100755
--- a/dh_octave_examples
+++ b/dh_octave_examples
@@ -75,6 +75,13 @@ L<dh_octave_version(1)>, L<dh_octave_changelogs(1)>, L<dh_octave_substvar(1)>
 
 This program is meant to be used together with debhelper for Debian
 packages derived from Octave-Forge packages.
+It is recommended to enable it by adding the dh-sequence-octave
+virtual package to Build-Depends, Build-Depends-Arch or
+Build-Depends-Indep.
+This is equivalent to adding dh-octave to the same field and adding
+--with=octave to the dh sequencer in debian/rules, except that only
+-arch/-indep/profiled builds are affected.
+This is also slightly more simple in the most common case.
 
 =head1 AUTHOR
 
diff --git a/dh_octave_substvar b/dh_octave_substvar
index 55cfc58..2b3a88c 100755
--- a/dh_octave_substvar
+++ b/dh_octave_substvar
@@ -131,6 +131,13 @@ L<dh_octave_version(1)>, L<dh_octave_changelogs(1)>, , L<dh_octave_examples(1)>
 
 This program is meant to be used together with debhelper for Debian
 packages derived from Octave-Forge packages.
+It is recommended to enable it by adding the dh-sequence-octave
+virtual package to Build-Depends, Build-Depends-Arch or
+Build-Depends-Indep.
+This is equivalent to adding dh-octave to the same field and adding
+--with=octave to the dh sequencer in debian/rules, except that only
+-arch/-indep/profiled builds are affected.
+This is also slightly more simple in the most common case.
 
 =head1 AUTHOR
 
diff --git a/dh_octave_version b/dh_octave_version
index bbd7f05..2561a1a 100755
--- a/dh_octave_version
+++ b/dh_octave_version
@@ -42,6 +42,13 @@ L<dh_octave_check(1)>, L<dh_octave_changelogs(1)>, L<dh_octave_examples(1)>
 
 This program is meant to be used together with debhelper for Debian
 packages derived from Octave-Forge packages.
+It is recommended to enable it by adding the dh-sequence-octave
+virtual package to Build-Depends, Build-Depends-Arch or
+Build-Depends-Indep.
+This is equivalent to adding dh-octave to the same field and adding
+--with=octave to the dh sequencer in debian/rules, except that only
+-arch/-indep/profiled builds are affected.
+This is also slightly more simple in the most common case.
 
 =head1 AUTHOR
 
-- 
2.30.2

Reply via email to