# pkg update problem



## hac3ru (Jun 2, 2015)

Hello,

Recently, I have encountered a problem with pkg. Whenever I want to use pkg I get stuck at 

```
Updating FreeBSD repository catalogue...
```
So I did `pkg -d update` and got

```
# pkg -d update
DBG(1)[99384]> pkg initialized
Updating FreeBSD repository catalogue...
DBG(1)[99384]> PkgRepo: verifying update for FreeBSD
DBG(1)[99384]> Pkgrepo, begin update of '/var/db/pkg/repo-FreeBSD.sqlite'
```
Anyone got any ideas of what's going on?


----------



## ShelLuser (Jun 2, 2015)

Don't have an idea from mind what's going on, but I do wonder if your network connection is fully working as expected? Both network as well as DNS, especially the latter is a common factor for timeouts to occur. So double check /etc/resolv.conf and make sure that any name server entries there are actually usable (using either dig or perhaps drill).

This is the full sequence of events when using `# pkg -d update -f`:


```
DBG(1)[4747]> pkg initialized
Updating FreeBSD repository catalogue...
DBG(1)[4747]> PkgRepo: verifying update for FreeBSD
DBG(1)[4747]> Pkgrepo, begin update of '/var/db/pkg/repo-FreeBSD.sqlite'
DBG(1)[4747]> Fetch: fetching from: http://pkgmir.pkg.freebsd.org/FreeBSD:9:i386/latest/meta.txz with opts "i"
Fetching meta.txz...
DBG(1)[4747]> Read status: 968 over 0
Fetching meta.txz... done
DBG(1)[4747]> PkgRepo: extracting meta of repo FreeBSD
DBG(1)[4749]> PkgRepo: extracting signature of repo in a sandbox
DBG(1)[4747]> Fetch: fetching from: http://pkgmir.pkg.freebsd.org/FreeBSD:9:i386/latest/packagesite.txz with opts "i"
Fetching packagesite.txz...
DBG(1)[4747]> Read status: 10240 over 0
```
(actually that was `# pkg -d update -f |& tee update.log` but who's keeping track  )

As you can see the host pkgmir.pkg.freebsd.org needs to be contacted next. Because the host is active I'm pretty sure your issues are caused by a network issue on your end, most likely DNS.


----------



## hac3ru (Jun 2, 2015)

ShelLuser said:


> Don't have an idea from mind what's going on, but I do wonder if your network connection is fully working as expected? Both network as well as DNS, especially the latter is a common factor for timeouts to occur. So double check /etc/resolv.conf and make sure that any name server entries there are actually usable (using either dig or perhaps drill).
> 
> This is the full sequence of events when using `# pkg -d update -f`:
> 
> ...




```
host pkgmir.pkg.freebsd.org
pkgmir.pkg.freebsd.org has address 77.88.40.109
pkgmir.pkg.freebsd.org has IPv6 address 2a02:6b8:b010:1001::50:1
pkgmir.pkg.freebsd.org mail is handled by 0 .
```
So it's not a DNS problem.... Besides that, this is the machine that does the NAT for a 600 PC's network and everything works correctly inside the network...
Any other ideas?


----------



## junovitch@ (Jun 3, 2015)

Did it work before and just suddenly stop working?  What about `drill SRV _http._tcp.pkg.freebsd.org`?


----------



## hac3ru (Jun 3, 2015)

Hello,
Thank you for the interest. I have created another VM, installed FreeBSD last night (it took about 10 mins so...) and that one worked until this morning, when I tried to pkg update and it didn't work. I turned on the old FreeBSD machine, I did what you requested and it responded correctly -> 
	
	



```
;; ->>HEADER<<- opcode: QUERY, rcode: NOERROR, id: 39413
;; flags: qr rd ra ; QUERY: 1, ANSWER: 5, AUTHORITY: 0, ADDITIONAL: 0                             ;; QUESTION SECTION:
;; _http._tcp.pkg.freebsd.org.  IN      SRV

;; ANSWER SECTION:                                                                                                                                                                                                                                                       
_http._tcp.pkg.freebsd.org.     111     IN      SRV     10 10 80 pkgmir.pkg.freebsd.org.
_http._tcp.pkg.freebsd.org.     111     IN      SRV     50 10 80 pkg0.nyi.freebsd.org.
_http._tcp.pkg.freebsd.org.     111     IN      SRV     50 10 80 pkg0.isc.freebsd.org.
_http._tcp.pkg.freebsd.org.     111     IN      SRV     50 10 80 pkg0.bme.freebsd.org.
_http._tcp.pkg.freebsd.org.     111     IN      SRV     50 10 80 pkg0.ydx.freebsd.org.

;; AUTHORITY SECTION:

;; ADDITIONAL SECTION:

;; Query time: 0 msec
;; SERVER: 193.226.5.151
;; WHEN: Wed Jun  3 10:03:27 2015
;; MSG SIZE  rcvd: 246
```

Both machines respond the same, the one that can't do pkg update (the new one) and the old one that can update now. I was thinking that maybe I should try a restart to the new FreeBSD and now it can update.... Anyone got any ideas what's that about?

//Later Edit: It can update but can't do `pkg search php` or `pkg search htop` or anything. It just returns blank, whilst the old machine works...
`pkg search php`

```
asp2php-0.76.26
beautifyphp-0.5.0
cakephp-2.3.6
lots of stuff.....
```

// Solved. Execute:
`mv -r /var/db/pkg /var/db/pkg_old
mkdir /var/db/pkg
pkg update`


----------



## junovitch@ (Jun 4, 2015)

hac3ru said:


> Hello,
> // Solved. Execute:
> `mv -r /var/db/pkg /var/db/pkg_old
> mkdir /var/db/pkg
> pkg update`



Don't do that.  /var/db/pkg/local.sqlite is the database that holds info on everything you have installed on the system.  If those commands are helping, what does `pkg update -f` result in?  That should result in a forced refresh of /var/db/pkg/FreeBSD.meta and /var/db/pkg/repo-FreeBSD.sqlite.


----------

