0

If I'm writing a Debian package maintainer script (such as a pre-install script) for a package I create, how can I make the script determine if it is supposed to be running in non-interactive mode (e.g. if apt-get install was invoked with -y, and things like that)?

0

1 Answer 1

1

If your maintainer scripts need to interact with the user running the installation, the recommended way to proceed is to use debconf; see Conditional file and directory installation in Debian Packages for pointers. This might seem complicated but it does bring a number of benefits — not only does debconf handle non-interactive setups (with an explicit DEBIAN_FRONTEND=noninteractive invocation, or because there is no way to interact with a user), it also supports various frontends, and settings managed by debconf can be set ahead of installation (using “pre-seeding”). This might not be relevant in your case but debconf also supports prompts in various languages.

Note that apt-get flags are separate from maintainer script interactivity; see Is DEBIAN_FRONTEND=noninteractive redundant with apt-get -yqq?

2
  • Thanks for this. I switched over to debconf just now, it was rather easy and is definitely the right way to go. However, it still displays unanswered questions even if -y is specified to apt-get, so I still have the same question: How can I skip the debconf questions and use the defaults if -y is specified? Commented Apr 22, 2024 at 15:50
  • 1
    Ah, I thought “and things like that” in the question was significant. See the last link in the answer: -y given to apt-get isn’t visible to maintainer scripts, you need to set DEBIAN_FRONTEND. Commented Apr 22, 2024 at 15:55

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.