2

I have a .deb installer for a Django system and there are questions I need to ask the person installing the software. I can see a few ways to do this, and I want to know what constitutes best practice for a Debian package.

Now normally, debconf would be the obvious solution. However in this case I want to ask the question every time, rather than have Debian memorize them and apply them to every subsequent upgrade. The reason for that has to do with the nature of the questions. Specifically, the questions are "Do you want to apply database migrations now?" and "Do you want to set up a demo database?"

Now, these could both be done manually after the install, but experience so far shows that this step is easy to forget, so I'd like to prompt for it. The Migration step I'd do automatically, except we occasionally need to migrate databases from other machines, and that's easier to do before migrations are applied. The "demo database" question would only usually be used on a first install and therefore depends on the migration case. BUT, we don't want Debian to remember that choice and apply it every time since it could damage existing, in-use databases.

So I was wondering what the orthodox, Debian-ish approach might be. I can use a shell prompt from the postinst script, but if there's a better way I'd sooner do that. I should add that I know about "Ask Again", but that seems to only work as a global setting, and I'd sooner make this just for this package.

One last thing: this is an in-house system and never going to be hosted on public repos, so I'm not unduly worried about considerations like unattended installs or non-bash installation environments.

This has been bugging me for a couple of weeks now. Any help gratefully received.

2

There is an orthodox approach to your problem, which should allow you to handle your situation in a “Debian-like” way.

You can reset a debconf question so that it’s shown again, every time: use db_reset to forget the previous answer (if necessary), and db_fset ... seen false to forget that the question has been shown previously. That should allow you to ask whether to apply migrations every time.

To handle the demo database question, I’d add an additional, hidden setting, which remembers whether the demo database was installed. That way, you can use the usual debconf mechanisms to remember whether the question has been asked or not, so that it’s only shown on first installations; and then, you can check to see whether the demo database has already been installed, to avoid installing it twice.

1

I'd split the demo database out into a separate package. This is something that novice users play with, but I'd want to keep this and any supporting code out of a production environment. Getting asked about whether I wanted to install demo stuff while all I want to do is update would be really annoying.

The update question I'd handle as a normal DebConf question, but reversed: a low-priority (so usually hidden), default-no question that asks whether updates should be stopped if a database migration is necessary. This allows the admin to configure either a fully automated process, or one that is fully automated except for migrations.

Most updates will not need a migration, so it is pointless to bother the user then, and giving the user an option to leave the old system running and abort the update gives them a safe option.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.