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

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

Gergely Nagy <algernon@balabit.hu> writes:

> 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.
> (There's also a rename-capable .install helper in the sources, but
> because the syntax used by it is bad to say the least, it's disabled for
> now).

After a night of very little sleep, I came up with a hack so funny, that
it even scares me. Nevertheless, since I had nightmares ever since, I'm
going to tell you all, dear readers, so the horror can be shared by
many, and in years to come, we can frighten little children with it.

I rewrote the .install helper so that it uses a nicer syntax:

| #! /usr/bin/dh-exec
| etc/sample.conf => /etc/my-package/my-package.conf
| examples/* /usr/share/doc/my-package/examples

The syntax itself isn't all that bad. But the implementation! OH MY!

To make it behave nicely, and not break dh_install in various
interesting ways, the requirement was that it must be dh_install that
will put the files to their final place. The script must not fiddle with
the destination at all.

Another requirement I had was that I do not wish to litter the source
tree, so copying the file to a new name within the source tree was ruled
out aswell.

I didn't want to leave temporary files behind, as those would need extra
care to get properly cleaned up.

And then it dawned on me: why not abuse debian/tmp for this purpose? It
will be deleted by dh_prep on clean, so whatever I put there, will be
cleaned up.

If I use a suitable temporary directory under debian/tmp, then it should
not conflict with anything else, either.

So I went ahead and did that. The new helper will take the input
mentioned above, copy etc/sample.conf to something like
debian/tmp/dh-exec.DEADBEEF/etc/my-package/my-package.conf, and rewrite
its output to look like this:

| dh-exec.DEADBEEF/etc/my-package/my-package.conf /etc/my-package
| examples/* /usr/share/doc/my-package/examples

As far as I see, this should cause no ill side-effects, apart from
strangely named directories under debian/tmp.

The code is available on the feature/exec-install/arrow-syntax[1] branch
of my repository[2].

 [1]: https://github.com/algernon/dh-exec/tree/feature/exec-install/arrow-syntax
 [2]: https://github.com/algernon/dh-exec

Let me know what you think.


Reply to: