Re: Corrupted pkg db. Recoverable? [RESOLVED]

From: Jonathan Adams <jfadams1963_at_proton.me>
Date: Sat, 15 Mar 2025 23:30:31 UTC
On Friday, March 14th, 2025 at 10:23 PM, Steve Rikli <sr@genyosha.net> wrote:

> On Sat, Mar 15, 2025 at 01:45:50AM +0000, Jonathan Adams wrote:
>
> > Hi all,
> > I'm running 14.2-RELEASE-p2 with packages pulled from latest in Qemu running within Termux on an Android device. (I guess I like to create interesting challenges!)
> >
> > I recently ran `pkg upgrade`, then selected 'n' to cancel. (Too many packages.) Moments later, I decided to upgrade Vim only, and got this:
> >
> > # pkg install vim
> > Updating FreeBSD repository catalogue...
> > pkg: An error occured while fetching package: No error
> > pkg: An error occured while fetching package: No error
> > repository FreeBSD has no meta file, using default settings
> > pkg: An error occured while fetching package: No error
> > pkg: An error occured while fetching package: No error
> > pkg: An error occured while fetching package: No error
> > pkg: An error occured while fetching package: No error
> > Unable to update repository FreeBSD
> > Error updating repositories!
> >
> > I'm now unable to install|upgrade packages, though I can do `pkg delete <pkg>` and `pkg autoremove` just fine.
> > Is there a way to rebuild the pkg db, or in any way recover the ability to install|upgrade packages? I have backups of the drive images from before I updated to p2, but I'd like to try to fix the current install first.
>
>
> Check your system for /var/backups/pkg.sql.xz file(s).
>
> The pkg(8) man page has an example for restoring a backup pkg database.
>
> Cheers,
> sr.

Hi Steve, Thanks for your response.

  It turns out _NOT_ to have been a package database problem, but rather a Qemu networking issue.
  I had forgotten that in between running pkg successfully and then getting the above errors, I had stopped the vm and added port forwarding to the `qemu` command in my launch script. That was the culprit; once removed, I could do package upgrades just fine.
  Odd, since I could ping any routable IP|hostname with out issue, and could do queries with dig. What tipped me off was that I could no longer ssh out, and freebsd-update was unable to fetch. I set up the port forwarding so as to ssh in from Termux.
  I'll need to look into this more; not sure yet if it was error in my usage of the port forwarding option, a bug in Qemu, or possibly an Android SELinux issue.

Thanks again!

- Jonathan
____________________________________________
"Before Turing, things were done to numbers.
After Turing, numbers began doing things"