# Make deinstall reinstall



## teoburger (May 15, 2010)

Hallo,

I install some port using command:

[cmd=]make install clean[/cmd]

When I want to reinstall this port should I use:

[cmd=]make deinstall reinstall[/cmd]

or

[cmd=]make install clean[/cmd]?


----------



## graudeejs (May 15, 2010)

I do

```
# make deinstall clean reinstall clean
```
1st clean is nessacery only if it wasn't cleaned last time


----------



## SirDice (May 15, 2010)

Don't do *make deinstall*. Only use that if you are deinstalling the exact same version as the port. Use pkg_delete(1) to remove an installed port.


----------



## graudeejs (May 15, 2010)

Never thought about that. Now that you mentioned, it makes perfect logic.
Thanks


----------



## phoenix (May 15, 2010)

Yeah, "make deinstall" uses the information in the port Makefile and pkg-plist to see what to remove.  If the version in the Makefile is not identical to the installed version, files can be left behind or accidentally deleted.

"pkg_delete" uses the information in /var/db/pkg, which corresponds to what's actually on the disk.

"make deinstall" and "make reinstall" should really only be used for testing.  "pkg_delete" and "make install" are better, more reliable tools.


----------



## wblock@ (May 15, 2010)

phoenix said:
			
		

> Yeah, "make deinstall" uses the information in the port Makefile and pkg-plist to see what to remove.  If the version in the Makefile is not identical to the installed version, files can be left behind or accidentally deleted.



`# less +/deinstall: /usr/ports/Mk/bsd.port.mk` shows that 'make deinstall' actually just runs 'pkg_delete -f' on the installed version.

So 'make deinstall' and 'pkg_delete' are the same, except that 'make deinstall' has some additional checks and so is actually safer.  pkg_delete -f will blindly delete whatever package you tell it, while deinstall will actually look up the correct package.

But back to the original question:`# make reinstall` lets you reinstall a port without deinstalling it first.  If there's a need to redo a port, I usually use deinstall, look for leftover files, then install.


----------



## phoenix (May 15, 2010)

wblock said:
			
		

> `# less +/deinstall: /usr/ports/Mk/bsd.port.mk` shows that 'make deinstall' actually just runs 'pkg_delete -f' on the installed version.



That's right.  They changed how this works last year, to remove the possible mismatch.  I always forget this.  Thanks for the reminder.  One of these days, I'll remember it.  



> So 'make deinstall' and 'pkg_delete' are the same, except that 'make deinstall' has some additional checks and so is actually safer.  pkg_delete -f will blindly delete whatever package you tell it, while deinstall will actually look up the correct package.



Adding *-xi* to pkg_delete makes it much safer as well.


----------



## wblock@ (May 15, 2010)

phoenix said:
			
		

> That's right.  They changed how this works last year, to remove the possible mismatch.  I always forget this.  Thanks for the reminder.  One of these days, I'll remember it.



make deinstall as pkg_delete has been around since... well, a long time.  Maybe you're thinking of that horrible "this conflicts with something you have installed so you can't even download it" change last year.


----------



## mdudley (Feb 18, 2011)

When trying to update my psp, it said I had to do a *make deinstall* and *make reinstall* first, which I did.  Now it will not install properly, not creating or populating the extensions directory of 20090626 for one.  So I guess I need to do a *pkg_delete* of the old version now. Problem is, I don't know the exact version number of the old version, and cannot find it since the new version has been installed.  I know it is 5.2.XXXX, but that is all, and *pkg_delete* requires the proper version number to work.  Is there any way I can find out what versions of php still need deleting?

Marshall


----------



## SirDice (Feb 18, 2011)

mdudley said:
			
		

> I know it is 5.2.XXXX, but that is all, and pkg_delete requires the proper version number to work.


See pkg_delete(1), more specifically the -x option.



> Is there any way I can find out what versions of php still need deleting?


pkg_version(1), pkg_info(1).


----------

