Changeset e1b08a2 for app


Ignore:
Timestamp:
03/12/08 12:27:45 (16 years ago)
Author:
pawelk <pawelk@…>
Branches:
master, help
Children:
8d3e6ab
Parents:
eedf648
git-author:
pawelk <pawelk@…> (03/12/08 12:27:45)
git-committer:
pawelk <pawelk@…> (03/12/08 12:27:45)
Message:

Poprawiłem programik, generujący domyślną konfigurację dla użytkownika.

git-svn-id: svn://atos.wmid.amu.edu.pl/utt@8 e293616e-ec6a-49c2-aa92-f4a8b91c5d16

Location:
app/dist
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • app/dist/common/utt_make_config.pl

    r25ae32e re1b08a2  
    1 #!/usr/bin/perl 
     1#!c:\usr\perl\bin\perl.exe 
    22 
    33use Cwd 'abs_path'; 
    44use File::Basename; 
     5use File::HomeDir; 
     6use File::Spec::Functions; 
    57use POSIX; 
    68 
    7 my $cur_dir = dirname(abs_path($0)); 
     9my $sys_home = catdir(dirname(abs_path($0)), ".."); 
     10my $usr_home = catdir(home(), '.utt'); 
    811 
    9 open(FILE, ">$cur_dir/conf/utt.conf"); 
     12prepareUttUsrHome($usr_home); 
     13conf_cor(catfile($usr_home, 'cor.conf'), $sys_home); 
     14conf_grp(catfile($usr_home, 'grp.conf'), $sys_home); 
     15conf_gue(catfile($usr_home, 'gue.conf'), $sys_home); 
     16conf_lem(catfile($usr_home, 'lem.conf'), $sys_home); 
     17conf_ser(catfile($usr_home, 'ser.conf'), $sys_home); 
     18conf_utt(catfile($usr_home, 'utt.conf'), $sys_home); 
    1019 
    11 # we put some description into utt.conf file 
    12 print FILE "# ************************************************************\n"; 
    13 print FILE "# * This file was created automatically during installation. *\n"; 
    14 print FILE "# * If you don't need do not change it.                      *\n"; 
    15 print FILE "# *                                                          *\n"; 
    16 print FILE "# * UAM Text Tools                                           *\n"; 
    17 print FILE "# * Adam Mickiewicz University, Poland                       *\n"; 
    18 print FILE "# * http://utt.amu.edu.pl                                    *\n"; 
    19 print FILE "# ************************************************************\n"; 
    20 print FILE "\n\n"; 
    21  
    22 # we need utt home directory 
    23 print FILE "# absolute path to utt directory\n"; 
    24 print FILE "UTT_HOME=$cur_dir\n\n"; 
    25  
    26  
    27 # we need user default locale 
    28 $best_locale = findLocale(); 
    29 print FILE "# user locale\n"; 
    30 print FILE "UTT_LOCALE=$best_locale\n"; 
    31 print FILE "\n"; 
    32  
    33 close FILE; 
     20print "UTT user configuration created in $usr_home\n"; 
    3421 
    3522 
    3623 
     24#Kasuje stare configi i tworzy katalog .utt 
     25sub prepareUttUsrHome() { 
     26    my $dir = shift; 
     27 
     28        if(-d $dir) { 
     29                print "Old configuration will be deleted!\n"; 
     30                my $cnt = unlink <$dir/*>; 
     31                print "$cnt files deleted.\n"; 
     32        } 
     33        else { 
     34                print "Creating directory $dir\n"; 
     35                if(1 != mkdir $dir) { 
     36                  die "Unable to create UTT user configuration!\n"; 
     37                } 
     38        } 
     39} 
     40 
     41# Tworzy naglowek dla wszystkich plikow konfiguracyjnych 
     42sub makeConfigHeader() { 
     43  return "# ************************************************************\n". 
     44                 "# * This file was created automatically during installation. *\n". 
     45                 "# * If you don't need do not change it.                      *\n". 
     46                 "# *                                                          *\n". 
     47                 "# * UAM Text Tools                                           *\n". 
     48                 "# * Adam Mickiewicz University, Poland                       *\n". 
     49                 "# * http://utt.amu.edu.pl                                    *\n". 
     50                 "# ************************************************************\n". 
     51                 "#\n". 
     52                 "# All lines must looks like:\n". 
     53                 "# parameter_name [=] value\n". 
     54                 "#\n\n"; 
     55} 
     56 
     57sub conf_cor() { 
     58        my $cor_file = shift; 
     59        my $utthome = shift; 
     60  open(FILE, ">$cor_file"); 
     61 
     62  print FILE makeConfigHeader(); 
     63  print FILE "dictionary-home=", abs_path("$utthome/share/utt"), "\n"; 
     64 
     65  close FILE; 
     66} 
     67 
     68sub conf_grp() { 
     69        my $grp_file = shift; 
     70        my $utthome = shift; 
     71  open(FILE, ">$grp_file"); 
     72 
     73  print FILE makeConfigHeader(); 
     74  print FILE "macros=", abs_path("$utthome/lib/utt/terms.m4"), "\n"; 
     75 
     76  close FILE; 
     77} 
     78 
     79sub conf_gue() { 
     80        my $gue_file = shift; 
     81        my $utthome = shift; 
     82  open(FILE, ">$gue_file"); 
     83 
     84  print FILE makeConfigHeader(); 
     85 
     86  close FILE; 
     87} 
     88 
     89sub conf_lem() { 
     90        my $lem_file = shift; 
     91        my $utthome = shift; 
     92  open(FILE, ">$lem_file"); 
     93 
     94  print FILE makeConfigHeader(); 
     95  print FILE "dictionary-home=", abs_path("$utthome/share/utt"), "\n"; 
     96 
     97  close FILE; 
     98} 
     99 
     100sub conf_ser() { 
     101        my $ser_file = shift; 
     102        my $utthome = shift; 
     103  open(FILE, ">$ser_file"); 
     104 
     105  print FILE makeConfigHeader(); 
     106  print FILE "macros=", abs_path("$utthome/lib/utt/terms.m4"), "\n"; 
     107  print FILE "flex-template=", abs_path("$utthome/lib/utt/ser.l.template"), "\n"; 
     108 
     109  close FILE; 
     110} 
     111 
     112sub conf_utt() { 
     113        my $utt_file = shift; 
     114        my $utthome = shift; 
     115  open(FILE, ">$utt_file"); 
     116 
     117  print FILE makeConfigHeader(); 
     118  print FILE "# user locale\n"; 
     119  print FILE "language=", findLocale(), "\n"; 
     120 
     121  close FILE; 
     122} 
     123 
     124# Szuka locali u uzytkownika 
    37125sub findLocale() { 
    38126        $cur_locale = setlocale(LC_CTYPE); 
Note: See TracChangeset for help on using the changeset viewer.