Index: trunk/tools/mwmultiversion/multiversion/checkoutMediaWiki.php |
— | — | @@ -1,125 +0,0 @@ |
2 | | -<?php |
3 | | -if ( php_sapi_name() !== 'cli' ) { |
4 | | - die( "This script can only be run from the command line.\n" ); |
5 | | -} |
6 | | - |
7 | | -error_reporting( E_ALL ); |
8 | | - |
9 | | -/** |
10 | | - * Automatically SVN checkout a MediaWiki version and do some basic wmf setup. |
11 | | - * LocalSettings.php will be created (which loads CommonSettings.php) and verious |
12 | | - * symlinks will also be created. |
13 | | - * |
14 | | - * The first argument is the SVN directory (relative to mediawiki/branches/wmf). |
15 | | - * This is typically a version of the format "X.XXwmfX" ("e.g. 1.17wmf1"). |
16 | | - * The second argument is the target path (relative to /home/wikipedia/common/) |
17 | | - * to store local copy of the SVN checkout. This is typically of the format "php-X.XX". |
18 | | - * |
19 | | - * The script will not run if files already existing in the target directory. |
20 | | - * Also, assume the user running this script must have an SVN account |
21 | | - * with the SSH agent/key available. |
22 | | - * |
23 | | - * @return void |
24 | | - */ |
25 | | -function checkoutMediaWiki() { |
26 | | - global $argv; |
27 | | - $commonDir = '/home/wikipedia/common'; |
28 | | - |
29 | | - $argsValid = false; |
30 | | - if ( count( $argv ) >= 3 ) { |
31 | | - $svnVersion = $argv[1]; // e.g. "X.XXwmfX" |
32 | | - $dstVersion = $argv[2]; // e.g. "php-X.XX" |
33 | | - if ( preg_match( '/^php-(\d+\.\d+|trunk)$/', $dstVersion, $m ) ) { |
34 | | - $dstVersionNum = $m[1]; |
35 | | - $argsValid = true; |
36 | | - } |
37 | | - } |
38 | | - |
39 | | - if ( !$argsValid ) { |
40 | | - die( "Usage: checkoutMediaWiki.php X.XXwmfX php-X.XX\n" ); |
41 | | - } |
42 | | - |
43 | | - # The url to SVN to checkout from |
44 | | - $source = "svn+ssh://svn.wikimedia.org/svnroot/mediawiki/branches/wmf/$svnVersion"; |
45 | | - |
46 | | - # Create the destination path to SVN checkout to... |
47 | | - $destIP = "$commonDir/$dstVersion"; |
48 | | - if ( file_exists( $destIP ) ) { |
49 | | - die( "Cannot checkout, the directory $destIP already exists.\n" ); |
50 | | - } |
51 | | - print "Creating checkout directory $destIP..."; |
52 | | - mkdir( $destIP, 0775 ); |
53 | | - print "done.\n"; |
54 | | - |
55 | | - print "Checking out $source to $destIP...\n"; |
56 | | - # Checkout the SVN directory... |
57 | | - $retval = 1; // error by default? |
58 | | - passthru( "svn checkout $source $destIP", $retval ); |
59 | | - if ( $retval !== 0 ) { |
60 | | - rmdir( $destIP ); // rollback |
61 | | - die( "\nUnable to checkout SVN path.\n" ); |
62 | | - } |
63 | | - print "...SVN checkout done.\n"; |
64 | | - |
65 | | - $localSettingsCode = <<<EOT |
66 | | -<?php |
67 | | -# WARNING: This file is publically viewable on the web. Do not put private data here. |
68 | | -if ( defined('TESTWIKI') ) { |
69 | | - include_once( "/home/wikipedia/common/wmf-config/CommonSettings.php" ); |
70 | | -} else { |
71 | | - include_once( "/apache/common/wmf-config/CommonSettings.php" ); |
72 | | -} |
73 | | -EOT; |
74 | | - |
75 | | - # Create LocalSettings.php stub... |
76 | | - $path = "$destIP/LocalSettings.php"; |
77 | | - if ( !file_exists( $path ) ) { |
78 | | - if ( file_put_contents( $path, $localSettingsCode ) ) { |
79 | | - print "Created LocalSettings.php file.\n"; |
80 | | - } |
81 | | - } else { |
82 | | - print "File already exists: $path\n"; |
83 | | - } |
84 | | - |
85 | | - # Create symlink to wmf-config/AdminSettings.php... |
86 | | - $path = "$destIP/AdminSettings.php"; |
87 | | - if ( !file_exists( $path ) ) { |
88 | | - if ( symlink( "../wmf-config/AdminSettings.php", $path ) ) { |
89 | | - print "Created AdminSettings.php symlink.\n"; |
90 | | - } |
91 | | - } else { |
92 | | - print "File already exists: $path\n"; |
93 | | - } |
94 | | - |
95 | | - # Create symlink to wmf-config/StartProfiler.php... |
96 | | - $path = "$destIP/StartProfiler.php"; |
97 | | - if ( !file_exists( $path ) ) { |
98 | | - if ( symlink( "../wmf-config/StartProfiler.php", $path ) ) { |
99 | | - print "Created StartProfiler.php symlink.\n"; |
100 | | - } |
101 | | - } else { |
102 | | - print "File already exists: $path\n"; |
103 | | - } |
104 | | - |
105 | | - # Create bits.wikimedia.org symlinks... |
106 | | - $path = "$commonDir/docroot/bits/skins-$dstVersionNum"; |
107 | | - if ( !file_exists( $path ) ) { |
108 | | - if ( symlink( "/usr/local/apache/common/php-$dstVersionNum/skins/", $path ) ) { |
109 | | - print "Created skins-$dstVersionNum symlink.\n"; |
110 | | - } |
111 | | - } else { |
112 | | - print "File already exists: $path\n"; |
113 | | - } |
114 | | - $path = "$commonDir/docroot/bits/w/extensions-$dstVersionNum"; |
115 | | - if ( !file_exists( $path ) ) { |
116 | | - if ( symlink( "/usr/local/apache/common/php-$dstVersionNum/extensions", $path ) ) { |
117 | | - print "Created w/extensions-$dstVersionNum symlink.\n"; |
118 | | - } |
119 | | - } else { |
120 | | - print "File already exists: $path\n"; |
121 | | - } |
122 | | - |
123 | | - print "MediaWiki $dstVersionNum, from $svnVersion, successfully checked out.\n"; |
124 | | -} |
125 | | - |
126 | | -checkoutMediaWiki(); |
Index: trunk/tools/mwmultiversion/multiversion/activeMWVersions |
— | — | @@ -1,6 +1,5 @@ |
2 | 2 | #!/usr/bin/env php |
3 | 3 | <?php |
4 | | -error_reporting( E_ALL ); |
5 | 4 | /* |
6 | 5 | * Returns a space separated list of all active MW versions (e.g. "x.xx"). |
7 | 6 | * Versions are read from /usr/local/apache/common-local/wikiversions.cdb. |
Index: trunk/tools/mwmultiversion/multiversion/checkoutMediaWiki |
— | — | @@ -0,0 +1,121 @@ |
| 2 | +#!/usr/bin/env php |
| 3 | +<?php |
| 4 | +error_reporting( E_ALL ); |
| 5 | +/** |
| 6 | + * Automatically SVN checkout a MediaWiki version and do some basic wmf setup. |
| 7 | + * LocalSettings.php will be created (which loads CommonSettings.php) and verious |
| 8 | + * symlinks will also be created. |
| 9 | + * |
| 10 | + * The first argument is the SVN directory (relative to mediawiki/branches/wmf). |
| 11 | + * This is typically a version of the format "X.XXwmfX" ("e.g. 1.17wmf1"). |
| 12 | + * The second argument is the target path (relative to /home/wikipedia/common/) |
| 13 | + * to store local copy of the SVN checkout. This is typically of the format "php-X.XX". |
| 14 | + * |
| 15 | + * The script will not run if files already existing in the target directory. |
| 16 | + * Also, assume the user running this script must have an SVN account |
| 17 | + * with the SSH agent/key available. |
| 18 | + * |
| 19 | + * @return void |
| 20 | + */ |
| 21 | +function checkoutMediaWiki() { |
| 22 | + global $argv; |
| 23 | + $commonDir = '/home/wikipedia/common'; |
| 24 | + |
| 25 | + $argsValid = false; |
| 26 | + if ( count( $argv ) >= 3 ) { |
| 27 | + $svnVersion = $argv[1]; // e.g. "X.XXwmfX" |
| 28 | + $dstVersion = $argv[2]; // e.g. "php-X.XX" |
| 29 | + if ( preg_match( '/^php-(\d+\.\d+|trunk)$/', $dstVersion, $m ) ) { |
| 30 | + $dstVersionNum = $m[1]; |
| 31 | + $argsValid = true; |
| 32 | + } |
| 33 | + } |
| 34 | + |
| 35 | + if ( !$argsValid ) { |
| 36 | + die( "Usage: checkoutMediaWiki.php X.XXwmfX php-X.XX\n" ); |
| 37 | + } |
| 38 | + |
| 39 | + # The url to SVN to checkout from |
| 40 | + $source = "svn+ssh://svn.wikimedia.org/svnroot/mediawiki/branches/wmf/$svnVersion"; |
| 41 | + |
| 42 | + # Create the destination path to SVN checkout to... |
| 43 | + $destIP = "$commonDir/$dstVersion"; |
| 44 | + if ( file_exists( $destIP ) ) { |
| 45 | + die( "Cannot checkout, the directory $destIP already exists.\n" ); |
| 46 | + } |
| 47 | + print "Creating checkout directory $destIP..."; |
| 48 | + mkdir( $destIP, 0775 ); |
| 49 | + print "done.\n"; |
| 50 | + |
| 51 | + print "Checking out $source to $destIP...\n"; |
| 52 | + # Checkout the SVN directory... |
| 53 | + $retval = 1; // error by default? |
| 54 | + passthru( "svn checkout $source $destIP", $retval ); |
| 55 | + if ( $retval !== 0 ) { |
| 56 | + rmdir( $destIP ); // rollback |
| 57 | + die( "\nUnable to checkout SVN path.\n" ); |
| 58 | + } |
| 59 | + print "...SVN checkout done.\n"; |
| 60 | + |
| 61 | + $localSettingsCode = <<<EOT |
| 62 | +<?php |
| 63 | +# WARNING: This file is publically viewable on the web. Do not put private data here. |
| 64 | +if ( defined('TESTWIKI') ) { |
| 65 | + include_once( "/home/wikipedia/common/wmf-config/CommonSettings.php" ); |
| 66 | +} else { |
| 67 | + include_once( "/apache/common/wmf-config/CommonSettings.php" ); |
| 68 | +} |
| 69 | +EOT; |
| 70 | + |
| 71 | + # Create LocalSettings.php stub... |
| 72 | + $path = "$destIP/LocalSettings.php"; |
| 73 | + if ( !file_exists( $path ) ) { |
| 74 | + if ( file_put_contents( $path, $localSettingsCode ) ) { |
| 75 | + print "Created LocalSettings.php file.\n"; |
| 76 | + } |
| 77 | + } else { |
| 78 | + print "File already exists: $path\n"; |
| 79 | + } |
| 80 | + |
| 81 | + # Create symlink to wmf-config/AdminSettings.php... |
| 82 | + $path = "$destIP/AdminSettings.php"; |
| 83 | + if ( !file_exists( $path ) ) { |
| 84 | + if ( symlink( "../wmf-config/AdminSettings.php", $path ) ) { |
| 85 | + print "Created AdminSettings.php symlink.\n"; |
| 86 | + } |
| 87 | + } else { |
| 88 | + print "File already exists: $path\n"; |
| 89 | + } |
| 90 | + |
| 91 | + # Create symlink to wmf-config/StartProfiler.php... |
| 92 | + $path = "$destIP/StartProfiler.php"; |
| 93 | + if ( !file_exists( $path ) ) { |
| 94 | + if ( symlink( "../wmf-config/StartProfiler.php", $path ) ) { |
| 95 | + print "Created StartProfiler.php symlink.\n"; |
| 96 | + } |
| 97 | + } else { |
| 98 | + print "File already exists: $path\n"; |
| 99 | + } |
| 100 | + |
| 101 | + # Create bits.wikimedia.org symlinks... |
| 102 | + $path = "$commonDir/docroot/bits/skins-$dstVersionNum"; |
| 103 | + if ( !file_exists( $path ) ) { |
| 104 | + if ( symlink( "/usr/local/apache/common/php-$dstVersionNum/skins/", $path ) ) { |
| 105 | + print "Created skins-$dstVersionNum symlink.\n"; |
| 106 | + } |
| 107 | + } else { |
| 108 | + print "File already exists: $path\n"; |
| 109 | + } |
| 110 | + $path = "$commonDir/docroot/bits/w/extensions-$dstVersionNum"; |
| 111 | + if ( !file_exists( $path ) ) { |
| 112 | + if ( symlink( "/usr/local/apache/common/php-$dstVersionNum/extensions", $path ) ) { |
| 113 | + print "Created w/extensions-$dstVersionNum symlink.\n"; |
| 114 | + } |
| 115 | + } else { |
| 116 | + print "File already exists: $path\n"; |
| 117 | + } |
| 118 | + |
| 119 | + print "MediaWiki $dstVersionNum, from $svnVersion, successfully checked out.\n"; |
| 120 | +} |
| 121 | + |
| 122 | +checkoutMediaWiki(); |
Property changes on: trunk/tools/mwmultiversion/multiversion/checkoutMediaWiki |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 123 | + native |