lib/initend.c: allow XBPS{,_TARGET}_ARCH variables to overwrite config
This commit is contained in:
parent
b26f4068b7
commit
c6aaafb123
@ -43,6 +43,7 @@
|
|||||||
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;
|
||||||
|
|
||||||
@ -88,25 +89,12 @@ xbps_init(struct xbps_handle *xhp)
|
|||||||
if (xbps_path_clean(xhp->sysconfdir) == -1)
|
if (xbps_path_clean(xhp->sysconfdir) == -1)
|
||||||
return ENOTSUP;
|
return ENOTSUP;
|
||||||
|
|
||||||
/* target architecture */
|
/* set default native architecture before parsing configuration file */
|
||||||
xhp->target_arch = getenv("XBPS_TARGET_ARCH");
|
if (uname(&un) == -1)
|
||||||
if (xhp->target_arch && *xhp->target_arch == '\0')
|
return ENOTSUP;
|
||||||
xhp->target_arch = NULL;
|
if (xbps_strlcpy(xhp->native_arch, un.machine,
|
||||||
|
sizeof xhp->native_arch) >= sizeof xhp->native_arch)
|
||||||
/* native architecture */
|
return ENOBUFS;
|
||||||
if ((native_arch = getenv("XBPS_ARCH")) && *native_arch != '\0') {
|
|
||||||
if (xbps_strlcpy(xhp->native_arch, native_arch,
|
|
||||||
sizeof xhp->native_arch) >= sizeof xhp->native_arch)
|
|
||||||
return ENOBUFS;
|
|
||||||
} else {
|
|
||||||
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);
|
|
||||||
|
|
||||||
xbps_fetch_set_cache_connection(XBPS_FETCH_CACHECONN, XBPS_FETCH_CACHECONN_HOST);
|
xbps_fetch_set_cache_connection(XBPS_FETCH_CACHECONN, XBPS_FETCH_CACHECONN_HOST);
|
||||||
|
|
||||||
@ -114,6 +102,19 @@ xbps_init(struct xbps_handle *xhp)
|
|||||||
if ((rv = xbps_conf_init(xhp)) != 0)
|
if ((rv = xbps_conf_init(xhp)) != 0)
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
|
/* target arch only through env var */
|
||||||
|
xhp->target_arch = getenv("XBPS_TARGET_ARCH");
|
||||||
|
if (xhp->target_arch && *xhp->target_arch == '\0')
|
||||||
|
xhp->target_arch = NULL;
|
||||||
|
|
||||||
|
/* allow to overwrite uname(3) and conf file with env variable */
|
||||||
|
if ((native_arch = getenv("XBPS_ARCH")) && *native_arch != '\0') {
|
||||||
|
if (xbps_strlcpy(xhp->native_arch, native_arch,
|
||||||
|
sizeof xhp->native_arch) >= sizeof xhp->native_arch)
|
||||||
|
return ENOBUFS;
|
||||||
|
}
|
||||||
|
assert(*xhp->native_arch);
|
||||||
|
|
||||||
/* Set cachedir */
|
/* Set cachedir */
|
||||||
if (xhp->cachedir[0] == '\0') {
|
if (xhp->cachedir[0] == '\0') {
|
||||||
if (xbps_path_join(xhp->cachedir, sizeof xhp->cachedir,
|
if (xbps_path_join(xhp->cachedir, sizeof xhp->cachedir,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user