Take the 2-minute tour ×

I have a deb package that I've created. From the postinst script, I would like to run:

apt-get update

The package adds a proxy to the apt system by dropping a file in /etc/apt/apt.conf.d/. I would like to force the apt system to do the equivalent of "apt-get update". However, I cannot run that command directly from postinst, since the apt lock file has already been placed by dpkg which is installing this package! Is there some debconf tools/commands to do this?

As a bonus, I would love to be able to remove a package from within preinst/postinst:

apt-get remove popularitycontest

NOTE - this package is for an internal project - not a deb that will ever be released into the wild or submitted to Debian.

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

It is not possible to invoke an APT command (apt-get, aptitude..) from within a package script (preinst, postinst, prerm, postrm...).

Enabling so would raise lots of problems, especially for dependency and ordering of package installation.

Various workaround have been used, either by using proper package (pre) dependencies or by providing an easy-to-use tool for your users (like module-assistant and other tools).

In your case, your package could just conflict with popularitycontest to uninstall it. Also, if your user have "your" package, it means they have already added an entry to their sources.list, so they can add another one!

share|improve this answer
I was hoping there would be a debconf command for doing this kind of thing - or at least triggering an "apt-get update". –  Seth Sep 5 '13 at 19:12
As for using the conflict field, it means you have to remove it yourself, before installing. I could not find an automatic way to do it. Perhaps a module assistant is the way to go. –  Seth Sep 5 '13 at 19:12
add comment

Your Answer


