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
This commit is contained in:
Slava Zanko 2009-05-21 01:01:10 +03:00
parent c6b42a7369
commit 0c17219b2a
18 changed files with 143 additions and 40 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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");
}

View File

@ -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)

View File

@ -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

View File

@ -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;
}

View File

@ -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);

View File

@ -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);

View File

@ -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

View File

@ -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);

View File

@ -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 =

View File

@ -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);
}
}
}

View File

@ -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);
}
}
}

View File

@ -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)

View File

@ -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);

View File

@ -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)