Module: tools Branch: master Commit: ec745f28cd7491880662fc6fe0119d2d7ed4d11e URL: http://source.winehq.org/git/tools.git/?a=commit;h=ec745f28cd7491880662fc6fe...
Author: Francois Gouget fgouget@codeweavers.com Date: Mon Oct 29 20:10:36 2012 +0100
testbot: Autodetect where the WineTestBot is running from.
This avoids having to hardcode paths in the configuration file.
---
testbot/bin/CheckForWinetestUpdate.pl | 9 +++++---- testbot/bin/Engine.pl | 9 +++++---- testbot/bin/Janitor.pl | 9 +++++---- testbot/bin/PingEngine.pl | 9 +++++---- testbot/bin/RevertVM.pl | 9 +++++---- testbot/bin/WinePatchesMLSubmit.pl | 9 +++++---- testbot/bin/WinePatchesWebGet.pl | 9 +++++---- testbot/bin/WinePatchesWebNotify.pl | 9 +++++---- testbot/bin/WineRunBuild.pl | 9 +++++---- testbot/bin/WineRunReconfig.pl | 9 +++++---- testbot/bin/WineRunTask.pl | 9 +++++---- testbot/bin/WineSendLog.pl | 9 +++++---- testbot/bin/build/Build.pl | 11 ++++++----- testbot/bin/build/Reconfig.pl | 13 +++++++------ testbot/doc/vhost_winetestbot.conf | 6 +++++- testbot/lib/WineTestBot/Config.pm | 10 +++++----- testbot/scripts/CheckWineTestBot.pl | 9 +++++---- testbot/scripts/TestAgent | 17 +++++++++-------- 18 files changed, 97 insertions(+), 77 deletions(-)
diff --git a/testbot/bin/CheckForWinetestUpdate.pl b/testbot/bin/CheckForWinetestUpdate.pl index de8befb..5ca5aa9 100755 --- a/testbot/bin/CheckForWinetestUpdate.pl +++ b/testbot/bin/CheckForWinetestUpdate.pl @@ -22,13 +22,14 @@
use strict;
-my $Dir; sub BEGIN { - $0 =~ m=^(.*)/[^/]*$=; - $Dir = $1; + if ($0 =~ m=^(.*)/[^/]+/[^/]+$=) + { + $::RootDir = $1; + unshift @INC, "$::RootDir/lib"; + } } -use lib "$Dir/../lib";
use Fcntl; use File::Compare; diff --git a/testbot/bin/Engine.pl b/testbot/bin/Engine.pl index 7834619..b3cfbee 100755 --- a/testbot/bin/Engine.pl +++ b/testbot/bin/Engine.pl @@ -20,13 +20,14 @@
use strict;
-my $Dir; sub BEGIN { - $0 =~ m=^(.*)/[^/]*$=; - $Dir = $1; + if ($0 =~ m=^(.*)/[^/]+/[^/]+$=) + { + $::RootDir = $1; + unshift @INC, "$::RootDir/lib"; + } } -use lib "$Dir/../lib";
use Errno qw(EAGAIN); use Fcntl; diff --git a/testbot/bin/Janitor.pl b/testbot/bin/Janitor.pl index 6ae3c8f..6c398d7 100755 --- a/testbot/bin/Janitor.pl +++ b/testbot/bin/Janitor.pl @@ -21,13 +21,14 @@
use strict;
-my $Dir; sub BEGIN { - $0 =~ m=^(.*)/[^/]*$=; - $Dir = $1; + if ($0 =~ m=^(.*)/[^/]+/[^/]+$=) + { + $::RootDir = $1; + unshift @INC, "$::RootDir/lib"; + } } -use lib "$Dir/../lib";
use WineTestBot::Config; use WineTestBot::Jobs; diff --git a/testbot/bin/PingEngine.pl b/testbot/bin/PingEngine.pl index 4faddf6..ef43807 100755 --- a/testbot/bin/PingEngine.pl +++ b/testbot/bin/PingEngine.pl @@ -20,13 +20,14 @@
use strict;
-my $Dir; sub BEGIN { - $0 =~ m=^(.*)/[^/]*$=; - $Dir = $1; + if ($0 =~ m=^(.*)/[^/]+/[^/]+$=) + { + $::RootDir = $1; + unshift @INC, "$::RootDir/lib"; + } } -use lib "$Dir/../lib";
use WineTestBot::Engine::Notify;
diff --git a/testbot/bin/RevertVM.pl b/testbot/bin/RevertVM.pl index ee46218..7104a28 100755 --- a/testbot/bin/RevertVM.pl +++ b/testbot/bin/RevertVM.pl @@ -23,13 +23,14 @@
use strict;
-my $Dir; sub BEGIN { - $0 =~ m=^(.*)/[^/]*$=; - $Dir = $1; + if ($0 =~ m=^(.*)/[^/]+/[^/]+$=) + { + $::RootDir = $1; + unshift @INC, "$::RootDir/lib"; + } } -use lib "$Dir/../lib";
use WineTestBot::Config; use WineTestBot::Log; diff --git a/testbot/bin/WinePatchesMLSubmit.pl b/testbot/bin/WinePatchesMLSubmit.pl index 9ab8b3c..7ee4ecf 100755 --- a/testbot/bin/WinePatchesMLSubmit.pl +++ b/testbot/bin/WinePatchesMLSubmit.pl @@ -22,13 +22,14 @@
use strict;
-my $Dir; sub BEGIN { - $0 =~ m=^(.*)/[^/]*$=; - $Dir = $1; + if ($0 =~ m=^(.*)/[^/]+/[^/]+$=) + { + $::RootDir = $1; + unshift @INC, "$::RootDir/lib"; + } } -use lib "$Dir/../lib";
use File::Copy; use WineTestBot::Config; diff --git a/testbot/bin/WinePatchesWebGet.pl b/testbot/bin/WinePatchesWebGet.pl index d6b3f2b..ed84a50 100755 --- a/testbot/bin/WinePatchesWebGet.pl +++ b/testbot/bin/WinePatchesWebGet.pl @@ -21,13 +21,14 @@
use strict;
-my $Dir; sub BEGIN { - $0 =~ m=^(.*)/[^/]*$=; - $Dir = $1; + if ($0 =~ m=^(.*)/[^/]+/[^/]+$=) + { + $::RootDir = $1; + unshift @INC, "$::RootDir/lib"; + } } -use lib "$Dir/../lib";
use LWP::UserAgent; use HTTP::Request; diff --git a/testbot/bin/WinePatchesWebNotify.pl b/testbot/bin/WinePatchesWebNotify.pl index 185a0f1..6940d76 100755 --- a/testbot/bin/WinePatchesWebNotify.pl +++ b/testbot/bin/WinePatchesWebNotify.pl @@ -21,13 +21,14 @@
use strict;
-my $Dir; sub BEGIN { - $0 =~ m=^(.*)/[^/]*$=; - $Dir = $1; + if ($0 =~ m=^(.*)/[^/]+/[^/]+$=) + { + $::RootDir = $1; + unshift @INC, "$::RootDir/lib"; + } } -use lib "$Dir/../lib";
use File::Copy; use WineTestBot::Config; diff --git a/testbot/bin/WineRunBuild.pl b/testbot/bin/WineRunBuild.pl index 86f03c7..cc0746f 100755 --- a/testbot/bin/WineRunBuild.pl +++ b/testbot/bin/WineRunBuild.pl @@ -21,13 +21,14 @@
use strict;
-my $Dir; sub BEGIN { - $0 =~ m=^(.*)/[^/]*$=; - $Dir = $1; + if ($0 =~ m=^(.*)/[^/]+/[^/]+$=) + { + $::RootDir = $1; + unshift @INC, "$::RootDir/lib"; + } } -use lib "$Dir/../lib";
use WineTestBot::Config; use WineTestBot::Jobs; diff --git a/testbot/bin/WineRunReconfig.pl b/testbot/bin/WineRunReconfig.pl index 89fe3da..9cc1e5e 100755 --- a/testbot/bin/WineRunReconfig.pl +++ b/testbot/bin/WineRunReconfig.pl @@ -21,13 +21,14 @@
use strict;
-my $Dir; sub BEGIN { - $0 =~ m=^(.*)/[^/]*$=; - $Dir = $1; + if ($0 =~ m=^(.*)/[^/]+/[^/]+$=) + { + $::RootDir = $1; + unshift @INC, "$::RootDir/lib"; + } } -use lib "$Dir/../lib";
use WineTestBot::Config; use WineTestBot::Jobs; diff --git a/testbot/bin/WineRunTask.pl b/testbot/bin/WineRunTask.pl index bfbffe8..9ec499f 100755 --- a/testbot/bin/WineRunTask.pl +++ b/testbot/bin/WineRunTask.pl @@ -20,13 +20,14 @@
use strict;
-my $Dir; sub BEGIN { - $0 =~ m=^(.*)/[^/]*$=; - $Dir = $1; + if ($0 =~ m=^(.*)/[^/]+/[^/]+$=) + { + $::RootDir = $1; + unshift @INC, "$::RootDir/lib"; + } } -use lib "$Dir/../lib";
use POSIX qw(:fcntl_h); use WineTestBot::Config; diff --git a/testbot/bin/WineSendLog.pl b/testbot/bin/WineSendLog.pl index 95814fe..768e129 100755 --- a/testbot/bin/WineSendLog.pl +++ b/testbot/bin/WineSendLog.pl @@ -21,13 +21,14 @@
use strict;
-my $Dir; sub BEGIN { - $0 =~ m=^(.*)/[^/]*$=; - $Dir = $1; + if ($0 =~ m=^(.*)/[^/]+/[^/]+$=) + { + $::RootDir = $1; + unshift @INC, "$::RootDir/lib"; + } } -use lib "$Dir/../lib";
use Algorithm::Diff; use WineTestBot::Config; diff --git a/testbot/bin/build/Build.pl b/testbot/bin/build/Build.pl index a37537e..7a20c1a 100755 --- a/testbot/bin/build/Build.pl +++ b/testbot/bin/build/Build.pl @@ -22,14 +22,15 @@
use strict;
-my $Dir; sub BEGIN { - $main::BuildEnv = 1; - $0 =~ m=^(.*)/[^/]*$=; - $Dir = $1; + if ($0 =~ m=^(.*)/[^/]+/[^/]+/[^/]+$=) + { + $::RootDir = $1; + unshift @INC, "$::RootDir/lib"; + } + $::BuildEnv = 1; } -use lib "$Dir/../../lib";
use WineTestBot::Config;
diff --git a/testbot/bin/build/Reconfig.pl b/testbot/bin/build/Reconfig.pl index daa03b1..89296bc 100755 --- a/testbot/bin/build/Reconfig.pl +++ b/testbot/bin/build/Reconfig.pl @@ -22,14 +22,15 @@
use strict;
-my $Dir; sub BEGIN { - $main::BuildEnv = 1; - $0 =~ m=^(.*)/[^/]*$=; - $Dir = $1; -} -use lib "$Dir/../../lib"; + if ($0 =~ m=^(.*)/[^/]+/[^/]+/[^/]+$=) + { + $::RootDir = $1; + unshift @INC, "$::RootDir/lib"; + } + $::BuildEnv = 1; + }
use WineTestBot::Config;
diff --git a/testbot/doc/vhost_winetestbot.conf b/testbot/doc/vhost_winetestbot.conf index 9c53876..735292e 100644 --- a/testbot/doc/vhost_winetestbot.conf +++ b/testbot/doc/vhost_winetestbot.conf @@ -7,7 +7,11 @@ PerlSwitches -Tw <Perl> use strict; - use lib qw(/home/winehq/tools/testbot/lib); + BEGIN + { + $::RootDir = "/home/winehq/tools/testbot"; + unshift @INC, "$::RootDir/lib"; + } use ObjectModel::CGI::Page; use WineTestBot::CGI::PageBase; SetPageBaseCreator(&CreatePageBase); diff --git a/testbot/lib/WineTestBot/Config.pm b/testbot/lib/WineTestBot/Config.pm index 98fcbb0..aa9f3e2 100644 --- a/testbot/lib/WineTestBot/Config.pm +++ b/testbot/lib/WineTestBot/Config.pm @@ -48,9 +48,9 @@ require Exporter; $JobPurgeDays $JobArchiveDays $WebHostName); @EXPORT_OK = qw($DbDataSource $DbUsername $DbPassword);
-$LogDir = "/home/winehq/tools/testbot/var"; -$DataDir = "/home/winehq/tools/testbot/var"; -$BinDir = "/home/winehq/tools/testbot/bin"; +$LogDir = "$::RootDir/var"; +$DataDir = "$::RootDir/var"; +$BinDir = "$::RootDir/bin";
$MaxRevertingVMs = 1; $MaxRunningVMs = 2; @@ -77,9 +77,9 @@ $LDAPEMailAttribute = undef; $JobPurgeDays = 7; $JobArchiveDays = 0;
-if (!$main::BuildEnv) +if (!$::BuildEnv) { - $main::BuildEnv = 0; + $::BuildEnv = 0; eval 'require "WineTestBot/ConfigLocal.pl";'; if ($@) { diff --git a/testbot/scripts/CheckWineTestBot.pl b/testbot/scripts/CheckWineTestBot.pl index f6f0666..b749eff 100755 --- a/testbot/scripts/CheckWineTestBot.pl +++ b/testbot/scripts/CheckWineTestBot.pl @@ -20,13 +20,14 @@
use strict;
-my $Dir; sub BEGIN { - $0 =~ m=^(.*)/[^/]*$=; - $Dir = $1; + if ($0 =~ m=^(.*)/[^/]+/[^/]+$=) + { + $::RootDir = $1; + unshift @INC, "$::RootDir/lib"; + } } -use lib "$Dir/../lib";
use WineTestBot::Config; use WineTestBot::Engine::Notify; diff --git a/testbot/scripts/TestAgent b/testbot/scripts/TestAgent index 2e9850d..a16bd5f 100755 --- a/testbot/scripts/TestAgent +++ b/testbot/scripts/TestAgent @@ -18,19 +18,20 @@ # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA -use strict; - -my $name0=$0; -$name0 =~ s+^.*/++;
+use strict;
-my $Dir; sub BEGIN { - $0 =~ m=^(.*)/[^/]*$=; - $Dir = $1; + if ($0 =~ m=^(.*)/[^/]+/[^/]+$=) + { + $::RootDir = $1; + unshift @INC, "$::RootDir/lib"; + } } -use lib "$Dir/../lib"; + +my $name0=$0; +$name0 =~ s+^.*/++;
use WineTestBot::Config; use WineTestBot::TestAgent;