diff --git a/src/Intrinsic.c b/src/Intrinsic.c index c9624ec..addcdba 100644 --- a/src/Intrinsic.c +++ b/src/Intrinsic.c @@ -1312,21 +1312,101 @@ static void FillInLangSubs( } else (void) strcpy(*rest, string); } + + /* - * default path used if environment variable XFILESEARCHPATH - * is not defined. Also substitued for %D. - * The exact value should be documented in the implementation - * notes for any Xt implementation. + Return the default search path for the function + XtResolvePathname to use if XFILESEARCHPATH is + not defined. + + It returns the combination the set of values which are the 6 "stems" below, + prepended with "/run/current-system/profile", and $GUIX_PROFILE and + "$HOME/.guix-profile" + + These values provide the default paths where Guix/GuixSD can expect + to find resources for installed packages. */ -static const char *implementation_default_path(void) +static const char *guix_default_path(void) { -#if defined(WIN32) - static char xfilesearchpath[] = ""; + static const char *search_path_default_stem[] = { + "/lib/X11/%L/%T/%N%C%S", + "/lib/X11/%l/%T/%N%C%S", + "/lib/X11/%T/%N%C%S", + "/lib/X11/%L/%T/%N%S", + "/lib/X11/%l/%T/%N%S", + "/lib/X11/%T/%N%S" + }; + +#define SIZEOF_STEMS (strlen (search_path_default_stem[0]) \ + + strlen (search_path_default_stem[1]) \ + + strlen (search_path_default_stem[2]) \ + + strlen (search_path_default_stem[3]) \ + + strlen (search_path_default_stem[4]) \ + + strlen (search_path_default_stem[5])) + + + int i; + const char *current_profile = "/run/current-system/profile"; + char *home = getenv ("HOME"); + char *guix_profile = getenv ("GUIX_PROFILE"); + + size_t bytesAllocd = SIZEOF_STEMS + 1; + + /* This function is evaluated multiple times and the calling + code assumes that it is idempotent. So we must not allow + (say) a changed environment variable to cause it to return + something different. */ + static char *path = NULL; + if (path) + return path; + + bytesAllocd += 6 * (1 + strlen (current_profile)); + + if (guix_profile != NULL) + { + bytesAllocd += SIZEOF_STEMS; + bytesAllocd += 6 * (1 + strlen (guix_profile)); + } - return xfilesearchpath; -#else - return XFILESEARCHPATHDEFAULT; -#endif + if (home != NULL) + { + bytesAllocd += SIZEOF_STEMS; + bytesAllocd += 6 * (1 + strlen(home) + strlen ("/.guix-profile")); + } + + path = XtMalloc(bytesAllocd); + if (path == NULL) _XtAllocError(NULL); + + memset (path, 0, bytesAllocd); + + for (i = 0 ; i < 6 ; ++i) + { + strcat (path, current_profile); + strcat (path, search_path_default_stem[i]); + strcat (path, ":"); + } + + if (guix_profile != NULL) + for (i = 0 ; i < 6 ; ++i) + { + strcat (path, guix_profile); + strcat (path, search_path_default_stem[i]); + strcat (path, ":"); + } + + if (home != NULL) + for (i = 0 ; i < 6 ; ++i) + { + strcat (path, home); + strcat (path, "/.guix-profile"); + strcat (path, search_path_default_stem[i]); + strcat (path, ":"); + } + + /* Remove final : */ + path[strlen(path) - 1] = '\0'; + + return path; } @@ -1354,7 +1434,7 @@ _XtString XtResolvePathname( { XtPerDisplay pd; static const char *defaultPath = NULL; - const char *impl_default = implementation_default_path(); + const char *impl_default = guix_default_path(); int idef_len = (int) strlen(impl_default); char *massagedPath; int bytesAllocd, bytesLeft; scm, gnu/tests/cups.scm, gnu/tests/databases.scm, gnu/tests/desktop.scm, gnu/tests/dict.scm, gnu/tests/docker.scm, gnu/tests/file-sharing.scm, gnu/tests/ganeti.scm, gnu/tests/guix.scm, gnu/tests/ldap.scm, gnu/tests/linux-modules.scm, gnu/tests/mail.scm, gnu/tests/messaging.scm, gnu/tests/monitoring.scm, gnu/tests/networking.scm, gnu/tests/nfs.scm, gnu/tests/package-management.scm, gnu/tests/reconfigure.scm, gnu/tests/rsync.scm, gnu/tests/security-token.scm, gnu/tests/singularity.scm, gnu/tests/ssh.scm, gnu/tests/telephony.scm, gnu/tests/version-control.scm, gnu/tests/virtualization.scm, gnu/tests/web.scm: Remove (mkdir #$output) (chdir #$output) and pass #$output as argument to 'system-test-runner'. Ludovic Courtès 2021-09-25tests: Adjust to SRFI-64 as found in Guile 3.0.7....In Guile 3.0.7, 'test-runner-current' is set to #f upon 'test-end'. Consequently, the previous strategy, where we'd call 'test-runner-current' after 'test-end', no longer works. Instead, set the test runner in each test right before 'test-begin'. * gnu/build/marionette.scm (system-test-runner): New procedure. * gnu/tests/audio.scm (run-mpd-test): Replace (exit (= ...)) idiom by (test-runner-current (system-test-runner)). * gnu/tests/base.scm (run-basic-test) (run-cleanup-test, run-mcron-test, run-nss-mdns-test): Likewise. * gnu/tests/ci.scm (run-laminar-test): Likewise. * gnu/tests/cups.scm (run-cups-test): Likewise. * gnu/tests/databases.scm (run-memcached-test) (run-postgresql-test, run-mysql-test): Likewise. * gnu/tests/desktop.scm (run-elogind-test): Likewise. * gnu/tests/dict.scm (run-dicod-test): Likewise. * gnu/tests/docker.scm (run-docker-test): Likewise. (run-docker-system-test): Likewise. * gnu/tests/file-sharing.scm (run-transmission-daemon-test): Likewise. * gnu/tests/ganeti.scm (run-ganeti-test): Likewise. * gnu/tests/guix.scm (run-guix-build-coordinator-test): Likewise. (run-guix-data-service-test): Likewise. * gnu/tests/ldap.scm (run-ldap-test): Likewise. * gnu/tests/linux-modules.scm (run-loadable-kernel-modules-test-base): Likewise. * gnu/tests/mail.scm (run-opensmtpd-test) (run-exim-test, run-dovecot-test, run-getmail-test): Likewise. * gnu/tests/messaging.scm (run-xmpp-test) (run-bitlbee-test, run-quassel-test): Likewise. * gnu/tests/monitoring.scm (run-prometheus-node-exporter-server-test) (run-zabbix-server-test): Likewise. * gnu/tests/networking.scm (run-inetd-test, run-openvswitch-test) (run-dhcpd-test, run-tor-test, run-iptables-test, run-ipfs-test): Likewise. * gnu/tests/nfs.scm (run-nfs-test) (run-nfs-server-test, run-nfs-root-fs-test): Likewise. * gnu/tests/package-management.scm (run-nix-test): Likewise. * gnu/tests/reconfigure.scm (run-switch-to-system-test) (run-upgrade-services-test, run-install-bootloader-test): Likewise. * gnu/tests/rsync.scm (run-rsync-test): Likewise. * gnu/tests/security-token.scm (run-pcscd-test): Likewise. * gnu/tests/singularity.scm (run-singularity-test): Likewise. * gnu/tests/ssh.scm (run-ssh-test): Likewise. * gnu/tests/telephony.scm (run-jami-test): Likewise. * gnu/tests/version-control.scm (run-cgit-test): Likewise. (run-git-http-test, run-gitolite-test, run-gitile-test): Likewise. * gnu/tests/virtualization.scm (run-libvirt-test, run-childhurd-test): Likewise. * gnu/tests/web.scm (run-webserver-test, run-php-fpm-test) (run-hpcguix-web-server-test, run-tailon-test, run-patchwork-test): Likewise. Ludovic Courtès