Browse Source

Move global config files from pkg_datadir to sysconfdir

 * Also fixed 'make dist' command
 * changed contrib/dist/redhat/mc.spec.in for builds with new dir
Slava Zanko 16 years ago
parent
commit
0c17219b2a
10 changed files with 84 additions and 22 deletions
  1. 4 2
      contrib/Makefile.am
  2. 13 1
      contrib/dist/redhat/mc.spec.in
  3. 2 1
      doc/Makefile.am
  4. 9 6
      edit/editcmd.c
  5. 9 0
      edit/syntax.c
  6. 16 6
      misc/Makefile.am
  7. 5 2
      src/Makefile.am
  8. 6 1
      src/charsets.c
  9. 16 3
      src/cmd.c
  10. 4 0
      src/ext.c

+ 4 - 2
contrib/Makefile.am

@@ -17,7 +17,9 @@ SCRIPTS_OUT = mc.csh mc.sh mc-wrapper.csh mc-wrapper.sh
 
 suppbin_SCRIPTS = $(SCRIPTS_OUT)
 
-pkgdata_DATA = $(LIBFILES_ADD)
+cfgdir = $(sysconfdir)/@PACKAGE@
+cfg_DATA = \
+	$(LIBFILES_ADD)
 
 CLEANFILES = $(SCRIPTS_OUT)
 
@@ -25,7 +27,7 @@ CLEANFILES = $(SCRIPTS_OUT)
 EXTRA_DIST = \
 	$(SCRIPTS_IN) \
 	$(noinst_DATA) \
-	mc.charsets
+	$(cfg_DATA)
 
 mc.csh: $(srcdir)/mc.csh.in
 	sed "s%@""suppbindir@%$(suppbindir)%" $(srcdir)/mc.csh.in > mc.csh

+ 13 - 1
contrib/dist/redhat/mc.spec.in

@@ -15,7 +15,7 @@
 Summary:   User-friendly text console file manager and visual shell
 Name:      mc
 Version:   %rpmver
-Release:   %rel%{?dist}
+Release:   %rel
 Epoch:     1
 License:   GPLv2
 Group:     System Environment/Shells
