Index: trunk/tools/mwmultiversion/populateWikiversionCDB.php |
— | — | @@ -0,0 +1,49 @@ |
| 2 | +<?php |
| 3 | +if ( php_sapi_name() !== 'cli' ) { |
| 4 | + die( 'This script can only be run from the command line.' ); |
| 5 | +} |
| 6 | + |
| 7 | +error_reporting( E_ALL ); |
| 8 | + |
| 9 | +/* |
| 10 | + * Populate wikiversions.cdb file using all the items in all.dblist |
| 11 | + * as keys, each having a value of the specified MediaWiki version. |
| 12 | + * This means that all will be configured to run that version. |
| 13 | + * |
| 14 | + * The first argument is the version, typically of the format "php-X.XX". |
| 15 | + * |
| 16 | + * @return void |
| 17 | + */ |
| 18 | +function populateWikiversionsCDB() { |
| 19 | + global $argv; |
| 20 | + |
| 21 | + $argsValid = false; |
| 22 | + if ( count( $argv ) >= 2 ) { |
| 23 | + $version = $argv[1]; // e.g. "php-X.XX" |
| 24 | + if ( preg_match( '/^php-(\d+\.\d+|trunk)$/', $version ) ) { |
| 25 | + $argsValid = true; |
| 26 | + } |
| 27 | + } |
| 28 | + |
| 29 | + if ( !$argsValid ) { |
| 30 | + die( "Usage: populateWikiVersionsCDB.php php-X.XX" ); |
| 31 | + } |
| 32 | + |
| 33 | + $path = '/home/wikipedia/common/all.dblist'; |
| 34 | + $dbList = explode( "\n", file_get_contents( $path ) ); |
| 35 | + if ( !count( $dbList ) ) { |
| 36 | + die( "Unable to read all.dblist." ); |
| 37 | + } |
| 38 | + |
| 39 | + $wikiVersionList = ''; |
| 40 | + foreach ( $dbList as $dbName ) { |
| 41 | + $wikiVersionList .= "$dbName $version\n"; |
| 42 | + } |
| 43 | + |
| 44 | + $path = '/home/wikipedia/common/wikiversions.cdb'; |
| 45 | + if ( !file_put_contents( $path, $wikiVersionList ) ) { |
| 46 | + die( "Unable to write to wikiversions.cdb." ); |
| 47 | + } |
| 48 | +} |
| 49 | + |
| 50 | +populateWikiversionsCDB(); |
Property changes on: trunk/tools/mwmultiversion/populateWikiversionCDB.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 51 | + native |
Index: trunk/tools/mwmultiversion/scripts/cdbmake-12.sh |
— | — | @@ -1,14 +0,0 @@ |
2 | | -#!/bin/sh |
3 | | -# This File is from the following cdb package |
4 | | -# http://cr.yp.to/cdb.html |
5 | | -# Version: cdb-0.75 (2000.02.19, "beta") |
6 | | -# Usage: cdbmake-12.sh wikiversions.cdb wikiversions.tmp < wikiversions.dat |
7 | | -# See: wikiversions.dat.sample |
8 | | -awk ' |
9 | | - /^[^#]/ { |
10 | | - print "+" length($1) "," length($2) ":" $1 "->" $2 |
11 | | - } |
12 | | - END { |
13 | | - print "" |
14 | | - } |
15 | | -' | cdbmake "$@" |