Bug 270157 - ports-mgmt/portupgrade: with portupgrade -P install of ports-mgmt/pkg fails
Summary: ports-mgmt/portupgrade: with portupgrade -P install of ports-mgmt/pkg fails
Status: Open
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-ports-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-03-12 14:55 UTC by Fabian Wenk
Modified: 2023-09-24 22:27 UTC (History)
4 users (show)

See Also:
fernape: maintainer-feedback? (bdrewery)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Fabian Wenk 2023-03-12 14:55:45 UTC
I am running a hand full of servers and in the past I have build and installed all the ports on each server individually. As some of them are not so powerful I have create a kind of an unusual setup to build packages only on the most powerful server. The packages are stored in the NFS shared /usr/ports/packages/All/ directory.

My workflow is like this:

1) on all servers I run (at the same time):
cd /usr/ports/ && nice -n 5 make update && nice -n 5 make fetchindex && nice -n 5 portupgrade -an
2) on the build server I run:
nice -n 5 portupgrade -ap
and then an own script to remove outdated packages, create .txz link to .pkg and also run:
pkg repo /usr/ports/packages
3) on all other server then I run:
nice -n 5 portupgrade -akP

As not all ports are installed on the build server, other servers will build the port locally (mostly small stuff which does not need a lot to build).
With the use of 'portupgrade -P' ports installed from packages are done with 'pkg', but when the port is build locally, then 'pkg-static' is used (as it also is the case when -P is not used).
With an update of ports-mgmt/pkg on the build server it gets build and a package  is created and stored in /usr/ports/packages/All/. But then on the other server the installation fails as the installed ports-mgmt/pkg gets removed and pkg is not there any more to install. Why is 'portupgrade -P' using 'pkg' instead of 'pkg-static' to upgrade from a packages?

My workaround currently is like this (needs to be done before running 'portupgrade -akP'):
pkg install /usr/ports/packages/All/pkg-1.19.1_1.pkg

I am aware that I could create a proper build environment with a jail and poudriere, but what I currently have works fine for my use case. My next improvements will be to also use a NFS share for /usr/ports/ (to only run 'make update' and 'make fetchindex' on one server) and /var/db/ports/ and use something like 'WRKDIRPREFIX=/path/to/ports-workdir portupgrade' to avoid building over NFS.
Comment 1 Michael Osipov 2023-09-22 08:13:01 UTC
While I don't know whether this is a genuine bug or not, but as mentioned in the other ticket I recommend doing this with poudriere, then you can upgrade with "pkg upgrade". Done.
Comment 2 Baptiste Daroussin freebsd_committer freebsd_triage 2023-09-22 08:43:01 UTC
pkg and pkg-static both belong to the pkg package, so using either won't change anything if I am understanding this correctly.
Comment 3 Baptiste Daroussin freebsd_committer freebsd_triage 2023-09-22 08:43:34 UTC
I remove pkg@ from cc as this has nothing to do with pkg itself.
Comment 4 Fabian Wenk 2023-09-23 21:48:53 UTC
(In reply to Baptiste Daroussin from comment #2)

Running on the build system (where the port is build from source) with:

portupgrade -pa

this gets logged into syslog:
Sep 22 20:15:42 riddler pkg[59460]: webp-1.3.1_1 deinstalled
Sep 22 20:15:44 riddler pkg-static[59708]: webp-1.3.2 installed

And running on any of the other systems (where an available pre-built package is taken) with:

portupgrade -kPa

this gets logged into syslog:
Sep 22 20:44:48 batman pkg[4699]: webp-1.3.1_1 deinstalled
Sep 22 20:44:49 batman pkg[4728]: webp-1.3.2 installed

Usually this does not make a difference, unless there is an update for ports-mgmt/pkg itself. On the build system it works just fine, but then fails on the other systems and leaves them in a broken state where ports-mgmt/pkg is removed.  
The only way out of this is with a local manual build like this:
cd /usr/ports/ports-mgmt/pkg
make install

So my (slightly rewritten) question from the original report still stands:
Why is 'portupgrade -P' using 'pkg' instead of 'pkg-static' when upgrading from a package instead of a locally done build?

Some other thoughts, could it be that portupgrade is taking different steps / commands when run with -P during install from a local build or a package? So what I see in syslog with the 'pkg' and 'pkg-static' is just a coincident?