# Upgrade packages in chroot



## Peter2121 (Aug 24, 2020)

I'm trying to upgrade 11.3 to 12.1 using boot environments.
I created a new BE, mounted it as /upgrade121, and successfully upgraded  the system in the new BE.
Now I'm trying to upgrade packages.
I could bootstrap pkg using

```
% chroot /upgrade121 pkg bootstrap -f
```
Then I could update the packages using

```
% chroot /upgrade121 /usr/sbin/pkg update -q
```
But when I try to upgrade all packages I got the error:

```
% chroot /upgrade121 /usr/sbin/pkg upgrade -fy
...
Checking integrity...Assertion failed: (strcmp(uid, p->uid) != 0), function pkg_conflicts_check_local_path, file pkg_jobs_conflicts.c, line 386.
Child process pid=79248 terminated abnormally: Abort trap
```
How can I finish the upgrade?


----------



## Deleted member 63539 (Aug 27, 2020)

Peter2121 said:


> I'm trying to upgrade 11.3 to 12.1 using boot environments.
> I created a new BE, mounted it as /upgrade121, and successfully upgraded  the system in the new BE.
> Now I'm trying to upgrade packages.
> I could bootstrap pkg using
> ...


I don't understand what you are doing. If you already use BE, why don't just activate the new BE and reboot into it? If something goes wrong, you could choose to boot to the previous BE at boot. The FreeBSD boot loader supports it. Why have to go through all of this troubles?


----------



## Bobi B. (Aug 27, 2020)

pkg(8) supports `-c <chroot path>` command-line option; try with `pkg -c /upgrade121 update` and/or `pkg -c /upgrade121 upgrade -fy`.


----------



## Peter2121 (Aug 27, 2020)

sysctl said:


> Why have to go through all of this troubles?


I have 1500+ packages installed and very slow Internet connection. It takes several hours to download the packages. So I prefer to upgrade everything in background.


----------



## Peter2121 (Aug 27, 2020)

Bobi B. said:


> pkg(8) supports `-c <chroot path>` command-line option; try with `pkg -c /upgrade121 update` and/or `pkg -c /upgrade121 upgrade -fy`.


Thanks for this advise. I tried this option before (some months ago), it did not work correctly for major upgrade. Maybe it works better now, I cannot test anymore - after some digging I could finish my upgrade removing 'f' option from the command. It seems that this problem is not related to chroot, but to the fact that I have some packages with modified files (for example, I replaced some binaries by my own versions), so they don't pass integrity checks. I don't understand the reason of blocking upgrade in this case when 'f' option is specified. There is a bug open about it https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=223751


----------



## Mjölnir (Aug 27, 2020)

Peter2121 said:


> [...] It seems that this problem is not related to chroot, but to the fact that I have some packages with modified files (for example, I replaced some binaries by my own versions), so they don't pass integrity checks.


If you want to change port knobs or run patched ports, it is better not to use packages, but install from ports (via ports-mgmt/poudriere or ports-mgmt/synth).  1st patch the port's source, then build & install the package you built yourself.  Then the package manager does not get confused by your changes.


----------



## Mjölnir (Aug 27, 2020)

From the man page of pkg(8):
`pkg check -r` or `pkg check --recompute` recalculates and sets the checksums
     of installed packages.  This command should only be used when the
administrator has made modifications that invalidate a package checksum.
Spontaneous checksum problems can indicate data or security problems.


----------



## Peter2121 (Aug 27, 2020)

mjollnir said:


> `pkg check -r` or `pkg check --recompute`


Great! Thanks! I did not know that it is possible!


----------



## grahamperrin@ (May 7, 2021)

Peter2121 said:


> … new BE, mounted … and successfully upgraded the system in the new BE.



At that point, you might have found (in the mounted environment) a mismatch between the installed kernel and the running kernel.

`freebsd-version -kru`

freebsd-version(1)



> Now I'm trying to upgrade packages. …



I can't comment on what you found in August 2020 but for future reference, I guess that it's appropriate to *specify an ABI*. 

Ignoring (for a moment) the PkgBase context, see for example <https://lists.freebsd.org/pipermail/freebsd-current/2018-November/072000.html>.

Also, food for thought: 

`env IGNORE_OSVERSION=yes pkg bootstrap -f`



Deleted member 63539 said:


> … activate the new BE and reboot into it …



True, however it'll be nice when things can become more streamlined (without the need for multiple reboots) …









						PkgBase
					

… how to safely update the system (regardless of how far out of date) reliably. …   Let's assume that PkgBase is the way forward.   and so on.  https://lists.freebsd.org/mailman/listinfo/freebsd-pkgbase  In addition to the list, there's sometimes discussion of PkgBase in IRC for FreeBSD...




					forums.freebsd.org


----------

