Index: trunk/tools/mwmultiversion/multiversion/refreshWikiversionsCDB |
— | — | @@ -24,8 +24,13 @@ |
25 | 25 | die( "Unable to create wikiversions.cdb.tmp.\n" ); |
26 | 26 | } |
27 | 27 | foreach ( $verList as $row ) { |
28 | | - list( $dbName, $version ) = explode( ' ', $row ); |
29 | | - dba_insert( $dbName, $version, $db ); |
| 28 | + $items = explode( ' ', $row ); |
| 29 | + $dbName = $items[0]; |
| 30 | + $version = $items[1]; |
| 31 | + $extVersion = isset( $items[2] ) ? $items[2] : ''; |
| 32 | + |
| 33 | + dba_insert( "ver:$dbName", $version, $db ); |
| 34 | + dba_insert( "ext:$dbName", $extVersion, $db ); |
30 | 35 | } |
31 | 36 | dba_close( $db ); |
32 | 37 | |
Index: trunk/tools/mwmultiversion/multiversion/activeMWVersions |
— | — | @@ -7,7 +7,9 @@ |
8 | 8 | * |
9 | 9 | * Given --home, versions are instead read from /home/wikipedia/common/wikiversions.cdb. |
10 | 10 | * Given --withdb, each item in the list will be appended with '=' followed by |
11 | | - * the DB name of *some* wiki that uses that version. Used to run maintenance scripts. |
| 11 | + * the DB name of *some* wiki that uses that version. Used to run maintenance scripts. |
| 12 | + * Given --extended, versions will include any extra suffix specified in wikiversions.cdb. |
| 13 | + * This may result in more items being listed than without. |
12 | 14 | * Given --report, error messages would be displayed if this dies. |
13 | 15 | * |
14 | 16 | * @return string |
— | — | @@ -33,7 +35,11 @@ |
34 | 36 | |
35 | 37 | $result = $activeVersions = array(); |
36 | 38 | foreach ( $verList as $item ) { |
37 | | - list( $dbname, $version ) = explode( ' ', $item ); |
| 39 | + $items = explode( ' ', $row ); |
| 40 | + $dbName = $items[0]; |
| 41 | + $version = $items[1]; |
| 42 | + $extVersion = isset( $items[2] ) ? $items[2] : ''; |
| 43 | + |
38 | 44 | if ( substr( $version, 0, 4 ) !== 'php-' ) { |
39 | 45 | if ( in_array( '--report', $options ) ) { |
40 | 46 | echo( "Unable to read wikiversions.dat entry: $version.\n" ); |
— | — | @@ -41,10 +47,15 @@ |
42 | 48 | die( 1 ); |
43 | 49 | } |
44 | 50 | $version = substr( $version, 4 ); // remove 'php-' |
| 51 | + |
| 52 | + if ( $extVersion !== '' && in_array( '--extended', $options ) ) { |
| 53 | + $version .= "-$extVersion"; |
| 54 | + } |
| 55 | + |
45 | 56 | if ( !isset( $activeVersions[$version] ) ) { |
46 | 57 | $activeVersions[$version] = 1; |
47 | 58 | if ( in_array( '--withdb', $options ) ) { |
48 | | - $result[] = "{$version}={$dbname}"; |
| 59 | + $result[] = "{$version}={$dbName}"; |
49 | 60 | } else { |
50 | 61 | $result[] = "{$version}"; |
51 | 62 | } |
Index: trunk/tools/mwmultiversion/multiversion/checkoutMediaWiki |
— | — | @@ -25,7 +25,7 @@ |
26 | 26 | if ( count( $argv ) >= 3 ) { |
27 | 27 | $svnVersion = $argv[1]; // e.g. "X.XXwmfX" |
28 | 28 | $dstVersion = $argv[2]; // e.g. "php-X.XX" |
29 | | - if ( preg_match( '/^php-(\d+\.\d+|trunk)$/', $dstVersion, $m ) ) { |
| 29 | + if ( preg_match( '/^php-((?:\d+\.\d+|trunk)(?:-\d)?)$/', $dstVersion, $m ) ) { |
30 | 30 | $dstVersionNum = $m[1]; |
31 | 31 | $argsValid = true; |
32 | 32 | } |
Index: trunk/tools/mwmultiversion/multiversion/MWMultiVersion.php |
— | — | @@ -12,6 +12,18 @@ |
13 | 13 | * @var string |
14 | 14 | */ |
15 | 15 | private $db; |
| 16 | + /** |
| 17 | + * @var string |
| 18 | + */ |
| 19 | + private $version; |
| 20 | + /** |
| 21 | + * @var string |
| 22 | + */ |
| 23 | + private $extVersion; |
| 24 | + /** |
| 25 | + * @var bool |
| 26 | + */ |
| 27 | + private $versionLoaded = false; |
16 | 28 | |
17 | 29 | /** |
18 | 30 | * To get an inststance of this class, use the statuc helper methods. |
— | — | @@ -155,7 +167,7 @@ |
156 | 168 | $dbname = isset( $argv[2] ) ? $argv[2] : ''; // "script.php --wiki dbname" |
157 | 169 | } elseif ( isset( $argv[1] ) && substr( $argv[1], 0, 7 ) === '--wiki=' ) { |
158 | 170 | $dbname = substr( $argv[1], 7 ); // "script.php --wiki=dbname" |
159 | | - } elseif ( isset( $argv[1] )&& substr( $argv[1], 0, 2 ) !== '--' ) { |
| 171 | + } elseif ( isset( $argv[1] ) && substr( $argv[1], 0, 2 ) !== '--' ) { |
160 | 172 | $dbname = $argv[1]; // "script.php dbname" |
161 | 173 | } elseif ( in_array( $argv[0], self::wikilessScripts() ) ) { |
162 | 174 | # For addwiki.php, the DB doesn't yet exist, and for nextJobDB.php |
— | — | @@ -205,34 +217,75 @@ |
206 | 218 | } |
207 | 219 | |
208 | 220 | /** |
209 | | - * Get the version as specified in a cdb file located |
210 | | - * at /usr/local/apache/common/wikiversions.cdb. |
211 | | - * The key should be the dbname and the version should be the version directory. |
212 | | - * @return String the version directory for this wiki |
| 221 | + * Get the space-seperated list of version params for this wiki. |
| 222 | + * The first item is the MW version and the optional second item |
| 223 | + * an extra version parameter to use for builds and caches. |
| 224 | + * @return void |
213 | 225 | */ |
214 | | - public function getVersion() { |
| 226 | + private function loadVersionInfo() { |
| 227 | + if ( $this->versionLoaded ) { |
| 228 | + return; |
| 229 | + } |
| 230 | + $this->versionLoaded = true; |
| 231 | + |
215 | 232 | $db = dba_open( '/usr/local/apache/common/wikiversions.cdb', 'r', 'cdb' ); |
216 | 233 | if ( $db ) { |
217 | | - $version = dba_fetch( $this->getDatabase(), $db ); |
| 234 | + $version = dba_fetch( "ver:{$this->db}", $db ); |
218 | 235 | if ( $version === false ) { |
219 | | - die( "wikiversions.cdb has no entry for `$db`.\n" ); |
| 236 | + die( "wikiversions.cdb has no version entry for `$db`.\n" ); |
220 | 237 | } elseif ( strpos( $version, 'php-' ) !== 0 ) { |
221 | | - die( "wikiversions.cdb entry does not start with `php-` (got `$version`).\n" ); |
| 238 | + die( "wikiversions.cdb version entry does not start with `php-` (got `$version`).\n" ); |
222 | 239 | } |
| 240 | + $extraVersion = dba_fetch( "ext:{$this->db}", $db ); |
| 241 | + if ( $extraVersion === false ) { |
| 242 | + die( "wikiversions.cdb has no extra version entry for `$db`.\n" ); |
| 243 | + } |
223 | 244 | } else { |
224 | | - //trigger_error( "Unable to open /usr/local/apache/common/wikiversions.cdb. Assuming php-1.17", E_USER_ERROR ); |
| 245 | + //trigger_error( "Unable to open wikiversions.cdb. Assuming php-1.17", E_USER_ERROR ); |
225 | 246 | $version = 'php-1.17'; |
| 247 | + $extraVersion = ''; |
226 | 248 | } |
227 | | - return $version; |
| 249 | + dba_close( $db ); |
| 250 | + |
| 251 | + $this->version = $version; |
| 252 | + $this->extVersion = $extraVersion; |
228 | 253 | } |
229 | 254 | |
230 | 255 | /** |
| 256 | + * Get the version as specified in a cdb file located |
| 257 | + * at /usr/local/apache/common/wikiversions.cdb. |
| 258 | + * Result is of the form "php-X.XX" or "php-trunk". |
| 259 | + * @return String the version directory for this wiki |
| 260 | + */ |
| 261 | + public function getVersion() { |
| 262 | + $this->loadVersionInfo(); |
| 263 | + return $this->version; |
| 264 | + } |
| 265 | + |
| 266 | + /** |
231 | 267 | * Get the version number as specified in a cdb file located |
232 | | - * at /usr/local/apache/common/wikiversions.cdb. |
| 268 | + * at /usr/local/apache/common/wikiversions.cdb. Do not use this |
| 269 | + * to determine the path to cache or binary files, only the core MW code. |
233 | 270 | * @return String the version number for this wiki (e.g. "x.xx" or "trunk") |
234 | 271 | */ |
235 | 272 | public function getVersionNumber() { |
236 | | - list( /*...*/, $ver ) = explode( '-', $this->getVersion(), 2 ); |
| 273 | + $this->loadVersionInfo(); |
| 274 | + return substr( $this->version, 4 ); // remove "php-" |
| 275 | + } |
| 276 | + |
| 277 | + /* |
| 278 | + * Get the version number to use for building caches & binaries for this wiki. |
| 279 | + * Like getVersionNumber() but may have a dash with another string appended. |
| 280 | + * Some wikis may share core MW versions but be using different extension versions. |
| 281 | + * We need to keep the caches and binary builds separate for such wikis. |
| 282 | + * @return String |
| 283 | + */ |
| 284 | + public function getExtendedVersionNumber() { |
| 285 | + $this->loadVersionInfo(); |
| 286 | + $ver = $this->getVersionNumber(); |
| 287 | + if ( $this->extVersion !== '' ) { |
| 288 | + $ver .= "-{$this->extVersion}"; |
| 289 | + } |
237 | 290 | return $ver; |
238 | 291 | } |
239 | 292 | } |
Index: trunk/tools/mwmultiversion/multiversion/MWScript.php |
— | — | @@ -46,5 +46,5 @@ |
47 | 47 | return $file; |
48 | 48 | } |
49 | 49 | |
50 | | -# Run the script! (for HipHip, we will need to shell out here) |
| 50 | +# Run the script! |
51 | 51 | require_once( getMWScriptWithArgs() ); |
Index: trunk/tools/mwmultiversion/scripts/scap |
— | — | @@ -43,6 +43,7 @@ |
44 | 44 | $BINDIR/sync-common |
45 | 45 | |
46 | 46 | |
| 47 | +mwVerDbSets=(`mwversionsinuse --extended --withdb`) |
47 | 48 | # Regenerate the extension message file list for all active MediaWiki versions |
48 | 49 | for i in "${mwVerDbSets[@]}" |
49 | 50 | do |
Index: trunk/tools/mwmultiversion/scripts/sync-l10nupdate |
— | — | @@ -3,11 +3,10 @@ |
4 | 4 | PATH=/bin:/usr/bin:/sbin:/usr/sbin: |
5 | 5 | MWVER="$1" |
6 | 6 | |
7 | | -mwVersionNums=(`mwversionsinuse`) |
| 7 | +mwVersionNums=(`mwversionsinuse --extended`) |
8 | 8 | |
9 | 9 | echo "Synchronizing /home/wikipedia/common/php-$MWVER/cache/l10n to /usr/local/apache/common-local/php-$MWVER/cache/l10n..." |
10 | 10 | echo "mediawiki-installation:" |
11 | 11 | |
12 | 12 | ddsh -cM -g mediawiki-installation \ |
13 | 13 | "sudo -u mwdeploy rsync -a 10.0.5.8::common/php-$MWVER/cache/l10n/ /usr/local/apache/common-local/php-$MWVER/cache/l10n" |
14 | | - |
Index: trunk/tools/mwmultiversion/scripts/l10nupdate |
— | — | @@ -15,7 +15,7 @@ |
16 | 16 | exit 1 |
17 | 17 | fi |
18 | 18 | |
19 | | -mwVerDbSets=(`mwversionsinuse --withdb`) |
| 19 | +mwVerDbSets=(`mwversionsinuse --extended --withdb`) |
20 | 20 | if [ -z "$mwVerDbSets" ]; then |
21 | 21 | /home/wikipedia/bin/dologmsg "!log LocalisationUpdate failed" |
22 | 22 | echo "FAILED" |