Teach me package management

What am I doing wrong since this doesn't make sense?

I have almost all packages installed with pkg as binary. I have very few packages installed from ports - vim without all gtk dependencies but with everything else and nvidia without linux dependencies.

I am using pkg upgrade to well upgrade binary packages.

Code:
# pkg upgrade
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
Checking for upgrades (4 candidates): 100%
Processing candidates (4 candidates): 100%
The following 5 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
   linux-c6-xorg-libs: 7.4_9
   linux-c6-fontconfig: 2.8.0_3
   linux-c6-expat: 2.0.1_5
   linux_base-c6: 6.9

Installed packages to be REINSTALLED:
   nvidia-driver-340-340.102 (options changed)

Number of packages to be installed: 4
Number of packages to be reinstalled: 1

The process will require 296 MiB more space.
68 MiB to be downloaded.

Proceed with this action? [y/N]:

Both me and FreeBSD know that I installed nvidia from ports. Even versions match so the only difference is (options changed) part. No I don't want linux_* thank you.

Why does pkg upgrade try to mess with package installed from ports? I need pkg upgrade to well upgrade everything I installed as binary packages, as needed.

What am I missing? I don't appreciate pkg upgrade trying to upgrade nvidia, since it obviously makes no sense to do that. What when some other packages need to be upgraded too? Is the only option to install again one by one and avoid pkg upgrade that way?

Even if sources and ways of building differ, binary packages and ports work well together. I bet it is very common to have 99% installed as binary and several specific packages build. It makes no sense to have to either stick with the ports or binaries completely, I don't want't to build xorg or firefox from source, than you.

So please teach me some package management, I may be doing something wrong here.
 
What's also strange is that pkg upgrade offers to install binary nvidia but I have also built vim which is 'fine' by pkg? Is that because of linux_* libraries that binary nvidia requires?

I am trying to understand userland packaging logic since it looks like I am doing something wrong or it needs some love before it gets better.
 
Teach me package management: What am I doing wrong since this doesn't make sense?

Start reading FreeBSD Handbook 4. Installing Applications: Packages and Ports. If you did read it already do it again. Get known to the Pkg subcommands you use like pkg help upgrade.

I have almost all packages installed with pkg as binary. I have very few packages installed from ports

It has been discussed en length here on the forums, as a lot of people run into problems mixing ports and packages. The distillate from this is that packages on the FreeBSD-repositories are built with default port options. Therefore you may mix ports and packages as long as you stay with the default options when building ports.

Now if you start using custom port options things might get really complex in some cases because of (chaines of) the dependencies. While trying to use pkg lock it may help to tell Pkg not touching some custom ports, but do not expect that it works in every case.

So general advice to newbies is: Do NOT mix ports and packages unless you have to do it for a good reason.

Also note that there is editors/vim-lite which is built for console use without the gtk stuff.
 
Last edited:
  • Thanks
Reactions: dpx
Thanks getopt for your help.

Start reading FreeBSD Handbook 4. Installing Applications: Packages and Ports. If you did read it already do it again. Get known to the Pkg subcommands you use like pkg help upgrade.

I did and it is not completely clear. For example, when it comes to using pkg to upgrade, it should either upgrade binary packages only or binary + ports that I built. It should not offer to replace port that I built with stock binary package especially if it is obvious that I used different build options. I have 25+ years of professional programming experience, with every language imaginable, so I should be able to understand the logic quickly. Sooner I do sooner I would be able to contribute.

It has been discussed en length here on the forums, as a lot of people run into problems mixing ports and packages. The distillate from this is that packages on the FreeBSD-repositories are built with default port options. Therefore you may mix ports and packages unless you stay with the default options when building ports.

