Bug 265943 - editors/libreoffice: upgrading via portmaster leads to conflict with existing installed port
Summary: editors/libreoffice: upgrading via portmaster leads to conflict with existing...
Status: In Progress
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: FreeBSD Office Team
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-08-19 11:26 UTC by Martin Birgmeier
Modified: 2022-08-20 13:17 UTC (History)
3 users (show)

See Also:
bugzilla: maintainer-feedback? (office)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Birgmeier 2022-08-19 11:26:54 UTC
Scenario:
- FreeBSD 12.3 latest
- ports latest
- Installed (amongst others): editors/libreoffice, french/libreoffice, portuguese/libreoffice, editors/libreoffice-it
- upgrading ports using portmaster

Result:
- french/libreoffice starts being upgraded before editors/libreoffice
- because it is a dependency, editors/libreoffice gets upgrade before french/libreoffice is installed
- the installation of editors/libreoffice proceeds without deinstalling the old version first:

Install /usr/local/man/man1/loffice.1.gz
Install /usr/local/bin/unopkg
Install /usr/local/man/man1/unopkg.1.gz
Install /basis/program/java-set-classpath
/usr/tmp/net/hal/z/SRC/FreeBSD/ports/MBi/main/editors/libreoffice/work/libreoffice-7.4.0.3/bin/distro-install-sdk
SDK installation clean up
/usr/tmp/net/hal/z/SRC/FreeBSD/ports/MBi/main/editors/libreoffice/work/libreoffice-7.4.0.3/bin/distro-install-file-lists
Generating package file lists for FreeBSD ports...
gmake[2]: Leaving directory '/usr/tmp/net/hal/z/SRC/FreeBSD/ports/MBi/main/editors/libreoffice/work/libreoffice-7.4.0.3'
====> Compressing man pages (compress-man)
Updating database digests format: 100%
Checking integrity... done (0 conflicting)
Deinstallation has been requested for the following 1 packages (of 0 packages in the universe):

Installed packages to be REMOVED:
        fr-libreoffice: 7.3.5.2

Number of packages to be removed: 1

The operation will free 28 MiB.
[1/1] Deinstalling fr-libreoffice-7.3.5.2...
[1/1] Deleting files for fr-libreoffice-7.3.5.2: 100%

===>>> Starting check for runtime dependencies
===>>> Gathering dependency list for editors/libreoffice from ports
===>>> Dependency check complete for editors/libreoffice

===>>> All >> fr-libreoffice-7.3.5.2 (90/102)

===>  Installing for libreoffice-7.4.0.3
===>  Checking if libreoffice is already installed
===>   An older version of libreoffice is already installed (libreoffice-7.3.5.2_2)
      You may wish to ``make deinstall'' and install this port again
      by ``make reinstall'' to upgrade it properly.
      If you really wish to overwrite the old port of libreoffice
      without deleting it first, set the variable "FORCE_PKG_REGISTER"
      in your environment or the "make install" command line.
*** Error code 1

Stop.
make[1]: stopped in /net/hal/z/SRC/FreeBSD/ports/MBi/main/editors/libreoffice
*** Error code 1

Stop.
make: stopped in /net/hal/z/SRC/FreeBSD/ports/MBi/main/editors/libreoffice

===>>> Installation of libreoffice-7.4.0.3 (editors/libreoffice) failed
===>>> Aborting update

===>>> Update for editors/libreoffice failed
===>>> Aborting update

===>>> There are messages from installed ports to display,
       but first take a moment to review the error messages
       above.  Then press Enter when ready to proceed. 

Expected result:
- The upgrade should proceed normally.

Notes:
- This has been happening since a few months.
- The workaround is to deinstall all libreoffice ports first and then to run "portmaster editors/libreoffice-i18n"
- See also bug #265936, but here neither editors/libreoffice-i18n nor german/libreoffice were installed so that the bug described there does not occur (infinite portmaster recursion).

-- Martin
Comment 1 Martin Birgmeier 2022-08-19 11:33:27 UTC
Maybe all libreoffice ports have a cyclic dependency on themselves.
Comment 2 Dima Panov freebsd_committer freebsd_triage 2022-08-19 11:33:53 UTC
This is not a libreoffice failure but portmaster itself. please ping portmaster maintainer.
Comment 3 Martin Birgmeier 2022-08-19 11:42:52 UTC
Hi Stefan,

Could you please have look at this?

-- Martin
Comment 4 Stefan Eßer freebsd_committer freebsd_triage 2022-08-19 14:56:17 UTC
(In reply to Martin Birgmeier from comment #3)

This is a common issue if a port has a run dependency that is required to stage or package the port, but which is not declared as a build dependency.

Portmaster is more strict than poudriere with regard to different types of dependencies. When building with poudriere, all RUN_DEPENDS are installed into the build jail before a port build starts.

Portmaster builds and installs BUILD_DEPENDS and LIB_DEPENDS before working on the respective port that declares these dependencies, but installs RUN_DEPENDS only after completing the port build.

The basic ports system does not perform the same kind of dependency checking as either portmaster or poudriere does. It just recurses into dependent ports for each target before invoking the target on the port itself - thus is recursively calls "make install" on all dependencies (including RUN_DEPENDS) before installing the port itself. The reason is simply that make works on sub-goals before main-goals, and the installation of dependencies is a sub-goal that has to be completed before the main-goal may be attempted. (If the order was reversed and the installation of the port succeeded but the installation of a RUN_DEPENDS port failed thereafter, calling "make install" would find the port being installed and would not make another attempt to install the run dependencies).

You can use "portmaster -t" to force portmaster to provide RUN_DEPENDS before building a port, but that can result in much overhead and can cause dependency loops.

If a RUN_DEPENDS target is required before a port can be staged or packaged, then it actually is a build dependency and should be declared as such.
Comment 5 Martin Birgmeier 2022-08-19 15:29:56 UTC
Thank you for the detailed explanation, even though I must admit to not fully understanding it.

Something must have changed in either portmaster or the libreoffice ports a few months ago, resulting in the behavior described in this ticket and also in bug #265936.

I have noticed that for the libreoffice ports I am using, portmaster first builds, e.g., german/libreoffice, then uninstalls the old version of this port, then notices that it needs to upgrade editors/libreoffice as a (presumably runtime) dependency, then builds that one and tries to install it. But that fails because the old version is already installed. The result is that german/libreoffice remains deinstalled after this failure, the old editors/libreoffice remains installed, and the build directory contains a readily built new editors/libreoffice.

It seems to me that if portmaster detects such a kind of runtime dependency where the depended-on port needs to be upgraded, it should first perform the upgrade of that port before proceeding to the upgrade of the depending port (in this case, german/libreoffice).

This seemingly inverted dependency order is also visible in the output of the first scan portmaster performs, before it is asking whether to continue (if not using --no-confirm): The depended-on ports are listed after the depending ports when it would seem more logical to invert this.

-- Martin

p.s. It is also visible in the following command I am using to watch the progress of portmaster:

ps -axuewww | sed -n 's/.*PM_NEEDS_UPDATE= //p' | sort -u | tail -1 | sed 's/ /\
/g' | sed '/^$/,$ d' | less

Not fully functional but still helpful.
Comment 6 Martin Birgmeier 2022-08-19 18:44:27 UTC
(In reply to Martin Birgmeier from comment #5)

In portmasterfail.txt one can also see the "inverse" ordering of dependencies.