From a1a0167d8027d0360d8988d69616d0c8e1b2be9e Mon Sep 17 00:00:00 2001 From: Duncan Overbruck Date: Tue, 28 Dec 2021 15:16:47 +0100 Subject: [PATCH] add XBPS_SYSLOG environment variable to overwrite configuration --- NEWS | 4 ++++ bin/xbps-alternatives/xbps-alternatives.1 | 14 ++++++++++++++ bin/xbps-install/xbps-install.1 | 5 +++++ bin/xbps-reconfigure/xbps-reconfigure.1 | 20 ++++++++++++++++++++ bin/xbps-remove/xbps-remove.1 | 20 ++++++++++++++++++++ lib/initend.c | 22 ++++++++++------------ run-tests | 1 + 7 files changed, 74 insertions(+), 12 deletions(-) diff --git a/NEWS b/NEWS index 2cfb6f70..f02afd11 100644 --- a/NEWS +++ b/NEWS @@ -52,6 +52,10 @@ xbps-X.XX.X (2020-XX-XX): * xbps.d(5): describe ignorepkg more precisely. [chocimier] + * libxbps, xbps-install(1), xbps-remove(1), xbps-reconfigure(1), + xbps-alternatives(1): add `XBPS_SYSLOG` environment variable to overwrite + syslog configuration option. [duncaen] + xbps-0.59.1 (2020-04-01): * libxbps: fixed a double free with malformed/incomplete diff --git a/bin/xbps-alternatives/xbps-alternatives.1 b/bin/xbps-alternatives/xbps-alternatives.1 index d78cb01e..78743f00 100644 --- a/bin/xbps-alternatives/xbps-alternatives.1 +++ b/bin/xbps-alternatives/xbps-alternatives.1 @@ -69,6 +69,20 @@ Default package database (0.38 format). Keeps track of installed packages and pr .It Ar /var/cache/xbps Default cache directory to store downloaded binary packages. .El +.Sh ENVIRONMENT +.Bl -tag -width XBPS_TARGET_ARCH +.It Sy XBPS_ARCH +Overrides +.Xr uname 2 +machine result with this value. +.It Sy XBPS_TARGET_ARCH +Sets the target architecture to this value. +.It Sy XBPS_SYSLOG +Overrides the +.Xr xbps.d 5 +.Sy syslog=true|false +configuration option. +.El .Sh SEE ALSO .Xr xbps-checkvers 1 , .Xr xbps-create 1 , diff --git a/bin/xbps-install/xbps-install.1 b/bin/xbps-install/xbps-install.1 index 95695756..d171e267 100644 --- a/bin/xbps-install/xbps-install.1 +++ b/bin/xbps-install/xbps-install.1 @@ -245,6 +245,11 @@ This variable differs from in that it allows you to install packages partially, because configuration phase is skipped (the target binaries might not be compatible with the native architecture). +.It Sy XBPS_SYSLOG +Overrides the +.Xr xbps.d 5 +.Sy syslog=true|false +configuration option. .El .Sh FILES .Bl -tag -width /var/db/xbps/.-files.plist diff --git a/bin/xbps-reconfigure/xbps-reconfigure.1 b/bin/xbps-reconfigure/xbps-reconfigure.1 index b3052d86..fd068973 100644 --- a/bin/xbps-reconfigure/xbps-reconfigure.1 +++ b/bin/xbps-reconfigure/xbps-reconfigure.1 @@ -71,6 +71,26 @@ Enables verbose messages. .It Fl V, Fl -version Show the version information. .El +.Sh ENVIRONMENT +.Bl -tag -width XBPS_TARGET_ARCH +.It Sy XBPS_ARCH +Overrides +.Xr uname 2 +machine result with this value. +Useful to install packages with a fake architecture +.It Sy XBPS_TARGET_ARCH +Sets the target architecture to this value. +This variable differs from +.Sy XBPS_ARCH +in that it allows you to install packages partially, because +configuration phase is skipped (the target binaries might not be compatible with +the native architecture). +.It Sy XBPS_SYSLOG +Overrides the +.Xr xbps.d 5 +.Sy syslog=true|false +configuration option. +.El .Sh FILES .Bl -tag -width /var/db/xbps/.-files.plist .It Ar /etc/xbps.d diff --git a/bin/xbps-remove/xbps-remove.1 b/bin/xbps-remove/xbps-remove.1 index b9b778e9..76062ab1 100644 --- a/bin/xbps-remove/xbps-remove.1 +++ b/bin/xbps-remove/xbps-remove.1 @@ -97,6 +97,26 @@ Assume yes to all questions and avoid interactive questions. .It Fl V, Fl -version Show the version information. .El +.Sh ENVIRONMENT +.Bl -tag -width XBPS_TARGET_ARCH +.It Sy XBPS_ARCH +Overrides +.Xr uname 2 +machine result with this value. +Useful to remove packages with a fake architecture +.It Sy XBPS_TARGET_ARCH +Sets the target architecture to this value. +This variable differs from +.Sy XBPS_ARCH +in that it allows you to remove packages partially, because +configuration phase is skipped (the target binaries might not be compatible with +the native architecture). +.It Sy XBPS_SYSLOG +Overrides the +.Xr xbps.d 5 +.Sy syslog=true|false +configuration option. +.El .Sh FILES .Bl -tag -width /var/db/xbps/.-files.plist .It Ar /etc/xbps.d diff --git a/lib/initend.c b/lib/initend.c index 9ed9c03a..70ee26cb 100644 --- a/lib/initend.c +++ b/lib/initend.c @@ -25,9 +25,10 @@ */ #include +#include #include #include -#include +#include #include "xbps_api_impl.h" @@ -43,7 +44,7 @@ int xbps_init(struct xbps_handle *xhp) { - const char *native_arch = NULL; + const char *native_arch = NULL, *p; int rv = 0; assert(xhp != NULL); @@ -154,16 +155,13 @@ xbps_init(struct xbps_handle *xhp) if (xbps_path_clean(xhp->metadir) == -1) return ENOTSUP; - xbps_dbg_printf("rootdir=%s\n", xhp->rootdir); - xbps_dbg_printf("metadir=%s\n", xhp->metadir); - xbps_dbg_printf("cachedir=%s\n", xhp->cachedir); - xbps_dbg_printf("confdir=%s\n", xhp->confdir); - xbps_dbg_printf("sysconfdir=%s\n", xhp->sysconfdir); - xbps_dbg_printf("syslog=%s\n", xhp->flags & XBPS_FLAG_DISABLE_SYSLOG ? "false" : "true"); - xbps_dbg_printf("bestmatching=%s\n", xhp->flags & XBPS_FLAG_BESTMATCH ? "true" : "false"); - xbps_dbg_printf("keepconf=%s\n", xhp->flags & XBPS_FLAG_KEEP_CONFIG ? "true" : "false"); - xbps_dbg_printf("Architecture: %s\n", xhp->native_arch); - xbps_dbg_printf("Target Architecture: %s\n", xhp->target_arch ? xhp->target_arch : "(null)"); + p = getenv("XBPS_SYSLOG"); + if (p) { + if (strcasecmp(p, "true") == 0) + xhp->flags &= ~XBPS_FLAG_DISABLE_SYSLOG; + else if (strcasecmp(p, "false") == 0) + xhp->flags |= XBPS_FLAG_DISABLE_SYSLOG; + } if (xhp->flags & XBPS_FLAG_DEBUG) { const char *repodir; diff --git a/run-tests b/run-tests index 0601b564..ab8a516d 100755 --- a/run-tests +++ b/run-tests @@ -9,6 +9,7 @@ NPROCS=1 if [ -r /proc/cpuinfo ]; then NPROCS=$(grep ^proc /proc/cpuinfo|wc -l) fi +export XBPS_SYSLOG=false LIBRARY_PATH=$PWD/lib LD_LIBRARY_PATH=$PWD/lib ATF_SHELL=/bin/sh kyua --variable parallelism=$NPROCS test -r result.db -k tests/xbps/Kyuafile rv=$? kyua report --verbose -r result.db