From e357f6cc0273fec606faeaf50f2186ebd9a089f1 Mon Sep 17 00:00:00 2001 From: Omega Weapon Date: Sun, 10 Nov 2013 17:36:59 +0000 Subject: [PATCH 1/2] Honour GNU standard sysconfdir variable when installing udevil.conf --- etc/Makefile.am | 16 ++++++++++------ etc/Makefile.in | 16 ++++++++++------ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/etc/Makefile.am b/etc/Makefile.am index 886c665..906f6e9 100644 --- a/etc/Makefile.am +++ b/etc/Makefile.am @@ -5,13 +5,17 @@ EXTRA_DIST = udevil.conf endif install-data-hook: - test -d $(DESTDIR)/etc/udevil || mkdir -p -- $(DESTDIR)/etc/udevil - test -f $(DESTDIR)/etc/udevil/udevil.conf || $(INSTALL_DATA) \ - $(srcdir)/udevil.conf $(DESTDIR)/etc/udevil/udevil.conf + test -d $(DESTDIR)$(sysconfdir)/udevil || mkdir -p -- \ + $(DESTDIR)$(sysconfdir)/udevil + test -f $(DESTDIR)$(sysconfdir)/udevil/udevil.conf || $(INSTALL_DATA) \ + $(srcdir)/udevil.conf \ + $(DESTDIR)$(sysconfdir)/udevil/udevil.conf if ADD_SYSTEMD - test -d $(DESTDIR)/etc/conf.d || mkdir -p -- $(DESTDIR)/etc/conf.d - test -f $(DESTDIR)/etc/conf.d/devmon || $(INSTALL_DATA) \ - $(srcdir)/systemd/devmon $(DESTDIR)/etc/conf.d/devmon + test -d $(DESTDIR)$(sysconfdir)/conf.d || mkdir -p -- \ + $(DESTDIR)$(sysconfdir)/conf.d + test -f $(DESTDIR)$(sysconfdir)/conf.d/devmon || $(INSTALL_DATA) \ + $(srcdir)/systemd/devmon \ + $(DESTDIR)$(sysconfdir)/conf.d/devmon test -d $(DESTDIR)/$(libdir)/systemd/system || \ mkdir -p -- $(DESTDIR)/$(libdir)/systemd/system $(INSTALL_DATA) $(srcdir)/systemd/devmon@.service \ diff --git a/etc/Makefile.in b/etc/Makefile.in index 7a56068..4fda560 100644 --- a/etc/Makefile.in +++ b/etc/Makefile.in @@ -457,12 +457,16 @@ uninstall-am: install-data-hook: - test -d $(DESTDIR)/etc/udevil || mkdir -p -- $(DESTDIR)/etc/udevil - test -f $(DESTDIR)/etc/udevil/udevil.conf || $(INSTALL_DATA) \ - $(srcdir)/udevil.conf $(DESTDIR)/etc/udevil/udevil.conf -@ADD_SYSTEMD_TRUE@ test -d $(DESTDIR)/etc/conf.d || mkdir -p -- $(DESTDIR)/etc/conf.d -@ADD_SYSTEMD_TRUE@ test -f $(DESTDIR)/etc/conf.d/devmon || $(INSTALL_DATA) \ -@ADD_SYSTEMD_TRUE@ $(srcdir)/systemd/devmon $(DESTDIR)/etc/conf.d/devmon + test -d $(DESTDIR)$(sysconfdir)/udevil || mkdir -p -- \ + $(DESTDIR)$(sysconfdir)/udevil + test -f $(DESTDIR)$(sysconfdir)/udevil/udevil.conf || $(INSTALL_DATA) \ + $(srcdir)/udevil.conf \ + $(DESTDIR)$(sysconfdir)/udevil/udevil.conf +@ADD_SYSTEMD_TRUE@ test -d $(DESTDIR)$(sysconfdir)/conf.d || mkdir -p -- \ +@ADD_SYSTEMD_TRUE@ $(DESTDIR)$(sysconfdir)/conf.d +@ADD_SYSTEMD_TRUE@ test -f $(DESTDIR)$(sysconfdir)/conf.d/devmon || $(INSTALL_DATA) \ +@ADD_SYSTEMD_TRUE@ $(srcdir)/systemd/devmon \ +@ADD_SYSTEMD_TRUE@ $(DESTDIR)$(sysconfdir)/conf.d/devmon @ADD_SYSTEMD_TRUE@ test -d $(DESTDIR)/$(libdir)/systemd/system || \ @ADD_SYSTEMD_TRUE@ mkdir -p -- $(DESTDIR)/$(libdir)/systemd/system @ADD_SYSTEMD_TRUE@ $(INSTALL_DATA) $(srcdir)/systemd/devmon@.service \ From 04ab5b682ae4cbd9c30b302c769d699d669e889e Mon Sep 17 00:00:00 2001 From: Omega Weapon Date: Sun, 10 Nov 2013 19:55:33 +0000 Subject: [PATCH 2/2] Communicate SYSCONFDIR to udevil and have it look up the config there, along with referencing the correct path in text --- src/Makefile.am | 3 ++- src/Makefile.in | 4 +++- src/udevil.c | 13 ++++++++----- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index d9074f7..cd5871e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,4 +1,5 @@ -INCLUDES = -DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" +INCLUDES = -DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \ + -DSYSCONFDIR=\""$(sysconfdir)"\" noinst_PROGRAMS = udevil diff --git a/src/Makefile.in b/src/Makefile.in index 4ed3537..df57b37 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -346,7 +346,9 @@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ -INCLUDES = -DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" +INCLUDES = -DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \ + -DSYSCONFDIR=\""$(sysconfdir)"\" + udevil_SOURCES = udevil.c device-info.c canonicalize.c bin_SCRIPTS = devmon INSTALL_DIR = $(DESTDIR)/$(prefix)/bin diff --git a/src/udevil.c b/src/udevil.c index f96a254..76a77a6 100644 --- a/src/udevil.c +++ b/src/udevil.c @@ -784,12 +784,12 @@ static char* parse_config() char* str; char* msg = NULL; - conf_path = g_strdup_printf( "/etc/udevil/udevil-user-%s.conf", g_get_user_name() ); + conf_path = g_strdup_printf( "%s/udevil/udevil-user-%s.conf", SYSCONFDIR, g_get_user_name() ); file = fopen( conf_path, "r" ); if ( !file ) { g_free( conf_path ); - conf_path = g_strdup_printf( "/etc/udevil/udevil.conf" ); + conf_path = g_strdup_printf( SYSCONFDIR "/udevil/udevil.conf" ); file = fopen( conf_path, "r" ); } drop_privileges( 0 ); // file is open now so drop priv @@ -900,7 +900,7 @@ static char* parse_config() } else { - msg = g_strdup_printf( _("udevil: warning 7: /etc/udevil/udevil.conf could not be read\n") ); + msg = g_strdup_printf( _("udevil: warning 7: %s/udevil/udevil.conf could not be read\n"), SYSCONFDIR ); g_free( conf_path ); conf_path = NULL; } @@ -4900,7 +4900,8 @@ static void show_help() printf( _("HELP - Show this help\n") ); printf( " udevil help|--help|-h\n" ); printf( "\n" ); - printf( "http://ignorantguru.github.com/udevil/ %s\n", _("See /etc/udevil/udevil.conf for config.") ); + printf( "http://ignorantguru.github.com/udevil/ " ); + printf( _("See %s/udevil/udevil.conf for config.\n"), SYSCONFDIR ); printf( _("For automounting with udevil run 'devmon --help'\n") ); printf( "\n" ); @@ -4997,8 +4998,10 @@ printf("\n-----------------------\n"); wlog( str, NULL, 0 ); g_free( str ); } + + // Configuration file path left out as it is dependent on SYSCONFDIR if ( config_msg && strcmp( config_msg, - _("udevil: read config /etc/udevil/udevil.conf\n") ) ) + _("udevil: read config ") ) ) // this only works for english wlog( config_msg, NULL, strstr( config_msg, "warning:" ) ? 1 : 0 ); g_free( config_msg );