Description
For my use I'm patching TWIN to place the system config files in /etc/twin
as opposed to /usr/lib/twin
. This seems more *NIX-like to me. I also moved the personal config files to ~/.config/twin
. I suppose that's just personal taste. I'd like my home folder to be less messy. :-D I have tried to make this patch work with your auto*
stuff. But since I don't use these tools, and rather dislike them, I have likely done it wrong.
Here's my patch:
diff --git a/Makefile.in b/Makefile.in
index f9f7ca4..82cc764 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -411,7 +411,7 @@ sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
sys_symbol_underscore = @sys_symbol_underscore@
-sysconfdir = @sysconfdir@
+sysconfdir = @sysconfdir@/twin
target_alias = @target_alias@
top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
@@ -458,10 +458,10 @@ $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
$(am__aclocal_m4_deps):
install-pkglibexecSCRIPTS: $(pkglibexec_SCRIPTS)
@$(NORMAL_INSTALL)
- @list='$(pkglibexec_SCRIPTS)'; test -n "$(pkglibexecdir)" || list=; \
+ @list='$(pkglibexec_SCRIPTS)'; test -n "$(sysconfdir)" || list=; \
if test -n "$$list"; then \
- echo " $(MKDIR_P) '$(DESTDIR)$(pkglibexecdir)'"; \
- $(MKDIR_P) "$(DESTDIR)$(pkglibexecdir)" || exit 1; \
+ echo " $(MKDIR_P) '$(DESTDIR)$(sysconfdir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(sysconfdir)" || exit 1; \
fi; \
for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
@@ -480,17 +480,17 @@ install-pkglibexecSCRIPTS: $(pkglibexec_SCRIPTS)
while read type dir files; do \
if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
test -z "$$files" || { \
- echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(pkglibexecdir)$$dir'"; \
- $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(pkglibexecdir)$$dir" || exit $$?; \
+ echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(sysconfdir)$$dir'"; \
+ $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(sysconfdir)$$dir" || exit $$?; \
} \
; done
uninstall-pkglibexecSCRIPTS:
@$(NORMAL_UNINSTALL)
- @list='$(pkglibexec_SCRIPTS)'; test -n "$(pkglibexecdir)" || exit 0; \
+ @list='$(pkglibexec_SCRIPTS)'; test -n "$(sysconfdir)" || exit 0; \
files=`for p in $$list; do echo "$$p"; done | \
sed -e 's,.*/,,;$(transform)'`; \
- dir='$(DESTDIR)$(pkglibexecdir)'; $(am__uninstall_files_from_dir)
+ dir='$(DESTDIR)$(sysconfdir)'; $(am__uninstall_files_from_dir)
mostlyclean-libtool:
-rm -f *.lo
diff --git a/server/Makefile.am b/server/Makefile.am
index 479bbc6..7a90cfc 100644
--- a/server/Makefile.am
+++ b/server/Makefile.am
@@ -14,7 +14,7 @@ if LIBTERM_la
pkglib_LTLIBRARIES += libterm.la
endif
-AM_CPPFLAGS = -I$(top_srcdir)/include $(LTDLINCL) -DPKG_LIBDIR="\"$(pkglibdir)\""
+AM_CPPFLAGS = -I$(top_srcdir)/include $(LTDLINCL) -DPKG_LIBDIR="\"$(pkglibdir)\"" -DPKG_CONFDIR="\"$(sysconfdir)\""
twin_CPPFLAGS = -I$(top_srcdir)/include $(LTDLINCL) -DBINDIR="\"$(bindir)\""
twdisplay_SOURCES = alloc.cpp display.cpp dl_helper.cpp missing.cpp hw.cpp
diff --git a/server/Makefile.in b/server/Makefile.in
index 32e5cb9..c21511d 100644
--- a/server/Makefile.in
+++ b/server/Makefile.in
@@ -526,7 +526,7 @@ top_srcdir = @top_srcdir@
SUBDIRS = hw
bin_SCRIPTS = twstart
pkglib_LTLIBRARIES = $(am__append_1) $(am__append_2) $(am__append_3)
-AM_CPPFLAGS = -I$(top_srcdir)/include $(LTDLINCL) -DPKG_LIBDIR="\"$(pkglibdir)\""
+AM_CPPFLAGS = -I$(top_srcdir)/include $(LTDLINCL) -DPKG_LIBDIR="\"$(pkglibdir)\"" -DPKG_CONFDIR="\"$(sysconfdir)\""
twin_CPPFLAGS = -I$(top_srcdir)/include $(LTDLINCL) -DBINDIR="\"$(bindir)\""
twdisplay_SOURCES = alloc.cpp display.cpp dl_helper.cpp missing.cpp hw.cpp
twin_SOURCES = wrapper.c
diff --git a/server/data.cpp b/server/data.cpp
index 920a73c..0bfa920 100644
--- a/server/data.cpp
+++ b/server/data.cpp
@@ -29,6 +29,14 @@
const char *pkg_libdir = PKG_LIBDIR;
+/* TODO: replace with autoconf var */
+#ifndef PKG_CONFDIR
+#warning PKG_CONFDIR is not #defined, assuming "/usr/local/etc"
+#define PKG_CONFDIR "/usr/local/etc"
+#endif
+
+const char *pkg_confdir = PKG_CONFDIR "/twin";
+
/* First, some structures */
#define L 0x55
diff --git a/server/data.h b/server/data.h
index 0cda065..a092452 100644
--- a/server/data.h
+++ b/server/data.h
@@ -17,6 +17,7 @@ typedef struct s_rgb {
} rgb;
extern const char *pkg_libdir;
+extern const char *pkg_confdir;
extern rgb Palette[tmaxcol + 1], defaultPalette[tmaxcol + 1];
diff --git a/server/rcparse.h b/server/rcparse.h
index 2bdd991..5ef7656 100644
--- a/server/rcparse.h
+++ b/server/rcparse.h
@@ -1421,7 +1421,7 @@ static byte rcload(void) {
#endif
byte c = tfalse;
- if (!(path = FindFile(".twinrc", &len)))
+ if (!(path = FindFile("twinrc", &len)))
return c;
/*
diff --git a/server/util.cpp b/server/util.cpp
index 15ed6e3..015900b 100644
--- a/server/util.cpp
+++ b/server/util.cpp
@@ -1104,10 +1104,10 @@ byte SetServerUid(uldat uid, byte privileges) {
}
/*
- * search for a file relative to HOME, to PKG_LIBDIR or as path
+ * search for a file relative to HOME, to PKG_CONFDIR or as path
*
* this for example will search "foo"
- * as "${HOME}/foo", "${PKG_LIBDIR}/system.foo" or plain "foo"
+ * as "${HOME}/.foo", "${PKG_CONFDIR}/foo" or plain "foo"
*/
char *FindFile(const char *name, uldat *fsize) {
const char *prefix[3], *infix[3];
@@ -1117,14 +1117,14 @@ char *FindFile(const char *name, uldat *fsize) {
struct stat buf;
prefix[0] = HOME;
- infix[0] = (HOME && *HOME) ? "/" : "";
- prefix[1] = pkg_libdir;
- infix[1] = "/system";
+ infix[0] = (HOME && *HOME) ? "/.config/twin/" : ".";
+ prefix[1] = pkg_confdir;
+ infix[1] = "/system.";
prefix[2] = "";
infix[2] = "";
if (flag_secure)
- min_i = max_i = 1; /* only pkg_libdir */
+ min_i = max_i = 1; /* only pkg_confdir */
else
min_i = 0, max_i = 2;
@@ -1199,7 +1199,7 @@ void RunTwEnvRC(void) {
if (flag_secure == 0) {
flag_envrc = 0;
- if ((path = FindFile(".twenvrc.sh", &len))) {
+ if ((path = FindFile("twenvrc.sh", &len))) {
if ((pipe(fds) >= 0)) {
switch (fork()) {
case -1: /* error */
With this patch you could place the config files in the "lib" directory with a configure command like:
./configure --prefix=/usr --sysconfdir=/usr/lib
But people I share this with always go, "Huh?!?!", when I tell them where to find the system-wide config files. And I'm fairly certain that Debian packaging politics (policy) demands they be placed in /etc
. I'm sure other distros are just as opinionated.
I can't say I've tested the uninstall since *NO* program gets installed on my system without being placed in a .deb first. So if I uninstall it I let dpkg
do the clean up. Hence, I never run make uninstall
.