# pkg upgrade, portupgrade



## putin.is.a.thief (Jun 10, 2020)

I feel like I can't develop a complete scenario of updating my system.  I have read mans for pkg-upgrade, portmaster and portupgrade, but I still don't understand it.
First of all, I chose to mix ports and binary pkgs with due respect to:
- pkg's repo URL matches ports tree branch (FreeBSD 12.1, repo /quarterly, ports 2020Q2 from github)
- I *always* use the default config (make -DBATCH) when building ports

As I understand, the rules above are enough for making ports and pkgs 100% compatible.
( I've read this: https://forums.freebsd.org/threads/mixing-ports-and-packages-question.64444/ )

OK, lets suppose this is correct.
How do I upgrade now? What tools are responsible for rebuilding port sources (which I *git pull*ed) and what
tools is for upgrading binary packages? How do they detect which ports are built from source and which are
installed with *pkg*? Why did I get a different outputs from different tools (below)?
pkg(8) says:

```
root@host:/usr/ports/textproc/groff # pkg upgrade -F
...
Installed packages to be REINSTALLED:
        gcc9-9.3.0 (provided shared library changed)
        groff-1.22.4_3 (needed shared library changed)
        gstreamer1-plugins-gl-1.16.2 (needed shared library changed)
        qt5-buildtools-5.13.2_1 (needed shared library changed)
...
```

portmaster(8) detects only groff(1):

```
root@host:/usr/ports/textproc/groff # portmaster -n

===>>> Currently installed version: groff-1.22.4_3
===>>> Port directory: /usr/ports/textproc/groff

===>>> Gathering dependency list for textproc/groff from ports
===>>> Initial dependency check complete for textproc/groff

===>>> Starting build for textproc/groff <<<===

===>>> All dependencies are up to date
```

`portupgrade -arR` just upgraded gdb(1) which was not in both previous outputs (it's actually updated to new version in ports tree pulled from git).


----------



## richardtoohey2 (Jun 10, 2020)

I followed the discussion you linked to and it seems (to me) to be saying do not mix ports and packages unless you really really know what you are doing.

portmaster is what I use but I get the feeling it's not well-liked by the developers or some of the developers and it was very nearly killed off when flavors arrived.  I stick to ports 100% (but have started trying packages on new machines and will see how I go with that.  So far seems nice and simple.)

I use the following sequence: portsnap fetch update, then pkg version -vIL=, then portmaster -a.  This has worked for me for some time but I'd have to go and re-read exactly what it all does to be sure!  (And technically this might be mixing the two to a degree?)

Seeing the knots people are tying themselves trying to mix 'n' match in seems to reinforce what I've read over the years - choose one or the other, and unless you've got a really good reason for using ports then use binary packages.

Neither option is going to be perfect, but mixing them results in unhappiness.

Will be interested to see what other say, though.  YMMV as always.


----------



## Minbari (Jun 10, 2020)

Don't mix ports with packages you will end up with a broken system. The only "safe method" to mix ports with packages is following the quarterly ports and packages repository and even then you can still end up with a broken system. 
Choose either ports or packages and stay with that update method.


----------



## SirDice (Jun 10, 2020)

putin.is.a.thief said:


> - I *always* use the default config (make -DBATCH) when building ports


Then you have no reason to build from ports in the first place.


----------



## richardtoohey2 (Jun 10, 2020)

I _think_ this other current post is what happens if you mix the two: https://forums.freebsd.org/threads/mysql-broken-after-upgrading-freebsd.75566/

But I could be completely wrong!


----------



## putin.is.a.thief (Jun 10, 2020)

SirDice said:


> Then you have no reason to build from ports in the first place.



My reasons:
1. I want to build with debug info (/etc/make.conf's `WITH_DEBUG= yes` so I can quickly debug any crashed program with cgdb)
2. I use local patches (/etc/make.conf's `EXTRA_PATCH_TREE` thing, really useful)
3. If I'm allowed to mix, I don't want to make rule like 'never mix ports/pkgs'. If it's conceptually
acceptable, I want to have such option.

By the way, your `pkg version -iIL=` really helped me yesterday to dig into the details. Thx.



richardtoohey2 said:


> I _think_ this other current post is what happens if you mix the two: https://forums.freebsd.org/threads/mysql-broken-after-upgrading-freebsd.75566/
> 
> But I could be completely wrong!



I think the problem can be that he mixes quarterly pkgs (default in freebsd-RELEASE) and latest ports (
default and probably the only option for portsnap):


> Then I did `freebsd-update -r 12.1-RELEASE upgrade`  and ran that. It grab the files and downloaded it.  It then installed the upgrade. It told me to restart and run `freebsd-update fetch` and update and install. I then ran `portsnap fetch` and then update.  I used ports.



However, I still believe (I really want to) that there is no conceptual problem mixing pots and pkgs, you just need to be very accurate and to understand the details. Some things are not clear to me now, for example:

- How to handle the situation where port's source is updated, but its build-deps are already installed
via pkg in binary.


----------



## richardtoohey2 (Jun 11, 2020)

I think it's a case of "here be dragons" but if you've got your St. George's suit of armour and a lance, you might slay them!  Good luck.


----------

