From 0c17219b2ab5cb5fe2e73f8d7cc9c11c755a3ae4 Mon Sep 17 00:00:00 2001 From: Slava Zanko Date: Thu, 21 May 2009 01:01:10 +0300 Subject: [PATCH] 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 --- contrib/Makefile.am | 6 ++++-- contrib/dist/redhat/mc.spec.in | 14 +++++++++++++- doc/Makefile.am | 3 ++- edit/editcmd.c | 15 +++++++++------ edit/syntax.c | 9 +++++++++ misc/Makefile.am | 22 ++++++++++++++++------ src/Makefile.am | 7 +++++-- src/charsets.c | 7 ++++++- src/cmd.c | 19 ++++++++++++++++--- src/ext.c | 4 ++++ src/main.c | 11 ++++++++--- src/main.h | 1 + src/setup.c | 14 +++++++++++++- src/user.c | 5 +++++ src/util.c | 20 ++++++++++++++------ syntax/Makefile.am | 9 +++++++-- vfs/extfs.c | 8 ++++---- vfs/extfs/Makefile.am | 9 +++++++-- 18 files changed, 143 insertions(+), 40 deletions(-) diff --git a/contrib/Makefile.am b/contrib/Makefile.am index a4dff7353..1fb63dfe0 100644 --- a/contrib/Makefile.am +++ b/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 diff --git a/contrib/dist/redhat/mc.spec.in b/contrib/dist/redhat/mc.spec.in index b53a26b62..9fd471267 100644 --- a/contrib/dist/redhat/mc.spec.in +++ b/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 +- Fix install patches: use %{_sysconfdir}/mc directory + * Fri May 8 2009 Slava Zanko - Review spec-file to build on the current distributions - Change build rules diff --git a/doc/Makefile.am b/doc/Makefile.am index d2abcfd1f..cacc72803 100644 --- a/doc/Makefile.am +++ b/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 diff --git a/edit/editcmd.c b/edit/editcmd.c index e72f88c9d..42e38ef83 100644 --- a/edit/editcmd.c +++ b/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); diff --git a/edit/syntax.c b/edit/syntax.c index 302b0bf3f..3dc28022e 100644 --- a/edit/syntax.c +++ b/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"); } diff --git a/misc/Makefile.am b/misc/Makefile.am index c177c52e3..19ab73171 100644 --- a/misc/Makefile.am +++ b/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) diff --git a/src/Makefile.am b/src/Makefile.am index d4738c7fa..d2fcca84c 100644 --- a/src/Makefile.am +++ b/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 diff --git a/src/charsets.c b/src/charsets.c index 6da9c26e1..3e7d43497 100644 --- a/src/charsets.c +++ b/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; } diff --git a/src/cmd.c b/src/cmd.c index e24b0ba92..b6f79304f 100644 --- a/src/cmd.c +++ b/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); diff --git a/src/ext.c b/src/ext.c index 7c0152aa7..ea796a413 100644 --- a/src/ext.c +++ b/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); diff --git a/src/main.c b/src/main.c index e2c6d6c21..c40a37241 100644 --- a/src/main.c +++ b/src/main.c @@ -287,9 +287,12 @@ int midnight_shutdown = 0; /* The user's shell */ const char *shell = NULL; -/* mc_home: The home of MC */ +/* mc_home: The home of MC - /etc/mc or defined by MC_DATADIR */ char *mc_home = NULL; +/* mc_home_alt: Alternative home of MC - deprecated /usr/share/mc */ +char *mc_home_alt = NULL; + char cmd_buf[512]; #ifdef USE_INTERNAL_EDIT @@ -1806,8 +1809,9 @@ OS_Setup (void) if ((mc_libdir = getenv ("MC_DATADIR")) != NULL) { mc_home = g_strdup (mc_libdir); } else { - mc_home = g_strdup (DATADIR); + mc_home = g_strdup (SYSCONFDIR); } + mc_home_alt = mc_libdir != NULL ? g_strdup (SYSCONFDIR) : g_strdup (DATADIR); } static void @@ -1940,7 +1944,7 @@ process_args (poptContext ctx, int c, const char *option_arg) break; case 'f': - printf ("%s\n", mc_home); + printf ("%s (%s)\n", mc_home, mc_home_alt); exit (0); break; @@ -2300,6 +2304,7 @@ main (int argc, char *argv[]) } g_free (last_wd_string); + g_free (mc_home_alt); g_free (mc_home); done_key (); #ifdef HAVE_CHARSET diff --git a/src/main.h b/src/main.h index 1c3edbe06..4fd9ff535 100644 --- a/src/main.h +++ b/src/main.h @@ -127,6 +127,7 @@ void print_vfs_message(const char *msg, ...) extern const char *prompt; extern const char *edit_one_file; extern char *mc_home; +extern char *mc_home_alt; char *get_mc_lib_dir (void); int maybe_cd (int move_up_dir); diff --git a/src/setup.c b/src/setup.c index 635928109..1033e9055 100644 --- a/src/setup.c +++ b/src/setup.c @@ -500,8 +500,15 @@ setup_init (void) if (exist_file (inifile)){ g_free (profile); profile = inifile; - } else + } else { g_free (inifile); + inifile = concat_dir_and_file (mc_home_alt, "mc.ini"); + if (exist_file (inifile)) { + g_free (profile); + profile = inifile; + } else + g_free (inifile); + } } profile_name = profile; @@ -521,6 +528,11 @@ load_setup (void) ~/.mc/ini. FIXME: it's only used for keys and treestore now */ global_profile_name = concat_dir_and_file (mc_home, "mc.lib"); + if (!exist_file(global_profile_name)) { + g_free (global_profile_name); + global_profile_name = concat_dir_and_file (mc_home_alt, "mc.lib"); + } + /* Load integer boolean options */ for (i = 0; int_options[i].opt_name; i++) *int_options[i].opt_addr = diff --git a/src/user.c b/src/user.c index 03ff8605d..6dec06802 100644 --- a/src/user.c +++ b/src/user.c @@ -739,6 +739,11 @@ user_menu_cmd (struct WEdit *edit_widget) g_free (menu); menu = concat_dir_and_file \ (mc_home, edit_widget ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU); + if (!exist_file (menu)) { + g_free (menu); + menu = concat_dir_and_file \ + (mc_home_alt, edit_widget ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU); + } } } diff --git a/src/util.c b/src/util.c index 5195a246d..6196816f2 100644 --- a/src/util.c +++ b/src/util.c @@ -575,16 +575,24 @@ load_mc_home_file (const char *filename, char **allocated_filename) if (!data) { g_free (hintfile); - /* Fall back to the two-letter language code */ - if (lang[0] && lang[1]) - lang[2] = 0; + g_free (hintfile_base); + hintfile_base = concat_dir_and_file (mc_home_alt, filename); + hintfile = g_strconcat (hintfile_base, ".", lang, (char *) NULL); data = load_file (hintfile); if (!data) { - g_free (hintfile); - hintfile = hintfile_base; - data = load_file (hintfile_base); + /* Fall back to the two-letter language code */ + if (lang[0] && lang[1]) + lang[2] = 0; + hintfile = g_strconcat (hintfile_base, ".", lang, (char *) NULL); + data = load_file (hintfile); + + if (!data) { + g_free (hintfile); + hintfile = hintfile_base; + data = load_file (hintfile_base); + } } } diff --git a/syntax/Makefile.am b/syntax/Makefile.am index 258576038..09d68d420 100644 --- a/syntax/Makefile.am +++ b/syntax/Makefile.am @@ -1,5 +1,4 @@ SYNTAXFILES = \ - Syntax \ ada95.syntax \ awk.syntax \ aspx.syntax \ @@ -57,9 +56,15 @@ SYNTAXFILES = \ unknown.syntax \ xml.syntax +SYNTAXCONFFILES = \ + Syntax + if USE_EDIT syntaxdir = $(pkgdatadir)/syntax syntax_DATA = $(SYNTAXFILES) + +syntaxconfdir = $(sysconfdir)/@PACKAGE@ +syntaxconf_DATA = $(SYNTAXCONFFILES) endif -EXTRA_DIST = $(SYNTAXFILES) +EXTRA_DIST = $(SYNTAXFILES) $(SYNTAXCONFFILES) diff --git a/vfs/extfs.c b/vfs/extfs.c index b3650360b..7d06ac62c 100644 --- a/vfs/extfs.c +++ b/vfs/extfs.c @@ -1,6 +1,6 @@ /* Virtual File System: External file system. Copyright (C) 1995, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, - 2006, 2007 Free Software Foundation, Inc. + 2006, 2007, 2009 Free Software Foundation, Inc. Written by: 1995 Jakub Jelinek Rewritten by: 1998 Pavel Machek @@ -256,7 +256,7 @@ extfs_open_archive (int fstype, const char *name, struct archive **pparc) tmp = name_quote (name, 0); } - mc_extfsdir = concat_dir_and_file (mc_home, "extfs" PATH_SEP_STR); + mc_extfsdir = concat_dir_and_file (mc_home_alt, "extfs" PATH_SEP_STR); cmd = g_strconcat (mc_extfsdir, extfs_prefixes[fstype], " list ", local_name ? local_name : tmp, (char *) NULL); @@ -631,7 +631,7 @@ extfs_cmd (const char *extfs_cmd, struct archive *archive, archive_name = name_quote (extfs_get_archive_name (archive), 0); quoted_localname = name_quote (localname, 0); - mc_extfsdir = concat_dir_and_file (mc_home, "extfs" PATH_SEP_STR); + mc_extfsdir = concat_dir_and_file (mc_home_alt, "extfs" PATH_SEP_STR); cmd = g_strconcat (mc_extfsdir, extfs_prefixes[archive->fstype], extfs_cmd, archive_name, " ", quoted_file, " ", quoted_localname, (char *) NULL); @@ -660,7 +660,7 @@ extfs_run (struct vfs_class *me, const char *file) g_free (p); archive_name = name_quote (extfs_get_archive_name (archive), 0); - mc_extfsdir = concat_dir_and_file (mc_home, "extfs" PATH_SEP_STR); + mc_extfsdir = concat_dir_and_file (mc_home_alt, "extfs" PATH_SEP_STR); cmd = g_strconcat (mc_extfsdir, extfs_prefixes[archive->fstype], " run ", archive_name, " ", q, (char *) NULL); g_free (mc_extfsdir); diff --git a/vfs/extfs/Makefile.am b/vfs/extfs/Makefile.am index ab88d928d..48253f325 100644 --- a/vfs/extfs/Makefile.am +++ b/vfs/extfs/Makefile.am @@ -1,7 +1,9 @@ extfsdir = $(pkgdatadir)/extfs +EXTFSCONFFILES = extfs.ini sfs.ini + # Files to install and distribute other than extfs scripts -EXTFS_MISC = README extfs.ini sfs.ini +EXTFS_MISC = README # Scripts hat don't need adaptation to the local system EXTFS_CONST = bpp rpm trpm srpm u7z @@ -63,7 +65,10 @@ EXTFS_OUT = \ if USE_VFS extfs_DATA = $(EXTFS_MISC) extfs_SCRIPTS = $(EXTFS_CONST) $(EXTFS_OUT) + +extfsconfdir = $(sysconfdir)/@PACKAGE@/extfs +extfsconf_DATA = $(EXTFSCONFFILES) endif -EXTRA_DIST = $(EXTFS_MISC) $(EXTFS_CONST) +EXTRA_DIST = $(EXTFS_MISC) $(EXTFS_CONST) $(EXTFSCONFFILES)