mostly complete upgrade system
This commit is contained in:
parent
cf92cb5a4f
commit
1a79d607af
13 changed files with 399 additions and 698 deletions
14
var/upgrades/7.9.8-8.0.0/addMaintenancePageToConfig.pl
Normal file
14
var/upgrades/7.9.8-8.0.0/addMaintenancePageToConfig.pl
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
use WebGUI::Upgrade::Script;
|
||||
|
||||
use File::Basename;
|
||||
use Cwd qw(realpath);
|
||||
use File::Spec::Functions;
|
||||
use WebGUI::Paths;
|
||||
|
||||
report "\tMoving preload files ";
|
||||
|
||||
my $webgui_root = realpath( catdir( dirname( $INC{'WebGUI/Upgrade/Script.pm'} ), updir x 3 ) );
|
||||
|
||||
config->set('maintenancePage', catfile( $webgui_root, 'www', 'maintenance.html' );
|
||||
|
||||
done;
|
||||
35
var/upgrades/7.9.8-8.0.0/migrateToNewCache.pl
Normal file
35
var/upgrades/7.9.8-8.0.0/migrateToNewCache.pl
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
use WebGUI::Upgrade::Script;
|
||||
use Module::Find;
|
||||
|
||||
report "\tMigrating to new cache ";
|
||||
|
||||
rm_lib
|
||||
findallmod('WebGUI::Cache'),
|
||||
'WebGUI::Workflow::Activity::CleanDatabaseCache',
|
||||
'WebGUI::Workflow::Activity::CleanFileCache',
|
||||
;
|
||||
|
||||
config->set("cache", {
|
||||
'driver' => 'FastMmap',
|
||||
'expires_variance' => '0.10',
|
||||
'root_dir' => '/tmp/WebGUICache',
|
||||
});
|
||||
|
||||
config->set('hotSessionFlushToDb', 600);
|
||||
config->delete('disableCache');
|
||||
config->delete('cacheType');
|
||||
config->delete('fileCacheRoot');
|
||||
config->deleteFromArray('workflowActivities/None', 'WebGUI::Workflow::Activity::CleanDatabaseCache');
|
||||
config->deleteFromArray('workflowActivities/None', 'WebGUI::Workflow::Activity::CleanFileCache');
|
||||
|
||||
sql 'DROP TABLE cache';
|
||||
sql 'DELETE FROM WorkflowActivity WHERE className in (?,?)',
|
||||
'WebGUI::Workflow::Activity::CleanDatabaseCache',
|
||||
'WebGUI::Workflow::Activity::CleanFileCache',
|
||||
;
|
||||
sql 'DELETE FROM WorkflowActivityData WHERE activityId IN (?,?)',
|
||||
'pbwfactivity0000000002',
|
||||
'pbwfactivity0000000022',
|
||||
;
|
||||
|
||||
done;
|
||||
20
var/upgrades/7.9.8-8.0.0/moveFileLocations.pl
Normal file
20
var/upgrades/7.9.8-8.0.0/moveFileLocations.pl
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
use WebGUI::Upgrade::Script;
|
||||
|
||||
use File::Basename;
|
||||
use Cwd qw(realpath);
|
||||
use File::Spec::Functions;
|
||||
use WebGUI::Paths;
|
||||
|
||||
report "\tMoving preload files ";
|
||||
|
||||
my $webgui_root = realpath( catdir( dirname( $INC{'WebGUI/Upgrade/Script.pm'} ), updir x 3 ) );
|
||||
|
||||
unlink catfile($webgui_root, 'lib', 'default.ttf');
|
||||
|
||||
unlink catfile($webgui_root, 'sbin', 'preload.custom.example');
|
||||
unlink catfile($webgui_root, 'sbin', 'preload.exclude.example');
|
||||
|
||||
rename catfile($webgui_root, 'sbin', 'preload.custom'), WebGUI::Paths->preloadCustom;
|
||||
rename catfile($webgui_root, 'sbin', 'preload.exclude'), WebGUI::Paths->preloadExclusions;
|
||||
|
||||
done;
|
||||
12
var/upgrades/7.9.8-8.0.0/moveMaintenance.pl
Normal file
12
var/upgrades/7.9.8-8.0.0/moveMaintenance.pl
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
use WebGUI::Upgrade::Script;
|
||||
|
||||
use File::Spec::Functions;
|
||||
use Cwd qw(realpath);
|
||||
|
||||
my $webgui_root = realpath( catdir( dirname( $INC{'WebGUI/Upgrade/Script.pm'} ), (updir) x 3 ) );
|
||||
|
||||
report "\tMoving maintenance file ";
|
||||
|
||||
unlink catfile($webgui_root, 'docs', 'maintenance.html');
|
||||
|
||||
done;
|
||||
|
|
@ -1,117 +1,25 @@
|
|||
#!/usr/bin/env perl
|
||||
use WebGUI::Upgrade::Script;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
#-------------------------------------------------------------------
|
||||
# Please read the legal notices (docs/legal.txt) and the license
|
||||
# (docs/license.txt) that came with this distribution before using
|
||||
# this software.
|
||||
#-------------------------------------------------------------------
|
||||
# http://www.plainblack.com info@plainblack.com
|
||||
#-------------------------------------------------------------------
|
||||
report "\tRunning an upgrade step...";
|
||||
|
||||
use strict;
|
||||
use Getopt::Long;
|
||||
use WebGUI::Paths -inc;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Storage;
|
||||
use WebGUI::Asset;
|
||||
# if (! quiet) { ... }
|
||||
|
||||
# clear_cache;
|
||||
|
||||
my $toVersion = "0.0.0"; # make this match what version you're going to
|
||||
my $quiet; # this line required
|
||||
# my $session = session;
|
||||
# my $config = config;
|
||||
# my $dbh = dbh;
|
||||
# sql 'CREATE TABLE ...';
|
||||
# version_tag "Doing asset work";
|
||||
|
||||
# rm_lib 'WebGUI::Old::Module';
|
||||
|
||||
my $session = start(); # this line required
|
||||
# my $asset = asset('assetId');
|
||||
# my $asset = asset('asset/url');
|
||||
# my $asset = import_node->addChild( ... );
|
||||
# my $assets = root_asset->getLineage( ... );
|
||||
|
||||
# upgrade functions go here
|
||||
# my $file = collateral->file('filename');
|
||||
# import_package 'some_files.wgpkg';
|
||||
|
||||
finish($session); # this line required
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Describe what our function does
|
||||
#sub exampleFunction {
|
||||
# my $session = shift;
|
||||
# print "\tWe're doing some stuff here that you should know about... " unless $quiet;
|
||||
# # and here's our code
|
||||
# print "DONE!\n" unless $quiet;
|
||||
#}
|
||||
|
||||
|
||||
# -------------- DO NOT EDIT BELOW THIS LINE --------------------------------
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Add a package to the import node
|
||||
sub addPackage {
|
||||
my $session = shift;
|
||||
my $file = shift;
|
||||
|
||||
print "\tUpgrading package $file\n" unless $quiet;
|
||||
# Make a storage location for the package
|
||||
my $storage = WebGUI::Storage->createTemp( $session );
|
||||
$storage->addFileFromFilesystem( $file );
|
||||
|
||||
# Import the package into the import node
|
||||
my $package = eval {
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
$node->importPackage( $storage, {
|
||||
overwriteLatest => 1,
|
||||
clearPackageFlag => 1,
|
||||
setDefaultTemplate => 1,
|
||||
} );
|
||||
};
|
||||
|
||||
if ($package eq 'corrupt') {
|
||||
die "Corrupt package found in $file. Stopping upgrade.\n";
|
||||
}
|
||||
if ($@ || !defined $package) {
|
||||
die "Error during package import on $file: $@\nStopping upgrade\n.";
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
#-------------------------------------------------
|
||||
sub start {
|
||||
my $configFile;
|
||||
$|=1; #disable output buffering
|
||||
GetOptions(
|
||||
'configFile=s'=>\$configFile,
|
||||
'quiet'=>\$quiet
|
||||
);
|
||||
my $session = WebGUI::Session->open($configFile);
|
||||
$session->user({userId=>3});
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Upgrade to ".$toVersion});
|
||||
return $session;
|
||||
}
|
||||
|
||||
#-------------------------------------------------
|
||||
sub finish {
|
||||
my $session = shift;
|
||||
updateTemplates($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->commit;
|
||||
$session->db->write("insert into webguiVersion values (".$session->db->quote($toVersion).",'upgrade',".time().")");
|
||||
$session->close();
|
||||
}
|
||||
|
||||
#-------------------------------------------------
|
||||
sub updateTemplates {
|
||||
my $session = shift;
|
||||
return undef unless (-d "packages-".$toVersion);
|
||||
print "\tUpdating packages.\n" unless ($quiet);
|
||||
opendir(DIR,"packages-".$toVersion);
|
||||
my @files = readdir(DIR);
|
||||
closedir(DIR);
|
||||
my $newFolder = undef;
|
||||
foreach my $file (@files) {
|
||||
next unless ($file =~ /\.wgpkg$/);
|
||||
# Fix the filename to include a path
|
||||
$file = "packages-" . $toVersion . "/" . $file;
|
||||
addPackage( $session, $file );
|
||||
}
|
||||
}
|
||||
|
||||
#vim:ft=perl
|
||||
done;
|
||||
|
|
|
|||
|
|
@ -1,172 +0,0 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
|
||||
#-------------------------------------------------------------------
|
||||
# Please read the legal notices (docs/legal.txt) and the license
|
||||
# (docs/license.txt) that came with this distribution before using
|
||||
# this software.
|
||||
#-------------------------------------------------------------------
|
||||
# http://www.plainblack.com info@plainblack.com
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
use strict;
|
||||
use File::Path qw/rmtree/;
|
||||
use Getopt::Long;
|
||||
use WebGUI::Paths -inc;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Storage;
|
||||
use WebGUI::Asset;
|
||||
|
||||
|
||||
my $toVersion = "8.0.0"; # make this match what version you're going to
|
||||
my $quiet; # this line required
|
||||
|
||||
|
||||
my $session = start(); # this line required
|
||||
|
||||
moveMaintenance($session);
|
||||
migrateToNewCache($session);
|
||||
moveFileLocations($session);
|
||||
addMaintenancePageToConfig($session);
|
||||
|
||||
finish($session); # this line required
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
sub migrateToNewCache {
|
||||
my $session = shift;
|
||||
print "\tMigrating to new cache " unless $quiet;
|
||||
rmtree "../../lib/WebGUI/Cache";
|
||||
unlink "../../lib/WebGUI/Workflow/Activity/CleanDatabaseCache.pm";
|
||||
unlink "../../lib/WebGUI/Workflow/Activity/CleanFileCache.pm";
|
||||
my $config = $session->config;
|
||||
$config->set("cache", {
|
||||
"driver" => "FastMmap",
|
||||
"expires_variance" => "0.10",
|
||||
"root_dir" => "/tmp/WebGUICache",
|
||||
});
|
||||
$config->set("hotSessionFlushToDb", 600);
|
||||
$config->delete("disableCache");
|
||||
$config->delete("cacheType");
|
||||
$config->delete("fileCacheRoot");
|
||||
$config->deleteFromArray("workflowActivities/None", "WebGUI::Workflow::Activity::CleanDatabaseCache");
|
||||
$config->deleteFromArray("workflowActivities/None", "WebGUI::Workflow::Activity::CleanFileCache");
|
||||
my $db = $session->db;
|
||||
$db->write("drop table cache");
|
||||
$db->write("delete from WorkflowActivity where className in ('WebGUI::Workflow::Activity::CleanDatabaseCache','WebGUI::Workflow::Activity::CleanFileCache')");
|
||||
$db->write("delete from WorkflowActivityData where activityId in ('pbwfactivity0000000002','pbwfactivity0000000022')");
|
||||
print "DONE!\n" unless $quiet;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
sub moveMaintenance {
|
||||
my $session = shift;
|
||||
print "\tMoving maintenance file " unless $quiet;
|
||||
unlink '../../docs/maintenance.html';
|
||||
print "DONE!\n" unless $quiet;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
sub addMaintenancePageToConfig {
|
||||
my $session = shift;
|
||||
print "\tAdd maintenance page entry to the config file " unless $quiet;
|
||||
$session->config->set('maintenancePage', '/data/WebGUI/www/maintenance.html');
|
||||
print "DONE!\n" unless $quiet;
|
||||
}
|
||||
|
||||
sub moveFileLocations {
|
||||
my $session = shift;
|
||||
print "\tMoving preload files " unless $quiet;
|
||||
unlink '../../sbin/preload.custom.example';
|
||||
rename '../../sbin/preload.custom', File::Spec->catfile(WebGUI::Paths->configBase, 'preload.custom');
|
||||
unlink '../../sbin/preload.exclude.example';
|
||||
rename '../../sbin/preload.exclude', File::Spec->catfile(WebGUI::Paths->configBase, 'preload.exclude');
|
||||
unlink '../../lib/default.ttf';
|
||||
print "Done.\n" unless $quiet;
|
||||
}
|
||||
|
||||
|
||||
# -------------- DO NOT EDIT BELOW THIS LINE --------------------------------
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Add a package to the import node
|
||||
sub addPackage {
|
||||
my $session = shift;
|
||||
my $file = shift;
|
||||
|
||||
# Make a storage location for the package
|
||||
my $storage = WebGUI::Storage->createTemp( $session );
|
||||
$storage->addFileFromFilesystem( $file );
|
||||
|
||||
# Import the package into the import node
|
||||
my $package = eval { WebGUI::Asset->getImportNode($session)->importPackage( $storage ); };
|
||||
|
||||
if ($package eq 'corrupt') {
|
||||
die "Corrupt package found in $file. Stopping upgrade.\n";
|
||||
}
|
||||
if ($@ || !defined $package) {
|
||||
die "Error during package import on $file: $@\nStopping upgrade\n.";
|
||||
}
|
||||
|
||||
# Turn off the package flag, and set the default flag for templates added
|
||||
my $assetIds = $package->getLineage( ['self','descendants'] );
|
||||
for my $assetId ( @{ $assetIds } ) {
|
||||
my $asset = WebGUI::Asset->newByDynamicClass( $session, $assetId );
|
||||
if ( !$asset ) {
|
||||
print "Couldn't instantiate asset with ID '$assetId'. Please check package '$file' for corruption.\n";
|
||||
next;
|
||||
}
|
||||
my $properties = { isPackage => 0 };
|
||||
if ($asset->isa('WebGUI::Asset::Template')) {
|
||||
$properties->{isDefault} = 1;
|
||||
}
|
||||
$asset->update( $properties );
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
#-------------------------------------------------
|
||||
sub start {
|
||||
my $configFile;
|
||||
$|=1; #disable output buffering
|
||||
GetOptions(
|
||||
'configFile=s'=>\$configFile,
|
||||
'quiet'=>\$quiet
|
||||
);
|
||||
my $session = WebGUI::Session->open($configFile);
|
||||
$session->user({userId=>3});
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Upgrade to ".$toVersion});
|
||||
return $session;
|
||||
}
|
||||
|
||||
#-------------------------------------------------
|
||||
sub finish {
|
||||
my $session = shift;
|
||||
updateTemplates($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->commit;
|
||||
$session->db->write("insert into webguiVersion values (".$session->db->quote($toVersion).",'upgrade',".$session->datetime->time().")");
|
||||
$session->close();
|
||||
}
|
||||
|
||||
#-------------------------------------------------
|
||||
sub updateTemplates {
|
||||
my $session = shift;
|
||||
return undef unless (-d "packages-".$toVersion);
|
||||
print "\tUpdating packages.\n" unless ($quiet);
|
||||
opendir(DIR,"packages-".$toVersion);
|
||||
my @files = readdir(DIR);
|
||||
closedir(DIR);
|
||||
my $newFolder = undef;
|
||||
foreach my $file (@files) {
|
||||
next unless ($file =~ /\.wgpkg$/);
|
||||
# Fix the filename to include a path
|
||||
$file = "packages-" . $toVersion . "/" . $file;
|
||||
addPackage( $session, $file );
|
||||
}
|
||||
}
|
||||
|
||||
#vim:ft=perl
|
||||
Loading…
Add table
Add a link
Reference in a new issue