From 6bdeeacd50d864e195aabc1595b60ded6a1e45c6 Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Tue, 31 Aug 2010 15:54:32 -0500 Subject: [PATCH] don't require WEBGUI_UPGRADE_VERSION if we can detect it from the dir directory --- lib/WebGUI/Upgrade/Script.pm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/WebGUI/Upgrade/Script.pm b/lib/WebGUI/Upgrade/Script.pm index 49ffc40e3..19810e71c 100644 --- a/lib/WebGUI/Upgrade/Script.pm +++ b/lib/WebGUI/Upgrade/Script.pm @@ -41,11 +41,17 @@ my @cleanups; sub _build_exports { my $configFile = $ENV{WEBGUI_CONFIG} or die 'WEBGUI_CONFIG environment variable must be specified'; - my $version = $ENV{WEBGUI_UPGRADE_VERSION} - or die 'WEBGUI_UPGRADE_VERSION must be set'; + my $version = $ENV{WEBGUI_UPGRADE_VERSION}; my $upgrade_file = $caller_upgrade_file; (my $vol, my $dir, my $shortname) = File::Spec->splitpath( $upgrade_file ); $shortname =~ s/\.[^.]*$//; + my $last_dir = (File::Spec->splitdir($dir))[-1]; + if ( !$version && $last_dir =~ /\A\d+\.\d+\.\d+-(\d+\.\d+\.\d+)\z/msx ) { + $version = $1; + } + if (! $version) { + die 'WEBGUI_UPGRADE_VERSION must be set'; + } # need to be able to reference these directly in the cleanup code my $session;