#!/usr/bin/perl
# patch.pl
# STTA Rev. 1.3 Copyright (c) 2001-2003 Jesús Pérez Lorenzo  --- license GNU GPL

$patch_date="2003_1_31_055502";
$patch_num="1#1.3pre1043988902-";

%infoCfg=();
# Use config.info to create config inputs
&read_file("$root_directory/$module/config.info", \%infoCfg);
foreach $o (@lang_order_list) {
   &read_file("$root_directory/$module/config.info.$o", \%infoCfg);
}

sub do_patch 
{
 %minfo=&load_minfo("$root_directory/stta/");
 print "<i>$minfo{name} &nbsp;&nbsp;&nbsp; $minfo{version} &nbsp;&nbsp;&nbsp; ( $minfo{brand} &nbsp;&nbsp;&nbsp; $minfo{stamp} )</i><br>\n";
 if ( $minfo{version} ne "1.3pre" ) {
      print "ERROR: <b>$text{error_version}</b><br>";
      return false;
 }
 if ( $minfo{stamp} ne "2003_1_15_121724" ||  $minfo{brand} ne "1.3pre1042620827-" ) {
      print "ERROR: <b>$text{error_stamp}</b><br>";
      return false;
 }
 &extract_code();     # To extract stta pack 
 &concat_dataconf();  # To fix dataconf by concat.sh 

}

sub extract_code
{
   print "Extracting ..... <br>";
   local $str="cd $DirInstall/tmp; gunzip -f *.gz";
   &run_cmd($str);

   $str="cd $root_directory;";
   $str .= "tar xvf $DirInstall/tmp/stta-1.3.wbm >/dev/null";
   &run_cmd($str);
 
   print "Setting Permissions  ..... <br>";
   $str="cd $root_directory/stta; chmod -R 555 *.cgi *.sh *.pl ";
   &run_cmd($str);
   print "ˇˇ Done !!! <br>";
}

sub step_fixstampdata
{
   print "No Branding and Stamp need <br>";
}

sub concat_dataconf
{
    local $line=$config{apps_list};
    local @dataline=split(/\//,$line, -1);
    $line=~ s/\/$dataline[$#dataline]//g;
    $str="sh $DirInstall/tmp/concatfiles.sh $current_lang $DirInstall/tmp/dataconf $config_directory/stta/dataconf $line";
    &run_cmd($str);
}
1;
