http://www.mediawiki.org/wiki/Special:Code/MediaWiki/100522
Revision: 100522 Author: aaron Date: 2011-10-22 22:41:36 +0000 (Sat, 22 Oct 2011) Log Message: ----------- Added a script to remove symlinks for an obsolete MW version Modified Paths: -------------- trunk/tools/mwmultiversion/multiversion/checkoutMediaWiki Added Paths: ----------- trunk/tools/mwmultiversion/multiversion/deleteMediaWiki Modified: trunk/tools/mwmultiversion/multiversion/checkoutMediaWiki =================================================================== --- trunk/tools/mwmultiversion/multiversion/checkoutMediaWiki 2011-10-22 22:34:46 UTC (rev 100521) +++ trunk/tools/mwmultiversion/multiversion/checkoutMediaWiki 2011-10-22 22:41:36 UTC (rev 100522) @@ -35,13 +35,15 @@ die( "Usage: checkoutMediaWiki X.XXwmfX php-X.XX\n" ); } - echo "Creating new MediaWiki install at $commonHomeDir/$dstVersion...\n\n"; + # MW install path + $destIP = "$commonHomeDir/$dstVersion"; + echo "Creating new MediaWiki install at $destIP...\n\n"; + # The url to SVN to checkout from $source = "svn+ssh://svn.wikimedia.org/svnroot/mediawiki/branches/wmf/$svnVersion"; # Create the destination path to SVN checkout to... - $destIP = "$commonHomeDir/$dstVersion"; if ( file_exists( $destIP ) ) { print "Skipping checkout, the directory $destIP already exists.\n"; } else { Added: trunk/tools/mwmultiversion/multiversion/deleteMediaWiki =================================================================== --- trunk/tools/mwmultiversion/multiversion/deleteMediaWiki (rev 0) +++ trunk/tools/mwmultiversion/multiversion/deleteMediaWiki 2011-10-22 22:41:36 UTC (rev 100522) @@ -0,0 +1,67 @@ +#!/usr/bin/env php +<?php +error_reporting( E_ALL ); +/** + * Delete various symlinks created by checkoutMediaWiki. + * + * The first argument is target path (relative to /home/wikipedia/common/) + * storing the local copy of the SVN checkout. This is typically of the format "php-X.XX". + * + * @return void + */ +function deleteMediaWiki() { + global $argv; + $commonHomeDir = '/home/wikipedia/common'; + + $argsValid = false; + if ( count( $argv ) >= 2 ) { + $dstVersion = $argv[1]; // e.g. "php-X.XX" + if ( preg_match( '/^php-((?:\d+\.\d+|trunk)(?:-\w+)?)$/', $dstVersion, $m ) ) { + $dstVersionNum = $m[1]; // everything after 'php-' + $argsValid = true; + } + } + + if ( !$argsValid ) { + die( "Usage: deleteMediaWiki php-X.XX\n" ); + } + + # MW install path + $destIP = "$commonHomeDir/$dstVersion"; + + echo "Deleting symlink files for MediaWiki install at $destIP...\n\n"; + + # Check the destination path of the SVN checkout... + if ( !file_exists( $destIP ) ) { + die( "No MediaWiki install at $destIP.\n" ); + } + + # Destroy symlinks created by checkoutMediaWiki outside of $destIP + $symlinks = array( + "$commonHomeDir/docroot/bits/skins-$dstVersionNum", + "$commonHomeDir/docroot/bits/w/extensions-$dstVersionNum", + "$commonHomeDir/docroot/secure/skins-$dstVersionNum", + "$commonHomeDir/live-1.5/extensions-$dstVersionNum", + "$commonHomeDir/live-1.5/skins-$dstVersionNum", + "$commonHomeDir/live-1.5/resources-$dstVersionNum" + ); + foreach ( $symlinks as $path ) { + deleteSymlink( $path ); + } + + print "\nReferences to MediaWiki $dstVersionNum deleted.\n"; +} + +function deleteSymlink( $path ) { + if ( !file_exists( $path ) ) { + print "Symlink file already removed: $path\n"; + } elseif ( filetype( $path ) !== 'link' ) { // sanity + print "Expected symlink file is not actually a symlink: $path\n"; + } else { + if ( unlink( $path ) ) { + print "Symlink file removed: $path\n"; + } + } +} + +deleteMediaWiki(); Property changes on: trunk/tools/mwmultiversion/multiversion/deleteMediaWiki ___________________________________________________________________ Added: svn:executable + * Added: svn:eol-style + native _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs