1package ConvwatchHelper; 2 3use English; 4use warnings; 5use strict; 6use Cwd; 7use Cwd 'chdir'; 8 9use CallExternals; 10use stringhelper; 11use filehelper; 12use oshelper; 13use loghelper; 14 15BEGIN { 16 use Exporter (); 17 our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); 18 19 $VERSION = 1.00; 20 # if using RCS/CVS, this may be preferred 21 $VERSION = do { my @r = (q$Revision: 1.39 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; # must be all one line, for MakeMaker 22 @ISA = qw(Exporter); 23 @EXPORT = qw(&getQADEVToolsPath &setProjectRoot &getProjectRoot &checkForStop &getSofficeExe &setINPATH); 24 %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ], 25 # your exported package globals go here, 26 # as well as any optionally exported functions 27 @EXPORT_OK = ( ); # qw($Var1 %Hashit &func3); 28} 29 30# ------------------------------------------------------------------------------ 31our $tempprefix; 32 33# sub getTempDir() 34# { 35# my $sTempDir; 36# if (! $tempprefix) 37# { 38# if ($OSNAME eq "MSWin32" || $OSNAME eq "cygwin") 39# { 40# # $tempdir = "C:/gfxcmp/temp"; 41# $tempprefix = "//so-gfxcmp-lin/gfxcmp-data/wntmsci/temp"; 42# } 43# elsif ($OSNAME eq "linux") 44# { 45# $tempprefix = "/net/so-gfxcmp-lin/export/gfxcmp/data/unxlngi/temp"; 46# } 47# elsif ($OSNAME eq "solaris") 48# { 49# # $tempdir = "/space/gfxcmp/temp"; 50# $tempprefix = "/net/so-gfxcmp-lin/export/gfxcmp/data/unxsoli/temp"; 51# } 52# else 53# { 54# print "Error: This environment isn't supported yet.\n"; 55# exit(1); 56# } 57# } 58# $sTempDir = $tempprefix; 59# return $sTempDir; 60# } 61# ------------------------------------------------------------------------------ 62# in filehelper 63# our $programprefix; 64# 65# sub getProgramPrefix($) 66# { 67# my $sDBDistinct = shift; 68# 69# my $sProgramPrefix; 70# if (! $programprefix) 71# { 72# if ($OSNAME eq "MSWin32") 73# { 74# # $programprefix = "C:/gfxcmp/programs"; 75# $programprefix = "C:/gp"; 76# } 77# elsif ($OSNAME eq "linux") 78# { 79# $programprefix = "/space/gfxcmp/programs"; 80# } 81# elsif ($OSNAME eq "solaris") 82# { 83# $programprefix = "/space/gfxcmp/programs"; 84# } 85# else 86# { 87# print "Error: This environment isn't supported yet.\n"; 88# exit(1); 89# } 90# } 91# $sProgramPrefix = appendPath($programprefix, substr($sDBDistinct, 0, 19)); 92# return $sProgramPrefix; 93# } 94# ------------------------------------------------------------------------------ 95sub getQADEVToolsPath() 96{ 97 my $sNewPath = appendPath(getToolsPrefix(), "qadev"); 98 $sNewPath = appendPath($sNewPath, "scripts"); 99 $sNewPath = appendPath($sNewPath, "gfxcmp_ui"); 100 return $sNewPath; 101} 102 103# in filehelper 104# our $toolsprefix; 105# 106# sub getToolsPrefix() 107# { 108# my $sToolsPrefix; 109# if (! $toolsprefix) 110# { 111# if ($OSNAME eq "MSWin32") 112# { 113# $toolsprefix = "C:/gfxcmp/tools"; 114# } 115# elsif ($OSNAME eq "linux") 116# { 117# $toolsprefix = "/space/gfxcmp/tools"; 118# } 119# elsif ($OSNAME eq "solaris") 120# { 121# $toolsprefix = "/space/gfxcmp/tools"; 122# } 123# else 124# { 125# print "Error: This environment isn't supported yet.\n"; 126# exit(1); 127# } 128# } 129# $sToolsPrefix = $toolsprefix; 130# return $sToolsPrefix; 131# } 132# ------------------------------------------------------------------------------ 133our $sProjectRoot; 134sub setProjectRoot($) 135{ 136 $sProjectRoot = shift; 137 log_print "\$sProjectRoot := $sProjectRoot\n"; 138} 139sub getProjectRoot() 140{ 141 if ($sProjectRoot) 142 { 143 return $sProjectRoot; 144 } 145 die "setProjectRoot(PATH) not set.\n"; 146} 147 148our $sINPATH; 149sub setINPATH($) 150{ 151 $sINPATH = shift; 152} 153sub getINPATH() 154{ 155 if ($sINPATH) 156 { 157 return $sINPATH; 158 } 159 die "setINPATH(PATH) not set.\n"; 160} 161our $dataprefix; 162 163# sub getDataPrefix() 164# { 165# my $sDataPrefix; 166# if (! $dataprefix) 167# { 168# if ($OSNAME eq "MSWin32" || $OSNAME eq "cygwin") 169# { 170# # $dataprefix = "C:/gfxcmp/data"; 171# # $dataprefix = "//so-gfxcmp-lin/gfxcmp-data/wntmsci"; 172# $dataprefix = getProjectRoot(); 173# } 174# elsif ($OSNAME eq "linux") 175# { 176# # $dataprefix = "/space/gfxcmp/data"; 177# # $dataprefix = "/net/so-gfxcmp-lin/export/gfxcmp/data/unxlngi"; 178# $dataprefix = getProjectRoot(); 179# } 180# elsif ($OSNAME eq "solaris") 181# { 182# # $dataprefix = "/space/gfxcmp/data"; 183# # $dataprefix = "/net/so-gfxcmp-lin/export/gfxcmp/data/unxsoli"; 184# $dataprefix = getProjectRoot(); 185# } 186# else 187# { 188# print "Error: This environment isn't supported yet.\n"; 189# exit(1); 190# } 191# $dataprefix = appendPath(getProjectRoot(), getINPATH()); 192# $dataprefix = appendPath($dataprefix, "data"); 193# } 194# $sDataPrefix = $dataprefix; 195# return $sDataPrefix; 196# } 197 198# ------------------------------------------------------------------------------ 199 200# sub _shortsleep($) 201# { 202# # sleep 1; 203# select(undef, undef, undef, 0.333); 204# } 205# 206# sub _waitInSeconds($) 207# { 208# my $nLength = shift; 209# my $i; 210# my $j; 211# 212# for ($j=0;$j<$nLength;$j++) 213# { 214# for ($i=0;$i<$j;$i++) 215# { 216# print "."; 217# } 218# for ($i=$j;$i<$nLength;$i++) 219# { 220# print " "; 221# } 222# _shortsleep( 1 ); 223# print "\r"; 224# } 225# 226# for ($j=0;$j<=$nLength;$j++) 227# { 228# for ($i=0;$i<$j;$i++) 229# { 230# print " "; 231# } 232# for ($i=$j;$i<$nLength;$i++) 233# { 234# print "."; 235# } 236# _shortsleep( 1 ); 237# print "\r"; 238# } 239# } 240# 241# sub wait30seconds() 242# { 243# _waitInSeconds(20); 244# _waitInSeconds(20); 245# } 246 247sub checkForStop($) 248{ 249 my $sStopFilename = shift; 250 my $sStopFilePath; 251 if ($OSNAME eq "MSWin32") 252 { 253 $sStopFilePath = "C:/temp/"; 254 } 255 else 256 { 257 $sStopFilePath = "/tmp/"; 258 } 259 my $sStopFile = $sStopFilePath . $sStopFilename; 260 if ( -e "$sStopFile" ) 261 { 262 print "Stop of Convwatch tool forced!\n"; 263 unlink($sStopFile); 264 exit(2); 265 } 266} 267 268# ---------------------------------------------------------------------------------------- 269sub readdirectory($$$); 270 271sub readdirectory($$$) 272{ 273 my $startdir = shift; 274 my $sUserParameter = shift; 275 my $hook = shift; 276 277 my $myfile; 278 279 local *DIR; 280 chdir $startdir; 281 cwd(); 282 283 my $nCountFiles = 0; 284 if (opendir (DIR, $startdir)) # Directory oeffnen 285 { 286 while ($myfile = readdir(DIR)) 287 { # ein filename holen 288 #if (! -l $myfile) # not a link 289 #{ 290 if (-d $myfile ) # is a directory 291 { 292 if ( -l $myfile) 293 { 294 next; 295 } 296 # if ( $myfile eq "help" || 297 # $myfile eq "presets" || 298 # $myfile eq "registry" || 299 # $myfile eq "uno_packages" || 300 # $myfile eq "lib" || 301 # $myfile eq "user_tree" ) 302 # { 303 # next; 304 # } 305 306 if ($myfile ne "." && $myfile ne "..") 307 { 308 my $sNewStartDir = appendPath($startdir, $myfile); # neuen Directorystring erstellen 309 # if ($sNewStartDir =~ "^\/proc" || 310 # $sNewStartDir =~ "^\/dev" || 311 # $sNewStartDir =~ "^\/udev" || 312 # $sNewStartDir =~ "lost+found" ) 313 # { 314 # next; 315 # } 316 # my $sNewSUserParameter = $sUserParameter . $myfile ."/"; 317 # do a recursive call 318 # $nCountFiles++; 319 my $nFileCount = readdirectory($sNewStartDir, $sUserParameter, $hook); 320 # workOnDir($sNewDir, $nFileCount); 321 $nCountFiles += $nFileCount; 322 323 chdir ($startdir); # zurueckwechseln. 324 cwd(); 325 } 326 } 327 else 328 { 329 # File must exist, be a regular file and must not be the $onlyOnFile 330 if (-f $myfile) 331 { 332 # print STDERR " $startdir" . "$myfile\n"; 333 $nCountFiles++; 334 # workOnFile($startdir, $myfile, $destdir); 335 $hook->($startdir, $myfile, $sUserParameter); 336 } 337 } 338 #} 339 #else 340 #{ 341 # print STDERR "linked file: $dir/$myfile\n"; 342 #} 343 } 344 closedir(DIR); 345 } 346 else 347 { 348 print STDERR "could not open $startdir\n"; 349 } 350 return $nCountFiles; 351} 352 353our $lcl_sSofficeBinPath; 354our $lcl_sSofficeBinName; 355 356sub searchSofficeBin($$$) 357{ 358 my $currentDir = shift; 359 my $currentFile = shift; 360 my $sUserParameter = shift; 361 362 if ($currentFile eq $sUserParameter) 363 { 364 my $sSourceFilename; 365 $sSourceFilename = appendPath($currentDir, $currentFile); 366 367 if ( -e "$sSourceFilename" ) 368 { 369 $lcl_sSofficeBinPath = $currentDir; 370 $lcl_sSofficeBinName = $currentFile; 371 } 372 } 373} 374 375# our $lcl_sUnoPkgPath; 376# 377# sub searchUnoPkgBin($$$) 378# { 379# my $currentDir = shift; 380# my $currentFile = shift; 381# my $sUserParameter = shift; 382# 383# if ($currentFile eq $sUserParameter) 384# { 385# my $sSourceFilename; 386# $sSourceFilename = appendPath($currentDir, $currentFile); 387# if ( -e "$sSourceFilename" ) 388# { 389# $lcl_sUnoPkgPath = $currentDir; 390# } 391# } 392# } 393 394# our $lcl_sJARPath; 395 396# sub searchJARFile($$$) 397# { 398# my $currentDir = shift; 399# my $currentFile = shift; 400# my $sUserParameter = shift; 401# 402# if ($currentFile eq $sUserParameter) 403# { 404# my $sSourceFilename; 405# $sSourceFilename = appendPath($currentDir, $currentFile); 406# if ( -e "$sSourceFilename" ) 407# { 408# $lcl_sJARPath = $currentDir; 409# } 410# } 411# } 412 413# return the PATH, where the file was found 414# sub searchForJAR($$) 415# { 416# my $sPathToInstallOffice = shift; 417# my $sJARFileName = shift; 418# 419# my $sCurrentPath = cwd(); 420# 421# $lcl_sJARPath = ""; 422# readdirectory(${sPathToInstallOffice}, ${sJARFileName}, \&searchJARFile); 423# 424# chdir $sCurrentPath; 425# cwd(); 426# 427# return $lcl_sJARPath; 428# } 429 430# sub getUnoPkg($) 431# { 432# my $sPathToInstallOffice = shift; 433# 434# my $sUnoPkgName = "unopkg.bin"; 435# if (isWindowsEnvironment()) 436# { 437# $sUnoPkgName = "unopkg.exe"; 438# } 439# 440# my $sCurrentPath = cwd(); 441# 442# $lcl_sUnoPkgPath = ""; 443# readdirectory(${sPathToInstallOffice}, ${sUnoPkgName}, \&searchUnoPkgBin); 444# 445# chdir $sCurrentPath; 446# cwd(); 447# 448# return ($lcl_sUnoPkgPath, $sUnoPkgName); 449# } 450 451sub getSofficeExe($) 452{ 453 my $sPathToOffice = shift; 454 455 my $sSofficeExeName = "soffice"; 456 if (isWindowsEnvironment()) 457 { 458 $sSofficeExeName = "soffice.exe"; 459 } 460 461 my $sCurrentPath = cwd(); 462 463 $lcl_sSofficeBinPath = ""; 464 $lcl_sSofficeBinName = ""; 465 readdirectory(${sPathToOffice}, ${sSofficeExeName}, \&searchSofficeBin); 466 467 chdir $sCurrentPath; 468 cwd(); 469 470 return ($lcl_sSofficeBinPath, $lcl_sSofficeBinName); 471} 472 473# sub checkOfficeAlreadyInstalled($) 474# { 475# my $sOfficePath = shift; 476# 477# my $sCurrentPath = cwd(); 478# 479# $lcl_sSofficeBinPath = ""; 480# my $sOldOfficePath = appendPath($sOfficePath, "program"); 481# if ( -d "$sOldOfficePath" ) 482# { 483# $sOldOfficePath = appendPath($sOldOfficePath, "soffice.bin"); 484# if ( -e $sOldOfficePath ) 485# { 486# return 1; 487# } 488# } 489# else 490# { 491# if (isWindowsEnvironment()) 492# { 493# my $sThreeLayerOffice = appendPath($sOfficePath, "Sun"); 494# $sThreeLayerOffice = appendPath($sThreeLayerOffice, "StarOffice 9"); 495# $sThreeLayerOffice = appendPath($sThreeLayerOffice, "program"); 496# $sThreeLayerOffice = appendPath($sThreeLayerOffice, "soffice.bin"); 497# 498# if ( -e "$sThreeLayerOffice" ) 499# { 500# return 1; 501# } 502# } 503# else 504# { 505# my $sThreeLayerOffice = appendPath($sOfficePath, "staroffice9"); 506# $sThreeLayerOffice = appendPath($sThreeLayerOffice, "program"); 507# $sThreeLayerOffice = appendPath($sThreeLayerOffice, "soffice.bin"); 508# if ( -e "$sThreeLayerOffice" ) 509# { 510# return 1; 511# } 512# } 513# } 514# 515# # soffice.bin not found in fast path 516# readdirectory($sOfficePath, "soffice.bin", \&searchSofficeBin); 517# chdir $sCurrentPath; 518# cwd(); 519# 520# if ( $lcl_sSofficeBinPath ne "" ) 521# { 522# return 1; 523# } 524# return 0; 525# # this is the old check 526# # my $sOfficePathCheck = appendPath(${sPathToInstallOffice}, "program"); 527# # $sOfficePathCheck = appendPath($sOfficePathCheck, "soffice.bin"); 528# # if ( -e $sOfficePathCheck ) 529# # { 530# # return 1; 531# # } 532# # 533# # # check path system of tree layer office 534# # if ( isWindowsEnvironment() ) 535# # { 536# # $sOfficePathCheck = appendPath(${sPathToInstallOffice}, "Sun"); 537# # if ( ! -e $sOfficePathCheck) 538# # { 539# # # could be an OpenOffice.org 540# # return 0; 541# # } 542# # else 543# # { 544# # 545# # $sOfficePathCheck = appendPath($sOfficePathCheck, "StarOffice 9"); 546# # $sOfficePathCheck = appendPath($sOfficePathCheck, "program"); 547# # $sOfficePathCheck = appendPath($sOfficePathCheck, "soffice.bin"); 548# # if ( -e $sOfficePathCheck ) 549# # { 550# # return 1; 551# # } 552# # print "Error: There exist no Office, maybe an unsupported version?\n"; 553# # } 554# # } 555# # elsif ( isUnixEnvironment() ) 556# # { 557# # $sOfficePathCheck = appendPath(${sPathToInstallOffice}, "staroffice9"); 558# # $sOfficePathCheck = appendPath($sOfficePathCheck, "staroffice9"); 559# # $sOfficePathCheck = appendPath($sOfficePathCheck, "program"); 560# # $sOfficePathCheck = appendPath($sOfficePathCheck, "soffice.bin"); 561# # if ( -e $sOfficePathCheck ) 562# # { 563# # return 1; 564# # } 565# # print "Error: There exist no Office, maybe an unsupported version?\n"; 566# # } 567# # else 568# # { 569# # print "Error: There exist no Office, maybe an unsupported version?\n"; 570# # } 571# # return 0; 572# } 573 5741; 575