install: add --ignore-unavailable
a package named on the command line which no repository provides is now
reported and skipped instead of failing the whole request
Fixes: #2195
utils: read the root databases through the root descriptor
Open the user and group databases of the root directory with openat(2) on
ctx.rootfd after pkg_resolve_beneath(), as the files are written, rather
than by a path built from ctx.pkg_rootdir.
Do not read the host databases when the root is "/", and drop the invalid
ids with strtonum(3) instead of giving 0 to chown(2).
search: match several fields with -S any
The search fields were either a single column or the fixed combination of
the comment and the description, so matching a keyword in the name, the
origin, the comment and the description at once, the way the ports tree
searches its index, required as many runs.
Add an "any" field composing them, sorted by package name.
Fixes: #2700
fetch: look the server list up once
When the SRV records or the mirror list of a repository cannot be resolved,
pkg falls back on the host of its URL, but the list was only cached on
success: the failing lookup, which is slow on a network without DNS, was
done again for every file fetched from the repository, and its error was
reported as many times.
Remember that the list could not be resolved for the repository, so that a
run looks it up once and reports it once.
Reported in #2786.
install|upgrade: tell that --fetch-only only downloads
The summary of a --fetch-only operation was the one of a real operation:
it asked to proceed with "this action" and announced the space which would
be freed or required, although nothing is installed, upgraded or removed
and only the packages are downloaded.
Say so in the summary, ask to proceed with the download, and leave the
space announcement out. Add pkg_jobs_get_flags(), the counterpart of
pkg_jobs_set_flags(), to let the frontend know about the flags of the
jobs.
Reported in #2716.
install: resolve the ownership in the root directory
The users and groups of a package were resolved with getpwnam(3) and
getgrnam(3), which read the database of the host: a file declared as
belonging to a user of the root directory pkg installs into was given the
id the host knows for that name, or 0 when the host does not know it at
all, so the files were not owned by their user in the target.
Read the user and group databases of the root directory instead when pkg
installs into one, and keep resolving on the host when the files are not
there or do not carry the name. pkg check, which resolves the names the
same way, compares against the right ids too.
Reported in #2179.
fetch: retry a transfer which fails in the middle
Only the connection set up was retried, FETCH_RETRY times per server, so a
connection which died in the middle of a large package aborted the whole
transaction and the bytes already downloaded were dropped.
Retry the transfer itself, the same number of times, resuming the package
where it stopped: the archives are opened for appending and the request is
ranged, which is the mechanism already used to resume a package left over
by an interrupted run.
Reported in #2786.
Add upgradable
This new command provides an easy way for scripts to determine whether
updates are available for any currently installed package, or for a
specific currently installed package or set of packages. Locked
packages are ignored unless --force / -f is specified.
The command-line syntax is largely the same as for upgrade, and the
output (if --quiet / -q is not specified) is largely the same as well.
pkgdb_iterator: Free package when done
The iterator currently frees the current package when it advances, but
not when it reaches the end, resulting in hard-to-fix memory leaks.
search: report an invalid regular expression once
The regular expressions are compiled by the SQL function when the query
runs, so an invalid pattern was reported by the SQL layer, with the name
of an internal file, and once per repository it was applied to.
Check the pattern when the query is created instead: it is now reported
once, as a user error, by every command which matches a pattern as a
regular expression. pkg info also fails instead of reporting the error
and exiting successfully.
Reported in #2751.
upgrade: expand deps of the selected candidate
The upgrade chain can be narrowed to a candidate whose dependencies
have not been seen yet, in particular when a lower-priority repository
still carries an older version of the package. Select the candidate
before expanding the dependencies, as the partial upgrade path already
does.
Fixes: #2761
scripts: add pre-transaction scripts
A package could only check that the system is ready for it from its
pre-install script, which runs in the middle of the transaction: failing
there leaves the system half updated, in a state which cannot be rolled
back.
This script is run early in the transaction, add and register also calls
it.
This would allow to move sanity checks out of *install scripts
search: match a glob-looking pattern as a glob
pkg search matches regular expressions by default, so a pattern like
'*rust' was reported as an invalid regular expression. When no match
mode is requested, match a pattern which looks like a shell glob and
does not compile as a regular expression as a glob instead.
A pattern which is a valid regular expression keeps its meaning, and an
explicitly requested regular expression is still reported as invalid.
Also match the package name and not only the name and the version in the
remote queries, like the local ones do: with a glob or an exact match, a
pattern meant to match the name alone could never match, so '-e rust' and
'-g *rust' found nothing.
Reported in #2751.
zsh-completion: update for new options and sub-commands
Complete options for pkg config and shared libraries for pkg shlib.
Handle pkg repositories, pkg rwhich, pkg checksum and pkg unregister.
Add some new configuration options and command options.
register: fail when a pre-install script fails
pkg register ignored the exit status of the pre-install shell scripts and
lua files, so a package was registered even when its pre-install script
failed, unlike pkg add. Check them before anything is extracted: the
registration is still in a transaction at that point, so it is rolled
back and the package is not left registered.
Post-install failures are still not fatal, here and in pkg add: the
package is already installed by then, and aborting in the middle of a
transaction leaves the system in a state which cannot be rolled back.
That part of #2073 needs the pre-transaction sanity hook discussed in
#2111 and is left for later.
fetch: show the port in the fetch diagnostics
libfetch keeps the port apart from the host, and the diagnostics rebuilt the
URL from its components without it: a repository served on a non default
port was reported as scheme://host/doc, which points at the wrong server and
hides the actual port used.
Format the URL once, with the port when it is set, and use it in the fetch
debug line and in the two error messages.
upgrade: tell which version a locked package would be upgraded to
A locked package which the repositories can upgrade was reported as
locked, without any hint that a newer version exists, and pkg could even
claim that the most recent version is installed.
Carry the available version in the locked event so that the report says
which version the package would be upgraded to, and look the repositories
up when the locked package is found while its candidate is not at hand.
Fixes: #2698
upgrade: pick the newest version of a package, not the first one
The items of a request are in universe order, which is not the version
order, and the solver assumes the first item to be installed. When a
repository publishes several versions of the same package, the first one
can be any of them, including an older one, so the upgrade proposes a
downgrade.
Keep assuming the first item unless it is older than the installed
package: in that case use the newest candidate of the repository the
package was installed from, or keep the installed package when none of
the candidates is an upgrade. The same repository selection in the
universe now also prefers the newest candidate instead of the first one.
Fixes: #1757
metalog: log all the directories of the package
The metalog only got entries for the directories which did not exist when
the temporary extraction directory was opened. That happened once per
package, for the first file only, and the directories were logged from
the children to the parents, which is not a valid mtree specification.
Compute the directories from the package content instead, log the ones
pkg creates, with the attributes of the declared ones, and sort them from
the parents to the children.
Fixes: #2672
metalog: log all the directories of the package
The metalog only got entries for the directories which did not exist when
the temporary extraction directory was opened. That happened once per
package, for the first file only, and the directories were logged from
the children to the parents, which is not a valid mtree specification.
Compute the directories from the package content instead, log the ones
pkg creates, with the attributes of the declared ones, and sort them from
the parents to the children.
Fixes: #2672