Skip to content

Conversation

@dch
Copy link
Contributor

@dch dch commented Jan 13, 2026

  • skip unlinking the file
  • remove the temp file
  • skip looping instead of continuing to try to remove it
  • inform user with pkg: Cannot remove %s: file is busy (mount point?), skipping

This at least fixes my issue, but it's not clear to me if skipping the loop iteration is always the appropriate behaviour.

root@sendai /h/dch# podman run -it --dns 1.1.1.1 --volume /usr/local/sbin/pkg-static:/usr/local/sbin/pkg --volume /var/cache/podman/pkg:/var/cache/pkg ghcr.io/freebsd/freebsd-notoolchain:15.0
# sed -i '' -E -e s/quarterly/latest/ /etc/pkg/FreeBSD.conf ;
# rm -rf /usr/local/etc/pkg/repos/*.conf ;
# echo 'FreeBSD-base: { enabled: yes }' | tee /usr/local/etc/pkg/repos/FreeBSD.conf ;
FreeBSD-base: { enabled: yes }
# env ASSUME_ALWAYS_YES=yes pkg update -f
Updating FreeBSD-ports repository catalogue...
[a9cfb613f1ac] Fetching meta.conf: 100%    179 B   0.2 k/s    00:01
[a9cfb613f1ac] Fetching data: 100%   11 MiB   1.8 M/s    00:06
Processing entries: 100%
FreeBSD-ports repository update completed. 36658 packages processed.
Updating FreeBSD-ports-kmods repository catalogue...
[a9cfb613f1ac] Fetching meta.conf: 100%    179 B   0.2 k/s    00:01
[a9cfb613f1ac] Fetching data: 100%   35 KiB  35.6 k/s    00:01
Processing entries: 100%
FreeBSD-ports-kmods repository update completed. 239 packages processed.
Updating FreeBSD-base repository catalogue...
[a9cfb613f1ac] Fetching meta.conf: 100%    179 B   0.2 k/s    00:01
[a9cfb613f1ac] Fetching data: 100%   80 KiB  81.5 k/s    00:01
Processing entries: 100%
FreeBSD-base repository update completed. 496 packages processed.
All repositories are up to date.
# pkg upgrade -y
Updating FreeBSD-ports repository catalogue...
[a9cfb613f1ac] Fetching meta.conf:   0%
FreeBSD-ports repository is up to date.
Updating FreeBSD-ports-kmods repository catalogue...
FreeBSD-ports-kmods repository is up to date.
Updating FreeBSD-base repository catalogue...
FreeBSD-base repository is up to date.
All repositories are up to date.
Checking for upgrades (2 candidates): 100%      2 B   0.0 k/s    00:01
Processing candidates (2 candidates): 100%      2 B   0.0 k/s    00:01
Checking integrity... done (0 conflicting)
The following 2 package(s) will be affected (of 0 checked):

Installed packages to be UPGRADED:
        FreeBSD-runtime: 15.0 -> 15.0p1 [FreeBSD-base]
        FreeBSD-utilities: 15.0 -> 15.0p1 [FreeBSD-base]

Number of packages to be upgraded: 2
[a9cfb613f1ac] [1/2] Upgrading FreeBSD-runtime from 15.0 to 15.0p1...
[a9cfb613f1ac] [1/2] Extracting FreeBSD-runtime-15.0p1: 100%    608 B   0.6 k/s    00:01
pkg: Cannot remove /etc/hosts: file is busy (mount point?), skipping
[a9cfb613f1ac] [2/2] Upgrading FreeBSD-utilities from 15.0 to 15.0p1...
[a9cfb613f1ac] [2/2] Extracting FreeBSD-utilities-15.0p1: 100%    2 KiB   2.2 k/s    00:01
==> Running trigger: mandoc.ucl
Generating apropos(1) database for /usr/share/man...
Generating apropos(1) database for /usr/share/openssl/man...
#

Fixes #2589

- add a function to check if files are identical
- handle EBUSY such as /etc/hosts is nullfs mounted from parent into
jail
- just remove the temp file if its actually identical
- leave the temp file if not, as a pkgnew file
- exit the loop instead of continuing to try to remove it repeatedly
@dch dch force-pushed the fix/target-is-mountpoint branch from 70845bb to 63f58c6 Compare January 22, 2026 09:20
@dch
Copy link
Contributor Author

dch commented Jan 22, 2026

Generalised now, handling more error cases, and debug info.

new output:

# podman run -it --volume /repos/pkg/src/pkg-static:/usr/local/sbin/pkg \
   --volume /usr/local/etc/pkg/repos:/usr/local/etc/pkg/repos:ro \
   --volume /var/cache/podman/pkg:/var/cache/pkg \
   --env IGNORE_OSVERSION=yes \
   --env ABI=FreeBSD:15:(sysctl -n hw.machine_arch) \
   --env OSVERSION=1500000 \
   ghcr.io/freebsd/freebsd-notoolchain:15.0 /bin/sh

# pkg update -r FreeBSD-base
Updating FreeBSD-base repository catalogue...
[4a5977e26ff6] Fetching meta.conf: 100%    179 B   0.2 k/s    00:01
[4a5977e26ff6] Fetching data: 100%   80 KiB  81.5 k/s    00:01
Processing entries: 100%
FreeBSD-base repository update completed. 496 packages processed.
FreeBSD-base is up to date.
  • do the upgrade, knowing that /etc/hosts is bind mounted into jail
# pkg -dd upgrade -Uyr FreeBSD-base
…
DBG(2)[41214]> pkg_extract_finalize: identical, /etc/gettytab, skipping /etc/.pkgtemp.gettytab.NycCmeBK71go
DBG(2)[41214]> pkg_extract_finalize: identical, /etc/group, skipping /etc/.pkgtemp.group.XvBXrmhJtsoi
DBG(2)[41214]> pkg_extract_finalize: identical, /etc/hosts, skipping /etc/.pkgtemp.hosts.YtR9hi6spyUx
DBG(2)[41214]> pkg_extract_finalize: identical, /etc/hosts.equiv, skipping /etc/.pkgtemp.hosts.equiv.KQlMZg6BpfFY
DBG(2)[41214]> pkg_extract_finalize: identical, /etc/login.access, skipping /etc/.pkgtemp.login.access.vTkLVSapM2Qd
DBG(2)[41214]> pkg_extract_finalize: identical, /etc/login.conf, skipping /etc/.pkgtemp.login.conf.fOdVP5iP5wW2
...
DBG(2)[41214]> pkg_extract_finalize: done
DBG(2)[41214]> (jobs) end pkg_jobs_handle_install:
==> Running trigger: mandoc.ucl
Generating apropos(1) database for /usr/share/man...
Generating apropos(1) database for /usr/share/openssl/man...
DBG(1)[41214]> (db) release an exclusive lock on a database
DBG(1)[41214]> (jobs) execute done
DBG(1)[41214]> (db) release an advisory lock on a database

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pkg update of base system pkg enters infinite loop if upgrade target file is mountpoint

2 participants