debian - how to reinstall a package

I always thought that apt-get install --reinstall would reinstall a package, but it doesn't seem to work. I broke a file that belongs to a package (/etc/xen/scripts/vscsi) and want it reinstalled from the package source but it doesn't work - even if I delete the file, --reinstall doesn't put it back again. The man page doesn't tell me anything immediately obvious, although the solution will probably come to me as soon as I've hit send here. Any suggestions? Thanks James

Hi James On Sun, Aug 5, 2012 at 11:26 PM, James Harper <james.harper@bendigoit.com.au
wrote:
I always thought that apt-get install --reinstall would reinstall a package, but it doesn't seem to work. I broke a file that belongs to a package (/etc/xen/scripts/vscsi) and want it reinstalled from the package source but it doesn't work - even if I delete the file, --reinstall doesn't put it back again.
The man page doesn't tell me anything immediately obvious, although the solution will probably come to me as soon as I've hit send here.
Any suggestions?
Dont know if this is what you need but maybe an apt-get purge <package> will give you a fresh starting point -- Mark "Hiddensoul" Clohesy Mob Phone: (+61) 406 417 877 Email: hiddensoul@twistedsouls.com G-Talk: mark.clohesy@gmail.com - www.shed.twistedsouls.com - GNU/Linux.. Linux Counter #457297 "I would love to change the world, but they won't give me the source code" "Linux is user friendly...its just selective about who its friends are" "Never underestimate the bandwidth of a V8 station wagon full of tapes hurtling down the highway" "The difference between e-mail and regular mail is that computers handle e-mail, and computers never decide to come to work one day and shoot all the other computers"

Hiddensoul (Mark Clohesy) <hiddensoul@twistedsouls.com> wrote:
Dont know if this is what you need but maybe an apt-get purge <package> will give you a fresh starting point
Indeed it should. Configuration files are not removed by a remove command; you need to use purge instead, and I strongly suspect --reinstall performs a "remove" rather than a "purge".

On Mon, 6 Aug 2012, Jason White wrote:
Hiddensoul (Mark Clohesy) <hiddensoul@twistedsouls.com> wrote:
Dont know if this is what you need but maybe an apt-get purge <package> will give you a fresh starting point
Indeed it should.
Configuration files are not removed by a remove command; you need to use purge instead, and I strongly suspect --reinstall performs a "remove" rather than a "purge".
Which is a pain in the arse, because sometimes you just want to reinstall the default package version of a config file, and don't care to lose the other half dozen customised files from that package that would also be removed by a purge. Apt/dpkg also has some pretty stupid handling regarding obsolete conffiles. dpkg -s shows a file in /etc/ as obsolete, so remove the conf file, and dpkg -s still shows that file as obsolete even though it no longer exists! Er, and I had other beefs with it, but I can't remember what they were. Carry on. (maybe that it won't install a new renamed version of that conffile even with a --reinstall, so then you have to purge and start again. Some corner case, anyway). -- Tim Connors

On 06/08/2012, at 4:55 PM, Tim Connors <tconnors@rather.puzzling.org> wrote:
On Mon, 6 Aug 2012, Jason White wrote:
Configuration files are not removed by a remove command; you need to use purge instead, and I strongly suspect --reinstall performs a "remove" rather than a "purge".
Which is a pain in the arse, because sometimes you just want to reinstall the default package version of a config file, and don't care to lose the other half dozen customised files from that package that would also be removed by a purge.
I wonder if "apt-get --purge --reinstall install <package>" behaves like that. If not, perhaps someone should write a patch to ensure that it does. ;-)

Hi James
On Sun, Aug 5, 2012 at 11:26 PM, James Harper <james.harper@bendigoit.com.au> wrote:
I always thought that apt-get install --reinstall would reinstall a package, but it doesn't seem to work. I broke a file that belongs to a package (/etc/xen/scripts/vscsi) and want it reinstalled from the package source but it doesn't work - even if I delete the file, --reinstall doesn't put it back again.
The man page doesn't tell me anything immediately obvious, although the solution will probably come to me as soon as I've hit send here.
Any suggestions?
Dont know if this is what you need but maybe an apt-get purge <package> will give you a fresh starting point
Thanks I did end up doing that and it seemed to work (along with --force-depends so I could remove it without removing other dependencies). It would be nice to be able to cherry pick files to put back again - this isn't the first time I've accidently broken a script while trying to debug it :) James

James Harper <james.harper@bendigoit.com.au> wrote:
It would be nice to be able to cherry pick files to put back again - this isn't the first time I've accidently broken a script while trying to debug it :)
If it's in /etc you can always install etckeeper (unless disk space is a problem) and have the other advantages that arise from having your entire /etc hierarchy under revision control. If it isn't in /etc then I would suggest: 1. debcheckout packagename 2. Make the changes in the checked out files. 3. Change the version number with dch -i for example (or just the dch command line). 4. Rebuild the package and use dpkg -i to install your local version. You can then revert to the official version if your changes don't work as expected. 5. Submit a patch and a bug report.

James Harper wrote:
I always thought that apt-get install --reinstall would reinstall a package, but it doesn't seem to work. I broke a file that belongs to a package (/etc/xen/scripts/vscsi) and want it reinstalled from the package source but it doesn't work - even if I delete the file, --reinstall doesn't put it back again.
It reinstalls a package, but leaves conffiles as you configured them. So if you delete or break a file in /etc, a reinstall will faithfully preserve that configuration. The right answer to this problem is etckeeper. Failing that, separate purge and install commands (if you can do so without a lot of dependency grief). Failing that, aptitude download <package name>, pull it open with dpkg -x, and grab the conffile in question.
participants (6)
-
Hiddensoul (Mark Clohesy)
-
James Harper
-
Jason White
-
Jeremy Visser
-
Tim Connors
-
Trent W. Buck