Index: trunk/tools/mwmultiversion/multiversion/populateWikiversions |
— | — | @@ -7,6 +7,7 @@ |
8 | 8 | * This means that all will be configured to run that version. |
9 | 9 | * |
10 | 10 | * The first argument is the version, typically of the format "php-X.XX". |
| 11 | + * The second argument is a confirmation ("confirm"). |
11 | 12 | * |
12 | 13 | * @return void |
13 | 14 | */ |
— | — | @@ -15,9 +16,9 @@ |
16 | 17 | $common = '/home/wikipedia/common'; |
17 | 18 | |
18 | 19 | $argsValid = false; |
19 | | - if ( count( $argv ) >= 2 ) { |
| 20 | + if ( count( $argv ) >= 3 && $argv[2] === 'confirm' ) { |
20 | 21 | $version = $argv[1]; // e.g. "php-X.XX" |
21 | | - if ( preg_match( '/^php-(\d+\.\d+|trunk)$/', $version ) ) { |
| 22 | + if ( preg_match( '/^php-(?:\d+\.\d+|trunk)(?:-\d)?$/', $version ) ) { |
22 | 23 | $argsValid = true; |
23 | 24 | } |
24 | 25 | } |
Index: trunk/tools/mwmultiversion/multiversion/checkoutMediaWiki |
— | — | @@ -32,7 +32,7 @@ |
33 | 33 | } |
34 | 34 | |
35 | 35 | if ( !$argsValid ) { |
36 | | - die( "Usage: checkoutMediaWiki.php X.XXwmfX php-X.XX\n" ); |
| 36 | + die( "Usage: checkoutMediaWiki X.XXwmfX php-X.XX\n" ); |
37 | 37 | } |
38 | 38 | |
39 | 39 | # The url to SVN to checkout from |
Index: trunk/tools/mwmultiversion/multiversion/switchAllMediaWikis |
— | — | @@ -0,0 +1,64 @@ |
| 2 | +#!/usr/bin/env php |
| 3 | +<?php |
| 4 | +error_reporting( E_ALL ); |
| 5 | +/* |
| 6 | + * This script switches all wikis running one version to another version. |
| 7 | + * It merely changes the wikiversions.dat and wikiversions.cdb files on /home, |
| 8 | + * so they will still need to be synced to push the upgrade/downgrade. |
| 9 | + * |
| 10 | + * The first argument is the old version, typically of the format "php-X.XX". |
| 11 | + * If "all" is given, then all wikis will be switched over. |
| 12 | + * The second argument is the new version, typically of the format "php-X.XX". |
| 13 | + * |
| 14 | + * @return void |
| 15 | + */ |
| 16 | +function switchAllMediaWikis() { |
| 17 | + global $argv; |
| 18 | + $common = '/home/wikipedia/common'; |
| 19 | + |
| 20 | + $argsValid = false; |
| 21 | + if ( count( $argv ) >= 3 ) { |
| 22 | + $oldVersion = $argv[1]; // e.g. "php-X.XX" |
| 23 | + $newVersion = $argv[2]; // e.g. "php-X.XX" |
| 24 | + if ( preg_match( '/^php-(?:\d+\.\d+|trunk)(?:-\d)?$/', $newVersion ) ) { |
| 25 | + $argsValid = true; |
| 26 | + } |
| 27 | + } |
| 28 | + |
| 29 | + if ( !$argsValid ) { |
| 30 | + die( "Usage: upgradeMediaWikis php-X.XX php-X.XX\n" ); |
| 31 | + } |
| 32 | + |
| 33 | + $path = "$common/wikiversions.dat"; |
| 34 | + $verList = array_filter( explode( "\n", file_get_contents( $path ) ) ); |
| 35 | + if ( !count( $verList ) ) { |
| 36 | + die( "Unable to read wikiversions.dat.\n" ); |
| 37 | + } |
| 38 | + |
| 39 | + $datList = ""; |
| 40 | + foreach ( $verList as $item ) { |
| 41 | + $items = explode( ' ', $row ); |
| 42 | + # Existing values... |
| 43 | + $dbName = $items[0]; |
| 44 | + $version = $items[1]; |
| 45 | + $extVersion = isset( $items[2] ) ? $items[2] : ''; |
| 46 | + # Update this wiki? |
| 47 | + if ( $version === $oldVersion || $oldVersion === 'all' ) { |
| 48 | + $version = $newVersion; // switch! |
| 49 | + } |
| 50 | + if ( $extVersion !== '' ) { |
| 51 | + $datList .= "{$dbName} {$version} {$extVersion}\n"; |
| 52 | + } else { |
| 53 | + $datList .= "{$dbName} {$version}\n"; |
| 54 | + } |
| 55 | + } |
| 56 | + |
| 57 | + # Create wikiversions.dat... |
| 58 | + if ( !file_put_contents( $path, $datList ) ) { |
| 59 | + die( "Unable to write to wikiversions.dat.\n" ); |
| 60 | + } |
| 61 | + # Rebuild wikiversions.cdb... |
| 62 | + shell_exec( "cd $common/multiversion && ./refreshWikiversionsCDB" ); |
| 63 | +} |
| 64 | + |
| 65 | +switchAllMediaWikis(); |
Property changes on: trunk/tools/mwmultiversion/multiversion/switchAllMediaWikis |
___________________________________________________________________ |
Added: svn:executable |
1 | 66 | + * |