Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Written a script to update SVN SS checkouts

Go to End



Community Member, 20 Posts

27 February 2009 at 3:49pm

Edited: 27/02/2009 3:50pm

I've written a Perl script that I use to update my SS install, as well as all the modules. It does many sanity checks, and updates all the modules and the core, and deletes the install files right away. Hope it helps!

BTW, the instructions are right there in the code. You'll need to run it from a shell, from the root of your SS install.

Also, the formatting is messed up, but if you copy and paste, it turns out fine.

#!/usr/bin/perl -w

# update-ss 0.1
# A script to update your SilverStripe installation, if you originally downloaded SS from Subversion.
# By: Daniil Kulchenko
# Licensed under: GPL v3
# Instructions:
# First, change the array below (@modules) to reflect what modules you currently have installed.
# Then, simply run this script (via shell) from the root of your SS installation to update.

#### Change this to reflect the modules that you have installed (the modules you list below must
#### also have been downloaded by SVN, not as a stable tarball) If your modules were not installed
#### with SVN, do not list them here.

@modules = (
    'forum', 'blog', 

## This will only have to be changed if SS adds new files to be cleaned up:
@cleanup_files = (
    'check-php.php', 'config-form.html', 'config-form.css', 'index.html', 'install.php', 'rewritetest.php',

####							     ####
#### You probably won't need to edit anything from here down ####
####							     ####

$successful_update = 0;

print("Welcome to the 'Update Silverstripe via SVN' script.\n\n");

# Check for a SS install

print("Checking for SilverStripe... ");
if(-e 'cms' && -e 'sapphire') {
} else {
    die("failed\n\nPlease run 'update-ss' from the root of your SilverStripe installation via the command-line.\n");

# Check for SVN checkout

print("Checking for SilverStripe SVN... ");
if(-e '.svn') {
} else {
    die("failed\n\nThis script can only be run on a SilverStripe installed from Subversion, or a daily build.\n");

# Pull in versions to check if up-to-date

print("\nPulling local SVN revision number... ");
$curr_ver = `svn info | grep Revision`;
$curr_ver =~ s/Revision..(\d+)\n/$1/;

print("Pulling repo SVN revision number... ");
$repo_ver = `svn info -r HEAD | grep Revision`;
$repo_ver =~ s/Revision..(\d+)\n/$1/;

if($repo_ver == $curr_ver) {
    print("\nSilverStripe up-to-date at version $curr_ver. Nothing to do.\n");
    exit 0;

# Get count of modules provided and count of cleanup files provided

$module_count = scalar(@modules);
$cleanup_count = scalar(@cleanup_files);

# Do a root 'svn up'

print("\nUpdating SilverStripe from version $curr_ver to $repo_ver (this can take a few minutes)... ");
system("svn up 2>>errors 1>>errors") and $successful_update = 1;
if($successful_update == 1) { die("failed\n\nPlease check the file 'errors' for more details."); } else { print("done\n"); }


# Go into each of the modules' directories and do an 'svn up' there

for($i = 0; $i < scalar(@modules); $i++) {
    $iplus = $i + 1;
    print("Updating module $iplus/$module_count: $modules[$i]... ");
    system("svn up 2>>errors 1>>errors") and $successful_update = 1;
    if($successful_update == 1) { die("failed\n\nPlease check the file 'errors' for more details."); } else { print("done\n"); }

# Remove the cleanup file

print("\nRemoving unnecessary files...\n\n");
for($i = 0; $i < $cleanup_count; $i++) {
    $iplus = $i + 1;
    print("Removing file $iplus/$cleanup_count: $cleanup_files[$i]... ");

# Remove the log file

if(-e 'errors') { unlink 'errors'; }

# Finish

print("\nSilverStripe updated successfully to revision $repo_ver. You should probably\nvisit http://www.<yoursite>.com/dev/build/?flush=all to finalize.\n");