# pkg_version the package info for package is corrupt



## setevoy (Aug 17, 2013)

Hello, people.

Sorry - I know that there are a lot of topics like this one - but I'll wish to post this one.

So - here is a problem. One friend of mine asked me to see what happened with his server. 
When I tried to run `# pkg_version -l '<'` I got a lot of errors like:


```
pkg_version: the package info for package 'proftpd-1.3.4d' is corrupt
pkg_version: the package info for package 'python26-2.6.6' is corrupt
pkg_version: the package info for package 'rar-4.0b6,2' is corrupt
```

There are also Apache and MySQL servers, Nginx and others. So, I tried to do next (on wget for example):

`# rm -rf /var/db/pkg/wget-1.14`
`# rm -rf /var/db/pkg/wget-1.14_2/`

Then I just reinstalled it by `# cd /usr/ports/ftp/wget && make install clean`.

It solved (?) the problem with wget... I mean - it now displays normally in pkg_version and pkg_info.

Is it a good solution to solve that problem?

Just note please - there are really a lot of broken dependencies. And I'm not sure it is a good idea to rebuild Perl, Python, MySQL, Apache etc. Also, the problem is that a lot of them are not being updated very often...

Thanks for any tips.


----------



## cpm@ (Aug 17, 2013)

Are you using pkgng? If so, you'll get the "package 'PKG' is corrupt" message for everything when you use pkg_version(1)(). You should instead be using the `pkg version` command.

Otherwise, if you have a recent backup of /var/db/pkg/* then you should restore from there. Alternatively, you could reinstall the ports to fix up the /var/db/pkg/* entries as you pretended


----------



## setevoy (Aug 17, 2013)

cpu82 said:
			
		

> Are you using pkgng? If so, you'll get the "package 'PKG' is corrupt" message for everything when you use pkg_version(1)(). You should instead be using `pkg version` command.




I'm not but I thought - maybe somebody else has used it before? But - it seems no:
`# pkg version`

```
The package management tool is not yet installed on your system.
Do you want to fetch and install it now? [y/N]:
```



> Otherwise, if you have a recent backup of /var/db/pkg/* then you should restore from there.



Unfortunately - there are no any system backups  As I told, it's not my server and its owner doesn't bother with it :\



> Alternatively, you could reinstall the ports to fix up the /var/db/pkg/* entries as you pretended



So, you mean my solution, which I described in first post?


----------



## cpm@ (Aug 17, 2013)

setevoy said:
			
		

> So - you mean my solution, which I described in first post?



Summarizing, you are correct


----------



## youngunix (Aug 18, 2013)

If you've used the following steps to make the switch to PKGNG:

```
20121015:
 	AFFECTS: users of ports-mgmt/portmaster
 	AUTHOR: bdrewery@FreeBSD.org
 	
 	Portmaster now supports pkgng. To use pkgng, enable the patch in the port,
 	enable pkgng in your make.conf, and convert your existing /var/db/pkg
 	database. Also see UPDATING entry 20121010 if you are on a recent CURRENT
 	and do not want to use pkg.
 	
 	This is optional and not currently required.
 	
 	# make -C /usr/ports/ports-mgmt/pkg install clean
 	# make -C /usr/ports/ports-mgmt/portmaster config build deinstall install clean
 	# echo 'WITH_PKGNG=yes' >> /etc/make.conf
 	# pkg2ng
```
Then you need to stop using `pkg_*`. Here are some examples:

```
# old way, install binary version of the package
[CMD]# pkg_add -r PKG_NAME[/CMD]
 
# New way,  install binary version of package
[CMD]# pkg install PKG_NAME[/CMD]
* You need to setup a repository before running this command 
 
# old way to list outdated packages
[CMD]# pkg_version -vIL=[/CMD]
 
# New way to list outdated packages
[CMD]# pkg version -vIL=[/CMD]
 
# Old way, list files installed by package
[CMD]# pkg_info -L PKG_NAME[/CMD]

# New way, list files installed by package
[CMD]# pkg info -l PKG_NAME[/CMD]
 
# Old way, list package that installed a file
[CMD]# pkg_info -W /path/to/file[/CMD]
 
# New way, list package that installed a file
[CMD]# pkg which /path/to/file[/CMD]
```
You can type `# pkg` in your terminal to get more info and a full list of supported commands.


----------



## kpa (Aug 18, 2013)

It's clear that the OP does not have a PKGNG database at /var/db/pkg and there's no reason to start using it. What I would do is to install ports-mgmt/portmaster and use the repair options of it to return the /var/db/pkg database into a sane state. Basically:

`portmaster --check-depends`
`portmaster --check-port-dbdir`
`portmaster --clean-distfiles`


----------



## setevoy (Aug 18, 2013)

kpa said:
			
		

> It's clear that the OP does not have a PKGNG database at /var/db/pkg and there's no reason to start using it. What I would do is to install ports-mgmt/portmaster and use the repair options of it to return the /var/db/pkg database in to a sane state. Basically:
> 
> `portmaster --check-depends`
> `portmaster --check-port-dbdir`
> `portmaster --clean-distfiles`



I already did it to fix errors like 
	
	



```
"pkg_version: corrupted record for package ImageMagick-nox11-6.6.7.10_2 (pkgdep line without argument), ignoring"
```

But none of portmater's options helps with my current problem :\


----------



## cpm@ (Aug 18, 2013)

setevoy said:
			
		

> I already did it to fix errors like `"pkg_version: corrupted record for package ImageMagick-nox11-6.6.7.10_2 (pkgdep line without argument), ignoring"`
> 
> But none of portmater's options helps with my current problem :\



To fix that try the following:

```
# portmaster --check-depends -y
# portmaster -a
```

Also another way to resolve this problem explained by Doug Barton:
http://lists.freebsd.org/pipermail/freebsd-ports/2009-August/056154.html.


----------



## jb_fvwm2 (Aug 18, 2013)

In my experience, the problem in the original post (fixing of the "corrupt" messages), once fixed, will increment upwards once more.  Probably no harm in just ignoring them... I would not post such a solution if the [cmd=] --check-depends [/cmd] did not use so much time or CPU power.


----------



## setevoy (Aug 18, 2013)

So, thanks to all - I'm already ended with it and it seems - everything is perfect 

Solution was, as I said before, to remove the directory with the affected port `rm -rf /var/db/pkg/portname` and then just reinstall it over again. All configurations saved, all dependencies rewritten. 

pkg_info and pkg_version display information now without any corrupts.

Hope - it is happened first and last time!


----------

