blob: eecee26a6ecec295eb4c7813f5b2be7017561b78 [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");
atoulme12882d52009-01-26 18:39:17 +000018require(dirname(__FILE__) . "/../../html/common_functions.php");
19require(dirname(__FILE__) . "/../system/dbconnection.class.php");
20require(dirname(__FILE__) . "/../system/feature.class.php");
atoulme7d8dcc72008-12-03 20:16:30 +000021$dbc = new DBConnection();
22$dbh = $dbc->connect();
23
24$work_dir = "/tmp/babel-working/";
atoulme7d8dcc72008-12-03 20:16:30 +000025
atoulme12882d52009-01-26 18:39:17 +000026global $context;
atoulme7d8dcc72008-12-03 20:16:30 +000027
28$work_context_dir = $work_dir . $context . "_site/";
29$tmp_dir = $work_context_dir . "tmp/";
30$output_dir = $work_context_dir . "output/";
31$sites_dir = $work_context_dir . "sites/";
32
33exec("rm -rf $work_context_dir*");
34exec("mkdir -p $output_dir");
atoulme2683f242008-12-05 20:33:45 +000035exec("mkdir -p $sites_dir");
atoulme7d8dcc72008-12-03 20:16:30 +000036
37
38//iterate over all the release trains
39foreach(ReleaseTrain::all() as $train) {
40 $features = array();
41 // create a dedicated folder for each of them
42 exec("mkdir -p $sites_dir/$train->id");
43 // create the output folder for temporary artifacts
44 $output_dir_for_train = "$output_dir/$train->id/";
45 // iterate over each language
46 foreach(Language::all() as $lang) {
47 // create a new feature object
48 $feature = new Feature($lang, $train, $tmp_dir, $output_dir_for_train);
49 // make it generate itself
50 $feature->generateAll();
51 $feature->jar();
atoulme7d8dcc72008-12-03 20:16:30 +000052 $features[] = $feature;
atoulme7d8dcc72008-12-03 20:16:30 +000053 }
54 $site = fopen("$output_dir_for_train/eclipse/site.xml", "w");
55 $head = <<<HEAD
56<site mirrorsURL="http://www.eclipse.org/downloads/download.php?file=/technology/babel/update-site/ganymede/site.xml&format=xml">
57<description url="http://babel.eclipse.org/">
58
59 This update site contains user-contributed translations of the strings in all Eclipse projects.
60 Please see the http://babel.eclipse.org/ Babel project web pages for a full how-to-use explanation of
61 these translations as well as how you can contribute to the translations of this and future versions of Eclipse.
62
63</description>
64HEAD;
65 fwrite($site, $head);
atoulme8b34bfa2008-12-08 21:53:18 +000066 $version = $train->version ."_". $train->timestamp;
atoulme7d8dcc72008-12-03 20:16:30 +000067 foreach($features as $f) {
68 $language_name = $f->language->name;
69 $filename = $f->filename();
atoulme8b34bfa2008-12-08 21:53:18 +000070
atoulme7d8dcc72008-12-03 20:16:30 +000071 $feature_text = <<<FEATURE_TEXT
72<category-def name="Babel Language Packs in $language_name" label="Babel Language Packs in $language_name">
73 <description>Babel Language Packs in Pseudo Translations</description>
74</category-def>
75
atoulmea5306e42008-12-03 21:26:56 +000076<feature url="features/$filename.jar" id="$filename" version="$version">
atoulme7d8dcc72008-12-03 20:16:30 +000077 <category name="Babel Language Packs in $language_name"/>
78</feature>
79FEATURE_TEXT;
80 fwrite($site, $feature_text);
81 }
82 fclose($site);
atoulme8b34bfa2008-12-08 21:53:18 +000083 exec("mv $output_dir_for_train/eclipse $sites_dir/" . $train->id . "_" . $train->timestamp);
atoulme7d8dcc72008-12-03 20:16:30 +000084}
85
86
87