Fix #69 (No way to set globally a custom architecture)
The "architecture" configuration keyword is now available to override the native machine architecture returned by (uname(2)). The XBPS_ARCH environment variable still has preference.
This commit is contained in:
parent
b2bc7af66e
commit
428a747fad
4
NEWS
4
NEWS
@ -1,5 +1,9 @@
|
|||||||
xbps-0.42 (???):
|
xbps-0.42 (???):
|
||||||
|
|
||||||
|
* Implemented issue #69 (No way to set globally a custom architecture)
|
||||||
|
A new configuration keyword "architecture" has been added to override
|
||||||
|
the native machine architecture (uname -m).
|
||||||
|
|
||||||
* Fixed issue #68 "xbps_binpkg_arch() asserts if arch contains a dash"
|
* Fixed issue #68 "xbps_binpkg_arch() asserts if arch contains a dash"
|
||||||
https://github.com/voidlinux/xbps/issues/68
|
https://github.com/voidlinux/xbps/issues/68
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ usage(void)
|
|||||||
" Available actions:\n"
|
" Available actions:\n"
|
||||||
" binpkgarch, binpkgver, cmpver, digest, fetch, getpkgdepname,\n"
|
" binpkgarch, binpkgver, cmpver, digest, fetch, getpkgdepname,\n"
|
||||||
" getpkgname, getpkgrevision, getpkgversion, pkgmatch, version,\n"
|
" getpkgname, getpkgrevision, getpkgversion, pkgmatch, version,\n"
|
||||||
" real-version.\n"
|
" real-version, arch.\n"
|
||||||
"\n"
|
"\n"
|
||||||
" Action arguments:\n"
|
" Action arguments:\n"
|
||||||
" binpkgarch\t<binpkg>\n"
|
" binpkgarch\t<binpkg>\n"
|
||||||
@ -138,6 +138,7 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
if ((strcmp(argv[0], "version") == 0) ||
|
if ((strcmp(argv[0], "version") == 0) ||
|
||||||
(strcmp(argv[0], "real-version") == 0) ||
|
(strcmp(argv[0], "real-version") == 0) ||
|
||||||
|
(strcmp(argv[0], "arch") == 0) ||
|
||||||
(strcmp(argv[0], "fetch") == 0)) {
|
(strcmp(argv[0], "fetch") == 0)) {
|
||||||
/*
|
/*
|
||||||
* Initialize libxbps.
|
* Initialize libxbps.
|
||||||
@ -269,6 +270,12 @@ main(int argc, char **argv)
|
|||||||
usage();
|
usage();
|
||||||
|
|
||||||
exit(xbps_cmpver(argv[1], argv[2]));
|
exit(xbps_cmpver(argv[1], argv[2]));
|
||||||
|
} else if (strcmp(argv[0], "arch") == 0) {
|
||||||
|
/* returns the xbps native arch */
|
||||||
|
if (argc != 1)
|
||||||
|
usage();
|
||||||
|
|
||||||
|
printf("%s\n", xh.native_arch);
|
||||||
} else if (strcmp(argv[0], "digest") == 0) {
|
} else if (strcmp(argv[0], "digest") == 0) {
|
||||||
/* Prints SHA256 hashes for specified files */
|
/* Prints SHA256 hashes for specified files */
|
||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
|
@ -157,7 +157,8 @@ parse_option(char *buf, char **k, char **v)
|
|||||||
"virtualpkg",
|
"virtualpkg",
|
||||||
"include",
|
"include",
|
||||||
"preserve",
|
"preserve",
|
||||||
"bestmatching"
|
"bestmatching",
|
||||||
|
"architecture"
|
||||||
};
|
};
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
@ -249,6 +250,10 @@ parse_file(struct xbps_handle *xhp, const char *cwd, const char *path, bool nest
|
|||||||
xbps_dbg_printf(xhp, "%s: cachedir set to %s\n",
|
xbps_dbg_printf(xhp, "%s: cachedir set to %s\n",
|
||||||
path, v);
|
path, v);
|
||||||
snprintf(xhp->cachedir, sizeof(xhp->cachedir), "%s", v);
|
snprintf(xhp->cachedir, sizeof(xhp->cachedir), "%s", v);
|
||||||
|
} else if (strcmp(k, "architecture") == 0) {
|
||||||
|
xbps_dbg_printf(xhp, "%s: native architecture set to %s\n",
|
||||||
|
path, v);
|
||||||
|
snprintf(xhp->native_arch, sizeof(xhp->native_arch), "%s", v);
|
||||||
} else if (strcmp(k, "syslog") == 0) {
|
} else if (strcmp(k, "syslog") == 0) {
|
||||||
if (strcasecmp(v, "true") == 0) {
|
if (strcasecmp(v, "true") == 0) {
|
||||||
xhp->flags &= ~XBPS_FLAG_DISABLE_SYSLOG;
|
xhp->flags &= ~XBPS_FLAG_DISABLE_SYSLOG;
|
||||||
|
@ -8,3 +8,5 @@ include('xbps-create/Kyuafile')
|
|||||||
include('xbps-install/Kyuafile')
|
include('xbps-install/Kyuafile')
|
||||||
include('xbps-query/Kyuafile')
|
include('xbps-query/Kyuafile')
|
||||||
include('xbps-rindex/Kyuafile')
|
include('xbps-rindex/Kyuafile')
|
||||||
|
include('xbps-uhelper/Kyuafile')
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
-include ../../config.mk
|
-include ../../config.mk
|
||||||
|
|
||||||
SUBDIRS = common libxbps xbps-checkvers xbps-create xbps-install xbps-query xbps-rindex
|
SUBDIRS = common libxbps xbps-checkvers xbps-create xbps-install xbps-query xbps-rindex xbps-uhelper
|
||||||
|
|
||||||
include ../../mk/subdir.mk
|
include ../../mk/subdir.mk
|
||||||
|
4
tests/xbps/xbps-uhelper/Kyuafile
Normal file
4
tests/xbps/xbps-uhelper/Kyuafile
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
syntax("kyuafile", 1)
|
||||||
|
|
||||||
|
test_suite("xbps-uhelper")
|
||||||
|
atf_test_program{name="arch_test"}
|
8
tests/xbps/xbps-uhelper/Makefile
Normal file
8
tests/xbps/xbps-uhelper/Makefile
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
TOPDIR = ../../..
|
||||||
|
-include $(TOPDIR)/config.mk
|
||||||
|
|
||||||
|
TESTSHELL = arch_test
|
||||||
|
TESTSSUBDIR = xbps/xbps-uhelper
|
||||||
|
EXTRA_FILES = Kyuafile
|
||||||
|
|
||||||
|
include $(TOPDIR)/mk/test.mk
|
39
tests/xbps/xbps-uhelper/arch_test.sh
Normal file
39
tests/xbps/xbps-uhelper/arch_test.sh
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
#! /usr/bin/env atf-sh
|
||||||
|
# Test that xbps-uhelper arch works as expected.
|
||||||
|
|
||||||
|
atf_test_case native
|
||||||
|
|
||||||
|
native_head() {
|
||||||
|
atf_set "descr" "xbps-uhelper arch: native test"
|
||||||
|
}
|
||||||
|
|
||||||
|
native_body() {
|
||||||
|
atf_check_equal $(xbps-uhelper arch) $(uname -m)
|
||||||
|
}
|
||||||
|
|
||||||
|
atf_test_case env
|
||||||
|
|
||||||
|
env_head() {
|
||||||
|
atf_set "descr" "xbps-uhelper arch: envvar override test"
|
||||||
|
}
|
||||||
|
env_body() {
|
||||||
|
export XBPS_ARCH=foo
|
||||||
|
atf_check_equal $(xbps-uhelper arch) foo
|
||||||
|
}
|
||||||
|
|
||||||
|
atf_test_case conf
|
||||||
|
|
||||||
|
conf_head() {
|
||||||
|
atf_set "descr" "xbps-uhelper arch: configuration override test"
|
||||||
|
}
|
||||||
|
conf_body() {
|
||||||
|
mkdir -p xbps.d
|
||||||
|
echo "architecture=x86_64-musl" > xbps.d/arch.conf
|
||||||
|
atf_check_equal $(xbps-uhelper -C $PWD/xbps.d arch) x86_64-musl
|
||||||
|
}
|
||||||
|
|
||||||
|
atf_init_test_cases() {
|
||||||
|
atf_add_test_case native
|
||||||
|
atf_add_test_case env
|
||||||
|
atf_add_test_case conf
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user