# pkg_version/portversion conflict



## dougs (Jun 30, 2010)

My system complains that postgresql-contrib succeeds index as follows:


```
orion-root@~: pkg_version -voIL=
databases/postgresql82-contrib      >   succeeds index (index has 8.2.17_1)
orion-root@~: portversion -v | g "<"
[Updating the pkgdb <format:bdb_btree> in /var/db/pkg ... - 191 packages found (-5 +5) 
(...)..... done]
[Updating the portsdb <format:bdb_btree> in /usr/ports ... - 21935 port entries found 
.........1000.........2000.........3000.........4000.........5000.........6000.........
7000.........8000.........9000.........10000.........11000.........12000.........13000.
........14000.........15000.........16000.........17000.........18000.........19000....
.....20000.........21000......... ..... done]
orion-root@~: portversion -v | g ">"
postgresql-contrib-8.4.3_2  >  succeeds port (port has 8.2.17_1) 
orion-root@~:
```

I find it strange that portversion -v reports databases/postgresql-8.4.3_2 while pkg_version -voIL= reports databases/postgresql82-contrib. I took over this system from a previous sysadmin so I'm guessing at one point databases/postgresql-contrib was installed as a package.

I saw in another thread on this forum that someone ran make index in /usr/ports and succeeded in resolving the conflict. I tried that and it didn't succeed.

Looking at contents of /usr/ports:


```
orion-root@~: ll /usr/ports
total 110606
-rw-r--r--     1 root  wheel        19 Jul 14  1997 .cvsignore
-rw-r--r--     1 root  wheel   1878245 Jun 29 15:20 .portsnap.INDEX
-rw-r--r--     1 root  wheel     56860 Jun  6 10:17 CHANGES
-rw-r--r--     1 root  wheel      1498 Dec 31 08:47 COPYRIGHT
-rw-r--r--     1 root  wheel      2396 Jun 28 00:10 GIDs
-rw-r--r--     1 root  wheel  10441465 Nov 24  2008 INDEX
-rw-r--r--     1 root  wheel  17370624 Jun 29 15:20 INDEX-5
-rw-r--r--     1 root  wheel  21985723 Jun 29 15:20 INDEX-6
-rw-r--r--     1 root  wheel  21870880 Jun 29 15:21 INDEX-7
-rw-r--r--     1 root  wheel  38115328 Jun 29 17:52 INDEX-7.db
-rw-r--r--     1 root  wheel      4631 Feb  7 03:51 KNOBS
-rw-r--r--     1 root  wheel     34225 Jun  8 00:18 LEGAL
-rw-r--r--     1 root  wheel    334852 Jun 27 06:06 MOVED
-rw-r--r--     1 root  wheel      6018 Dec 18  2009 Makefile
drwxr-xr-x     2 root  wheel      1536 Jun 23 13:50 Mk
-rw-r--r--     1 root  wheel      1298 May 22  2006 README
drwxr-xr-x     2 root  wheel       512 May 24  2007 Templates
drwxr-xr-x     4 root  wheel       512 Jun 29 15:20 Tools
-rw-r--r--     1 root  wheel     12087 Jun 28 00:10 UIDs
-rw-r--r--     1 root  wheel    336477 Jun 26 01:33 UPDATING
drwxr-xr-x    31 root  wheel      1024 Jun  2 10:39 accessibility

<..snip..>

drwxr-xr-x   145 root  wheel      3072 Jun 29 15:20 x11-wm
orion-root@~:
```

I see that I have several indexes. This system started out using FBSD 5.x and over time it was upgraded to version 6.x and is now at 7.3 p1 which, I assume, would account for these indexes.

How can I best fix this? As a side note, do I really need all of these indexes? What is the minimum I need to maintain ports? I regularly use portmaster but on occasion I have used portupgrade and portmanager to upgrade ports. I do not use packages. The handbook does not appear to provide me the answers I am seeking.

~Doug


----------



## SirDice (Jun 30, 2010)

Remove all the INDEX* files. Then run 

```
cd /usr/ports/
make index
```

That will recreate the INDEX-7 file with the information found in your current ports tree.


----------



## dougs (Jun 30, 2010)

I have this exact problem on another system but this system is *much* faster than the other system so am posting the results from this system here:


