[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: RFC/RFR: dh-exec -- Scripts to help with executable debhelper files



Roland Mas <lolando@debian.org> writes:

> Gergely Nagy, 2011-12-14 12:04:03 +0100 :
>
>> Hi!
>>
>> As a result of a recent discussion on this list, I started to prepare a
>> package[1] that will hopefully make it easier and more straightforward
>> to use the executable debhelper files introduces in 8.9.12.
>>
>> For now, it can only substitute environment variables, and stuff
>> dpkg-architecture(1) knows about (yes, it will work just fine even when
>> $DEB_HOST_MULTIARCH and similar aren't available in the environment),
>> but there's possibility to add more helpers, as the need arises, and a
>> suitable syntax can be agreed upon.
>
>   I'm sorry I'm not giving a true review of dh-exec, but I'm wondering
> if there could be a way of extending either dh or dh-exec so as to
> handle generic substitutions (or other preprocessing) in maintainer
> scripts.  There's already some stuff to handle Debconf (with the
> #DEBHELPER# magic), but I'm looking for something more generic.  Maybe
> dh-exec could be involved?

It can be done with dh-exec, for files that are executable. The
substitutions are actually done by two perl scripts (which are held
together with dh-exec-subst, which in turn, is called via dh-exec), one
expands environment variables, the other expands dpkg-architecture
stuff.

There is no limit on what can be expanded, and it's as easy as writing a
simple script, and dropping it into the appropriate place (ie, my
mailbox, so I can add it to dh-exec).

For example, if you'd want to expand debconf variables (you don't want
to do this, by the way), so that ${debconf:postfix/destinations} would
expand to the appropriate value, you could do something like this:

,----
| #! /usr/bin/perl -w
| use strict;
| use Debconf::Client::ConfModule ':all';
|
| while (<>) {
|   next unless /\$\{debconf:[^\}]+\}/;
|   s#(\$\{debconf:([^\}]+)\})/get($2) || $1/eg;
|   print;
| }
`----

(The above code is completely untested, but it should give you an idea).

You can make it expand ${...} whatever way you want it to, or can even
make it expand #MYSILLYSTUFF# specially, and so on.

dh-exec does not, and will not replace or extend debhelper's autoscripts
stuff (that's how the #DEBHELPER# magic is handled), it's only for
making common tasks that would be done with executable dh config files
easier. These do not include maintainer scripts, that's out of the scope
for dh-exec.

-- 
|8]


Reply to: