Merge branch '130_sysconfdir_mc'

* 130_sysconfdir_mc:
  scripts mc.sh, mc.csh, mc-wrapper.csh and mc-wrapper.sh now install into %{libexec}/mc directory
  edit/syntax.c: fixed path to Syntax file
  Move global config files from pkg_datadir to sysconfdir
This commit is contained in:
Slava Zanko 2009-05-22 15:44:28 +03:00
commit 28539b2363
20 changed files with 151 additions and 49 deletions

View File

@ -2,8 +2,6 @@
SUBDIRS = dist
suppbindir = $(pkgdatadir)/bin
if CHARSET
LIBFILES_ADD = mc.charsets
else
@ -15,9 +13,12 @@ noinst_DATA = README.xterm mcserv.init mcserv.pamd
SCRIPTS_IN = mc.csh.in mc.sh.in mc-wrapper.csh.in mc-wrapper.sh.in
SCRIPTS_OUT = mc.csh mc.sh mc-wrapper.csh mc-wrapper.sh
suppbin_SCRIPTS = $(SCRIPTS_OUT)
pkglibexec_SCRIPTS = $(SCRIPTS_OUT)
pkglibexecdir = $(libexecdir)/@PACKAGE@
pkgdata_DATA = $(LIBFILES_ADD)
cfgdir = $(sysconfdir)/@PACKAGE@
cfg_DATA = \
$(LIBFILES_ADD)
CLEANFILES = $(SCRIPTS_OUT)
@ -25,13 +26,13 @@ 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
sed "s%@""pkglibexecdir@%$(pkglibexecdir)%" $(srcdir)/mc.csh.in > mc.csh
mc.sh: $(srcdir)/mc.sh.in
sed "s%@""suppbindir@%$(suppbindir)%" $(srcdir)/mc.sh.in > mc.sh
sed "s%@""pkglibexecdir@%$(pkglibexecdir)%" $(srcdir)/mc.sh.in > mc.sh
mc-wrapper.csh: $(srcdir)/mc-wrapper.csh.in
sed "s%@""bindir@%$(bindir)%" $(srcdir)/mc-wrapper.csh.in > mc-wrapper.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

@ -1 +1 @@
alias mc 'source @suppbindir@/mc-wrapper.csh'
alias mc 'source @pkglibexecdir@/mc-wrapper.csh'

View File

@ -1,3 +1,3 @@
# Don't define aliases in plain Bourne shell
[ -n "${BASH_VERSION}${KSH_VERSION}${ZSH_VERSION}" ] || return 0
alias mc='. @suppbindir@/mc-wrapper.sh'
alias mc='. @pkglibexecdir@/mc-wrapper.sh'

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

@ -683,8 +683,17 @@ static FILE *open_include_file (const char *filename)
return f;
g_free (error_file_name);
error_file_name = g_strconcat (mc_home, PATH_SEP_STR "syntax" PATH_SEP_STR,
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");
}
@ -1028,7 +1037,7 @@ edit_read_syntax_file (WEdit * edit, char ***pnames, const char *syntax_file,
f = fopen (syntax_file, "r");
if (!f){
lib_file = concat_dir_and_file (mc_home, "syntax" PATH_SEP_STR "Syntax");
lib_file = concat_dir_and_file (mc_home, "Syntax");
f = fopen (lib_file, "r");
g_free (lib_file);
if (!f)

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)