Dealing with
https://github.com/freebsd/pkg/issues/744
https://forums.freebsd.org/threads/pkg-and-options-changed.65535/
https://forums.freebsd.org/threads/exclude-packages-from-pkg-upgrade.45590/
This doesn't seem like it's going to get fixed in a nice way any time soon, so combining some of the suggestions from some my searches, I think I've come up with a pretty good one-line solution.
First, use the annotations system to add the tag "from-ports" to any package you want built from ports (apr in this example). The value can be anything, but noting which options to select may help your future self.
Then run this huge one-liner to automatically lock those packages, run
Notes:
Please leave a comment if I've overlooked something!
pkg upgrade
wanting to clobber your custom optioned ports seems to be a common issue...https://github.com/freebsd/pkg/issues/744
https://forums.freebsd.org/threads/pkg-and-options-changed.65535/
https://forums.freebsd.org/threads/exclude-packages-from-pkg-upgrade.45590/
This doesn't seem like it's going to get fixed in a nice way any time soon, so combining some of the suggestions from some my searches, I think I've come up with a pretty good one-line solution.
First, use the annotations system to add the tag "from-ports" to any package you want built from ports (apr in this example). The value can be anything, but noting which options to select may help your future self.
sudo pkg annotate -M apr from-ports 'With SQLite option'
Then run this huge one-liner to automatically lock those packages, run
pkg upgrade
, and then unlock the packages
pkg query '%n %At' | grep from-ports | awk 'BEGIN {FS=" "};{printf "%s\n",$1}' | sudo xargs -L 1 pkg lock -y ;sudo pkg upgrade;pkg query '%n %At' | grep from-ports | awk 'BEGIN {FS=" "};{printf "%s\n",$1}' | sudo xargs -L 1 pkg unlock -y
Notes:
- The
pkg query
/grep
/awk
combo is to overcome the fact thatpkg query -e
doesn't appear to be able to match on annotation tag names. awk
using \n along with the -L argument to xargs is to overcomepkg lock
not supporting multiple package names in the command.- I know about custom repos. Like most people who have encountered this problem, they are not an appropriate solution compared to this one.
- %R in
pkg query
isn't reliable to key on for packages built from ports. For instance, ports may have built a package as a dependency, but it doesn't have any special options, so the binary update would be just fine.
Please leave a comment if I've overlooked something!