# duplicate dependency listing



## Helmut (Feb 7, 2022)

Hi,

is there a way to repair / rebuild / cleanup the pkgdb? Over the years it grew and got lots of duplicate dependency warnings:


```
[helmut@BSDHelmut ~]$ sudo pkg upgrade 2>&1 | grep -c "duplicate dependency listing"
4022
[helmut@BSDHelmut ~]$
```

Thank you!


----------



## SirDice (Feb 7, 2022)

Have you ever ran pkg-autoremove(8)? You might be collecting a bunch of unneeded dependencies.


----------



## Helmut (Feb 7, 2022)

Just did so, but


```
[helmut@BSDHelmut ~]$ sudo pkg upgrade 2>&1 | grep -c "duplicate dependency listing"
2825
[helmut@BSDHelmut ~]$
```

An example:


```
pkg: p11-kit: duplicate dependency listing: libtasn1
pkg: p11-kit: duplicate dependency listing: ca_root_nss
pkg: p11-kit: duplicate dependency listing: ca_root_nss
pkg: p11-kit: duplicate dependency listing: ca_root_nss
pkg: p11-kit: duplicate dependency listing: glib
pkg: p11-kit: duplicate dependency listing: glib
pkg: p11-kit: duplicate dependency listing: glib
pkg: p11-kit: duplicate dependency listing: glib
pkg: p11-kit: duplicate dependency listing: libtasn1
pkg: p11-kit: duplicate dependency listing: ca_root_nss
pkg: p11-kit: duplicate dependency listing: ca_root_nss
pkg: p11-kit: duplicate dependency listing: ca_root_nss
pkg: p11-kit: duplicate dependency listing: glib
pkg: p11-kit: duplicate dependency listing: glib
pkg: p11-kit: duplicate dependency listing: glib
pkg: p11-kit: duplicate dependency listing: glib
```


----------



## zirias@ (Feb 7, 2022)

Never seen something like this, but does `pkg update -f` solve it? This should rewrite your local database...


----------



## covacat (Feb 7, 2022)

try this if pkg won't fix it
sqlite3 /var/db/pkg/local.sqlite  "select * from deps where package_id=(select id from packages where name='p11-kit') ;"


----------



## Helmut (Feb 7, 2022)

Tried that before, also pkgdb -u. I'm using my own repo if that is important but on the building server everything is fine.


----------



## Helmut (Feb 7, 2022)

covacat said:


> try this if pkg won't fix it
> sqlite3 /var/db/pkg/local.sqlite  "select * from deps where package_id=(select id from packages where name='p11-kit') ;"




```
[helmut@BSDHelmut ~]$ sqlite3 /var/db/pkg/local.sqlite "select * from deps where package_id=(select id from packages where name='p11-kit') ;"
security/libtasn1|libtasn1|4.18.0|17837
security/ca_root_nss|ca_root_nss|3.75|17837
devel/libffi|libffi|3.3_1|17837
devel/glib20|glib|2.70.3,2|17837
devel/gettext-runtime|gettext-runtime|0.21|17837
[helmut@BSDHelmut ~]$
```


----------



## SirDice (Feb 7, 2022)

Helmut said:


> Tried that before, also pkgdb -u.


pkgdb(1) has nothing to do with pkg(8), it's part of the ports-mgmt/portupgrade. Which uses its own database, completely separate from the database pkg(8) uses.


----------



## covacat (Feb 7, 2022)

also this
sqlite3 /var/db/pkg/local.sqlite  "select * from deps where package_id in (select id from packages where name='p11-kit');"


----------



## SirDice (Feb 7, 2022)

It probably got into a really messy state at one point. It's a little drastic but you could backup the list from `pkg prime-list`, do a `pkg delete -a` then reinstall everything from that 'prime-list' you saved.


----------



## Helmut (Feb 7, 2022)

covacat said:


> also this
> sqlite3 /var/db/pkg/local.sqlite  "select * from deps where package_id in (select id from packages where name='p11-kit');"




```
[helmut@BSDHelmut ~]$ sqlite3 /var/db/pkg/local.sqlite "select * from deps where package_id in (select id from packages where name='p11-kit');"
security/libtasn1|libtasn1|4.18.0|17837
security/ca_root_nss|ca_root_nss|3.75|17837
devel/libffi|libffi|3.3_1|17837
devel/glib20|glib|2.70.3,2|17837
devel/gettext-runtime|gettext-runtime|0.21|17837
[helmut@BSDHelmut ~]$
```


----------



## T-Daemon (Feb 7, 2022)

You say you have your own repository. Are there maybe multiple enabled repositories specified in your repository configuration file(s)?

```
/etc/pkg/FreeBSD.conf
/usr/local/etc/pkg/repos/{xxx.conf, yyy.conf}
```


----------



## covacat (Feb 7, 2022)

package 2 deps looks ok, also package name should be unique
if you share the sqlite3 file i probably can figure out the problem but otherwise it's to much guesswork


----------



## Helmut (Feb 7, 2022)

T-Daemon said:


> You say you have your own repository. Are there maybe multiple enabled repositories specified in your repository configuration file(s)?
> 
> ```
> /etc/pkg/FreeBSD.conf
> ...




```
[helmut@BSDHelmut ~]$ ls /usr/local/etc/pkg/repos/
FreeBSD.conf
[helmut@BSDHelmut ~]$ ls /etc/pkg/
10-MyRepo.conf  99-FreeBSD.conf FreeBSD.conf
[helmut@BSDHelmut ~]$ cat /etc/pkg/10-MyRepo.conf
# $FreeBSD: release/10.0.0/etc/pkg/FreeBSD.conf 258710 2013-11-28 14:24:26Z gjb $

MyRepo: {
  url: "ftp://ftp.mydomain/pub/FreeBSD/ports/${ABI}",
  mirror_type: "none"
  enabled: yes
}
[helmut@BSDHelmut ~]$ cat /etc/pkg/99-FreeBSD.conf
# $FreeBSD: releng/10.1/etc/pkg/FreeBSD.conf 263938 2014-03-30 15:29:54Z bdrewery $

FreeBSD: {
  url: "pkg+http://pkg.FreeBSD.org/${ABI}/latest",
  mirror_type: "srv",
  signature_type: "fingerprints",
  fingerprints: "/usr/share/keys/pkg",
  enabled: no
}
[helmut@BSDHelmut ~]$ cat /etc/pkg/FreeBSD.conf
# $FreeBSD: releng/12.2/usr.sbin/pkg/FreeBSD.conf.quarterly 346780 2019-04-27 04:00:50Z cperciva $

FreeBSD: {
  url: "pkg+http://pkg.FreeBSD.org/${ABI}/quarterly",
  mirror_type: "srv",
  signature_type: "fingerprints",
  fingerprints: "/usr/share/keys/pkg",
  enabled: no
}
[helmut@BSDHelmut ~]$ cat /usr/local/etc/pkg/repos/FreeBSD.conf
MyRepo: { enabled: yes }
FreeBSD: { enabled: no }
[helmut@BSDHelmut ~]$
```


----------



## Helmut (Feb 7, 2022)

Thank you all for your input. I removed /usr/ports/packages on my build machine, created all packages with

```
pkg create -ao /usr/ports/packages
```
and created the repo with

```
pkg repo -l /usr/ports/packages
```
No more duplicates.

Does "pkg repo" require that only one version of a package is in /usr/ports/packages?


----------



## Helmut (Feb 11, 2022)

Answering myself: Yes, if I do a "pkg repo" on a directory with multiple versions of a package I get the "duplicate dependency listing" warnings back.


----------

