Wednesday, November 15, 2006

Non-interative package installation with APT

One of the frequently voiced frustrations of working with Debian's APT package management tool is the difficulty of running it completely non-interactively. I've had to solve this problem recently and found none of the usual solutions to be as successful as they claim to be.

Normally, even with when specifying the "noninteractive" option, the question of whether or not to replace local configuration files with the packager's configuration files will still appear and block the script. However, the following bash command will automatically select the default option for any questions that appear during installation:


/usr/bin/yes '' | DEBIAN_FRONTEND=noninteractive \
/usr/bin/apt-get -y install package


I'd be interested to hear from anybody who finds a real situation that for which the above technique does not work.

Note: when the empty parameter '' is passed to /usr/bin/yes it outputs a stream of carriage returns, rather than the usual stream of 'y's. This causes the default, usually safe, option to be selected as the answer to the questions that any packages may ask.

0 Comments:

Post a Comment

<< Home