# Delete all old pkg_ programs



## larryvc (Mar 4, 2014)

I am running FreeBSD 9.2-RELEASE-p3 and have implemented pkgng and would like to get rid of all of the old pkg_  programs.

Do I just `pkg delete somepkg` them?  Is there a list of what needs to be deleted to completely remove the old package system?


----------



## SirDice (Mar 4, 2014)

There are no packages because the tools are part of the base OS. You need to set WITHOUT_PKGTOOLS in /etc/src.conf and rebuild world. They can then be removed with `make delete-old`.


----------



## larryvc (Mar 4, 2014)

Thanks for the answer.  Is it even worth going through all of that?  I do plan on staying with 9.2 until 10 matures and more of the kinks are worked out of it.


----------



## SirDice (Mar 4, 2014)

I wouldn't bother. Just make sure a `pkg_version` doesn't return anything, i.e. all packages have correctly been migrated to PKGNG. And don't forget to add WITH_PKGNG to make.conf.


----------



## larryvc (Mar 4, 2014)

`pkg_version` returned a lot of messages like this one:


```
pkg_version: the package info for package 'ImageMagick-6.8.0.7_5,1' is corrupt
```


----------



## SirDice (Mar 4, 2014)

I've had that happen too. You need to look in /var/db/pkg/, you'll see subdirectories for each package. Those are the old package registrations. For each subdirectory check if the package has been properly registered in the new system with pkg-info(8) (it may have a different version but that's OK). If it's registered properly you can remove that subdirectory. Once all those subdirectories are gone the old tools will show there's nothing installed. That's what we want.


----------



## larryvc (Mar 4, 2014)

In each subdirectory of /var/db/pkg/ there is only the file distfiles  and they were all created by `portmaster`.  Am I missing some thing here?  As I built everything from ports would I even have any packages?


----------



## kpa (Mar 4, 2014)

larryvc said:
			
		

> In each subdirectory of /var/db/pkg/ there is only the file distfiles  and they were all created by `portmaster`.  Am I missing some thing here?  As I built everything from ports would I even have any packages?



Installed ports are packages, after installation there's no way to tell if a package was installed by compiling a port or by installing a binary package.


----------



## SirDice (Mar 4, 2014)

larryvc said:
			
		

> In each subdirectory of /var/db/pkg/ there is only the file distfiles  and they were all created by `portmaster`.  Am I missing some thing here?


Because the subdirectories are still there the old tools think they're installed. And because they're not complete you get the error messages. Each of those subdirectories should be removed. 



> As I built everything from ports would I even have any packages?


A port actually builds a package and it's this package that gets installed. Ports and packages aren't that different. A package is nothing more than a pre-compiled port.


----------



## larryvc (Mar 4, 2014)

SirDice said:
			
		

> ... And because they're not complete you get the error messages. Each of those subdirectories should be removed.


What you both have explained about ports and packages was what I thought, before I confused myself.   I understood it right to begin with.   I deleted the subdirectories and now `pkg_version` returned 
	
	



```
pkg_version: no packages installed
```
.
What would be the reason for why the subdirectories were not complete?


----------



## SirDice (Mar 4, 2014)

Sometimes `pkg2ng` seems to trip up and leave some stuff behind. Not sure why but it's usually easily solved. Perhaps it's caused by the extra files portmaster adds.


----------



## kpa (Mar 4, 2014)

It's a design flaw in the original pkg_* tools, any extra files or directories (like the ones added by portmaster) may make them think that there are packages installed when there are not,


----------



## larryvc (Mar 4, 2014)

So now I have nothing in /var/db/pkg/, is this okay?  Where/how does `pkgng` store its data?  Is there a document I can read that will explain `pkgng`? The handbook is a bit lean in what it explains about it.

I think I may have to put a pot of coffee on the stove, I may be up for a while longer than I thought.

EDIT: I found the pkgng wiki.


----------



## larryvc (Mar 4, 2014)

I fixed the problem.  I now have local.sqlite and repo-FreeBSD.sqlite files in /var/db/pkg.  Always good to back up before deleting.  I'm done for tonight.  Thanks all.


----------



## SirDice (Mar 4, 2014)

Yes, I should have mentioned that. The most important one is the local.sqlite file, it contains the new PKGNG registrations. The other file will get downloaded if you do a `pkg update`, it's a copy of the repository database.

Documentation is indeed a little sparse. But they're more focussed on getting it working and fully functional right now. I'm sure when things settle down the documentation will get updated.


----------



## larryvc (Mar 4, 2014)

I just updated some packages with `portmaster` and it created the folders with the distfiles files in them.  They are identical to the folders that I had before and upon running `pkg_version` I got the same output that I indicated above.  I believe that I could have left those directories in place and  that `pkg2ng` had already converted the packages to the `pkgng` format correctly.  No biggie, I moved them back, except for the new ones that were created by the update, and will not use the old package commands any longer.

Thanks again.


----------

