blob: 7fc4ccd677bc2ec8cb799913a7f845fee1e69050 [file] [log] [blame]
gobrien1a8e02f2008-01-30 01:46:26 +00001<?php
2/*******************************************************************************
3 * Copyright (c) 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 * Eclipse Foundation - Initial API and implementation
droy133e7462008-05-13 17:37:24 +000011 * Motoki MORT mori-m@mxa.nes.nec.co.jp - patch, bug 227366
kitlo9c7c62a2008-10-05 16:05:19 +000012 * Kit Lo (IBM) - patch, bug 217339, generate pseudo translations language packs
13 * Kit Lo (IBM) - patch, bug 234430, need language packs by means of other than update site
kitlo58d8a5a2008-09-24 20:08:44 +000014 *******************************************************************************/
gobrien1a8e02f2008-01-30 01:46:26 +000015
16/*
kitlo58d8a5a2008-09-24 20:08:44 +000017 * Documentation: http://wiki.eclipse.org/Babel_/_Server_Tool_Specification#Outputs
gobrien1a8e02f2008-01-30 01:46:26 +000018 */
gobrienb854dcb2008-01-30 18:50:45 +000019
droyb6e25c72008-07-18 13:01:13 +000020ob_start();
kitlo9c7c62a2008-10-05 16:05:19 +000021ini_set("memory_limit", "64M");
kitlo58d8a5a2008-09-24 20:08:44 +000022define("BABEL_BASE_DIR", "../../");
kitlo9c7c62a2008-10-05 16:05:19 +000023require(BABEL_BASE_DIR . "html/common_functions.php");
24require(BABEL_BASE_DIR . "classes/system/dbconnection.class.php");
kitlo399df202008-09-30 15:32:25 +000025$dbc = new DBConnection();
26$dbh = $dbc->connect();
droyb6e25c72008-07-18 13:01:13 +000027
kitlo58d8a5a2008-09-24 20:08:44 +000028$work_dir = "/home/babel-working/";
kitlo9c7c62a2008-10-05 16:05:19 +000029if (!($ini = @parse_ini_file(BABEL_BASE_DIR . "classes/base.conf"))) {
gobrienb854dcb2008-01-30 18:50:45 +000030 errorLog("Failed to find/read database conf file - aborting.");
31 exitTo("error.php?errNo=101300","error: 101300 - database conf can not be found");
32}
gobrienb854dcb2008-01-30 18:50:45 +000033$context = $ini['context'];
gobrienb854dcb2008-01-30 18:50:45 +000034
kitlo9c7c62a2008-10-05 16:05:19 +000035$work_context_dir = $work_dir . $context . "/";
36$tmp_dir = $work_context_dir . "tmp/";
37$babel_language_packs_dir = $work_context_dir . "babel_language_packs/";
38$output_dir = $work_context_dir . "output/";
kitlo58d8a5a2008-09-24 20:08:44 +000039$source_files_dir = "source_files_for_generate/";
gobrienb854dcb2008-01-30 18:50:45 +000040
gobrien1a8e02f2008-01-30 01:46:26 +000041$leader = ". . ";
kitlo58d8a5a2008-09-24 20:08:44 +000042$timestamp = date("Ymdhis");
gobrien1a8e02f2008-01-30 01:46:26 +000043
droyc4c834a2008-10-07 20:30:21 +000044
45if($context != "staging" && $context != "live") {
46 exec("rm -rf $work_dir");
47 exec("mkdir -p $output_dir");
48}
kitlo9c7c62a2008-10-05 16:05:19 +000049
50/*
51 * Create language pack links file
52 */
53exec("mkdir -p $babel_language_packs_dir");
54$language_pack_links_file = fopen("${babel_language_packs_dir}index.html", "w");
55fwrite($language_pack_links_file, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\">" .
56 "\n<html>\n<head>\n<title>Babel Language Packs</title>" .
57 "\n<meta http-equiv=Content-Type content=\"text/html; charset=UTF-8\">\n</head>" .
58 "\n<body>\n\t<h1>Babel Language Packs</h1>" .
59 "\n\t<h2>Build ID: $timestamp</h2>");
droy0b08d292008-05-28 15:18:11 +000060
kitlo58d8a5a2008-09-24 20:08:44 +000061echo "Generating update site\n";
kitlo9c7c62a2008-10-05 16:05:19 +000062$train_result = mysql_query("SELECT DISTINCT train_id FROM release_train_projects");
kitlo58d8a5a2008-09-24 20:08:44 +000063while (($train_row = mysql_fetch_assoc($train_result)) != null) {
64 $train_id = $train_row['train_id'];
65 $train_version = "3.4.0";
66 if (strcmp($train_id, "europa") == 0) {
67 $train_version = "3.3.0";
droy0b08d292008-05-28 15:18:11 +000068 }
kitlo9c7c62a2008-10-05 16:05:19 +000069 $train_version_timestamp = "$train_version.v$timestamp";
70 $site_xml = "";
kitlo58d8a5a2008-09-24 20:08:44 +000071
72 $output_dir_for_train = $output_dir . $train_row['train_id'] . "/";
73 exec("mkdir $output_dir_for_train");
74 exec("mkdir ${output_dir_for_train}features/");
75 exec("mkdir ${output_dir_for_train}plugins/");
76
kitlo9c7c62a2008-10-05 16:05:19 +000077 fwrite($language_pack_links_file, "\n\t<h3>Release Train: $train_id</h3>\n\t<ul>");
78
79 $language_result = mysql_query("SELECT * FROM languages WHERE languages.is_active");
80 while (($language_row = mysql_fetch_assoc($language_result)) != null) {
droy0b08d292008-05-28 15:18:11 +000081 $language_name = $language_row['name'];
kitlo58d8a5a2008-09-24 20:08:44 +000082 $language_iso = $language_row['iso_code'];
83 $language_locale = $language_row['locale'];
84 $language_id = $language_row['language_id'];
85 if (strcmp($language_iso, "en") == 0) {
86 $language_iso = "en_AA";
87 $language_name = "Pseudo Translations";
88 }
89 if ($language_locale != null) {
droy0b08d292008-05-28 15:18:11 +000090 $language_name = $language_locale . " " . $language_name;
gobrien1a8e02f2008-01-30 01:46:26 +000091 }
kitlo9c7c62a2008-10-05 16:05:19 +000092
93 $site_xml .= "\n\t<category-def name=\"Babel Language Packs in $language_name\" label=\"Babel Language Packs in $language_name\">";
94 $site_xml .= "\n\t\t<description>Babel Language Packs in $language_name</description>";
95 $site_xml .= "\n\t</category-def>";
96
97 fwrite($language_pack_links_file, "\n\t<h4>Language: $language_name</h4>\n\t<ul>");
98
kitlo58d8a5a2008-09-24 20:08:44 +000099 echo "${leader}Generating language pack for $train_id - $language_name ($language_iso) (language_id=" . $language_id . ")\n";
100
gobrien1a8e02f2008-01-30 01:46:26 +0000101 /*
droy0b08d292008-05-28 15:18:11 +0000102 * Determine which plug-ins need to be in this language pack.
gobrien1a8e02f2008-01-30 01:46:26 +0000103 */
kitlo58d8a5a2008-09-24 20:08:44 +0000104 if (strcmp($language_iso, "en_AA") == 0) {
105 $file_result = mysql_query("SELECT DISTINCT f.project_id, f.version, f.file_id, f.name
106 FROM files AS f
107 INNER JOIN strings AS s ON f.file_id = s.file_id
108 INNER JOIN release_train_projects as v ON (f.project_id = v.project_id AND f.version = v.version)
109 WHERE f.is_active
110 AND v.train_id = '" . $train_row['train_id'] . "'");
kitlo58d8a5a2008-09-24 20:08:44 +0000111 } else {
112 $file_result = mysql_query("SELECT DISTINCT f.project_id, f.version, f.file_id, f.name
113 FROM files AS f
114 INNER JOIN strings AS s ON f.file_id = s.file_id
115 INNER JOIN translations AS t ON (s.string_id = t.string_id AND t.is_active)
116 INNER JOIN release_train_projects as v ON (f.project_id = v.project_id AND f.version = v.version)
117 WHERE t.language_id = " . $language_id . "
118 AND f.is_active
119 AND v.train_id = '" . $train_row['train_id'] . "'");
120 }
121
droy0b08d292008-05-28 15:18:11 +0000122 $plugins = array();
kitlo9c7c62a2008-10-05 16:05:19 +0000123 $projects = array();
124 $project_versions = array();
125 $pseudo_translations_indexes = array();
kitlo58d8a5a2008-09-24 20:08:44 +0000126 while (($file_row = mysql_fetch_assoc($file_result)) != null) {
127 # save original filename
128 $file_row['origname'] = $file_row['name'];
129
droy02c430a2008-06-02 19:42:08 +0000130 # strip useless CVS structure before the plugin name (bug 221675 c14):
131 $pattern = '/^([a-zA-Z0-9\/_-])+\/([a-zA-Z0-9_-]+)\.([a-zA-Z0-9_-]+)(.*)\.properties$/i';
132 $replace = '${2}.${3}${4}.properties';
133 $file_row['name'] = preg_replace($pattern, $replace, $file_row['name']);
kitlo58d8a5a2008-09-24 20:08:44 +0000134
droy02c430a2008-06-02 19:42:08 +0000135 # strip source folder (bug 221675) (org.eclipse.plugin/source_folder/org/eclipse/plugin)
136 $pattern = '/^([a-zA-Z0-9_-]+)\.([a-zA-Z0-9_-]+)\.([a-zA-Z0-9\._-]+)(.*)\/(\1)([\.\/])(\2)([\.\/])(.*)\.properties$/i';
137 $replace = '${1}.${2}.${3}/${5}${6}${7}${8}${9}.properties';
droy0b08d292008-05-28 15:18:11 +0000138 $file_row['name'] = preg_replace($pattern, $replace, $file_row['name']);
kitlo58d8a5a2008-09-24 20:08:44 +0000139
140 if (preg_match("/^([a-zA-Z0-9\.]+)\/(.*)$/", $file_row['name'], $matches)) {
droy0b08d292008-05-28 15:18:11 +0000141 $file_row['subname'] = $matches[2];
142 $plugins[$matches[1]][] = $file_row;
143 } else {
144 echo " WARNING: no plug-in name found in file " . $file_row['file_id'] . " \"" . $file_row['name'] . "\"\n";
gobrien1a8e02f2008-01-30 01:46:26 +0000145 }
droy0b08d292008-05-28 15:18:11 +0000146 }
kitlo58d8a5a2008-09-24 20:08:44 +0000147
droy0b08d292008-05-28 15:18:11 +0000148 /*
149 * Generate one plug-in fragment for each plug-in
150 */
kitlo58d8a5a2008-09-24 20:08:44 +0000151 foreach ($plugins as $plugin_name => $plugin_row) {
152 echo "${leader}${leader}Generating plug-in fragment $plugin_name\n";
gobrien1a8e02f2008-01-30 01:46:26 +0000153 /*
droy0b08d292008-05-28 15:18:11 +0000154 * Clean and create the temporary directory
gobrien1a8e02f2008-01-30 01:46:26 +0000155 */
kitlo58d8a5a2008-09-24 20:08:44 +0000156 if (file_exists($tmp_dir)) {
157 exec("rm -rf $tmp_dir; mkdir $tmp_dir");
droy0b08d292008-05-28 15:18:11 +0000158 } else {
kitlo58d8a5a2008-09-24 20:08:44 +0000159 exec("mkdir $tmp_dir");
droy0b08d292008-05-28 15:18:11 +0000160 }
gobrien1a8e02f2008-01-30 01:46:26 +0000161 /*
droy0b08d292008-05-28 15:18:11 +0000162 * Generate each *.properties file
gobrien1a8e02f2008-01-30 01:46:26 +0000163 */
droy0b08d292008-05-28 15:18:11 +0000164 foreach ($plugin_row as $properties_file) {
165 /*
166 * Convert the filename to *_lang.properties, e.g., foo_fr.properties
167 */
168 $filename = $properties_file['subname'];
kitlo58d8a5a2008-09-24 20:08:44 +0000169 if (preg_match( "/^(.*)\.properties$/", $filename, $matches)) {
droy0b08d292008-05-28 15:18:11 +0000170 $filename = $matches[1] . '_' . $language_iso . '.properties';
gobrien1a8e02f2008-01-30 01:46:26 +0000171 }
kitlo58d8a5a2008-09-24 20:08:44 +0000172 echo "${leader}${leader}${leader}Generating properties file $filename (file_id=" . $properties_file['file_id'] . ")\n";
droy0b08d292008-05-28 15:18:11 +0000173 /*
174 * Create any needed sub-directories
175 */
kitlo58d8a5a2008-09-24 20:08:44 +0000176 $fullpath = $tmp_dir . $filename;
177 preg_match("/^((.*)\/)?(.+?)$/", $fullpath, $matches);
178 exec("mkdir -p \"" . $matches[1] . "\"");
droy0b08d292008-05-28 15:18:11 +0000179 /*
180 * Start writing to the file
181 */
kitlo58d8a5a2008-09-24 20:08:44 +0000182 $outp = fopen($fullpath, "w");
kitlo9c7c62a2008-10-05 16:05:19 +0000183 fwrite($outp, "# Copyright by many contributors; see http://babel.eclipse.org/");
kitlo58d8a5a2008-09-24 20:08:44 +0000184 if (strcmp($language_iso, "en_AA") == 0) {
185 $sql = "SELECT string_id, name, value FROM strings WHERE file_id = " . $properties_file['file_id'] .
186 " AND is_active AND non_translatable = 0";
187 $strings_result = mysql_query($sql);
188 while (($strings_row = mysql_fetch_assoc($strings_result)) != null) {
kitlo9c7c62a2008-10-05 16:05:19 +0000189 fwrite($outp, "\n" . $strings_row['name'] . "=" . $properties_file['project_id'] . $strings_row['string_id'] .
190 ":" . $strings_row['value']);
kitlo58d8a5a2008-09-24 20:08:44 +0000191
192 $value = htmlspecialchars($strings_row['value']);
193 if (strlen($value) > 100) {
194 $value = substr($value, 0, 100) . " ...";
195 }
kitlo9c7c62a2008-10-05 16:05:19 +0000196 $pseudo_translations_indexes[$properties_file['project_id']][] = "\n\t\t<li><a href=\"http://babel.eclipse.org/babel/translate.php?project=" .
197 $properties_file['project_id'] . "&version=" . $properties_file['version'] . "&file=" .
198 $properties_file['origname'] . "&string=" . $strings_row['name'] . "\">" .
199 $properties_file['project_id'] . $strings_row['string_id'] . "</a>&nbsp;" . $value . "</li>";
kitlo58d8a5a2008-09-24 20:08:44 +0000200 }
201 } else {
202 $sql = "SELECT
203 strings.name AS 'key',
204 strings.value AS orig,
205 translations.value AS trans
droy0b08d292008-05-28 15:18:11 +0000206 FROM strings, translations
207 WHERE strings.string_id = translations.string_id
kitlo58d8a5a2008-09-24 20:08:44 +0000208 AND translations.language_id = " . $language_id . "
droy0b08d292008-05-28 15:18:11 +0000209 AND strings.file_id = " . $properties_file['file_id'] . "
kitlo58d8a5a2008-09-24 20:08:44 +0000210 AND translations.is_active";
211 $strings_result = mysql_query($sql);
212 while (($strings_row = mysql_fetch_assoc($strings_result)) != null) {
213 fwrite($outp, $strings_row['key'] . "=");
kitlo9c7c62a2008-10-05 16:05:19 +0000214 # echo "${leader1S}${leaderS}${leaderS}${leaderS}" . $strings_row['key'] . "=";
kitlo58d8a5a2008-09-24 20:08:44 +0000215 if ($strings_row['trans']) {
216 # json_encode returns the string with quotes fore and aft. Need to strip them.
217 # $tr_string = preg_replace('/^"(.*)"$/', '${1}', json_encode($strings_row['trans']));
218 # $tr_string = str_replace('\\\\', '\\', $tr_string);
219 $tr_string = toescapedunicode($strings_row['trans']);
220 fwrite($outp, $tr_string);
221 # echo $strings_row['trans'];
222 } else {
223 fwrite($outp, $strings_row['orig']);
224 }
225 fwrite($outp, "\n");
droy0b08d292008-05-28 15:18:11 +0000226 }
droy0b08d292008-05-28 15:18:11 +0000227 }
228 /*
229 * Finish the properties file
230 */
kitlo58d8a5a2008-09-24 20:08:44 +0000231 fclose($outp);
232 echo "${leader}${leader}${leader}Completed properties file $filename\n";
gobrien1a8e02f2008-01-30 01:46:26 +0000233 }
234 /*
droy0b08d292008-05-28 15:18:11 +0000235 * Copy in the various legal files
gobrien1a8e02f2008-01-30 01:46:26 +0000236 */
kitlo9c7c62a2008-10-05 16:05:19 +0000237 exec("cp ${source_files_dir}about.html $tmp_dir");
droy0b08d292008-05-28 15:18:11 +0000238 /*
239 * Generate the META-INF/MANIFEST.MF file
240 */
241 $parent_plugin_id = $plugin_name;
kitlo9c7c62a2008-10-05 16:05:19 +0000242 $project_id = $properties_file['project_id'];
243 $fragment_id = "$parent_plugin_id.nl-$language_iso";
244 $fragment_filename = "${fragment_id}_$train_version_timestamp.jar";
kitlo58d8a5a2008-09-24 20:08:44 +0000245
droy0b08d292008-05-28 15:18:11 +0000246 $plugins[$plugin_name]['id'] = $fragment_id;
kitlo9c7c62a2008-10-05 16:05:19 +0000247 $plugins[$plugin_name]['version'] = $train_version_timestamp;
kitlo58d8a5a2008-09-24 20:08:44 +0000248
249 exec("mkdir $tmp_dir/META-INF" );
250 $outp = fopen("$tmp_dir/META-INF/MANIFEST.MF", "w");
251 fwrite($outp, "Manifest-Version: 1.0\n");
252 fwrite($outp, "Bundle-Name: $parent_plugin_id $language_name NLS Support\n");
253 fwrite($outp, "Bundle-SymbolicName: $fragment_id ;singleton=true\n");
kitlo9c7c62a2008-10-05 16:05:19 +0000254 fwrite($outp, "Bundle-Version: $train_version_timestamp\n");
255 fwrite($outp, "Bundle-Vendor: Eclipse.org\n");
kitlo58d8a5a2008-09-24 20:08:44 +0000256 fwrite($outp, "Fragment-Host: $parent_plugin_id\n");
257 fclose($outp);
droy0b08d292008-05-28 15:18:11 +0000258 /*
259 * Jar up this directory as the fragment plug-in jar
260 */
kitlo58d8a5a2008-09-24 20:08:44 +0000261 system("cd $tmp_dir; jar cfM ${output_dir_for_train}plugins/$fragment_filename .");
262 echo "${leader}${leader}Completed plug-in fragment $plugin_name\n";
kitlo58d8a5a2008-09-24 20:08:44 +0000263
kitlo9c7c62a2008-10-05 16:05:19 +0000264 $projects[$project_id][] = $fragment_id;
265 $project_versions[$project_id] = $properties_file['version'];
droy0b08d292008-05-28 15:18:11 +0000266 }
kitlo9c7c62a2008-10-05 16:05:19 +0000267 foreach ($projects as $project_id => $fragment_ids) {
268 /*
269 * Sort fragment names
270 */
271 asort($fragment_ids);
272 /*
273 * Create ${babel_language_packs_dir}tmp
274 */
275 exec("mkdir -p ${babel_language_packs_dir}tmp/eclipse/features");
276 exec("mkdir -p ${babel_language_packs_dir}tmp/eclipse/plugins");
277 /*
278 * Clean and create the temporary directory
279 */
280 if (file_exists($tmp_dir)) {
281 exec("rm -rf $tmp_dir; mkdir $tmp_dir");
282 } else {
283 exec("mkdir $tmp_dir");
284 }
285 /*
286 * Create the feature.xml
287 *
288 * TODO <url><update label=... url=... and <url><discovery label=... url=... are not implemented
289 *
290 * <url>
291 * <update label="%updateSiteName" url="http://update.eclipse.org/updates/3.2" />
292 * <discovery label="%updateSiteName" url="http://update.eclipse.org/updates/3.2" />
293 * </url>
294 */
295 $feature_id = "org.eclipse.babel.nls-$project_id-$language_iso";
296 $feature_version = "$train_version.v$timestamp";
297 $feature_filename = "${feature_id}_$train_version_timestamp.jar";
298
299 $project_version = $project_versions[$project_id];
300 $sql = "SELECT pct_complete
301 FROM project_progress
302 WHERE project_id = \"$project_id\"
303 AND version = \"$project_version\"
304 AND language_id = $language_id";
305 $project_pct_complete_result = mysql_query($sql);
306 $project_pct_complete = mysql_result($project_pct_complete_result, 0);
307 if (strcmp($language_iso, "en_AA") == 0) {
308 $project_pct_complete = 100;
309 }
310
311 $outp = fopen("$tmp_dir/feature.xml", "w");
312 fwrite($outp, "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" .
313 "\n<feature" .
314 "\n\tid=\"$feature_id\"" .
315 "\n\tlabel=\"Babel Language Pack for $project_id in $language_name ($project_pct_complete%)\"" .
316 "\n\timage=\"eclipse_update_120.jpg\"" .
317 "\n\tprovider-name=\"%providerName\"" .
318 "\n\tversion=\"$train_version_timestamp\">" .
319 "\n\t<copyright>\n\t\t%copyright\n\t</copyright>" .
320 "\n\t<license url=\"%licenseURL\">\n\t\t%license\n\t</license>" .
321 "\n\t<description>Babel Language Pack for $project_id in $language_name</description>" );
322 foreach ($fragment_ids as $fragment_id) {
323 $jar_name = "${output_dir_for_train}plugins/${fragment_id}_$train_version_timestamp.jar";
324 $size = filesize($jar_name);
325 fwrite($outp, "\n\t<plugin fragment=\"true\" id=\"$fragment_id\" unpack=\"false\" " .
326 "version=\"$train_version_timestamp\" download-size=\"$size\" install-size=\"$size\" />");
327 /*
328 * Copy the plugin to ${babel_language_packs_dir}tmp
329 */
330 exec("cp ${output_dir_for_train}plugins/${fragment_id}_$train_version_timestamp.jar ${babel_language_packs_dir}tmp/eclipse/plugins");
331 }
332 fwrite($outp, "\n</feature>");
333 fclose($outp);
334 /*
335 * Copy in the various legal files
336 */
337 exec("cp ${source_files_dir}about.html $tmp_dir");
338 exec("cp ${source_files_dir}eclipse_update_120.jpg $tmp_dir");
339 exec("cp ${source_files_dir}epl-v10.html $tmp_dir");
340 exec("cp ${source_files_dir}feature.properties $tmp_dir");
341 exec("cp ${source_files_dir}license.html $tmp_dir");
342 /*
343 * Copy in the Babel Pseudo Translations Index file
344 */
345 if (strcmp($language_iso, "en_AA") == 0) {
346 $pseudo_translations_index_file = fopen("${output_dir}BabelPseudoTranslationsIndex-$project_id.html", "w");
347 fwrite($pseudo_translations_index_file, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\">" .
348 "\n<html>\n<head>\n<title>Babel Pseudo Translations Index for $project_id</title>" .
349 "\n<meta http-equiv=Content-Type content=\"text/html; charset=UTF-8\">\n</head>" .
350 "\n<body>\n\t<h1>Babel Pseudo Translations Index for $project_id</h1>" .
351 "\n\t<h2>Version: $train_version_timestamp</h2>\n\t<ul>");
352 foreach ($pseudo_translations_indexes[$project_id] as $index) {
353 fwrite($pseudo_translations_index_file, $index);
354 }
355 fwrite($pseudo_translations_index_file, "\n\t</ul>\n</body>\n</html>");
356 fclose($pseudo_translations_index_file);
357 exec("cp ${output_dir}BabelPseudoTranslationsIndex-$project_id.html $tmp_dir");
358 exec("rm ${output_dir}BabelPseudoTranslationsIndex-$project_id.html");
359 }
360 /*
361 * Copy the feature to ${babel_language_packs_dir}tmp before jar'ing up
362 */
363 exec("mkdir -p ${babel_language_packs_dir}tmp/eclipse/features/${fragment_id}_$train_version_timestamp");
364 exec("cd $tmp_dir; cp * ${babel_language_packs_dir}tmp/eclipse/features/${fragment_id}_$train_version_timestamp");
365 /*
366 * Zip up language pack
367 */
368 $language_pack_name = "BabelLanguagePack-$project_id-${language_iso}_$train_version_timestamp.zip";
369 exec("cd ${babel_language_packs_dir}tmp; zip -r $babel_language_packs_dir$language_pack_name eclipse");
370 /*
371 * Clean up ${babel_language_packs_dir}tmp
372 */
373 exec("rm -rf ${babel_language_packs_dir}tmp");
374 /*
375 * Add project language pack link to language pack links file
376 */
377 fwrite($language_pack_links_file, "\n\t<li><a href=\"$language_pack_name\">$language_pack_name</a></li>");
378 /*
379 * Jar up this directory as the feature jar
380 */
381 system("cd $tmp_dir; jar cfM ${output_dir_for_train}features/$feature_filename .");
382 /*
383 * Register this feature with the site.xml
384 */
385 $site_xml .= "\n\t<feature url=\"features/$feature_filename\" id=\"$feature_id\" version=\"$feature_version\">";
386 $site_xml .= "\n\t\t<category name=\"Babel Language Packs in $language_name\"/>";
387 $site_xml .= "\n\t</feature>";
388 echo "${leader}Completed language pack for $language_name ($language_iso)\n";
kitlo58d8a5a2008-09-24 20:08:44 +0000389 }
kitlo9c7c62a2008-10-05 16:05:19 +0000390 fwrite($language_pack_links_file, "\n\t</ul>");
gobrien1a8e02f2008-01-30 01:46:26 +0000391 }
gobrien1a8e02f2008-01-30 01:46:26 +0000392 /*
droy0b08d292008-05-28 15:18:11 +0000393 * <site mirrorsURL=... implemented in the weekly build process by sed'ing <site>
gobrien1a8e02f2008-01-30 01:46:26 +0000394 */
kitlo58d8a5a2008-09-24 20:08:44 +0000395 $outp = fopen("${output_dir_for_train}site.xml", "w");
kitlo9c7c62a2008-10-05 16:05:19 +0000396 fwrite($outp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" .
397 "\n<site>" .
398 "\n\t<description url=\"http://babel.eclipse.org/\">" .
399 "\n\t\tThis update site contains user-contributed translations of the strings in all Eclipse projects." .
400 "\n\t\tPlease see the http://babel.eclipse.org/ Babel project web pages for a full how-to-use explanation of" .
401 "\n\t\tthese translations as well as how you can contribute to the translations of this and future versions of Eclipse." .
402 "\n\t</description>");
kitlo58d8a5a2008-09-24 20:08:44 +0000403 fwrite($outp, $site_xml);
kitlo9c7c62a2008-10-05 16:05:19 +0000404 fwrite($outp, "\n</site>");
kitlo58d8a5a2008-09-24 20:08:44 +0000405 fclose($outp);
kitlo9c7c62a2008-10-05 16:05:19 +0000406
407 fwrite($language_pack_links_file, "\n\t</ul>");
gobrien1a8e02f2008-01-30 01:46:26 +0000408}
gobrien1a8e02f2008-01-30 01:46:26 +0000409echo "Completed generating update site\n";
410
kitlo9c7c62a2008-10-05 16:05:19 +0000411fwrite($language_pack_links_file, "\n</body>\n</html>");
412fclose($language_pack_links_file);
413
gobrien1a8e02f2008-01-30 01:46:26 +0000414/*
kitlo58d8a5a2008-09-24 20:08:44 +0000415 2. what happens if the translation feature includes plug-in fragments for
416 plug-ins that are not in the current image?
417 does it load correctly and ignore those fragments? if so, good
418 A: warnings appear in the run-time error log
419 does it fail to load? if so, then we need to generate different features, perhaps
420 one feature for each plug or else we need to know more about the project
421 distro structure to know which plug-ins to put in each feature
422 what happens if those plug-ins are later added - does it load the strings now?
423 A: probably not
424 3. need to handle different versions of each feature/plugin/platform; generate different
425 language packs for each
426 */
gobrien1a8e02f2008-01-30 01:46:26 +0000427
kitlo58d8a5a2008-09-24 20:08:44 +0000428$alloutput = fopen($output_dir."langpack_output_".date("m_d_Y"), "w");
429fwrite($alloutput,ob_get_contents());
kitlo399df202008-09-30 15:32:25 +0000430?>