blob: 66ddeac6b3866f2dca954ebb529d3e29711e243e [file] [log] [blame]
atoulme7d8dcc72008-12-03 20:16:30 +00001<?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
atoulme7d8dcc72008-12-03 20:16:30 +000017ini_set("memory_limit", "64M");
atoulme3ac52612009-02-02 13:14:39 +000018require(dirname(__FILE__) . "/../system/backend_functions.php");
19
20global $addon;
21$context = $addon->callHook('context');
22$work_dir = $addon->callHook('babel_working');
23
atoulme12882d52009-01-26 18:39:17 +000024require(dirname(__FILE__) . "/../system/dbconnection.class.php");
25require(dirname(__FILE__) . "/../system/feature.class.php");
atoulme7d8dcc72008-12-03 20:16:30 +000026$dbc = new DBConnection();
27$dbh = $dbc->connect();
28
atoulme7d8dcc72008-12-03 20:16:30 +000029$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
34exec("rm -rf $work_context_dir*");
35exec("mkdir -p $output_dir");
atoulme2683f242008-12-05 20:33:45 +000036exec("mkdir -p $sites_dir");
atoulme7d8dcc72008-12-03 20:16:30 +000037
38
39//iterate over all the release trains
40foreach(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();
atoulme7d8dcc72008-12-03 20:16:30 +000053 $features[] = $feature;
atoulme7d8dcc72008-12-03 20:16:30 +000054 }
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>
65HEAD;
66 fwrite($site, $head);
atoulme8b34bfa2008-12-08 21:53:18 +000067 $version = $train->version ."_". $train->timestamp;
atoulme7d8dcc72008-12-03 20:16:30 +000068 foreach($features as $f) {
69 $language_name = $f->language->name;
70 $filename = $f->filename();
atoulme8b34bfa2008-12-08 21:53:18 +000071
atoulme7d8dcc72008-12-03 20:16:30 +000072 $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
atoulmea5306e42008-12-03 21:26:56 +000077<feature url="features/$filename.jar" id="$filename" version="$version">
atoulme7d8dcc72008-12-03 20:16:30 +000078 <category name="Babel Language Packs in $language_name"/>
79</feature>
80FEATURE_TEXT;
81 fwrite($site, $feature_text);
82 }
83 fclose($site);
atoulme8b34bfa2008-12-08 21:53:18 +000084 exec("mv $output_dir_for_train/eclipse $sites_dir/" . $train->id . "_" . $train->timestamp);
atoulme7d8dcc72008-12-03 20:16:30 +000085}
86
87
88