pkg_autoremove/force delete: Fix order
If package A depends on package B (on a binary or script for example), when
autoremove is called currently the order is (likely) by alphabetic.
This cause problems as if package A is removed first and package B needs a script
from package A it will fails to clean up correctly the system.
Since autoremove is considered as force internally simply remove the check so we will
process the removals in the correct order.
Sponsored by: Beckhoff Automation GmbH & Co. KG
pkg_autoremove/force delete: Fix order
If package A depends on package B (on a binary or script for example), when
autoremove is called currently the order is (likely) by alphabetic.
This cause problems as if package A is removed first and package B needs a script
from package A it will fails to clean up correctly the system.
Since autoremove is considered as force internally simply remove the check so we will
process the removals in the correct order.
Sponsored by: Beckhoff Automation GmbH & Co. KG
pkg_autoremove: Fix order
If package A depends on package B (on a binary or script for example), when
autoremove is called currently the order is (likely) by alphabetic.
This cause problems as if package A is removed first and package B needs a script
from package A it will fails to clean up correctly the system.
Since autoremove is considered as force internally simply extend the check so we will
process the removals in the correct order.
Sponsored by: Beckhoff Automation GmbH & Co. KG
pkgdb: skip WAL journal mode on read-only databases
PRAGMA journal_mode = WAL requires write access to create the -wal and
-shm sidecar files. When pkg-static runs as an unprivileged user (e.g.
nobody during poudriere's package phase), the local database is opened
read-only and the WAL pragma fails with "attempt to write a readonly
database".
This caused actual-package-depends to fail silently, producing packages
with missing dependencies. For example, gmake was packaged without its
gettext-runtime dependency, leading to "libintl.so.8 not found" errors
when gmake was later installed as a build dependency.
Use sqlite3_db_readonly() to check the connection mode before attempting
to enable WAL, consistent with other read-only guards in pkgdb.c.
Fixes: a7ccf3c03e92 ("pkgdb: enable WAL journal mode for local databases")
Reported-by: https://github.com/freebsd/pkg/issues/2605
pkgdb: open read-only databases in immutable mode to fix WAL access
When pkg enables WAL journal mode on the local database (during a
write-access session), the mode is persisted in the database header.
Subsequent read-only opens (e.g. as nobody during poudriere's package
phase) fail because WAL requires -shm/-wal sidecar files which cannot
be created without write access, causing all queries to fail — including
read-only ones like PRAGMA user_version.
This caused actual-package-depends to fail silently, producing packages
with missing dependencies. For example, gmake was packaged without its
gettext-runtime dependency, leading to "libintl.so.8 not found" errors.
Fix by opening the database with sqlite3_open_v2() and immutable=1 URI
parameter when write access is not available. Immutable mode tells
SQLite to bypass WAL/SHM entirely and read directly from the main
database file, which contains all committed data after the last
writer's checkpoint.
pkgdb: open read-only databases in immutable mode to fix WAL access
When pkg enables WAL journal mode on the local database (during a
write-access session), the mode is persisted in the database header.
Subsequent read-only opens (e.g. as nobody during poudriere's package
phase) fail because WAL requires -shm/-wal sidecar files which cannot
be created without write access, causing all queries to fail — including
read-only ones like PRAGMA user_version.
This caused actual-package-depends to fail silently, producing packages
with missing dependencies. For example, gmake was packaged without its
gettext-runtime dependency, leading to "libintl.so.8 not found" errors.
Fix by opening the database with sqlite3_open_v2() and immutable=1 URI
parameter when write access is not available. Immutable mode tells
SQLite to bypass WAL/SHM entirely and read directly from the main
database file, which contains all committed data after the last
writer's checkpoint.
pkgdb: skip WAL journal mode on read-only databases
PRAGMA journal_mode = WAL requires write access to create the -wal and
-shm sidecar files. When pkg-static runs as an unprivileged user (e.g.
nobody during poudriere's package phase), the local database is opened
read-only and the WAL pragma fails with "attempt to write a readonly
database".
This caused actual-package-depends to fail silently, producing packages
with missing dependencies. For example, gmake was packaged without its
gettext-runtime dependency, leading to "libintl.so.8 not found" errors
when gmake was later installed as a build dependency.
Use sqlite3_db_readonly() to check the connection mode before attempting
to enable WAL, consistent with other read-only guards in pkgdb.c.
Fixes: a7ccf3c03e92 ("pkgdb: enable WAL journal mode for local databases")
Reported-by: https://github.com/freebsd/pkg/issues/2605
Fix EBADF crash
if ftruncate() failes, it uses pkg_errno() which only log the error
instead of pkg_fatal_errno) which return (EPKG_FATAL).
While here fix a fd leak
Fixes: #2279
upgrade: Fix crash in pkg upgrade
when upgrading pkgbase, pkg may try in its plan to remove temporarily
itself, in such case we could reach a crash
Fixes: #2496
reproducibility: fix regression in DL_SORT
STREQ returns a boolean while DL_SORT expect the 3 kind of returns
provided by strcmp to properly sort.
Fixes: #2427
upgrade: multiple fixes on how decisions are taken
- Fix handling of shlibs on non pkgbase system
- Fix bad loop logic which resulted in some shlibs changed not being
detected
- Remove dead code