@@ -77,12 +77,24 @@ rm -rf $RPM_BUILD_ROOT
 
 %{_sysconfdir}/profile.d/*
 
+%config %{_sysconfdir}/mc/Syntax
+%config %{_sysconfdir}/mc/mc.charsets
+%config %{_sysconfdir}/mc/mc.lib
+%config(noreplace) %{_sysconfdir}/mc/*edit*
+%config(noreplace) %{_sysconfdir}/mc/mc.ext
+%config(noreplace) %{_sysconfdir}/mc/mc.menu
+%config(noreplace) %{_sysconfdir}/mc/extfs/extfs.ini
+%config(noreplace) %{_sysconfdir}/mc/extfs/sfs.ini
+
 %dir %{_datadir}/mc
 %{_datadir}/mc/*
 
 %dir %{_libexecdir}/mc
 
 %changelog
+* Thu May 21 2009 Slava Zanko <slavazanko@gmail.com>
+- Fix install patches: use %{_sysconfdir}/mc directory
+
 * Fri May 8 2009 Slava Zanko <slavazanko@gmail.com>
 - Review spec-file to build on the current distributions
 - Change build rules

+ 2 - 1
doc/Makefile.am

@@ -3,7 +3,8 @@ SUBDIRS = hints man $(DOC_LINGUAS)
 
 pkgdata_DATA = mc.hlp
 
-EXTRA_DIST = xnc.hlp $(DX_CONFIG) doxygen-include.am
+DOCS = FAQ HACKING INSTALL INSTALL.FAST MAINTAINERS
+EXTRA_DIST = xnc.hlp $(DX_CONFIG) doxygen-include.am $(pkgdata_DATA) $(DOCS)
 CLEANFILES = $(pkgdata_DATA)
 
 mc.hlp: man/mc.1 $(srcdir)/xnc.hlp $(top_builddir)/src/man2hlp

+ 9 - 6
edit/editcmd.c

@@ -1880,12 +1880,15 @@ edit_block_process_cmd (WEdit *edit, const char *shell_cmd, int block)
 	    goto edit_block_process_cmd__EXIT;
 	}
 	if (!(script_src = fopen (o, "r"))) {
-	    fclose (script_home);
-	    unlink (h);
-	    tmp = g_strconcat (_("Error reading script:"), o, (char *) NULL);
-	    edit_error_dialog ("", get_sys_error (tmp));
-	    g_free(tmp);
-	    goto edit_block_process_cmd__EXIT;
+	    o = g_strconcat (mc_home_alt, shell_cmd, (char *) NULL);
+	    if (!(script_src = fopen (o, "r"))) {
+		fclose (script_home);
+		unlink (h);
+		tmp = g_strconcat (_("Error reading script:"), o, (char *) NULL);
+		edit_error_dialog ("", get_sys_error (tmp));
+		g_free(tmp);
+		goto edit_block_process_cmd__EXIT;
+	    }
 	}
 	while (fgets (buf, sizeof (buf), script_src))
 	    fputs (buf, script_home);

+ 9 - 0
edit/syntax.c

@@ -685,6 +685,15 @@ static FILE *open_include_file (const char *filename)
     g_free (error_file_name);
     error_file_name = g_strconcat (mc_home, PATH_SEP_STR "syntax" PATH_SEP_STR,
 				   filename, (char *) NULL);
+
+    if ((f = fopen (error_file_name, "r"))) {
+	g_free (error_file_name);
+	return f;
+    }
+    g_free (error_file_name);
+    error_file_name = g_strconcat (mc_home_alt, PATH_SEP_STR "syntax" PATH_SEP_STR,
+				   filename, (char *) NULL);
+
     return fopen (error_file_name, "r");
 }
 

+ 16 - 6
misc/Makefile.am

@@ -1,21 +1,31 @@
 ## Process this file with automake to create Makefile.in.
 
-
 LIBFILES_OUT = mc.ext
 
-LIBFILES_CONST =  mc.lib mc.menu mc.menu.sr cedit.menu edit.indent.rc	\
-	edit.spell.rc
-
 noinst_DATA = xterm.ad
 
+pkgdata_DATA = mc.menu.sr
+
+LIBFILES_CONST = \
+	cedit.menu      \
+	edit.indent.rc \
+	edit.spell.rc \
+	mc.lib \
+	mc.menu
 
-pkgdata_DATA = $(LIBFILES_CONST) $(LIBFILES_ADD) $(LIBFILES_OUT)
 
 CLEANFILES = $(SCRIPTS_OUT)
 
+cfgdir = $(sysconfdir)/@PACKAGE@
+cfg_DATA = \
+	$(LIBFILES_CONST) \
+	$(LIBFILES_OUT) \
+	$(LIBFILES_ADD)
+
 # Files processed by configure don't need to be here
 EXTRA_DIST = \
 	$(LIBFILES_CONST) \
 	$(SCRIPTS_IN) \
-	$(noinst_DATA)
+	$(noinst_DATA) \
+	$(pkgdata_DATA)
 

+ 5 - 2
src/Makefile.am

@@ -10,9 +10,12 @@ bin_PROGRAMS = mc mcmfmt
 if CONS_SAVER
 pkglibexec_PROGRAMS = cons.saver
 AM_CPPFLAGS = -DDATADIR=\""$(pkgdatadir)/"\" -DLOCALEDIR=\""$(localedir)"\" \
-	-DSAVERDIR=\""$(pkglibexecdir)"\"
+	-DSAVERDIR=\""$(pkglibexecdir)"\" \
+	-DSYSCONFDIR=\""$(sysconfdir)/@PACKAGE@/"\"
 else
-AM_CPPFLAGS = -DDATADIR=\""$(pkgdatadir)/"\" -DLOCALEDIR=\""$(localedir)"\"
+AM_CPPFLAGS = -DDATADIR=\""$(pkgdatadir)/"\" \
+	-DLOCALEDIR=\""$(localedir)"\" \
+	-DSYSCONFDIR=\""$(sysconfdir)/@PACKAGE@/"\"
 endif
 
 noinst_PROGRAMS = man2hlp

+ 6 - 1
src/charsets.c

@@ -53,12 +53,17 @@ load_codepages_list (void)
     char *fname;
     char buf[256];
     extern char *mc_home;
+    extern char *mc_home_alt;
     extern int display_codepage;
     char *default_codepage = NULL;
 
     fname = concat_dir_and_file (mc_home, CHARSETS_INDEX);
     if (!(f = fopen (fname, "r"))) {
-	fprintf (stderr, _("Warning: file %s not found\n"), fname);
+	g_free (fname);
+	fname = concat_dir_and_file (mc_home_alt, CHARSETS_INDEX);
+	if (!(f = fopen (fname, "r"))) {
+	    fprintf (stderr, _("Warning: file %s not found\n"), fname);
+	}
 	g_free (fname);
 	return -1;
     }

+ 16 - 3
src/cmd.c

@@ -589,9 +589,13 @@ void ext_cmd (void)
 	check_for_default (extdir, buffer);
 	do_edit (buffer);
 	g_free (buffer);
-    } else if (dir == 1)
+    } else if (dir == 1) {
+	if (!exist_file(extdir)) {
+	    g_free (extdir);
+	    extdir = concat_dir_and_file (mc_home_alt, MC_LIB_EXT);
+	}
 	do_edit (extdir);
-
+    }
    g_free (extdir);
    flush_extension_file ();
 }
@@ -614,6 +618,11 @@ menu_edit_cmd (int where)
 
     menufile = concat_dir_and_file (mc_home, where ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU);
 
+    if (!exist_file(menufile)) {
+	g_free (menufile);
+	menufile = concat_dir_and_file (mc_home_alt, where ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU);
+    }
+
     switch (dir) {
 	case 0:
 	    buffer = g_strdup (where ? CEDIT_LOCAL_MENU : MC_LOCAL_MENU);
@@ -627,6 +636,10 @@ menu_edit_cmd (int where)
 	
 	case 2:
 	    buffer = concat_dir_and_file (mc_home, where ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU);
+	    if (!exist_file(buffer)) {
+		g_free (buffer);
+		buffer = concat_dir_and_file (mc_home_alt, where ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU);
+	    }
 	    break;
 
 	default:
@@ -685,7 +698,7 @@ edit_syntax_cmd (void)
 			  _(" Which syntax file you want to edit? "), D_NORMAL, 2,
 			  _("&User"), _("&System Wide"));
     }
-    extdir = concat_dir_and_file (mc_home, "syntax" PATH_SEP_STR "Syntax");
+    extdir = concat_dir_and_file (mc_home_alt, "syntax" PATH_SEP_STR "Syntax");
 
     if (dir == 0) {
 	buffer = concat_dir_and_file (home_dir, SYNTAX_FILE);

+ 4 - 0
src/ext.c

@@ -453,6 +453,10 @@ regex_command (const char *filename, const char *action, int *move_dir)
 	    g_free (extension_file);
 	  check_stock_mc_ext:
 	    extension_file = concat_dir_and_file (mc_home, MC_LIB_EXT);
+	    if (!exist_file (extension_file)) {
+		g_free (extension_file);
+		extension_file = concat_dir_and_file (mc_home_alt, MC_LIB_EXT);
+	    }
 	    mc_user_ext = 0;
 	}
 	data = load_file (extension_file);

Some files were not shown because too many files changed in this diff