Back to index

texmacs  1.0.7.15
init_upgrade.cpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : init_upgrade.cpp
00004 * DESCRIPTION: initializations which are only necessary when
00005 *              you just upgraded your TeXmacs distribution
00006 * COPYRIGHT  : (C) 1999  Joris van der Hoeven
00007 *******************************************************************************
00008 * This software falls under the GNU general public license version 3 or later.
00009 * It comes WITHOUT ANY WARRANTY WHATSOEVER. For details, see the file LICENSE
00010 * in the root directory or <http://www.gnu.org/licenses/gpl-3.0.html>.
00011 ******************************************************************************/
00012 
00013 #include "boot.hpp"
00014 #include "file.hpp"
00015 #include "path.hpp"
00016 #include "sys_utils.hpp"
00017 #include "data_cache.hpp"
00018 
00019 /******************************************************************************
00020 * Old style settings files
00021 ******************************************************************************/
00022 
00023 static string
00024 line_read (string s, int& i) {
00025   int start= i, n= N(s);
00026   for (start=i; i<n; i++)
00027     if (s[i]=='\n') break;
00028   string r= s (start, i);
00029   if (i<n) i++;
00030   return r;
00031 }
00032 
00033 void
00034 get_old_settings (string s) {
00035   int i= 0, j;
00036   while (i<N(s)) {
00037     string l= line_read (s, i);
00038     for (j=0; j<N(l); j++)
00039       if (l[j] == '=') {
00040        string left = l (0, j);
00041        while ((j<N(l)) && ((l[j]=='=') || (l[j]==' '))) j++;
00042        string right= l (j, N(l));
00043        set_setting (left, right);
00044       }
00045   }
00046 }
00047 
00048 /******************************************************************************
00049 * Check for old Init.scm and Init-buffer.scm files
00050 ******************************************************************************/
00051 
00052 static void
00053 init_upgrade_scheme () {
00054 #ifndef OS_WIN32
00055   url u= "$TEXMACS_HOME_PATH/progs";
00056   string prgs= as_string (u);
00057   if (exists (u * "Init.scm") && (!exists (u * "my-init-texmacs.scm"))) {
00058     system ("sed 's/Init.scm/init-texmacs.scm/'", u * "Init.scm",
00059            ">", u * "my-init-texmacs.scm");
00060     remove (u * "Init.scm");
00061   }
00062   if (exists (u * "Init-buffer.scm") && (!exists (u * "my-init-buffer.scm"))) {
00063     system ("sed 's/Init-buffer.scm/init-buffer.scm/'", u * "Init-buffer.scm",
00064            ">", u * "my-init-buffer.scm");
00065     remove (u * "Init-buffer.scm");
00066   }
00067 #endif
00068 }
00069 
00070 /******************************************************************************
00071 * Generate documentation about changes
00072 ******************************************************************************/
00073 
00074 static string
00075 string_load (url u) {
00076   string s;
00077   (void) load_string (u, s, false);
00078   return s;
00079 }
00080 
00081 static void
00082 init_upgrade_doc (string install_version) {
00083   url from_dir= "$TEXMACS_PATH/doc/about/changes";
00084   url to= "$TEXMACS_HOME_PATH/doc/about/changes/changes-recent.en.tm";
00085   string s= string_load (from_dir * "changes-pre.en.ptm");
00086   if (version_inf (install_version, "0.3.3.24"))
00087     s << string_load (from_dir * "changes-1.en.ptm");
00088   if (version_inf_eq (install_version, "0.3.4.9"))
00089     s << string_load (from_dir * "changes-2.en.ptm");
00090   if (version_inf_eq (install_version, "1.0.0.4"))
00091     s << string_load (from_dir * "changes-3.en.ptm");
00092   if (version_inf_eq (install_version, "1.0.0.6"))
00093     s << string_load (from_dir * "changes-4.en.ptm");
00094   if (version_inf_eq (install_version, "1.0.0.11"))
00095     s << string_load (from_dir * "changes-5.en.ptm");
00096   if (version_inf_eq (install_version, "1.0.2.0"))
00097     s << string_load (from_dir * "changes-6.en.ptm");
00098   if (version_inf_eq (install_version, "1.0.2.6"))
00099     s << string_load (from_dir * "changes-7.en.ptm");
00100   if (version_inf_eq (install_version, "1.0.2.8"))
00101     s << string_load (from_dir * "changes-8.en.ptm");
00102   if (version_inf_eq (install_version, "1.0.3.4"))
00103     s << string_load (from_dir * "changes-9.en.ptm");
00104   if (version_inf_eq (install_version, "1.0.4"))
00105     s << string_load (from_dir * "changes-10.en.ptm");
00106   if (version_inf_eq (install_version, "1.0.5.9"))
00107     s << string_load (from_dir * "changes-11.en.ptm");
00108   if (version_inf_eq (install_version, "1.0.5.9"))
00109     s << string_load (from_dir * "changes-12.en.ptm");
00110   if (version_inf_eq (install_version, "1.0.5.9"))
00111     s << string_load (from_dir * "changes-13.en.ptm");
00112   if (version_inf_eq (install_version, "1.0.6.2"))
00113     s << string_load (from_dir * "changes-14.en.ptm");
00114   if (version_inf_eq (install_version, "1.0.7.6"))
00115     s << string_load (from_dir * "changes-15.en.ptm");
00116   if (version_inf_eq (install_version, "1.0.7.7"))
00117     s << string_load (from_dir * "changes-16.en.ptm");
00118   if (version_inf_eq (install_version, "1.0.7.8"))
00119     s << string_load (from_dir * "changes-17.en.ptm");
00120   if (version_inf_eq (install_version, "1.0.7.9")) {
00121     s << string_load (from_dir * "changes-18.en.ptm");
00122     s << string_load (from_dir * "changes-post.en.ptm");
00123     save_string (to, s, false);
00124   }
00125   else remove (to);
00126 }
00127 
00128 /******************************************************************************
00129 * Upgrading TeXmacs
00130 ******************************************************************************/
00131 
00132 void
00133 init_upgrade () {
00134   string install_version= get_setting ("VERSION");
00135 
00136   cerr << HRULE;
00137   cerr << "Your disk contains a configuration file for TeXmacs-";
00138   cerr << install_version << ".\n";
00139   cerr << "I will now perform the upgrade to version " TEXMACS_VERSION "\n";
00140   cerr << HRULE;
00141 
00142   url old_settings= "$TEXMACS_HOME_PATH/system" * url_wildcard ("TEX_PATHS*");
00143   url new_settings= "$TEXMACS_HOME_PATH/system/settings.scm";
00144   remove (old_settings);
00145   remove (new_settings);
00146 
00147   setup_texmacs ();
00148   init_upgrade_scheme ();
00149   init_upgrade_doc (install_version);
00150 
00151   remove (url ("$TEXMACS_HOME_PATH/system/setup.scm"));
00152   remove (url ("$TEXMACS_HOME_PATH/system/cache") * url_wildcard ("__*"));
00153   remove (url ("$TEXMACS_HOME_PATH/system/cache/dir_cache.scm"));
00154   remove (url ("$TEXMACS_HOME_PATH/system/cache/doc_cache"));
00155   remove (url ("$TEXMACS_HOME_PATH/system/cache/file_cache"));
00156   remove (url ("$TEXMACS_HOME_PATH/system/cache/stat_cache.scm"));
00157   cache_refresh ();
00158 }