lib/initend.c: only use uname(3) if native_arch was not set
if the configuration file or the env variable is used we can skip uname(3).
This commit is contained in:
parent
c6aaafb123
commit
9a30f13300
@ -43,7 +43,6 @@
|
||||
int
|
||||
xbps_init(struct xbps_handle *xhp)
|
||||
{
|
||||
struct utsname un;
|
||||
const char *native_arch = NULL;
|
||||
int rv = 0;
|
||||
|
||||
@ -89,13 +88,6 @@ xbps_init(struct xbps_handle *xhp)
|
||||
if (xbps_path_clean(xhp->sysconfdir) == -1)
|
||||
return ENOTSUP;
|
||||
|
||||
/* set default native architecture before parsing configuration file */
|
||||
if (uname(&un) == -1)
|
||||
return ENOTSUP;
|
||||
if (xbps_strlcpy(xhp->native_arch, un.machine,
|
||||
sizeof xhp->native_arch) >= sizeof xhp->native_arch)
|
||||
return ENOBUFS;
|
||||
|
||||
xbps_fetch_set_cache_connection(XBPS_FETCH_CACHECONN, XBPS_FETCH_CACHECONN_HOST);
|
||||
|
||||
/* process xbps.d directories */
|
||||
@ -113,6 +105,15 @@ xbps_init(struct xbps_handle *xhp)
|
||||
sizeof xhp->native_arch) >= sizeof xhp->native_arch)
|
||||
return ENOBUFS;
|
||||
}
|
||||
|
||||
if (*xhp->native_arch == '\0') {
|
||||
struct utsname un;
|
||||
if (uname(&un) == -1)
|
||||
return ENOTSUP;
|
||||
if (xbps_strlcpy(xhp->native_arch, un.machine,
|
||||
sizeof xhp->native_arch) >= sizeof xhp->native_arch)
|
||||
return ENOBUFS;
|
||||
}
|
||||
assert(*xhp->native_arch);
|
||||
|
||||
/* Set cachedir */
|
||||
|
Loading…
Reference in New Issue
Block a user