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.
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!