```
corvus-root@/usr/ports: mv INDEX INDEX.old
corvus-root@/usr/ports: mv INDEX-6 INDEX-6.old
corvus-root@/usr/ports: mv INDEX-6.db INDEX-6.db.old
corvus-root@/usr/ports: mv INDEX-7 INDEX-7.old        
corvus-root@/usr/ports: mv INDEX-7.db INDEX-7.db.old  
corvus-root@/usr/ports: mv INDEX-8 INDEX-8.old        
corvus-root@/usr/ports: mv INDEX-8.db INDEX-8.db.old  
corvus-root@/usr/ports: make index
Generating INDEX-8 - please wait..Warning: Duplicate INDEX entry: freeciv-nox11-2.2.1_1
Warning: Duplicate INDEX entry: ocaml-notk-3.11.2
Warning: Duplicate INDEX entry: ploticus-nox11-2.40_3
Warning: Duplicate INDEX entry: cvsup-without-gui-16.1h_4
Warning: Duplicate INDEX entry: ghostscript7-nox11-7.07_23
Warning: Duplicate INDEX entry: ghostscript8-nox11-8.71_2
Warning: Duplicate INDEX entry: ssh2-nox11-3.2.9.1_8
Warning: Duplicate INDEX entry: ap22-mod_rpaf-ap2-0.6
 Done.
corvus-root@/usr/ports: pkg_version -voIL=
databases/postgresql82-contrib      >   succeeds index (index has 8.2.17_1)
corvus-root@/usr/ports: portversion -v
[Updating the portsdb <format:bdb_btree> in /usr/ports ... - 21927 port entries found
 .......1000.........2000.........3000.........4000.........5000.........6000.........
7000.........8000.........9000.........10000.........11000.........12000.........1300
0.........14000.........15000.........16000.........17000.........18000.........19000
.........20000.........21000......... ..... done]
9e-1.0                      =  up-to-date with port 

 < ..snip.. >

postgresql-client-8.4.4_1   =  up-to-date with port 
postgresql-contrib-8.4.3_2  >  succeeds port (port has 8.2.17_1) 
postgresql-server-8.4.4_2   =  up-to-date with port 

 < ..snip.. >

xz-4.999.9_1                =  up-to-date with port 
corvus-root@/usr/ports:  ll | g INDEX
-rw-r--r--     1 root  wheel   1878245 Jun 29 17:03 .portsnap.INDEX
-rw-r--r--     1 root  wheel  36355072 Feb 15  2008 INDEX-6.db.old
-rw-r--r--     1 root  wheel  21985371 Jun 29 17:03 INDEX-6.old
-rw-r--r--     1 root  wheel  36447232 Feb 18 17:36 INDEX-7.db.old
-rw-r--r--     1 root  wheel  21870528 Jun 29 17:03 INDEX-7.old
-rw-r--r--     1 root  wheel  21698492 Jun 30 09:45 INDEX-8
-rw-r--r--     1 root  wheel  37773312 Jun 30 10:09 INDEX-8.db
-rw-r--r--     1 root  wheel  38196224 Jun 29 17:03 INDEX-8.db.old
-rw-r--r--     1 root  wheel  21893085 Jun 29 17:03 INDEX-8.old
-rw-r--r--     1 root  wheel  10441465 Feb 18 15:23 INDEX.old
corvus-root@/usr/ports:
```

make index didn't work for me here.  Only INDEX-8 and INDEX-8.db were generated here.


----------



## dougs (Jun 30, 2010)

Okay, the original system finished make index. Here's the output:


```
orion-root@/usr/ports: make index
Generating INDEX-7 - please wait..Warning: Duplicate INDEX entry: ap13-mod_rpaf-0.6
 Done.
```

Checking to see if index is clean:

```
orion-root@/usr/ports: pkg_version -voIL=
databases/postgresql82-contrib      >   succeeds index (index has 8.2.17_1)
orion-root@/usr/ports: portversion -v | g postgresql
[Updating the portsdb <format:bdb_btree> in /usr/ports ... - 21934 port entries found
.........1000.........2000.........3000.........4000.........5000.........6000.......
..7000.........8000.........9000.........10000.........11000.........12000.........13
000.........14000.........15000.........16000.........17000.........18000.........190
00.........20000.........21000......... ..... done]
postgresql-client-8.4.4_1   =  up-to-date with port 
postgresql-contrib-8.4.3_2  >  succeeds port (port has 8.2.17_1) 
postgresql-server-8.4.4_2   =  up-to-date with port 
orion-root@/usr/ports:
```

I still have the same issue as before. Now what?

I notice that in both instances, I received a warning saying that the indexes had duplicate INDEX entry. How do I go about fixing this?


----------



## wblock@ (Jun 30, 2010)

dougs said:
			
		

