Ticket #130: global-config-into-sysconfdir-rev1.patch

File global-config-into-sysconfdir-rev1.patch, 13.2 KB (added by slavazanko, 15 years ago)

move global configs into ${sysconfdir}

  • edit/editcmd.c

    diff --git a/edit/editcmd.c b/edit/editcmd.c
    index 01262f1..4bb0ef6 100644
    a b  
    5050#include "../src/tty.h"         /* LINES */ 
    5151#include "../src/widget.h"      /* listbox_new() */ 
    5252#include "../src/layout.h"      /* clr_scr() */ 
    53 #include "../src/main.h"        /* mc_home */ 
     53#include "../src/main.h"        /* mc_home, mc_home_alt */ 
    5454#include "../src/help.h"        /* interactive_display() */ 
    5555#include "../src/key.h"         /* XCTRL */ 
    5656#include "../src/dialog.h"      /* do_refresh() */ 
    edit_block_process_cmd (WEdit *edit, const char *shell_cmd, int block) 
    25302530            return; 
    25312531        } 
    25322532        if (!(script_src = fopen (o, "r"))) { 
    2533             fclose (script_home); 
    2534             unlink (h); 
    2535             edit_error_dialog ("", get_sys_error (catstrs 
    2536                                                   (_("Error reading script:"), 
    2537                                                    o, (char *) NULL))); 
    2538             return; 
     2533            o = catstrs (mc_home_alt, shell_cmd, (char *) NULL); 
     2534            if (!(script_src = fopen (o, "r"))) { 
     2535                fclose (script_home); 
     2536                unlink (h); 
     2537                edit_error_dialog ("", get_sys_error (catstrs 
     2538                                                      (_("Error reading script:"), 
     2539                                                      o, (char *) NULL))); 
     2540                return; 
     2541            } 
    25392542        } 
    25402543        while (fgets (buf, sizeof (buf), script_src)) 
    25412544            fputs (buf, script_home); 
  • edit/syntax.c

    diff --git a/edit/syntax.c b/edit/syntax.c
    index 23e8b6c..1f6b2d6 100644
    a b  
    3838#include "edit.h" 
    3939#include "edit-widget.h" 
    4040#include "../src/color.h"       /* use_colors */ 
    41 #include "../src/main.h"        /* mc_home */ 
     41#include "../src/main.h"        /* mc_home, mc_home_alt */ 
    4242#include "../src/wtools.h"      /* message() */ 
    4343 
    4444/* bytes */ 
    static FILE *open_include_file (const char *filename) 
    681681    g_free (error_file_name); 
    682682    error_file_name = g_strconcat (mc_home, PATH_SEP_STR "syntax" PATH_SEP_STR, 
    683683                                   filename, (char *) NULL); 
     684 
     685    if (!(f = fopen (error_file_name, "r"))) { 
     686        g_free (error_file_name); 
     687        error_file_name = g_strconcat (mc_home_alt, PATH_SEP_STR "syntax" PATH_SEP_STR, 
     688                                       filename, (char *) NULL); 
     689    } else return f; 
     690 
    684691    return fopen (error_file_name, "r"); 
    685692} 
    686693 
  • lib/Makefile.am

    diff --git a/lib/Makefile.am b/lib/Makefile.am
    index 5f61432..c0f08c0 100644
    a b endif 
    99LIBFILES_OUT = mc.ext 
    1010LIBFILES_CONST = mc.hint mc.hint.cs mc.hint.es mc.hint.hu mc.hint.it    \ 
    1111        mc.hint.nl mc.hint.pl mc.hint.ru mc.hint.sr mc.hint.uk          \ 
    12         mc.hint.zh mc.lib mc.menu mc.menu.sr cedit.menu edit.indent.rc  \ 
    13         edit.spell.rc 
     12        mc.hint.zh mc.menu.sr 
    1413 
    1514noinst_DATA = README.xterm mcserv.init mcserv.pamd xterm.ad 
    1615 
    SCRIPTS_OUT = mc.csh mc.sh mc-wrapper.csh mc-wrapper.sh 
    1918 
    2019suppbin_SCRIPTS = $(SCRIPTS_OUT) 
    2120 
    22 pkgdata_DATA = $(LIBFILES_CONST) $(LIBFILES_ADD) $(LIBFILES_OUT) 
     21pkgdata_DATA = $(LIBFILES_CONST) 
    2322 
    2423CLEANFILES = $(SCRIPTS_OUT) 
    2524 
     25cfgdir = $(sysconfdir)/@PACKAGE@ 
     26cfg_DATA =              \ 
     27        cedit.menu      \ 
     28        edit.indent.rc  \ 
     29        edit.spell.rc   \ 
     30        $(LIBFILES_OUT) \ 
     31        mc.lib          \ 
     32        mc.menu         \ 
     33        $(LIBFILES_ADD) 
     34 
    2635# Files processed by configure don't need to be here 
    2736EXTRA_DIST = \ 
    2837        $(LIBFILES_CONST) \ 
  • src/Makefile.am

    diff --git a/src/Makefile.am b/src/Makefile.am
    index ccf0f8b..b93c9c8 100644
    a b bin_PROGRAMS = mc mcmfmt 
    88if CONS_SAVER 
    99pkglibexec_PROGRAMS = cons.saver 
    1010AM_CPPFLAGS = -DDATADIR=\""$(pkgdatadir)/"\" -DLOCALEDIR=\""$(localedir)"\" \ 
    11         -DSAVERDIR=\""$(pkglibexecdir)"\" 
     11        -DSAVERDIR=\""$(pkglibexecdir)"\" \ 
     12        -DSYSCONFDIR=\""$(sysconfdir)/@PACKAGE@/"\" 
    1213else 
    13 AM_CPPFLAGS = -DDATADIR=\""$(pkgdatadir)/"\" -DLOCALEDIR=\""$(localedir)"\" 
     14AM_CPPFLAGS = -DDATADIR=\""$(pkgdatadir)/"\" -DLOCALEDIR=\""$(localedir)"\" \ 
     15        -DSYSCONFDIR=\""$(sysconfdir)/@PACKAGE@/"\" 
    1416endif 
    1517 
    1618noinst_PROGRAMS = man2hlp 
  • src/charsets.c

    diff --git a/src/charsets.c b/src/charsets.c
    index 5666c23..bd29648 100644
    a b load_codepages_list (void) 
    4545    char *fname; 
    4646    char buf[256]; 
    4747    extern char *mc_home; 
     48    extern char *mc_home_alt; 
    4849    extern int display_codepage; 
    4950    char *default_codepage = NULL; 
    5051 
    5152    fname = concat_dir_and_file (mc_home, CHARSETS_INDEX); 
    5253    if (!(f = fopen (fname, "r"))) { 
    53         fprintf (stderr, _("Warning: file %s not found\n"), fname); 
     54        g_free (fname); 
     55        fname = concat_dir_and_file (mc_home_alt, CHARSETS_INDEX); 
     56        if (!(f = fopen (fname, "r"))) { 
     57            fprintf (stderr, _("Warning: file %s not found\n"), fname); 
     58        } 
    5459        g_free (fname); 
    5560        return -1; 
    5661    } 
  • src/cmd.c

    diff --git a/src/cmd.c b/src/cmd.c
    index 01d110f..f332789 100644
    a b void ext_cmd (void) 
    570570        check_for_default (extdir, buffer); 
    571571        do_edit (buffer); 
    572572        g_free (buffer); 
    573     } else if (dir == 1) 
     573    } else if (dir == 1) { 
     574        if (!exist_file(extdir)) { 
     575            g_free (extdir); 
     576            extdir = concat_dir_and_file (mc_home_alt, MC_LIB_EXT); 
     577        } 
    574578        do_edit (extdir); 
     579    } 
    575580 
    576581   g_free (extdir); 
    577582   flush_extension_file (); 
    menu_edit_cmd (int where) 
    595600 
    596601    menufile = concat_dir_and_file (mc_home, where ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU); 
    597602 
     603    if (!exist_file(menufile)) { 
     604        g_free (menufile); 
     605        menufile = concat_dir_and_file (mc_home_alt, where ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU); 
     606    } 
     607 
    598608    switch (dir) { 
    599609        case 0: 
    600610            buffer = g_strdup (where ? CEDIT_LOCAL_MENU : MC_LOCAL_MENU); 
    menu_edit_cmd (int where) 
    608618         
    609619        case 2: 
    610620            buffer = concat_dir_and_file (mc_home, where ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU); 
     621            if (!exist_file(buffer)) { 
     622                g_free (buffer); 
     623                buffer = concat_dir_and_file (mc_home_alt, where ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU); 
     624            } 
    611625            break; 
    612626 
    613627        default: 
    edit_syntax_cmd (void) 
    666680                          _(" Which syntax file you want to edit? "), 0, 2, 
    667681                          _("&User"), _("&System Wide")); 
    668682    } 
    669     extdir = concat_dir_and_file (mc_home, "syntax" PATH_SEP_STR "Syntax"); 
     683    extdir = concat_dir_and_file (mc_home_alt, "syntax" PATH_SEP_STR "Syntax"); 
    670684 
    671685    if (dir == 0) { 
    672686        buffer = concat_dir_and_file (home_dir, SYNTAX_FILE); 
  • src/ext.c

    diff --git a/src/ext.c b/src/ext.c
    index 8e64d2c..7acaf31 100644
    a b regex_command (const char *filename, const char *action, int *move_dir) 
    445445            g_free (extension_file); 
    446446          check_stock_mc_ext: 
    447447            extension_file = concat_dir_and_file (mc_home, MC_LIB_EXT); 
     448            if (!exist_file (extension_file)) { 
     449                g_free (extension_file); 
     450                extension_file = concat_dir_and_file (mc_home_alt, MC_LIB_EXT); 
     451            } 
    448452            mc_user_ext = 0; 
    449453        } 
    450454        data = load_file (extension_file); 
  • src/main.c

    diff --git a/src/main.c b/src/main.c
    index a59607e..c6f3bf9 100644
    a b int midnight_shutdown = 0; 
    276276/* The user's shell */ 
    277277const char *shell = NULL; 
    278278 
    279 /* mc_home: The home of MC */ 
     279/* mc_home: The home of MC - /etc/mc or defined by MC_DATADIR */ 
    280280char *mc_home = NULL; 
    281281 
     282/* mc_home_alt: Alternative home of MC - deprecated /usr/share/mc */ 
     283char *mc_home_alt = NULL; 
     284 
    282285char cmd_buf[512]; 
    283286 
    284287static void 
    OS_Setup (void) 
    17771780    if ((mc_libdir = getenv ("MC_DATADIR")) != NULL) { 
    17781781        mc_home = g_strdup (mc_libdir); 
    17791782    } else { 
    1780         mc_home = g_strdup (DATADIR); 
     1783        mc_home = g_strdup (SYSCONFDIR); 
    17811784    } 
     1785    mc_home_alt = mc_libdir != NULL ? g_strdup (SYSCONFDIR) : g_strdup (DATADIR); 
    17821786} 
    17831787 
    17841788static void 
    process_args (poptContext ctx, int c, const char *option_arg) 
    19081912        break; 
    19091913 
    19101914    case 'f': 
    1911         printf ("%s\n", mc_home); 
     1915        printf ("%s (%s)\n", mc_home, mc_home_alt); 
    19121916        exit (0); 
    19131917        break; 
    19141918 
    main (int argc, char *argv[]) 
    23042308    } 
    23052309    g_free (last_wd_string); 
    23062310 
     2311    g_free (mc_home_alt); 
    23072312    g_free (mc_home); 
    23082313    done_key (); 
    23092314#ifdef HAVE_CHARSET 
  • src/main.h

    diff --git a/src/main.h b/src/main.h
    index 3f3c695..0eaa4af 100644
    a b void print_vfs_message(const char *msg, ...) 
    110110 
    111111extern const char *prompt; 
    112112extern const char *edit_one_file; 
    113 extern char *mc_home; 
     113extern char *mc_home, *mc_home_alt; 
    114114char *get_mc_lib_dir (void); 
    115115 
    116116int maybe_cd (int move_up_dir); 
  • src/setup.c

    diff --git a/src/setup.c b/src/setup.c
    index 026ac02..cb38e01 100644
    a b setup_init (void) 
    484484        if (exist_file (inifile)){ 
    485485            g_free (profile); 
    486486            profile = inifile; 
    487         } else 
     487        } else { 
    488488            g_free (inifile); 
     489            inifile = concat_dir_and_file (mc_home_alt, "mc.ini"); 
     490            if (exist_file (inifile)) { 
     491                g_free (profile); 
     492                profile = inifile; 
     493            } else  
     494                g_free (inifile); 
     495        } 
    489496    } 
    490497 
    491498    profile_name = profile; 
    load_setup (void) 
    505512       ~/.mc/ini.  FIXME: it's only used for keys and treestore now */ 
    506513    global_profile_name = concat_dir_and_file (mc_home, "mc.lib"); 
    507514 
     515    if (!exist_file(global_profile_name)) { 
     516        g_free (global_profile_name); 
     517        global_profile_name = concat_dir_and_file (mc_home_alt, "mc.lib"); 
     518    } 
     519 
    508520    /* Load integer boolean options */ 
    509521    for (i = 0; int_options[i].opt_name; i++) 
    510522        *int_options[i].opt_addr = 
  • src/user.c

    diff --git a/src/user.c b/src/user.c
    index 01022aa..5ac07aa 100644
    a b user_menu_cmd (struct WEdit *edit_widget) 
    726726            g_free (menu); 
    727727            menu = concat_dir_and_file \ 
    728728                        (mc_home, edit_widget ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU); 
     729            if (!exist_file (menu)) { 
     730                g_free (menu); 
     731                menu = concat_dir_and_file \ 
     732                        (mc_home_alt, edit_widget ? CEDIT_GLOBAL_MENU : MC_GLOBAL_MENU); 
     733            } 
    729734        } 
    730735    } 
    731736 
  • src/util.c

    diff --git a/src/util.c b/src/util.c
    index da6d1b2..d32690e 100644
    a b  
    3737 
    3838#include "global.h" 
    3939#include "profile.h" 
    40 #include "main.h"               /* mc_home */ 
     40#include "main.h"               /* mc_home, mc_home_alt */ 
    4141#include "cmd.h"                /* guess_message_value */ 
    4242#include "mountlist.h" 
    4343#include "win.h"                /* xterm_flag */ 
    load_mc_home_file (const char *filename, char **allocated_filename) 
    693693 
    694694    if (!data) { 
    695695        g_free (hintfile); 
    696         /* Fall back to the two-letter language code */ 
    697         if (lang[0] && lang[1]) 
    698             lang[2] = 0; 
     696        g_free (hintfile_base); 
     697 
     698        hintfile_base = concat_dir_and_file (mc_home_alt, filename); 
     699 
    699700        hintfile = g_strconcat (hintfile_base, ".", lang, (char *) NULL); 
    700701        data = load_file (hintfile); 
    701702 
    702703        if (!data) { 
    703             g_free (hintfile); 
    704             hintfile = hintfile_base; 
    705             data = load_file (hintfile_base); 
     704            /* Fall back to the two-letter language code */ 
     705            if (lang[0] && lang[1]) 
     706                lang[2] = 0; 
     707            hintfile = g_strconcat (hintfile_base, ".", lang, (char *) NULL); 
     708            data = load_file (hintfile); 
     709 
     710            if (!data) { 
     711                g_free (hintfile); 
     712                hintfile = hintfile_base; 
     713                data = load_file (hintfile_base); 
     714            } 
    706715        } 
    707716    } 
    708717 
  • syntax/Makefile.am

    diff --git a/syntax/Makefile.am b/syntax/Makefile.am
    index d99dc3a..d35ff22 100644
    a b  
    11SYNTAXFILES =                   \ 
    2         Syntax                  \ 
    32        ada95.syntax            \ 
    43        aspx.syntax             \ 
    54        assembler.syntax        \ 
    SYNTAXFILES = \ 
    4544        unknown.syntax          \ 
    4645        xml.syntax 
    4746 
     47SYNTAXCONFFILES =               \ 
     48        Syntax 
     49 
    4850if USE_EDIT 
    4951syntaxdir =             $(pkgdatadir)/syntax 
    5052syntax_DATA =           $(SYNTAXFILES) 
     53 
     54syntaxconfdir =         $(sysconfdir)/@PACKAGE@ 
     55syntaxconf_DATA =       $(SYNTAXCONFFILES) 
    5156endif 
    5257 
    53 EXTRA_DIST =            $(SYNTAXFILES) 
     58EXTRA_DIST =            $(SYNTAXFILES) $(SYNTAXCONFFILES) 
  • vfs/extfs.c

    diff --git a/vfs/extfs.c b/vfs/extfs.c
    index d634e33..9c389dc 100644
    a b extfs_open_archive (int fstype, const char *name, struct archive **pparc) 
    246246        tmp = name_quote (name, 0); 
    247247    } 
    248248 
    249     mc_extfsdir = concat_dir_and_file (mc_home, "extfs" PATH_SEP_STR); 
     249    mc_extfsdir = concat_dir_and_file (mc_home_alt, "extfs" PATH_SEP_STR); 
    250250    cmd = 
    251251        g_strconcat (mc_extfsdir, extfs_prefixes[fstype], " list ", 
    252252                     local_name ? local_name : tmp, (char *) NULL); 
    extfs_cmd (const char *extfs_cmd, struct archive *archive, 
    621621    archive_name = name_quote (extfs_get_archive_name (archive), 0); 
    622622    quoted_localname = name_quote (localname, 0); 
    623623 
    624     mc_extfsdir = concat_dir_and_file (mc_home, "extfs" PATH_SEP_STR); 
     624    mc_extfsdir = concat_dir_and_file (mc_home_alt, "extfs" PATH_SEP_STR); 
    625625    cmd = g_strconcat (mc_extfsdir, extfs_prefixes[archive->fstype], 
    626626                       extfs_cmd, archive_name, " ", quoted_file, " ", 
    627627                       quoted_localname, (char *) NULL); 
    extfs_run (struct vfs_class *me, const char *file) 
    650650    g_free (p); 
    651651 
    652652    archive_name = name_quote (extfs_get_archive_name (archive), 0); 
    653     mc_extfsdir = concat_dir_and_file (mc_home, "extfs" PATH_SEP_STR); 
     653    mc_extfsdir = concat_dir_and_file (mc_home_alt, "extfs" PATH_SEP_STR); 
    654654    cmd = g_strconcat (mc_extfsdir, extfs_prefixes[archive->fstype], 
    655655                       " run ", archive_name, " ", q, (char *) NULL); 
    656656    g_free (mc_extfsdir); 
  • vfs/extfs/Makefile.am

    diff --git a/vfs/extfs/Makefile.am b/vfs/extfs/Makefile.am
    index e7efbe4..899e6c7 100644
    a b  
    11extfsdir = $(pkgdatadir)/extfs 
    22 
     3EXTFSCONFFILES = extfs.ini sfs.ini 
     4 
    35# Files to install and distribute other than extfs scripts 
    4 EXTFS_MISC  = README extfs.ini sfs.ini 
     6EXTFS_MISC  = README 
    57 
    68# Scripts hat don't need adaptation to the local system 
    79EXTFS_CONST = bpp rpm trpm u7z 
    EXTFS_OUT = \ 
    5759if USE_VFS 
    5860extfs_DATA = $(EXTFS_MISC) 
    5961extfs_SCRIPTS = $(EXTFS_CONST) $(EXTFS_OUT) 
     62 
     63extfsconfdir = $(sysconfdir)/@PACKAGE@/extfs 
     64extfsconf_DATA = $(EXTFSCONFFILES) 
    6065endif 
    6166 
    6267EXTRA_DIST = $(EXTFS_MISC) $(EXTFS_CONST)