# Keep the system clean



## Rulus (Dec 4, 2013)

Hi.

When I uninstall a package, the files created by it remain in the system. Is there any way of finding and deleting these files (if I'm right, `pkg info -l` only works with installed packages)? Also, if I recompile FreeBSD, will these files be deleted?

Thanks.


----------



## Beastie (Dec 4, 2013)

Rulus said:
			
		

> When I uninstall a package, the files created by it remain in the system.


That's wrong. Whatever was created during the installation is removed during the uninstallation. The two processes use the same data (that is included in the package itself). I believe only those files that were modified since the installation will be left.



			
				Rulus said:
			
		

> Is there any way of finding and deleting these files


They're listed in the +MANIFEST file included by standard in the root directory of every package (`tar xf somepackage.txz "+MANIFEST"`).



			
				Rulus said:
			
		

> Also, if I recompile FreeBSD, will these files be deleted?


On FreeBSD, the system and third-party applications installed through the ports tree or packages are two completely separate entities. When you "recompile FreeBSD" only the kernel and world (system applications and related files) can be rebuilt. No third-party file (anything under /usr/local) is ever touched during that process.


----------



## Rulus (Dec 4, 2013)

Thanks for the tip of the manifest. I didn't know. Are they in the same format of pkg-plist for ports?

About the files, after I run `make deinstall`, at least some of the files "survive". For example, after I uninstall editors/vim, /use/local/share/vim is not deleted, but some of the files in it are. I think that these files will not be useful anymore, so would be nice a way of find uninstalled programs files, since I don't remember what of they I had installed ever.

I know that kernel and third-party apps are both independent, but I didn't know if something was touched during the rebuild.

Thanks for your help.


----------



## fonz (Dec 4, 2013)

Rulus said:
			
		

> For example, after I uninstall editors/vim, /use/local/share/vim is not deleted, but some of the files in it are.


Ports are _supposed_ to delete upon deinstall anything they installed, but in practice this doesn't always go 100% right. The thing is that somewhere it has to be specified which files are/were installed. If this is being done manually, occasionally files are accidentally "forgotten about". I have to say, though, that the ports infrastructure is moving towards more automation in this area.

Moreover, please note that editors/vim recently got a new maintainer, who is probably quite busy fixing various things.


----------



## kpa (Dec 4, 2013)

There's also a long running problem with ports that install their files under the same shared directory but don't clean up after themselves properly because the ports may be uninstalled in a different order than they were installed in. Many of the DocBook SGML/XML DTD ports and X font ports are notorious for leaving leftover files behind on uninstall if they happen to be uninstalled in a different order than they were installed in.


----------



## fonz (Dec 4, 2013)

Yes, that too. However, I don't think that adequately explains why deinstalling editors/vim (as mentioned above as an example) leaves /usr/local/share/vim around. The only other port that has any business there is editors/vim-lite and those two are mutually exclusive (CONFLICTS).


----------



## wblock@ (Dec 4, 2013)

Some files are supposed to be left behind.  Any config file that has been edited, for example.


----------



## Rulus (Dec 5, 2013)

And is there a way of not keeping these files? Another example is textproc/texi2html, I am pretty sure that I didn't modify any file, maybe  another program did.

Would be safe make a script to find and delete these files using pkg-plist?



			
				fonz said:
			
		

> I have to say, though, that the ports infrastructure is moving towards more automation in this area.


Have you more information about this?

Thanks you all for your help


----------



## fonz (Dec 5, 2013)

Rulus said:
			
		

> fonz said:
> 
> 
> 
> ...


Part of it comes with staging: https://wiki.freebsd.org/ports/StageDir.


----------

