Jump to:

22993 Posts in 11843 Topics by 2828 members

General Questions

SilverStripe Forums » General Questions » Written a script to update SVN SS checkouts

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

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

Page: 1
Go to End
Author Topic: 1548 Views
  • D.K.
    Avatar
    Community Member
    20 Posts

    Written a script to update SVN SS checkouts Link to this post

    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') {
    print("done\n");
    } 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') {
    print("done\n");
    } 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("$curr_ver\n");

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

    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"); }

    print("\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]... ");
    chdir($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"); }
    chdir('../');
    }

    # 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]... ");
    unlink($cleanup_files[$i]);
    print("done\n");
    }

    # 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");

    1548 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.