Can you please clarify this? I did built nvidia with different options than what binary package offers (no linux, acpi only). So I did stay away from the default options (if that's what you suggest). If this is expected behavior I don't understand it. If it is not let's fix pkg -- please let me know how to contribute to its development.

Now if you start using custom port options things might get really complex in some cases because of (chaines of) the dependencies. While trying to use pkg lock it may help to tell Pkg not touching some custom ports, but do not expect that it works in every case.

Pkg lock is interesting but it looks like really ugly fix for something that should be fixed elsewhere. I'll try using it but it doesn't seem like clean or long term way I'd love to use.

I have examined some chains of the dependencies and I don't really understand why so much of them are version-hardcoded. I suspect that causes at least half of all the mixing problems. I understand that you want to limit lowest version number, but insisting on 'something 2.24.1' and not accepting either 2.24.2 or 2.24.0 seems wrong.

If there is any proper way to discuss this (forum is fine but I can switch to mailing list if that's more appropriate) please let me know. From my short experience with FreeBSD, it is amazing system that needs some work with packaging in general. Not even much work, just better way to fit things together. I am open to jump in and help with code or discuss stuff if there is a way to do so.
 
Example:
I have installed xmobar as binary package but it didn't offer xft fonts so I tried switching to ports.
I have ghc-7.10.2_3 (haskell compiler) installed as binary package, because I installed xmonad and xmonad-contrib as packages.
x11/hs-xmobar/Makefile incudes ../../lang/ghc/bsd.cabal.mk which in turn requires building ghc-8.0.2. Then ghc pulls in gcc (I think) and so on.

There is absolutely no need for this kind of mess. xmobar definitely doesn't care if I use ghc 7.x or ghc 8.x. I ended building xmobar using whatever gcc I have installed (7.10.2) with xft support in short 10 seconds. Pulling in dependencies with specific version number causes ton of problems, both in number of packages that have to be built and in building time. It is sure way to cause LONG chains of dependencies and ton of recompiling.

Same happened with rxvt (package vs ports) with perl version dependency. Some binary package pulled in perl5-5.24.1_1 as a dependency. Then ports x11/rxvt requests whatever latest perl version is in the ports, so it has to build it. There is absolutely no need for this.

Having hs-xmobar depend on the specific 8.0.2 version is just wrong. Same is all over the ports. We can symlink stuff and don't care at least about minor version. There is absolutely no reason why binary packages and ports can't mix well unless there are hard coded versions used.
 
Pkg lock is interesting but it looks like really ugly fix
True. But mixing ports and packages is ugly too. If you need custom options for more than 1 box consider building all on ports-mgmt/poudriere in bulk and have your own local repository. Then use Pkg for deploying your custom or default built packages in any combination you need.

In contrary to ports-mgmt/portmaster Poudriere builds in a clean environment not affecting the life system on which you build. That is what I do and I'm happy with that.
 
Thanks. I am thinking about reducing number of things I have to build, not increase. Poudriere looks interesting as a last resort option but I'd rather avoid more caching and more building if I can.

True. But mixing ports and packages is ugly too.

Why? That's what I can't understand yet. It doesn't have to be ugly. For at least 99% of dependencies you don't really care what minor version number is, if it is 4.2 or 4.1, often even you don't care if it is 7.x or 8.x (see my xmobar post above). For a very limited set of packages you would need to limit lowest version number but rarely or never maximal version number.
 
Why? That's what I can't understand yet. It doesn't have to be ugly. For at least 99% of dependencies you don't really care what minor version number is, if it is 4.2 or 4.1, often even you don't care if it is 7.x or 8.x (see my xmobar post above). For a very limited set of packages you would need to limit lowest version number but rarely or never maximal version number.

If you’ve built a package and linked against $dependancy 7.x, if you upgrade $dependancy to 8.x will your package break without rebuilding/relinking?

Ports are just Packages you have to compile, they aren’t really separate things.
 
Thanks. I am thinking about reducing number of things I have to build, not increase. Poudriere looks interesting as a last resort option but I'd rather avoid more caching and more building if I can.

True. But mixing ports and packages is ugly too.

Why? That's what I can't understand yet. It doesn't have to be ugly. ...

Beauty lies in the eye of the beholder. I won't submit the following solution to a beauty contest, however, it has the big advantage that it works, which by its own weighs out any opinions about aesthetics.
Code:
#!/bin/sh

### the list of the ports that shall be updated from sources
### in the future include 'devel/pecl-pthreads' before 'textproc/pecl-yaml'
portslist="\
devel/apr1 \
devel/subversion \
lang/php71 \
mail/postfix \
mail/roundcube \
net/mDNSResponder \
net/netatalk3 \
www/mod_php71 \
www/squid \
\
textproc/pecl-yaml \
archivers/php71-phar \
archivers/php71-zip \
archivers/php71-zlib \
converters/php71-iconv \
converters/php71-mbstring \
databases/php71-pdo \
databases/php71-pdo_pgsql \
databases/php71-pgsql \
databases/php71-sqlite3 \
devel/php71-intl \
devel/php71-json \
ftp/php71-curl \
graphics/php71-exif \
math/php71-bcmath \
net/php71-sockets \
security/php71-filter \
security/php71-hash \
security/php71-openssl \
sysutils/php71-fileinfo \
textproc/php71-dom \
textproc/php71-xml \
www/php71-session"

### fetching updates of the FreeBSD ports tree
/usr/bin/printf "\nFetching updates of the FreeBSD ports tree...\n"
/usr/sbin/portsnap fetch update
/usr/sbin/pkg version -v
/usr/sbin/pkg updating -d `date -v-2w +%Y%m%d`

### ask and in case of y|Y run the updating processes
/usr/bin/printf "\nDo you want to continue (y/n)? "
save_stty_state=$(stty -g); stty raw -echo; answer=$(head -c 1); stty $save_stty_state
if echo "$answer" | grep -iq "^y" ; then
   /usr/bin/printf "\n\n"
   /usr/sbin/pkg update

   portmake=""
   pkgslist=`/usr/sbin/pkg version -o | /usr/bin/cut -f1 -w`
   for port in $portslist ; do
      for pkg in $pkgslist ; do
         if [ "$pkg" == "$port" ] ; then
            continue 2
         fi
      done

      portmake="$portmake $port"
   done

   pkgslist=""
   outdated=`/usr/sbin/pkg version -ol\< | /usr/bin/cut -f1 -w`
   for outd in $outdated ; do
      for port in $portslist ; do
         if [ "$port" == "$outd" ] ; then
            portmake="$portmake $port"
            continue 2
         fi
      done

      pkgslist="$pkgslist $outd" 
   done

   pkgupgrd=""
   outdated=`/usr/sbin/pkg version -RU -ol\< | /usr/bin/cut -f1 -w`
   for outd in $outdated ; do
      for pkg in $pkgslist ; do
         if [ "$pkg" == "$outd" ] ; then
            pkgupgrd="$pkgupgrd $pkg"
            continue 2
         fi
      done
   done

   /usr/bin/printf "\nUpdating binary packages...\n"
   if [ "$pkgupgrd" != "" ] ; then
      /usr/sbin/pkg upgrade -U $pkgupgrd
   else
      echo "All installed packages are up-to-date."
   fi

   /usr/bin/printf "\nUpdating ports...\n"
   if [ "$portmake" != "" ] ; then
      cwd=$PWD

      for port in $portmake ; do
         cd /usr/ports/$port
         /usr/bin/make clean deinstall
         /usr/bin/make install clean
      done

      cd "$cwd"
   else
      echo "All installed ports are up-to-date."
   fi

   /usr/bin/printf "\nCleaning up...\n"
   /usr/sbin/pkg clean -y

else

   /usr/bin/printf "\n\n"

fi
The above script does what pkg(8) is not able to do, namely, ignore some ports of a software installation in the pkg upgrade process.

At the head of the script we need to inform the ports which must not be upgraded from the binary repository but shall be build from the ports tree -- of course the list of ports $portslist needs to be adapted for other machines, and maintained whenever a new port with custom options is installed on the system.

In the first stage it fetches the latest updates of the FreeBSD ports tree by the way of portsnap(8), and it shows a list of all installed software with indication of the version status. It will also show the entries in /usr/ports/UPDATING related to the installed software of the last two weeks. Depending on that information the user might decide to stop or to proceed.

In case of proceed it updates the local copy of the repository catalogue(s). You want to let pkg use the latest repository, by default it works against the quaterly repository which is with a higher probability out of synch with the ports tree.

Now the script compiles 3 lists, the list of all outdated software and more 2 divisions, namely outdated packages to be upgraded $pkgupgrd and outdated ports to be made $portsmake. BTW, pkg lock does not work as advertised.

Finally it calls the command pkg upgrade -U $pkgupgrd which takes care only for the outdated packages, and then it loops through the list of the outdated ports, stepping into each of the respective port's directory and calling the usual make deinstall/make install combo.

This script works now on 6 FreeBSD servers very well. All well and good, what about the risks? If you are not satisfied, then continue reading. ...



... In the case of deviations from the common feature set, people recommend to built everything on the local machine from the port's sources, and those people continue telling you that it is too risky to intermix pre-built packages with your customized port-builds.

In a certain sense, this is even correct, namely, without a serious risk assessment the best educated guess of the experts is always that many things may go wrong. And of course the conclusion from this is that Dual Mode updating of ports, i.e. mixed installation from locally built and pre-built packages is too risky for even trying it.

Risk assessment and Risk separation

A package with the common set of options can be created locally from the corresponding port with the make package command and by leaving the default options in the configuration dialog in place. The thus locally created package would be exactly identical to the corresponding package of the same version in the public repository of pre-built packages.

This identity of locally built vs. pre-built packages is one of the essential basis for the further discussion. The other basis is that the installation phase is agnostic to the origin of the package -- a package is a package is a package is ...

Any procedure of Dual Mode installation and updating of ports must stay on these basis, and given this constraints the risks can be named and classified into 2 groups:

1. First installation of a port/package

It may happen, that a selection of ports and options may conflict with installed packages. These conflicts must be resolved beforehand utilizing above script, by calling pkg delete on the infringing package and adding it to the list of ports at the head of the script.


2. Updating of the installed ports/packages collections

Ususally (amd64) the ports tree is ahead to the latest package repository by 2 to 3 days. In rare cases, it happens that a custom port depends on a new version of pre-built package which didn't made it yet into the remote repository. In this case we may wait for more 2 or 3 days and start the script again, or we manually run a local onetime build of the dependency before executing the software update script.

Special occasions, which usually show-up in the /usr/local/UPDATING file, need special actions before we can let the script do its automatic job. For example the recent switch from mail/dovecot2 to mail/dovecot needed to be done outside of the normal updating sequence.

The command pkg upgrade shows a list of actions to be done, and it asks whether to proceed [y/n]. If pkg wants to reinstall some of your custom ports because of changed options, then we need to tell n(o) here, because this means, that package dependencies have changed compared to our first installation. In order to reolve this conflict, we would need to customize the package, i.e. call pkg delete on it and put it into the list of the ports at the head of our script.
 
If you’ve built a package and linked against $dependancy 7.x, if you upgrade $dependancy to 8.x will your package break without rebuilding/relinking?

In most cases major version number will make the difference, minor will not. Not to mention unfortunate xmobar example that demands specific compiler version, up to the third version sequence identifier -- which simply makes no sense.

Haskell does/did offer dynamic and static linking, I think they have switched to dynamic only. If it is dynamic build it makes sense to be careful with version numbers but it won't break at third sequence identifier x.x.this. Most of the compilers may differ with major version number (so Makefile can demand <=8.x) but hard linking package with the full compiler version won't achieve anything.

Systemd distros have fixed this problem long ago, they keep major version symlink and all the packages compile using symlink. If my package needs Python 3.x it usually won't matter if I have 3.1 or 3.2. Even if it does require 3.1 and won't work with 3.0 it will surely work with 3.2 too. My makefile should demand 'at least 3.1' and be at ease with it.

If we have Python2 and Python3 packages it makes no sense that any particular port requires exactly Python 3.6.2. and refuses to build with Python 3.6.3. Then because it does require Python 3.6.3 we go to great length to compile and provide that exact version. That's nonsense. What FreeBSD needs instead is:
  • Both binary packages and ports create major version symlinks for other packages to use.
  • For all the ports, require minimal version that makes sense, in xmobar case that would be ghc 7.x or even 6.x. Not 8.0.2. and nothing but that exact version.
  • Anything that builds from ports follows symlinks and doesn't care what exact third version sequence identifier is. Not unless it breaks package and even then only by limiting lowest version that works. This would make packages and ports equal and play well with each other.
By doing this we don't care about exact minor versions, ports build using "what's already there", so we don't compile everything in the tree to build the package. I believe it can be done without much effort, if packages care about "I am the latest one installed" instead of "I am exactly 3.6.2 and I stay in my own folder".

Most importantly, small modification of Makefiles will make binary packages and ports play well with each other.

If there are any obstacles in doing this please let me know what they are. In this case it doesn't make sense to modify/submit one by one package -- it requires community discussion, decision and effort.

Ports are just Packages you have to compile, they aren’t really separate things.

Of course they are, that's why I try to understand FreeBSD userland building process and see if we can make it better. Ports are great, their hard coded dependencies are not.

FreeBSD is so far mindblowing for me as a long time 'nix user. Packages and ports on the other hand need to be fixed before they are truly usable.
 
I am seriously suggesting this for a consideration, it is invented many times over:
https://en.wikipedia.org/wiki/Dependency_hell

Especially this part:
Version numbering
A very common solution to this problem is to have a standardised numbering system, wherein software uses a specific number for each version (aka major version), and also a subnumber for each revision (aka minor version), e.g.: 10.1, or 5.7. The major version only changes when programs that used that version will no longer be compatible. The minor version might change with even a simple revision that does not prevent other software from working with it. In cases like this, software packages can then simply request a component that has a particular major version, and any minor version (greater than or equal to a particular minor version). As such, they will continue to work, and dependencies will be resolved successfully, even if the minor version changes.
Also:
Some package managers can perform smart upgrades, in which interdependent software components are upgraded at the same time, thereby resolving the major number incompatibility issue too.
Many current Linux distributions have also implemented repository-based package management systems to try to solve the dependency problem. These systems are a layer on top of the RPM, dpkg, or other packaging systems that are designed to automatically resolve dependencies by searching in predefined software repositories. Examples of these systems include Apt, Yum, Urpmi, ZYpp, Portage, Pacman and others.
 
Unfortunately it does make sense if it is known that 3.6.3 would break building for whatever reason. Although the restriction may be a temporary one.

If that ever happens it can only be very rare edge case. How many real world cases are there, that you know of? I can't think of any although I am aware it may _rarely_ happen.

Edge cases that are so rare that they may never happen should not prevent ports from being more flexible.

Edit: or alternatively makefiles should have min, max, skip versions. Min would be 3.0, max would be 3.9999, skip may be array of versions that break building.
 
Also we are talking about two software sources only, binary packages and ports. I am sure if 3.6.3 breaks anything it will be skipped in both sources, right?
 
Also we are talking about two software sources only, binary packages and ports. I am sure if 3.6.3 breaks anything it will be skipped in both sources, right?
I have not read through this thread, I'm just a poet and don't know it, so I apologize if this is out of context but, to be clear, packages are pre-compiled ports. So version X of a package is equal to version X of a port with all defaults set.
 
I have not read through this thread, I'm just a poet and don't know it, so I apologize if this is out of context but, to be clear, packages are pre-compiled ports. So version X of a package is equal to version X of a port with all defaults set.

They are the same in theory but being versions apart they can't communicate well. They could talk with small amount of effort and some amount of good will.

Tens of posts down the road and I still haven't heard or don't understand:

  • Why pkg wants to install binary nvidia package if it knows I have built the package from the ports? Bug or logic I don't understand?
  • Why ports require exact version numbers of all the dependencies?
Again if there is better place to discuss or at least get this answers please let me know. So far I have only seen pretty much circular reasoning that leads nowhere. Thank you.
 
Just as an example, here is ArchLinux makefile for xmobar-git. I have picked that example because it downloads source code and compiles everything for that package -- equivalent of x11/hs-xmobar port on FreeBSD.

# Maintainer: Vlad M. <vlad@archlinux.net>
# Contributer: euclio
# Contributer: Cedric Girard <girard.cedric@gmail.com>
# Contributer: Colin Woodbury <colingw@gmail.com>

pkgname=xmobar-git
pkgver=0.23.1.r12.g1b46609
pkgrel=2
pkgdesc="A minimal status bar for the XMonad Window Manager"
arch=('i686' 'x86_64')
url="http://projects.haskell.org/xmobar/"
license=('custom:BSD3')
makedepends=(
'ghc'
'haskell-x11'
'haskell-x11-xft'
'haskell-mtl'
'haskell-parsec'
'haskell-stm'
'haskell-utf8-string'
'haskell-regex-compat'
'haskell-http'
'git')
depends=('wireless_tools' 'gmp' 'libxml2' 'libxrandr' 'libxinerama' 'libxft')
optdepends=(
'haskell-alsa-mixer: Enables Volume plugin.'
'haskell-dbus: Control xmobar with DBUS.'
'haskell-libmpd: Enables MPD plugin.'
'haskell-hinotify: Support for inotify.'
'haskell-timezone-olson: With haskell-timezone-series, enables DateZone plugin'
'haskell-timezone-series: With haskell-timezone-olson, enables DateZone plugin')
conflicts=('xmobar' 'xmobar-darcs')
_gitroot="https://github.com/jaor/xmobar.git"
source=("${pkgname}::git+${_gitroot}")
md5sums=('SKIP')

pkgver() {
cd "$pkgname"
git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
}

build() {
cd "${pkgname}"

# XMOBAR INSTALLATION
# Several possible setup options are offered below. Choose whichever is
# best for you. Uncomment and recomment as necessary.
# See http://projects.haskell.org/xmobar/#optional-features for more information.

# Default setup.
runhaskell Setup configure --flags="with_xft with_iwlib" --prefix=/usr

# MPD Support. Must have `haskell-libmpd` installed.
# runhaskell Setup configure --flags="with_xft with_iwlib with_mpd" --prefix=/usr

# Alsa Support. Must have `haskell-alsa-mixer` installed.
# Be warned, its dependencies can be troublesome.
# runhaskell Setup configure --flags="with_xft with_iwlib with_alsa" --prefix=/usr

# If you have _all_ of the optdepends installed, and want all extentions:
# runhaskell Setup configure --flags="all_extensions" --prefix=/usr

runhaskell Setup build
}

package() {
cd "${pkgname}"

runhaskell Setup copy --destdir=${pkgdir}
install -Dm644 license ${pkgdir}/usr/share/licenses/$pkgname/BSD3
}

There is not a single version dependency, in all three dependency sections (makedepends, depends, optdepends). So it compiles with any ghc as it should.

runhaskell script only invokes latest whatever haskell installed.

We can do the same for FreeBSD ports. There are no downsides except for some effort to get there.
 
Tens of posts down the road and I still haven't heard or don't understand:

  • Why pkg wants to install binary nvidia package if it knows I have built the package from the ports? Bug or logic I don't understand?
...So far I have only seen pretty much circular reasoning that leads nowhere. Thank you.

You're issuing a command for pkg to install/upgrade a package and don't know why it wants to install a package?

...to be clear, packages are pre-compiled ports.
 
You're issuing a command for pkg to install/upgrade and don't know why it wants to install a package?

Yes, it makes no sense.

# pkg info nvidia-driver-340
nvidia-driver-340-340.102
Name : nvidia-driver-340
Version : 340.102
Installed on : Sun Aug 13 08:37:02 2017 CEST
Origin : x11/nvidia-driver-340
Architecture : FreeBSD:11:amd64
Prefix : /usr/local
Categories : x11 kld
Licenses : NVIDIA
Maintainer : danfe@FreeBSD.org
WWW : http://www.nvidia.com/object/unix.html
Comment : NVidia graphics card binary drivers for hardware OpenGL rendering
Options :
ACPI_PM : on
DOCS : off
LINUX : off
WBINVD : off

Shared Libs required:
libXext.so.6
libX11.so.6
Shared Libs provided:
libnvidia-eglcore.so.1
libGL.so.1
libvdpau_nvidia.so.1
libnvidia-glsi.so.1
libnvidia-cfg.so.1
libGLESv1_CM.so.1
libEGL.so.1
libGLESv2.so.2
libnvidia-glcore.so.1
libnvidia-tls.so.1
Annotations :
Flat size : 121MiB
Description :
These are the official NVidia binary drivers for hardware OpenGL rendering
in X11, using the GLX extensions.

WWW: http://www.nvidia.com/object/unix.html

# pkg upgrade
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
Checking for upgrades (8 candidates): 100%
Processing candidates (8 candidates): 100%
The following 9 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
linux-c6-xorg-libs: 7.4_9
linux-c6-fontconfig: 2.8.0_3
linux-c6-expat: 2.0.1_5
linux_base-c6: 6.9


Installed packages to be UPGRADED:
sudo: 1.8.20p2_2 -> 1.8.20p2_3
sqlite3: 3.20.0 -> 3.20.0_1
firefox: 54.0.1_1,1 -> 55.0.1,1
curl: 7.54.1 -> 7.55.0

Installed packages to be REINSTALLED:
nvidia-driver-340-340.102 (options changed)

Number of packages to be installed: 4
Number of packages to be upgraded: 4
Number of packages to be reinstalled: 1

The process will require 328 MiB more space.
106 MiB to be downloaded.

Proceed with this action? [y/N]:

Pkg upgrade knows I have changed options, see parts in bold, therefore it can safely assume I have installed from ports if there is no such direct info in DB. Pkg can offer to rebuild the port I used (I don't expect this and I know it would be complicated) or to ignore packages with "(optons changed)" that were obviously not installed as binary packages. What it shouldn't do under any circumstances is to demand all-or-nothing upgrade that overwrites all port installations. I wouldn't say a word if pkg has command to skip any options-changed package.

The way pkg and the way ports are structured, they offer all or nothing install. There is no reason for this, they could mix well and its not outlandish from user to expect such behavior. It is not like there are really big obstacles for mixing them well.

So in order to pkg upgrade sudo, sqlite3, firefox and curl I have to upgrade nvidia which was clearly not part of the pkg based installation? Edit: and 'upgrade' it offers is not even an upgrade, versions are the same, the only 'reason' for upgrade is because I haven't used defaults options and binary package.

This is not rocket science and yet I am not sure if what I am saying gets relayed that way. If I should clarify anything please let me know.
 
Yes, it makes no sense.

With all due respect, it makes perfect sense.

That is the function of pkg. To install packages.


There is a vulnerability in graphics/OpenEXR, which is included in the build of graphics/gimp.

If you try to build graphics/gimp with ports-mgmt/portmaster it will stop the build at graphics/OpenEXR due to the vulnerability and you would have to issue cd /usr/ports/graphics/gimp && make IGNORE_VULNERABILITIES=yes clean install to continue the build.

However, if you use pkg install gimp it will install it along with graphics/OpenEXR with no regard to the vulnerability.

Then you can cd /usr/ports/graphics/OpenEXR && make deinstall clean and graphics/gimp will still run without it.

And you thought you were confused before... ;)
 
As I said before I have 25+ years of programming under the belt. If I am confused that's because something doesn't check with logic.

That is the function of pkg. To install packages.

Respect & all but this is circular reasoning. Of course it does install packages. Grass is green because it is green. Let me rephrase:

- Why does pkg touch something that's clearly not installed by pkg?
- Why there is no switch in pkg to say 'upgrade everything'/'upgrade pkg installed packages only'?

Lack of this simple switch denies lots of flexibility that would be there if there is no lack of such switch. <- no intention to be difficult or go in circles but I can't be more clear.

The only reason, from the pkg/binary packages side of the story, for binary packages and ports not mixing well, is that pkg tries to overtake what's not its job to do, and there is no switch to prevent such behavior.

The only reason, from the ports side of the story, for binary packages and ports not mixing well, is that ports demand specific dependency version number.

Both can only be defended by 'things are that way because things are that way'. I am linux refugee that recognized how much better FreeBSD core is. Userland is far less quality and the reason I keep ask questions and try to understand is because I intend to keep using FreeBSD. It all can be fixed unless I hit the wall of circular reasoning.

Does anybody understand what I am saying and what the problems are?
 
Pkg upgrade knows I have changed options, see parts in bold, therefore it can safely assume I have installed from ports if there is no such direct info in DB.

I think that is a slightly wrong assertion. ports-mgmt/pkg knows that the options between the package installed and the package in the repository differs.
To assume that means said package must have been compiled by Ports assumes that the options haven’t been changed by the Port maintainer (I’m not 100% sure when such a change would require a “_x” version bump, and it could be forgotten).

I think you might find better, more complete answers on
freebsd-pkg@freebsd.org
It is more likely that they will come across a developer who can explain the reasoning to you, or tell you where to jump in to help, or perhaps be inspired by your answers.
 
  • Thanks
Reactions: dpx
forquare, thanks for the proper address to ask. I have sent email already.

You are right we can't be 100% sure where nvidia came from, unless that info is stored somewhere, but we can be 100% sure it wasn't pkg installed package.

It is not only nvidia, let's assume I am happy with 100 binary packages but I need to customize five of them. So I go to ports, make config and make install them. It all means that I put some effort into picking options and compiling. Pkg knows it is not its product '(options changed)' but it tries to overwrite my hard customization work. I can't see logic in doing that.

Edit: in such rare case where ports maintainer changes flags, I am sure I can deinstall package once then reinstall new one. I don't expect that to happen often and even if it does rest of the upgrade cycle would behave as expected.
 
dpx, packages are nothing more than pre-compiled ports. As a matter of fact, ports build packages and it's those packages that get installed. So, from the system's point of view, there is no difference between a port and a package once they are installed. That's where your confusion lies, you assume ports and packages are different when they are not. And that is why a pkg-upgrade(8) will upgrade everything, including the stuff you built from ports.
 
SirDice, thanks. I understand the mechanism.

When you customize 'make config' and change options that port is definitely not the same as stock pre-compiled port. I understand the logic but it makes no sense -- if I modify package settings I would probably want package to stay that way, not to be overwritten with newer/same version stock package. Because settings definitely differ, right?

If I upgrade package with changed config, I would either like to keep it manually upgraded or not touched at all. Either way it makes sense that I want my config to stay, right?

It is 'make config' & 'make install' not 'make config-until-next-pkg-update'. Overwriting manually customized ports with stock packages just makes no sense.
 
#pkg info | wc -l
606

# pkg query -e '%a = 0' "%n;%v;%sh;%R;%sb" | grep -i unknown-repository | sort --field-separator=';' -g -k5 | cut -f 1,2,3,4 -d';' | column -s';' -t
dialog4ports 0.1.6 24.3KiB unknown-repository
pkg 1.10.1 11.4MiB unknown-repository
vim 8.0.0867 29.2MiB unknown-repository
nvidia-driver-340 340.102 121MiB unknown-repository

So I have 606 packages in total, two of them (vim and nvidia) installed from ports. Since pkg upgrade can't at least skip those installed from ports all the suggestions so far is to either stick with the binary packages or with the ports. Since I want my vim customized I would have to compile other 602 (604 minus dialog4ports and pkg) packages too? That's plain silly, there is no need for that if pkg knows not to touch those two I need.

Also unknown-repository should be a pretty good indication for pkg not to touch that package?
 
Back
Top