atoulme | 7d8dcc7 | 2008-12-03 20:16:30 +0000 | [diff] [blame] | 1 | <?php |
| 2 | /******************************************************************************* |
| 3 | * Copyright (c) 2007-2008 Eclipse Foundation and others. |
| 4 | * All rights reserved. This program and the accompanying materials |
| 5 | * are made available under the terms of the Eclipse Public License v1.0 |
| 6 | * which accompanies this distribution, and is available at |
| 7 | * http://www.eclipse.org/legal/epl-v10.html |
| 8 | * |
| 9 | * Contributors: |
| 10 | * Antoine Toulme, Intalio Inc. bug 248845: Refactoring generate1.php into different files with a functional approach |
| 11 | *******************************************************************************/ |
| 12 | |
| 13 | /* |
| 14 | * Documentation: http://wiki.eclipse.org/Babel_/_Server_Tool_Specification#Outputs |
| 15 | */ |
| 16 | |
atoulme | 7d8dcc7 | 2008-12-03 20:16:30 +0000 | [diff] [blame] | 17 | ini_set("memory_limit", "64M"); |
atoulme | 3ac5261 | 2009-02-02 13:14:39 +0000 | [diff] [blame] | 18 | require(dirname(__FILE__) . "/../system/backend_functions.php"); |
| 19 | |
| 20 | global $addon; |
| 21 | $context = $addon->callHook('context'); |
| 22 | $work_dir = $addon->callHook('babel_working'); |
| 23 | |
atoulme | 12882d5 | 2009-01-26 18:39:17 +0000 | [diff] [blame] | 24 | require(dirname(__FILE__) . "/../system/dbconnection.class.php"); |
| 25 | require(dirname(__FILE__) . "/../system/feature.class.php"); |
atoulme | 7d8dcc7 | 2008-12-03 20:16:30 +0000 | [diff] [blame] | 26 | $dbc = new DBConnection(); |
| 27 | $dbh = $dbc->connect(); |
| 28 | |
atoulme | 7d8dcc7 | 2008-12-03 20:16:30 +0000 | [diff] [blame] | 29 | $work_context_dir = $work_dir . $context . "_site/"; |
| 30 | $tmp_dir = $work_context_dir . "tmp/"; |
| 31 | $output_dir = $work_context_dir . "output/"; |
| 32 | $sites_dir = $work_context_dir . "sites/"; |
| 33 | |
| 34 | exec("rm -rf $work_context_dir*"); |
| 35 | exec("mkdir -p $output_dir"); |
atoulme | 2683f24 | 2008-12-05 20:33:45 +0000 | [diff] [blame] | 36 | exec("mkdir -p $sites_dir"); |
atoulme | 7d8dcc7 | 2008-12-03 20:16:30 +0000 | [diff] [blame] | 37 | |
| 38 | |
| 39 | //iterate over all the release trains |
| 40 | foreach(ReleaseTrain::all() as $train) { |
| 41 | $features = array(); |
| 42 | // create a dedicated folder for each of them |
| 43 | exec("mkdir -p $sites_dir/$train->id"); |
| 44 | // create the output folder for temporary artifacts |
| 45 | $output_dir_for_train = "$output_dir/$train->id/"; |
| 46 | // iterate over each language |
| 47 | foreach(Language::all() as $lang) { |
| 48 | // create a new feature object |
| 49 | $feature = new Feature($lang, $train, $tmp_dir, $output_dir_for_train); |
| 50 | // make it generate itself |
| 51 | $feature->generateAll(); |
| 52 | $feature->jar(); |
atoulme | 7d8dcc7 | 2008-12-03 20:16:30 +0000 | [diff] [blame] | 53 | $features[] = $feature; |
atoulme | 7d8dcc7 | 2008-12-03 20:16:30 +0000 | [diff] [blame] | 54 | } |
| 55 | $site = fopen("$output_dir_for_train/eclipse/site.xml", "w"); |
| 56 | $head = <<<HEAD |
| 57 | <site mirrorsURL="http://www.eclipse.org/downloads/download.php?file=/technology/babel/update-site/ganymede/site.xml&format=xml"> |
| 58 | <description url="http://babel.eclipse.org/"> |
| 59 | |
| 60 | This update site contains user-contributed translations of the strings in all Eclipse projects. |
| 61 | Please see the http://babel.eclipse.org/ Babel project web pages for a full how-to-use explanation of |
| 62 | these translations as well as how you can contribute to the translations of this and future versions of Eclipse. |
| 63 | |
| 64 | </description> |
| 65 | HEAD; |
| 66 | fwrite($site, $head); |
atoulme | 8b34bfa | 2008-12-08 21:53:18 +0000 | [diff] [blame] | 67 | $version = $train->version ."_". $train->timestamp; |
atoulme | 7d8dcc7 | 2008-12-03 20:16:30 +0000 | [diff] [blame] | 68 | foreach($features as $f) { |
| 69 | $language_name = $f->language->name; |
| 70 | $filename = $f->filename(); |
atoulme | 8b34bfa | 2008-12-08 21:53:18 +0000 | [diff] [blame] | 71 | |
atoulme | 7d8dcc7 | 2008-12-03 20:16:30 +0000 | [diff] [blame] | 72 | $feature_text = <<<FEATURE_TEXT |
| 73 | <category-def name="Babel Language Packs in $language_name" label="Babel Language Packs in $language_name"> |
| 74 | <description>Babel Language Packs in Pseudo Translations</description> |
| 75 | </category-def> |
| 76 | |
atoulme | a5306e4 | 2008-12-03 21:26:56 +0000 | [diff] [blame] | 77 | <feature url="features/$filename.jar" id="$filename" version="$version"> |
atoulme | 7d8dcc7 | 2008-12-03 20:16:30 +0000 | [diff] [blame] | 78 | <category name="Babel Language Packs in $language_name"/> |
| 79 | </feature> |
| 80 | FEATURE_TEXT; |
| 81 | fwrite($site, $feature_text); |
| 82 | } |
| 83 | fclose($site); |
atoulme | 8b34bfa | 2008-12-08 21:53:18 +0000 | [diff] [blame] | 84 | exec("mv $output_dir_for_train/eclipse $sites_dir/" . $train->id . "_" . $train->timestamp); |
atoulme | 7d8dcc7 | 2008-12-03 20:16:30 +0000 | [diff] [blame] | 85 | } |
| 86 | |
| 87 | |
| 88 | |