Closed CismonX closed 1 month ago
In pkg.conf(5)
, it says:
MIRROR_TYPE: string MIRROR_TYPE for this repository only.
Default: NONE. Any of HTTP or SRV or
NONE.
And:
For a MIRROR_TYPE of NONE, any of the following URL schemes: http://,
https://, file://, ssh://, tcp://. Where MIRROR_TYPE is SRV, you
should use a pkg+http:// or pkg+https:// (etc.) URL scheme. Using an
http:// URL implies that the hostname part is a simple hostname accord-
ing to RFC 2616, and is no longer accepted.
I'm curious that if it's really necessary to explicitly declare mirror_type
as none
.
In pkg.conf(5)
:
Repository configuration files are searched for in order of the directories listed in the REPOS_DIR array, which defaults to
/etc/pkg/
and/usr/local/etc/pkg/repos/
.
Also:
Reusing the repository tag will cause those items defined in configuration files later on the REPOS_DIR search path to overwrite the equivalent settings for the same tag earlier on the search path.
Since the default configuration in /etc/pkg/FreeBSD.conf
already declares mirror_type
as srv
, that value will be used by pkg(8)
unless explicitly overridden.
In freebsd/pkg/libpkg/fetch_libcurl.c
:
// ...
if (repo->mirror_type == SRV && repo->srv == NULL) {
int urloff = 0;
cr->url = curl_url();
if (strncasecmp(repo->url, "pkg+", 4) == 0)
urloff = 4;
CURLUcode c = curl_url_set(cr->url, CURLUPART_URL, repo->url + urloff, 0);
if (c) {
pkg_emit_error("impossible to parse url: '%s'", repo->url);
return (EPKG_FATAL);
}
char *zone;
char *host = NULL, *scheme = NULL;
curl_url_get(cr->url, CURLUPART_HOST, &host, 0);
curl_url_get(cr->url, CURLUPART_SCHEME, &scheme, 0);
xasprintf(&zone, "_%s._tcp.%s", scheme, host);
repo->srv = dns_getsrvinfo(zone);
free(zone);
free(host);
free(scheme);
if (repo->srv == NULL) {
pkg_emit_error("No SRV record found for the "
"repo '%s'", repo->name);
repo->mirror_type = NOMIRROR;
}
}
// ...
When mirror_type
is srv
, pkg(8)
attempts to resolve the SRV
record even if the URL is not prefixed with pkg+
, leading to the aforementioned warning message.
This behavior is introduced in commit #f06399ce03, and continues to exist in all releases since 1.20.0. That explains why users never encountered this problem until recently...
Since currently there is no
SRV
record on either_http._tcp.mirrors.ustc.edu.cn
or_https._tcp.mirrors.ustc.edu.cn
, themirror_type
field in/etc/pkg/FreeBSD.conf
should be overridden tonone
, otherwisepkg(8)
may produce warnings like:See also: pkg.conf(5), #90665, #90716