#1053834 debhelper: dh_installman should support glob patterns like dh_install

Package:
debhelper
Source:
debhelper
Submitter:
Gioele Barabucci
Date:
2023-10-17 07:33:04 UTC
Severity:
normal
Tags:
#1053834#5
Date:
2023-10-12 11:12:16 UTC
From:
To:
Dear debhelper maintainer,

the line

```
debian/tmp/usr/share/man/*/man1/foo.1
```

is correctly expanded by dh_install (`d/pkg.install`) but it causes
dh_installman (`d/pkg.manpages`) to fail.

While it is technically possible to install manpages via d/pkg.install,
doing so skips all the man-specific processing done by dh_installman,
for instance handling the <nodoc> build profile.

It would be nice if dh_installman expanded glob patterns in the same way
dh_install and other dh helpers do.

Regards,

#1053834#10
Date:
2023-10-12 12:11:54 UTC
From:
To:
Gioele Barabucci:

Whatever problem you are experiencing, it is *not* that
`dh_installman`does not support globs, because definitely does as
debhelper itself would FTBFS otherwise (`debian/debhelper.mapages`
includes globs).

Best regards,
Niels

#1053834#17
Date:
2023-10-12 12:23:26 UTC
From:
To:
Hi,

maybe it is the combination of dh_installman + dh-exec?

This is the error message
<https://salsa.debian.org/gioele/util-linux/-/jobs/4799773#L2146>:

```
dh_installman: error: open debian/tmp/usr/share/man/*/man1/col.1 failed:
No such file or directory
	install -m0755 -d debian/util-linux-locales/usr/share/man/man1/
	install -p -m0644
debian/tmp/dh-exec.czfddtTB/usr/share/man/de/man1/rename.ul.1
debian/util-linux-locales/usr/share/man/man1/rename.ul.1
	install -m0755 -d debian/util-linux-locales/usr/share/man/man1/
	install -p -m0644 debian/tmp/usr/share/man/uk/man1/col.1
debian/util-linux-locales/usr/share/man/man1/col.1
dh_installman: error: Aborting due to earlier error
```

The `manpages` file starts with:

```
#!/usr/bin/dh-exec
debian/tmp/usr/share/man/de/man1/rename.1 =>
/usr/share/man/de/man1/rename.ul.1
debian/tmp/usr/share/man/uk/man1/col.1
debian/tmp/usr/share/man/*/man1/col.1
```

And the files are definitely there:

https://salsa.debian.org/gioele/util-linux/-/jobs/4799773#L2146

```
$ find debian/ | grep man | grep col.1 | sort
debian/tmp/usr/share/man/de/man1/col.1
debian/tmp/usr/share/man/man1/col.1
debian/tmp/usr/share/man/sr/man1/col.1
debian/tmp/usr/share/man/uk/man1/col.1
```

Regards,

#1053834#22
Date:
2023-10-12 12:11:54 UTC
From:
To:
Gioele Barabucci:

Whatever problem you are experiencing, it is *not* that
`dh_installman`does not support globs, because definitely does as
debhelper itself would FTBFS otherwise (`debian/debhelper.mapages`
includes globs).

Best regards,
Niels

#1053834#27
Date:
2023-10-12 12:54:16 UTC
From:
To:
Gioele Barabucci:

Behaviour is as documented in `man 7 debhelper` under the "Executable
debhelper config files":

"""
Executable debhelper config files


        When  using executable debhelper config files, please be aware of
        the following:

          * [...]

            Otherwise,  the  output will be used exactly as‐is.  Notably,
            debhelper will **not expand  wildcards** or  strip  comments
            or strip whitespace in the output.
"""
(emphasis mine)


As I see it, debhelper is working exactly as it is documented and
therefore as it is expected to do.  This restriction of the executable
config feature has been there from "day 1" of supporting executable
files (from the days of debhelper/9) and is unlikely to change given the
current architecture of debhelper.

Best regards,
Niels

#1053834#32
Date:
2023-10-12 20:56:35 UTC
From:
To:
This surprises me a bit. util-linux currently uses both dh-exec and
wildcards in `d/util-linux-locales.install` and it works as "expected"
(but not as documented?):

https://salsa.debian.org/debian/util-linux/-/blob/f7d972e9d/debian/util-linux-locales.install

Doesn't this mean that `dh_install` expands the globs found in the
output of the executable `foo.install`?

Regards,

#1053834#37
Date:
2023-10-13 05:54:43 UTC
From:
To:
Gioele Barabucci:

It does; `dh_install` is a special snowflake of doing everything
differently than anything else. The `dh_install` helper manually does
the glob'ing rather than using the `filedoublearray` for glob expansion.
  As a historical artefact, it never knew whether the `install` file
executable and therefore the restriction never fully applied there.

This artefact has (also) been there since the introduction of executable
debhelper config files.

I will accept this as a bug for dh_install not behaving as documented. I
am probably going to end with ratifying the current behaviour rather
than removing glob support (because removing glob support would require
more code and break anyone relying on it even though it should not work).

For everything else, glob support should be done by the executable
itself (possibly indirectly via dh-exec).

Best regards,
Niels

#1053834#46
Date:
2023-10-17 07:30:06 UTC
From:
To:
Hi Niels,

allow me, for the sake of argument, to champion the idea that what
`dh_install` does should done also by `dh_installman` (and others).

Independently from the implementation, I was quite surprised when I
realized, through trial and error, that just adding `#!/usr/bin/dh-exec`
to a `.manpages` file required two additional changes:

1) turning the glob patterns into exact paths, and
2) prefix each entry with `debian/tmp/`.

Although technically justified and documented in the man page, this goes
against the Principle of Least Astonishment for debhelper users.

(This is as surprising as the need to change debian/tmp/ into
debian/pkg/ when going from multi- to single-binary package.)

Making `dh_installman` behave like `dh_install` would not be a breaking
change. Currently no `.manpages` file use both globs and dh-exec (they
would not work), so enabling glob expansion would be a backward
compatible change.

Regards,