Skip to content

Commit 895052d

Browse files
committed
lightningd: fix up installs in subdirectories.
Commit a1fdeee "Makefile: clean up install path handling." broke the ability to configure with one path and then run in a different path. Turns out people actually do this! So, we have to use relative paths, compared to our existing binary. And we can't use path_rel, because that requires that the path exist (thanks @Lagrang3!). Fixes: #7595 Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent 4e309dc commit 895052d

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ CPATH := /usr/local/include
252252
LIBRARY_PATH := /usr/local/lib
253253
endif
254254

255-
CPPFLAGS += -DCLN_NEXT_VERSION="\"$(CLN_NEXT_VERSION)\"" -DPKGLIBEXECDIR="\"$(pkglibexecdir)\"" -DPLUGINDIR="\"$(plugindir)\"" -DCCAN_TAL_NEVER_RETURN_NULL=1
255+
CPPFLAGS += -DCLN_NEXT_VERSION="\"$(CLN_NEXT_VERSION)\"" -DPKGLIBEXECDIR="\"$(pkglibexecdir)\"" -DBINDIR="\"$(bindir)\"" -DPLUGINDIR="\"$(plugindir)\"" -DCCAN_TAL_NEVER_RETURN_NULL=1
256256
CFLAGS = $(CPPFLAGS) $(CWARNFLAGS) $(CDEBUGFLAGS) $(COPTFLAGS) -I $(CCANDIR) $(EXTERNAL_INCLUDE_FLAGS) -I . -I$(CPATH) $(SQLITE3_CFLAGS) $(POSTGRES_INCLUDE) $(FEATURES) $(COVFLAGS) $(DEV_CFLAGS) -DSHACHAIN_BITS=48 -DJSMN_PARENT_LINKS $(PIE_CFLAGS) $(COMPAT_CFLAGS) $(CSANFLAGS)
257257

258258
# If CFLAGS is already set in the environment of make (to whatever value, it
@@ -886,7 +886,7 @@ uninstall:
886886
installcheck: all-programs
887887
@rm -rf testinstall || true
888888
$(MAKE) DESTDIR=$$(pwd)/testinstall install
889-
DEV_LIGHTNINGD_DESTDIR_PREFIX=$$(pwd)/testinstall/ testinstall$(bindir)/lightningd --test-daemons-only --lightning-dir=testinstall
889+
testinstall$(bindir)/lightningd --test-daemons-only --lightning-dir=testinstall
890890
$(MAKE) DESTDIR=$$(pwd)/testinstall uninstall
891891
@if test `find testinstall '!' -type d | wc -l` -ne 0; then \
892892
echo 'make uninstall left some files in testinstall directory!'; \

lightningd/lightningd.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ static const char *find_my_directory(const tal_t *ctx, const char *argv0)
534534
static void find_subdaemons_and_plugins(struct lightningd *ld, const char *argv0)
535535
{
536536
const char *my_path = find_my_directory(tmpctx, argv0);
537-
const char *prefix;
537+
const char *rel;
538538

539539
/* If we're running in-tree, all the subdaemons are with lightningd. */
540540
if (has_all_subdaemons(my_path)) {
@@ -547,14 +547,15 @@ static void find_subdaemons_and_plugins(struct lightningd *ld, const char *argv0
547547
return;
548548
}
549549

550-
/* Assume we're running the installed version. Override
551-
* for "make installccheck" though. */
552-
prefix = getenv("DEV_LIGHTNINGD_DESTDIR_PREFIX");
553-
if (!prefix)
554-
prefix = "";
555-
ld->subdaemon_dir = tal_fmt(ld, "%s%s", prefix, PKGLIBEXECDIR);
550+
/* OK, we're running the installed version? But we used to allow
551+
* running in an arbitrary subtree, and people still do (plus,
552+
* installcheck does this). So we use relative paths here. */
553+
rel = path_rel(NULL, BINDIR, PKGLIBEXECDIR);
554+
ld->subdaemon_dir = path_join(ld, my_path, take(rel));
555+
556+
rel = path_rel(NULL, BINDIR, PLUGINDIR);
556557
plugins_set_builtin_plugins_dir(ld->plugins,
557-
tal_fmt(tmpctx, "%s%s", prefix, PLUGINDIR));
558+
path_join(tmpctx, my_path, take(rel)));
558559
}
559560

560561
/*~ We like to free everything on exit, so valgrind doesn't complain (valgrind

0 commit comments

Comments
 (0)