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
|
int
|
||||||
xbps_init(struct xbps_handle *xhp)
|
xbps_init(struct xbps_handle *xhp)
|
||||||
{
|
{
|
||||||
struct utsname un;
|
|
||||||
const char *native_arch = NULL;
|
const char *native_arch = NULL;
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
|
|
||||||
@ -89,13 +88,6 @@ xbps_init(struct xbps_handle *xhp)
|
|||||||
if (xbps_path_clean(xhp->sysconfdir) == -1)
|
if (xbps_path_clean(xhp->sysconfdir) == -1)
|
||||||
return ENOTSUP;
|
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);
|
xbps_fetch_set_cache_connection(XBPS_FETCH_CACHECONN, XBPS_FETCH_CACHECONN_HOST);
|
||||||
|
|
||||||
/* process xbps.d directories */
|
/* process xbps.d directories */
|
||||||
@ -113,6 +105,15 @@ xbps_init(struct xbps_handle *xhp)
|
|||||||
sizeof xhp->native_arch) >= sizeof xhp->native_arch)
|
sizeof xhp->native_arch) >= sizeof xhp->native_arch)
|
||||||
return ENOBUFS;
|
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);
|
assert(*xhp->native_arch);
|
||||||
|
|
||||||
/* Set cachedir */
|
/* Set cachedir */
|
||||||
|
Loading…
Reference in New Issue
Block a user