> ```
> postgresql-client-8.4.4_1   =  up-to-date with port
> postgresql-contrib-8.4.3_2  >  succeeds port (port has 8.2.17_1)
> postgresql-server-8.4.4_2   =  up-to-date with port
> ...



You can get a later version of a port if the ports tree has been updated but the index files have not.  Or by manually updating an individual port directory, which may be what happened here.  Or, I suppose, installing a package that's later than what's in the ports tree.

Either way, it looks like these versions are slightly behind what's current in ports.  databases/postgresql84-contrib is 8.4.4_1 now.  Updating ports ought to show the right versions.

As far as the error of portversion and pkg_version differing, don't know.  The -o option to pkg_version may be misleading.  I use
`# portversion -vL=`

`# portsdb -Fu`
will fetch the pre-built index and build index.db from it.


----------



## zeiz (Jun 30, 2010)

_-contrib_ package could be installed not from ports but from postgre website (their latest ver).

In general I used to have something like that and I fixed it by switching to *portsnap* that is much faster than cvsup. I deleted everything in /usr/ports then ran

```
# portsnap fetch extract
# pkgdb -u
```
First time it take time but then it's really fast.


----------



## phoenix (Jun 30, 2010)

dougs said:
			
		

> My system complains that postgresql-contrib succeeds index as follows:
> 
> 
> ```
> ...



pkg_version with *-I* uses /usr/ports/INDEX-version.
pkg_version without *-I* checks the actual PORTVERSION set in the Makefile for the port.

/usr/ports/INDEX-version (where version is your major FreeBSD version, 6, 7, 8, or 9) is not guaranteed to have the exact same version information in it ... unless you have manually built it via *make index* in /usr/ports.

The INDEX files downloaded via portsnap, csup, "make fetchindex", etc are not generated on every commit to the ports tree.  They are generated automatically every 1-2 hours.



> I find it strange that portversion -v reports



portversion, as with all the portupgrade tools, does not use /usr/ports/INDEX* directly.  Instead, it uses it's own databases, /usr/ports/INDEX-version.db (or something like that) which may or may not be synced with the actual INDEX file (which may or may not be synced to the actual PORTVERSIONs from the ports).

IOW, you are two abstraction layers away from the actual version info for a port.

IOW, don't rely on it to be accurate.  



> I see that I have several indexes. This system started out using FBSD 5.x and over time it was upgraded to version 6.x and is now at 7.3 p1 which, I assume, would account for these indexes.



Everyone has multiple INDEX files in /usr/ports.  Each INDEX file corresponds to the major version of FreeBSD that it is used with.  Not all ports install on all versions of FreeBSD.  Thus, a separate INDEX file is needed for each major version of FreeBSD.  Hence, all the different INDEX-version files.  You can safely ignore them all.



> I regularly use portmaster but on occasion I have used portupgrade and portmanager to upgrade ports. I do not use packages. The handbook does not appear to provide me the answers I am seeking.



Don't do that.  Pick *one* port management tool, and stick with it.  Using multiple different tools, that each use different methods to determine port versions and dependencies, that each keep their own databases, is just asking for trouble.

Personally, I'd recommend uninstalling all but portmaster.  It's the closest you will get to just using the bare ports tree (no extra databases to keep in sync, no extra gunk to worry about, just a "simple" shell script that handles everything automatically for you).


----------



## dougs (Jun 30, 2010)

After several fruitless attempts at reindexing via portsdb -Uu and portsdb -Fu, I threw in the towel and decided to reinstall. When I deinstalled, I received a message (which I have since lost from my copy buffer) that databases/postgresql82-contrib was being deinstalled along with a sub-message saying that postgresql-contrib-8.4.3_1 was also being deinstalled.

After installing version 8.4, this is what portversion and pkg_version report:


```
orion-root@/usr/ports/databases/postgresql84-contrib: pkg_version -v | g postgresql
postgresql-client-8.4.4_1           =   up-to-date with port
postgresql-contrib-8.4.4_1          =   up-to-date with port
postgresql-server-8.4.4_2           =   up-to-date with port
orion-root@/usr/ports/databases/postgresql84-contrib: portversion -v | g postgresql
postgresql-client-8.4.4_1   =  up-to-date with port 
postgresql-contrib-8.4.4_1  =  up-to-date with port 
postgresql-server-8.4.4_2   =  up-to-date with port 
orion-root@/usr/ports/databases/postgresql84-contrib:
```

Okay, both report the same version.

Thank you for all your help.

~Doug


----------

