diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2016-03-19 14:45:58 +0100 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2016-03-19 15:07:46 +0100 |
| commit | ef5f5c8659b1ca3999e362dfa33478e0a0150ced (patch) | |
| tree | e2967b666c0434b76e4a16a9346f50fa04067958 /m4 | |
| parent | 7c49ab5b1c1aa79a06504456e4decc5112c5b9f9 (diff) | |
build: Protect against misconfiguration of localstatedir.
Suggested by Jookia <166291@gmail.com>.
* m4/guix.m4 (GUIX_CURRENT_LOCALSTATEDIR, GUIX_CHECK_LOCALSTATEDIR): New
macros.
* config-daemon.ac: Use 'GUIX_CHECK_LOCALSTATEDIR'.
* Makefile.am (DISTCHECK_CONFIGURE_FLAGS): Add --localstatedir.
* doc/guix.texi (Requirements): Mention --localstatedir.
(The Store): Mention LOCALSTATEDIR as such.
Diffstat (limited to 'm4')
| -rw-r--r-- | m4/guix.m4 | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/m4/guix.m4 b/m4/guix.m4 index acfc33e170c..2d3dfd282ec 100644 --- a/m4/guix.m4 +++ b/m4/guix.m4 | |||
| @@ -307,3 +307,49 @@ AC_DEFUN([GUIX_LIBGCRYPT_LIBDIR], [ | |||
| 307 | fi]) | 307 | fi]) |
| 308 | $1="$guix_cv_libgcrypt_libdir" | 308 | $1="$guix_cv_libgcrypt_libdir" |
| 309 | ]) | 309 | ]) |
| 310 | |||
| 311 | dnl GUIX_CURRENT_LOCALSTATEDIR | ||
| 312 | dnl | ||
| 313 | dnl Determine the localstatedir of an existing Guix installation and set | ||
| 314 | dnl 'guix_cv_current_localstatedir' accordingly. Set it to "none" if no | ||
| 315 | dnl existing installation was found. | ||
| 316 | AC_DEFUN([GUIX_CURRENT_LOCALSTATEDIR], [ | ||
| 317 | AC_PATH_PROG([GUILE], [guile]) | ||
| 318 | AC_CACHE_CHECK([the current installation's localstatedir], | ||
| 319 | [guix_cv_current_localstatedir], | ||
| 320 | [dnl Call 'dirname' because (guix config) appends "/guix" to LOCALSTATEDIR. | ||
| 321 | guix_cv_current_localstatedir="`"$GUILE" \ | ||
| 322 | -c '(use-modules (guix config)) | ||
| 323 | (when (string=? %store-directory "'$storedir'") | ||
| 324 | (display (dirname %state-directory)))' \ | ||
| 325 | 2>/dev/null`" | ||
| 326 | if test "x$guix_cv_current_localstatedir" = "x"; then | ||
| 327 | guix_cv_current_localstatedir=none | ||
| 328 | fi])]) | ||
| 329 | |||
| 330 | dnl GUIX_CHECK_LOCALSTATEDIR | ||
| 331 | dnl | ||
| 332 | dnl Check that the LOCALSTATEDIR value is consistent with that of the existing | ||
| 333 | dnl Guix installation, if any. Error out or warn if they do not match. | ||
| 334 | AC_DEFUN([GUIX_CHECK_LOCALSTATEDIR], [ | ||
| 335 | AC_REQUIRE([GUIX_CURRENT_LOCALSTATEDIR]) | ||
| 336 | if test "x$guix_cv_current_localstatedir" != "xnone"; then | ||
| 337 | if test "$guix_cv_current_localstatedir" != "$guix_localstatedir"; then | ||
| 338 | case "$localstatedir" in | ||
| 339 | NONE|\${prefix}*) | ||
| 340 | # User kept the default value---i.e., did not pass '--localstatedir'. | ||
| 341 | AC_MSG_ERROR([chosen localstatedir '$guix_localstatedir' does not match \ | ||
| 342 | that of the existing installation '$guix_cv_current_localstatedir' | ||
| 343 | Installing may corrupt $storedir! | ||
| 344 | Use './configure --localstatedir=$guix_cv_current_localstatedir'.]) | ||
| 345 | ;; | ||
| 346 | *) | ||
| 347 | # User passed an explicit '--localstatedir'. Assume they know what | ||
| 348 | # they're doing. | ||
| 349 | AC_MSG_WARN([chosen localstatedir '$guix_localstatedir' does not match \ | ||
| 350 | that of the existing installation '$guix_cv_current_localstatedir']) | ||
| 351 | AC_MSG_WARN([installing may corrupt $storedir!]) | ||
| 352 | ;; | ||
| 353 | esac | ||
| 354 | fi | ||
| 355 | fi]) | ||
