
| Current Path : /var/www/web-klick.de/dsh/90_akt/DEV1303/DivBasicF/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : /var/www/web-klick.de/dsh/90_akt/DEV1303/DivBasicF/AutoInstall.pm |
package DivBasicF::AutoInstall;
use strict;
sub new {
my $class = shift;
my $self = {};
bless($self,$class);
return($self);
}
#*****************************************************************
# This function has been tested under Ubuntu
#
# To make a package from the git autotest directory,
# change into the main directory of autotest (where
# AutoQX, DivBasicF, ... are subdirectories of it.
# Then call:
#
# perl DivBasicF/p DivBasicF::AutoInstall::make_package <label>
#
# to build a new build package <label>.zip of autotest, and:
#
# perl DivBasicF/p DivBasicF::AutoInstall::make_package .<label>
#
# to build a new source package <label>.zip of autotest, and:
sub make_package {
my $self = shift;
my $project1 = shift;
my $qooxdoo_dir = shift;
my $source = 0;
$source = 1 if ($qooxdoo_dir =~ s/^\.//);
$source = 1 if ($project1 =~ s/^\.//);
$qooxdoo_dir = "/opt/qooxdoo-2.0.1-sdk" if (!$qooxdoo_dir);
$project1 = "autotest" if (!$project1);
my $project = "autotest";
my $git_dir = `pwd`;
$git_dir =~ s/\n//gs;
my $text;
if (!(-d("$git_dir/AutoQX"))) {
print("start this script from the root directory of the autotest git repository $git_dir\n");
return();
}
system("rm -rf /tmp/$project");
system("rm -rf /tmp/$project1");
# system("rm -f /tmp/$project1.zip");
chdir("/tmp");
system("$qooxdoo_dir/tool/bin/create-application.py -n $project");
system("rm -rf /tmp/$project/source/class/$project/*");
system("cp $git_dir/AutoQX/*.js /tmp/$project/source/class/$project/");
system("ln -s $git_dir/AutoQX/theme /tmp/$project/source/class/$project/");
system("ln -s $git_dir/AutoQX/translation /tmp/$project/source/class/$project/");
system("ln -s $git_dir/AutoQX/resource/$project/* /tmp/$project/source/resource/$project/");
chdir($project);
mkdir("/tmp/$project/htdocs");
mkdir("/tmp/$project/cgi-bin");
mkdir("/tmp/$project/htdocs/$project1");
mkdir("/tmp/$project/cgi-bin/$project1");
if ($source) {
system("./generate.py source");
system("mv source/* /tmp/$project/htdocs/$project1");
system("ln -s $qooxdoo_dir/framework /tmp/$project/htdocs/$project1");
open(FFILE,"/tmp/$project/htdocs/$project1/script/$project.js");
$text = join("",<FFILE>);
close(FFILE);
$text =~ s/\"(resourceUri|sourceUri)\"\:\"\.\.\/source\//\"$1\"\:\"/g;
$text =~ s/\"(resourceUri|sourceUri)\"\:\"([^\"]*?)framework/\"$1\"\:\"framework/g;
open(FFILE,">htdocs/$project1/script/$project.js");
print FFILE $text;
close(FFILE);
# print "/tmp/$project/htdocs/$project1/class/$project/Application.js\n"; sleep 1;
open(FFILE,"</tmp/$project/htdocs/$project1/class/$project/Application.js");
$text = join("",<FFILE>); # ... in the source version
close(FFILE);
$text =~ s/\/([^\"\/]+?)\/index\.cgi\"/\/$project1\/index.cgi\"/;
open(FFILE,">/tmp/$project/htdocs/$project1/class/$project/Application.js");
print FFILE $text;
close(FFILE);
} else {
system("./generate.py build");
system("mv build/* /tmp/$project/htdocs/$project1");
system("ln -s $git_dir/AutoQX/resource/$project/* /tmp/$project/htdocs/$project1/resource/$project");
}
system("cp -r $git_dir/AutoQX/index.html /tmp/$project/htdocs/$project1");
mkdir("/tmp/$project/cgi-bin/$project1/DivBasicF");
mkdir("/tmp/$project/cgi-bin/$project1/Qooxdoo");
system("cp $git_dir/DivBasicF/p /tmp/$project/cgi-bin/$project1/DivBasicF");
system("cp $git_dir/DivBasicF/*.pm /tmp/$project/cgi-bin/$project1/DivBasicF");
system("cp $git_dir/Qooxdoo/* /tmp/$project/cgi-bin/$project1/Qooxdoo");
system("cp $git_dir/index.cgi /tmp/$project/cgi-bin/$project1");
chdir("/tmp");
$text = <<"TEXT_ENDE" . "perl DivBasicF/p DivBasicF::AutoInstall::install $project1";
install script takes one parameter: an Apache Configuration file,
# for example: /etc/apache2/sites-available/default.
#
# The htdocs and cgi-bin entries will be made (resp. deinstalled).
#
# The site then is reachable under: <apache-site>/$project1
#
# If the directory in which this script is located is renamed,
# for example to: foo, a renamed installation in htdocs and
# cgi-bin is made, and the autotest-site is then reachable under
# <apache-site>/foo
#
# The parent directory of the directory containing this
# script will be choosen as the general test project directory.
#
chdir cgi-bin
chdir $project1
TEXT_ENDE
mkdir($project1);
open(FFILE,">$project1/install.sh");
print FFILE "\# This " . $text . " \$1\n";
close(FFILE);
open(FFILE,">$project1/deinstall.sh");
print FFILE "\# This de" . $text . " \$1 1\n";
close(FFILE);
$text =~ s/\#/REM/gs;
open(FFILE,">$project1/install.bat");
print FFILE "REM This " . $text . " \%1\n";
close(FFILE);
open(FFILE,">$project1/deinstall.bat");
print FFILE "REM This de" . $text . " \%1 1\n";
close(FFILE);
system("chmod a+rwx $project1/*install.*");
if ($project ne $project1) {
system("mv $project/htdocs $project1/htdocs");
system("mv $project/cgi-bin $project1/cgi-bin");
# system("rm -rf /tmp/$project");
}
system("zip -r $project1 $project1") if (!(-f("$project1.zip")));
return("Install package $project1.zip generated.");
}
#*****************************************************************
sub install {
my $self = shift;
my $project1 = shift; # Name of the autotest Installation
my $apache = shift; # Apache-Konfiguration
my $deinstall = shift;
my $project = "autotest";
chdir("..");
chdir("..");
my $dir = `pwd`; # This makes it possible to rename the installation directory
$dir =~ s/\n//gs; # and magically get the right directory in the apache directories
$dir =~ s/^(.*)\/(.*)$/$2/;
if ($dir ne $project1) {
system("mv htdocs/$project1 htdocs/$dir");
system("mv cgi-bin/$project1 cgi-bin/$dir");
$project1 = $dir;
}
open(FFILE,"<".$apache); # Einlesen des Apache-Files
my $text = join("",<FFILE>);
close(FFILE);
if (!$apache or !$text) {
return("ERROR: No Apache file given");
}
$project1 =~ s/\.zip$//;
my $htdocs = "";
my $cgi_alias = "";
my $cgi_dir = "";
if ($text =~ /DocumentRoot +(\S+)/) {
$htdocs = $1;
}
if ($text =~ /ScriptAlias +(\S+) +(\S+)/) {
$cgi_alias = $1;
$cgi_dir = $2;
}
$htdocs =~ s/[\/\\]$//gs;
$cgi_alias =~ s/[\/\\]$//gs;
$cgi_dir =~ s/[\/\\]$//gs;
if ($deinstall == 1) {
system("rm -R $cgi_dir/$project1");
system("rm -R $htdocs/$project1");
return("$project1 deinstalled.");
}
my $cgi_path = "$cgi_alias/$project1/index.cgi"; # Changing the path of the cgi-bin
open(FFILE,"<htdocs/$project1/script/$project.js");
my $text = join("",<FFILE>); # ... in the build version
close(FFILE);
$text =~ s/\"([^\"]+?)index\.cgi\"/\"$cgi_path\"/;
open(FFILE,">htdocs/$project1/script/$project.js");
print FFILE $text;
close(FFILE);
open(FFILE,"<htdocs/$project1/class/$project/Application.js");
$text = join("",<FFILE>); # ... in the source version
close(FFILE);
$text =~ s/\"([^\"]+?)index\.cgi\"/\"$cgi_path\"/;
open(FFILE,">htdocs/$project1/class/$project/Application.js");
print FFILE $text;
close(FFILE);
my $cgi_rel = `chdir ..;pwd`; # computing the directory path from the cgi-bin
$cgi_rel =~ s/\n//gs;
$dir = $cgi_dir;
while (0 == 0) {
last if ($dir !~ /^[\\\/](.*?)[\\\/]/);
$text = $1;
last if ($cgi_rel !~ s/^[\\\/]$text([\\\/])/$1/);
$dir =~ s/^[\\\/]$text([\\\/])/$1/;
}
$cgi_rel = ".." . $cgi_rel;
while ($dir =~ s/^(.*)([\\\/])(.*)$/$1/) {
$cgi_rel = ".." . $2 . $cgi_rel;
}
# $cgi_rel =~ s/^(.*)([\\\/])(.*?)[\\\/][\\\/]/$1$2/;
# $cgi_rel =~ s/([\\\/])[\\\/]/$1/;
open(FFILE,"<cgi-bin/$project1/DivBasicF/AutoSettings.pm");
$text = join("",<FFILE>); # ... changing the AutoSettings
close(FFILE);
$text =~ s/(\"R\")([^\n]*)\"(.*)\"/$1$2\"$cgi_rel\"/;
open(FFILE,">cgi-bin/$project1/DivBasicF/AutoSettings.pm");
print FFILE $text;
close(FFILE);
if (!$deinstall) {
return("Project $project1 exists in $cgi_dir") if (-d "$cgi_dir/$project1");
return("Project $project1 exists in $htdocs") if (-d "$htdocs/$project1");
#-----------------------------------------
system("cp cgi-bin/$project1/DivBasicF/p /usr/local/bin/p");
system("chmod a+rwx /usr/local/bin/p"); # Creating the helper scripts p, ot and ox
# in /usr/local/bin
open(FFILE,">/usr/local/bin/ot_".$project1);
print FFILE <<"TEXT_ENDE";
export PERL5LIB=$cgi_dir/$project1:\$PERL5LIB
p DivBasicF::AutoServer::client \$1 \$2 \$3 \$4 \$5 \$6 \$7 \$8 \$9
TEXT_ENDE
close(FFILE);
system("chmod a+rwx /usr/local/bin/ot_".$project1);
open(FFILE,">/usr/local/bin/ox_".$project1);
print FFILE <<"TEXT_ENDE";
export PERL5LIB=$cgi_dir/$project1:\$PERL5LIB
p DivBasicF::AutoServer::server \$1 \$2 \$3 \$4 \$5 \$6 \$7 \$8 \$9
TEXT_ENDE
close(FFILE);
system("chmod a+rwx /usr/local/bin/ox_".$project1);
#-----------------------------------------
system("mv cgi-bin/$project1 $cgi_dir\n");
system("mv htdocs/$project1 $htdocs\n");
system("chmod -R a+rwx $cgi_dir/$project1/index.cgi");
system("rmdir cgi-bin");
system("rmdir htdocs");
system("rm *");
chdir("..");
rmdir($project1);
chdir("/usr/local/bin");
system("ln -s ox_$project1 ox");
system("ln -s ot_$project1 ot");
system("chmod a+rwx ox");
system("chmod a+rwx ot");
return("Project $project1 imported.");
}
}
#************************************************************
sub develop {
my $self = shift;
my $dpath = shift;
chdir("DivBasicF");
my $file;
foreach $file (qw(AutoServer AutoInstall AutoItem
AutoRPC ObjTask ProcessServer TestTree)) {
system("mv $file.pm $file\_orig.pm; ln -s $dpath/$file.pm");
}
}
1;