blob: 2679093dab3a4ee111bc448e33efdadb55dd9cd3 [file] [log] [blame]
gobrien1a8e02f2008-01-30 01:46:26 +00001<?php
2/*******************************************************************************
Kit Lo6d440cc2013-03-02 19:56:45 -05003 * Copyright (c) 2008-2013 Eclipse Foundation, IBM Corporation and others.
gobrien1a8e02f2008-01-30 01:46:26 +00004 * 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
kitlo7f522672008-10-21 14:15:54 +000014 * Kit Lo (IBM) - patch, bug 251536, newline char missing after copyright comment on first line
kitlo1173dbd2008-10-21 15:58:36 +000015 * Kit Lo (IBM) - patch, bug 238580, language packs should not include strings that are marked "non-translatable"
kitlo5c9da712008-10-27 12:45:40 +000016 * Kit Lo (IBM) - patch, bug 252140, Illegal token characters in babel fragment names
atoulmedbda4272009-01-20 06:04:22 +000017 * Antoine Toulme (Intalio, Inc) - patch, bug 256430, Fragments with no host jeopardize Eclipse installation
kitlo47df0c62009-01-22 15:16:18 +000018 * Kit Lo (IBM) - patch, bug 261739, Inconsistent use of language names
kitlo8d7c0532009-03-14 23:57:49 +000019 * Sean Flanigan (Red Hat) - patch, bug 261584, wrong output folder
kitlocc405032009-04-04 01:10:30 +000020 * Kit Lo (IBM) - patch, bug 270456, Unable to use Babel PTT to verify PDE in the eclipse SDK
kitloe3fea252010-01-25 02:13:49 +000021 * Kit Lo (IBM) - Bug 299402, Extract properties files from Eclipse project update sites for translation
kitlob2ca7c02010-02-10 19:05:41 +000022 * Kit Lo (IBM) - Bug 276306, Re-enable p2 repository
kitlo844140c2010-04-28 16:16:05 +000023 * Kit Lo (IBM) - Bug 310135, Babel p2 update site not using mirrors
kitloaf749822010-07-29 05:19:44 +000024 * Kit Lo (IBM) - [289376] Need to start up a Helios build
kitloc2fbc882011-06-11 21:31:40 +000025 * Kit Lo (IBM) - [344764] Translation fragments discard the plug-in's directory structure
kitlo91a6f8c2011-06-27 19:58:18 +000026 * Kit Lo (IBM) - [330735] Generate a better id for the categories
kitlo838ee402011-09-16 03:53:15 +000027 * Kit Lo (IBM) - [313310] Support Eclipse-PlatformFilter for fragment of fragment
kitlo13edf222012-06-15 03:02:54 +000028 * Satoru Yoshida - [349107] properties file for template is located in wrong path
Kit Lo6d440cc2013-03-02 19:56:45 -050029 * Kit Lo (IBM) - [402215] Extract Orion JavaScript files for translation
syoshida966ef1d2016-02-14 20:24:16 +090030 * Satoru Yoshida - [487881] generate1.php needs some efficiency
syoshida2be8da52016-02-19 07:29:24 +090031 * Satoru Yoshida - [487881] generate1.php needs some efficiency, array define fix
kitlo58d8a5a2008-09-24 20:08:44 +000032 *******************************************************************************/
gobrien1a8e02f2008-01-30 01:46:26 +000033
34/*
kitlo58d8a5a2008-09-24 20:08:44 +000035 * Documentation: http://wiki.eclipse.org/Babel_/_Server_Tool_Specification#Outputs
gobrien1a8e02f2008-01-30 01:46:26 +000036 */
atoulme3fa5f5c2009-01-20 21:26:16 +000037define("METADATA_GENERATOR_LOCATION", "/home/genie/eclipse"); // you might want to read this value from a config file. Not sure yet.
gobrienb854dcb2008-01-30 18:50:45 +000038
droyaa172502009-05-06 20:50:07 +000039ini_set("memory_limit", "512M");
atoulme3ac52612009-02-02 13:14:39 +000040require(dirname(__FILE__) . "/../system/backend_functions.php");
atoulme12882d52009-01-26 18:39:17 +000041require(dirname(__FILE__) . "/../system/dbconnection.class.php");
droy3081da02009-05-11 15:54:56 +000042
kitlo22479022010-01-25 03:22:33 +000043# Get all release trains
kitloe3fea252010-01-25 02:13:49 +000044$dbc = new DBConnection();
45$dbh = $dbc->connect();
kitlo1d027092018-04-19 17:44:07 -040046$result = mysqli_query($dbh, "SELECT * FROM release_trains ORDER BY train_version DESC");
kitloe3fea252010-01-25 02:13:49 +000047$train_result = array();
kitlo1d027092018-04-19 17:44:07 -040048while ($train_row = mysqli_fetch_assoc($result)) {
kitloe3fea252010-01-25 02:13:49 +000049 $train_result[$train_row['train_id']] = $train_row['train_version'];
50}
droy3081da02009-05-11 15:54:56 +000051
52# Command-line parameter for the release train
53# bug 272958
droyc6eb7ac2009-05-12 17:25:46 +000054# b: build id
55# t: (optional: train id)
56
57$options = getopt("b:t:");
droy3081da02009-05-11 15:54:56 +000058$argv_train = "";
Kit Loe6c29bb2013-07-19 08:40:27 -040059if (isset($options['t'])) {
droyc6eb7ac2009-05-12 17:25:46 +000060 $argv_train = $options['t'];
Kit Loe6c29bb2013-07-19 08:40:27 -040061 if (array_key_exists($argv_train, $train_result)) {
droy3081da02009-05-11 15:54:56 +000062 # Picked a valid train .. remove all others
63 foreach ($train_result as $train_id => $train_version) {
Kit Loe6c29bb2013-07-19 08:40:27 -040064 if ($train_id != $argv_train) {
droy3081da02009-05-11 15:54:56 +000065 unset($train_result[$train_id]);
66 }
67 }
68 }
69}
70
kitlob1920882010-05-12 23:33:18 +000071$build_id = "";
Kit Loe6c29bb2013-07-19 08:40:27 -040072if (!isset($options['b'])) {
droyc6eb7ac2009-05-12 17:25:46 +000073 usage();
74 exit();
Kit Loe6c29bb2013-07-19 08:40:27 -040075} else {
kitlob1920882010-05-12 23:33:18 +000076 $build_id = $options['b'];
droyc6eb7ac2009-05-12 17:25:46 +000077}
78
kitloc8a47a42018-04-19 12:21:29 -040079$release_id = "0.16.0";
kitlob1920882010-05-12 23:33:18 +000080
atoulme3ac52612009-02-02 13:14:39 +000081global $addon;
Kit Loe6c29bb2013-07-19 08:40:27 -040082$work_dir = $addon->callHook('babel_working');
atoulme3ac52612009-02-02 13:14:39 +000083$context = $addon->callHook('context');
gobrienb854dcb2008-01-30 18:50:45 +000084
kitlo9c7c62a2008-10-05 16:05:19 +000085$work_context_dir = $work_dir . $context . "/";
86$tmp_dir = $work_context_dir . "tmp/";
87$babel_language_packs_dir = $work_context_dir . "babel_language_packs/";
kitlo532fc2c2011-06-22 02:03:59 +000088$output_dir = $work_context_dir . "update-site/";
atoulme3ac52612009-02-02 13:14:39 +000089$source_files_dir = dirname(__FILE__) . "/source_files_for_generate/";
syoshida2be8da52016-02-19 07:29:24 +090090$need_nl_path_case = array('templates/' => true, 'config/' => true, 'data/' => true, 'property_files/' => true);
gobrienb854dcb2008-01-30 18:50:45 +000091
Kit Loe6c29bb2013-07-19 08:40:27 -040092$leader = ". ";
kitlo58d8a5a2008-09-24 20:08:44 +000093$timestamp = date("Ymdhis");
gobrien1a8e02f2008-01-30 01:46:26 +000094
Kit Lo6d440cc2013-03-02 19:56:45 -050095# Generate Orion language packs
kitlo6ee68f72014-10-31 12:17:46 -040096exec("/usr/bin/php generate_orion.php -b $build_id -s $timestamp");
Kit Lo6d440cc2013-03-02 19:56:45 -050097
98# Generate Babel language packs
99exec("rm -rf $tmp_dir; rm -rf $output_dir");
droy082976e2008-10-07 21:02:23 +0000100exec("mkdir -p $output_dir");
101
droy3081da02009-05-11 15:54:56 +0000102echo "Requested builds: ";
kitlo78f97432009-03-17 22:28:58 +0000103foreach ($train_result as $train_id => $train_version) {
droy3081da02009-05-11 15:54:56 +0000104 echo $train_id . " ";
105}
106echo "\n";
kitlo78f97432009-03-17 22:28:58 +0000107
droy3081da02009-05-11 15:54:56 +0000108# Loop through the trains
109foreach ($train_result as $train_id => $train_version) {
droy3081da02009-05-11 15:54:56 +0000110 echo "Generating update site for: $train_id\n";
droy3081da02009-05-11 15:54:56 +0000111
112 /*
113 * Create language pack links file
114 */
kitlod43ec892011-06-25 23:27:28 +0000115 $babel_language_packs_dir_for_train = $babel_language_packs_dir . $train_id . "/";
116 exec("mkdir -p $babel_language_packs_dir_for_train");
117 $language_pack_links_file = fopen("${babel_language_packs_dir_for_train}${train_id}.php", "w");
droyc6eb7ac2009-05-12 17:25:46 +0000118 fwrite($language_pack_links_file, "<?php\n");
droy260639a2009-05-28 20:02:21 +0000119 fwrite($language_pack_links_file, "\$language_pack_leader = \".\";\n");
droy58951f72009-05-13 18:12:20 +0000120 fwrite($language_pack_links_file, "?>\n");
droyc6eb7ac2009-05-12 17:25:46 +0000121 # copy page_header.html here
122 $header = file_get_contents("${source_files_dir}page_header.html");
123 fwrite($language_pack_links_file, $header);
kitloe3fea252010-01-25 02:13:49 +0000124 fwrite($language_pack_links_file, "\n\t<h1>Babel Language Packs for " . ucfirst($train_id) . "</h1>" .
kitlob1920882010-05-12 23:33:18 +0000125 "\n\t<h2>Build ID: $build_id</h2>" .
droy3081da02009-05-11 15:54:56 +0000126 "\n\t<p>The following language packs are based on the community translations entered into the <a href='http://babel.eclipse.org/'>Babel Translation Tool</a>, and may not be complete or entirely accurate. If you find missing or incorrect translations, please use the <a href='http://babel.eclipse.org/'>Babel Translation Tool</a> to update them." .
kitloe3fea252010-01-25 02:13:49 +0000127 "\n\tAll downloads are provided under the terms and conditions of the <a href='http://www.eclipse.org/legal/epl/notice.php'>Eclipse Foundation Software User Agreement</a> unless otherwise specified.</p>" .
128 "\n\t<p>Go to: ");
kitlo9c7c62a2008-10-05 16:05:19 +0000129 $train_version_timestamp = "$train_version.v$timestamp";
kitloe3fea252010-01-25 02:13:49 +0000130 $language_pack_links_file_buffer = "";
kitlo9c7c62a2008-10-05 16:05:19 +0000131 $site_xml = "";
kitlo58d8a5a2008-09-24 20:08:44 +0000132
kitlo78f97432009-03-17 22:28:58 +0000133 $output_dir_for_train = $output_dir . $train_id . "/";
kitlo58d8a5a2008-09-24 20:08:44 +0000134 exec("mkdir $output_dir_for_train");
135 exec("mkdir ${output_dir_for_train}features/");
136 exec("mkdir ${output_dir_for_train}plugins/");
137
droy68864612009-04-14 15:44:05 +0000138 $sql = "SELECT language_id, iso_code, IF(locale <> '', CONCAT(CONCAT(CONCAT(name, ' ('), locale), ')'), name) as name, is_active, IF(language_id = 1,1,0) AS sorthack FROM languages ORDER BY sorthack, name ASC";
kitlo1d027092018-04-19 17:44:07 -0400139 $language_result = mysqli_query($dbh, $sql);
droyb3ff2742009-04-08 19:28:32 +0000140 if($language_result === FALSE) {
Kit Loe6c29bb2013-07-19 08:40:27 -0400141 # We may have lost the database connection with our shell-outs, reconnect
droyb3ff2742009-04-08 19:28:32 +0000142 $dbh = $dbc->connect();
kitlo1d027092018-04-19 17:44:07 -0400143 $language_result = mysqli_query($dbh, $sql);
droyb3ff2742009-04-08 19:28:32 +0000144 }
kitlo1d027092018-04-19 17:44:07 -0400145 while (($language_row = mysqli_fetch_assoc($language_result)) != null) {
droy0b08d292008-05-28 15:18:11 +0000146 $language_name = $language_row['name'];
kitlo58d8a5a2008-09-24 20:08:44 +0000147 $language_iso = $language_row['iso_code'];
kitlo58d8a5a2008-09-24 20:08:44 +0000148 $language_id = $language_row['language_id'];
149 if (strcmp($language_iso, "en") == 0) {
kitlo58d8a5a2008-09-24 20:08:44 +0000150 $language_name = "Pseudo Translations";
kitloe3fea252010-01-25 02:13:49 +0000151 $language_iso = "en_AA";
kitlo58d8a5a2008-09-24 20:08:44 +0000152 }
kitlo9c7c62a2008-10-05 16:05:19 +0000153
Kit Loe6c29bb2013-07-19 08:40:27 -0400154 echo "${leader}Generating language pack for: $language_name ($language_iso) (language_id=" . $language_id . ")\n";
kitlo58d8a5a2008-09-24 20:08:44 +0000155
Kit Loe6c29bb2013-07-19 08:40:27 -0400156 # Determine which plug-ins need to be in this language pack
kitlo58d8a5a2008-09-24 20:08:44 +0000157 if (strcmp($language_iso, "en_AA") == 0) {
kitlo1d027092018-04-19 17:44:07 -0400158 $file_result = mysqli_query($dbh, "SELECT DISTINCT f.project_id, f.version, f.file_id, f.name
kitlo58d8a5a2008-09-24 20:08:44 +0000159 FROM files AS f
160 INNER JOIN strings AS s ON f.file_id = s.file_id
161 INNER JOIN release_train_projects as v ON (f.project_id = v.project_id AND f.version = v.version)
162 WHERE f.is_active
kitlo78f97432009-03-17 22:28:58 +0000163 AND v.train_id = '" . $train_id . "'");
kitlo58d8a5a2008-09-24 20:08:44 +0000164 } else {
kitlo1d027092018-04-19 17:44:07 -0400165 $file_result = mysqli_query($dbh, "SELECT DISTINCT f.project_id, f.version, f.file_id, f.name
kitlo58d8a5a2008-09-24 20:08:44 +0000166 FROM files AS f
167 INNER JOIN strings AS s ON f.file_id = s.file_id
168 INNER JOIN translations AS t ON (s.string_id = t.string_id AND t.is_active)
169 INNER JOIN release_train_projects as v ON (f.project_id = v.project_id AND f.version = v.version)
170 WHERE t.language_id = " . $language_id . "
171 AND f.is_active
kitlo78f97432009-03-17 22:28:58 +0000172 AND v.train_id = '" . $train_id . "'");
kitlo58d8a5a2008-09-24 20:08:44 +0000173 }
174
droy0b08d292008-05-28 15:18:11 +0000175 $plugins = array();
kitlo9c7c62a2008-10-05 16:05:19 +0000176 $projects = array();
Kit Lo6d440cc2013-03-02 19:56:45 -0500177 $projects_include_orion = array();
kitlo9c7c62a2008-10-05 16:05:19 +0000178 $project_versions = array();
179 $pseudo_translations_indexes = array();
kitlo1d027092018-04-19 17:44:07 -0400180 while (($file_row = mysqli_fetch_assoc($file_result)) != null) {
kitlo58d8a5a2008-09-24 20:08:44 +0000181 # save original filename
182 $file_row['origname'] = $file_row['name'];
183
kitloc2fbc882011-06-11 21:31:40 +0000184 # remove optional outer dirs, e.g. 'pde/ui/'
185 $pos = strripos($file_row['name'], 'org.');
186 if ($pos !== false) {
187 $file_row['name'] = substr($file_row['name'], $pos);
188 }
189 $pos = strripos($file_row['name'], 'com.');
190 if ($pos !== false) {
191 $file_row['name'] = substr($file_row['name'], $pos);
192 }
193
194 $pattern =
195 '/^
196 (.*?)? # $1 plugin name
197 \/ # slash
198 (.*?\/)? # $2 dir name
199 ([^\/]+[.]properties) # $3 file name
200 $/ix';
201 $plugin_name_string = preg_replace($pattern, '$1', $file_row['name']);
202 $dir_name_string = preg_replace($pattern, '$2', $file_row['name']);
203 $file_name_string = preg_replace($pattern, '$3', $file_row['name']);
204
205 # remove optional source dir, e.g. 'src' or 'src_ant'
206 $pos = stripos($dir_name_string, 'org/');
207 if ($pos !== false) {
kitlo4e649d42011-06-12 12:50:35 +0000208 $dir_name_string = substr($dir_name_string, $pos);
kitloc2fbc882011-06-11 21:31:40 +0000209 }
210 $pos = strripos($dir_name_string, 'com/');
211 if ($pos !== false) {
212 $dir_name_string = substr($dir_name_string, $pos);
213 }
214
215 $file_row['plugin_name'] = $plugin_name_string;
216 $file_row['dir_name'] = $dir_name_string;
217 $file_row['file_name'] = $file_name_string;
218
Kit Lo6d440cc2013-03-02 19:56:45 -0500219 if (preg_match("/^(.*)\.js$/", $plugin_name_string)) {
220 $project_id = $file_row['project_id'];
221 $projects_include_orion[$project_id][] = "eclipse.orion";
222 $project_versions[$project_id] = $file_row['version'];
223 } else {
224 $plugins[$plugin_name_string][] = $file_row;
225 }
droy0b08d292008-05-28 15:18:11 +0000226 }
kitlo58d8a5a2008-09-24 20:08:44 +0000227
droy0b08d292008-05-28 15:18:11 +0000228 /*
229 * Generate one plug-in fragment for each plug-in
230 */
kitlobd84b752010-05-14 13:29:01 +0000231 ksort($plugins);
kitlo58d8a5a2008-09-24 20:08:44 +0000232 foreach ($plugins as $plugin_name => $plugin_row) {
233 echo "${leader}${leader}Generating plug-in fragment $plugin_name\n";
gobrien1a8e02f2008-01-30 01:46:26 +0000234 /*
droy0b08d292008-05-28 15:18:11 +0000235 * Clean and create the temporary directory
gobrien1a8e02f2008-01-30 01:46:26 +0000236 */
kitlo58d8a5a2008-09-24 20:08:44 +0000237 if (file_exists($tmp_dir)) {
238 exec("rm -rf $tmp_dir; mkdir $tmp_dir");
droy0b08d292008-05-28 15:18:11 +0000239 } else {
kitlo58d8a5a2008-09-24 20:08:44 +0000240 exec("mkdir $tmp_dir");
droy0b08d292008-05-28 15:18:11 +0000241 }
kitlo13edf222012-06-15 03:02:54 +0000242
gobrien1a8e02f2008-01-30 01:46:26 +0000243 /*
droy0b08d292008-05-28 15:18:11 +0000244 * Generate each *.properties file
gobrien1a8e02f2008-01-30 01:46:26 +0000245 */
droy0b08d292008-05-28 15:18:11 +0000246 foreach ($plugin_row as $properties_file) {
kitlo13edf222012-06-15 03:02:54 +0000247 $dirname = $properties_file['dir_name'];
kitloc2fbc882011-06-11 21:31:40 +0000248 $filename = $properties_file['file_name'];
kitlo13edf222012-06-15 03:02:54 +0000249
syoshida966ef1d2016-02-14 20:24:16 +0900250 if (isset($need_nl_path_case[$dirname])) {
kitlo13edf222012-06-15 03:02:54 +0000251 /*
252 * Convert the dirname to nl/lang/path, e.g., nl/fr/templates
253 */
254 $dirname = 'nl/' . $language_iso . '/' . $dirname;
255 } else {
256 /*
257 * Convert the filename to *_lang.properties, e.g., foo_fr.properties
258 */
259 if (preg_match( "/^(.*)\.properties$/", $filename, $matches)) {
260 $filename = $matches[1] . '_' . $language_iso . '.properties';
261 }
gobrien1a8e02f2008-01-30 01:46:26 +0000262 }
kitlo13edf222012-06-15 03:02:54 +0000263 echo "${leader}${leader}${leader}Generating properties file " . $dirname . $filename . " (file_id=" . $properties_file['file_id'] . ")\n";
droy0b08d292008-05-28 15:18:11 +0000264 /*
265 * Create any needed sub-directories
266 */
kitlo13edf222012-06-15 03:02:54 +0000267 exec("mkdir -p \"" . $tmp_dir . $dirname . "\"");
droy0b08d292008-05-28 15:18:11 +0000268 /*
269 * Start writing to the file
270 */
kitlo13edf222012-06-15 03:02:54 +0000271 $fullpath = $tmp_dir . $dirname . $filename;
kitlo58d8a5a2008-09-24 20:08:44 +0000272 $outp = fopen($fullpath, "w");
kitloc42941d2008-11-20 15:33:00 +0000273 fwrite($outp, "# Copyright by many contributors; see http://babel.eclipse.org/");
kitlo58d8a5a2008-09-24 20:08:44 +0000274 if (strcmp($language_iso, "en_AA") == 0) {
275 $sql = "SELECT string_id, name, value FROM strings WHERE file_id = " . $properties_file['file_id'] .
276 " AND is_active AND non_translatable = 0";
kitlo1d027092018-04-19 17:44:07 -0400277 $strings_result = mysqli_query($dbh, $sql);
278 while (($strings_row = mysqli_fetch_assoc($strings_result)) != null) {
kitlocc405032009-04-04 01:10:30 +0000279 /* Check for value starting with form tag (bug 270456) */
280 if (preg_match("/^(<form>)(.*)/i", $strings_row['value'], $matches)) {
281 $pattern = "/^(<form>)(.*)/i";
282 $replace = "$1" . "<p>" . $properties_file['project_id'] . $strings_row['string_id'] . ":" . "</p>" . "$2";
283 $strings_row['value'] = preg_replace($pattern, $replace, $strings_row['value']);
284 $outp_line = "\n" . $strings_row['name'] . "=" . $strings_row['value'];
285 } else {
286 $outp_line = "\n" . $strings_row['name'] . "=" . $properties_file['project_id'] . $strings_row['string_id'] .
287 ":" . $strings_row['value'];
288 }
289 fwrite($outp, $outp_line);
kitlo58d8a5a2008-09-24 20:08:44 +0000290
291 $value = htmlspecialchars($strings_row['value']);
292 if (strlen($value) > 100) {
293 $value = substr($value, 0, 100) . " ...";
294 }
kitlo9c7c62a2008-10-05 16:05:19 +0000295 $pseudo_translations_indexes[$properties_file['project_id']][] = "\n\t\t<li><a href=\"http://babel.eclipse.org/babel/translate.php?project=" .
296 $properties_file['project_id'] . "&version=" . $properties_file['version'] . "&file=" .
297 $properties_file['origname'] . "&string=" . $strings_row['name'] . "\">" .
298 $properties_file['project_id'] . $strings_row['string_id'] . "</a>&nbsp;" . $value . "</li>";
kitlo58d8a5a2008-09-24 20:08:44 +0000299 }
300 } else {
301 $sql = "SELECT
302 strings.name AS 'key',
303 strings.value AS orig,
304 translations.value AS trans
droy0b08d292008-05-28 15:18:11 +0000305 FROM strings, translations
306 WHERE strings.string_id = translations.string_id
droy0b08d292008-05-28 15:18:11 +0000307 AND strings.file_id = " . $properties_file['file_id'] . "
kitlo1173dbd2008-10-21 15:58:36 +0000308 AND strings.is_active
309 AND strings.non_translatable = 0
310 AND translations.language_id = " . $language_id . "
kitlo58d8a5a2008-09-24 20:08:44 +0000311 AND translations.is_active";
kitlo1d027092018-04-19 17:44:07 -0400312 $strings_result = mysqli_query($dbh, $sql);
313 while (($strings_row = mysqli_fetch_assoc($strings_result)) != null) {
kitlo7f522672008-10-21 14:15:54 +0000314 fwrite($outp, "\n" . $strings_row['key'] . "=");
kitlo9c7c62a2008-10-05 16:05:19 +0000315 # echo "${leader1S}${leaderS}${leaderS}${leaderS}" . $strings_row['key'] . "=";
kitlo58d8a5a2008-09-24 20:08:44 +0000316 if ($strings_row['trans']) {
317 # json_encode returns the string with quotes fore and aft. Need to strip them.
318 # $tr_string = preg_replace('/^"(.*)"$/', '${1}', json_encode($strings_row['trans']));
319 # $tr_string = str_replace('\\\\', '\\', $tr_string);
320 $tr_string = toescapedunicode($strings_row['trans']);
321 fwrite($outp, $tr_string);
322 # echo $strings_row['trans'];
323 } else {
324 fwrite($outp, $strings_row['orig']);
325 }
droy0b08d292008-05-28 15:18:11 +0000326 }
droy0b08d292008-05-28 15:18:11 +0000327 }
328 /*
329 * Finish the properties file
330 */
kitlo58d8a5a2008-09-24 20:08:44 +0000331 fclose($outp);
kitlo13edf222012-06-15 03:02:54 +0000332 echo "${leader}${leader}${leader}Completed properties file " . $dirname . $filename . "\n";
gobrien1a8e02f2008-01-30 01:46:26 +0000333 }
334 /*
droy0b08d292008-05-28 15:18:11 +0000335 * Copy in the various legal files
gobrien1a8e02f2008-01-30 01:46:26 +0000336 */
kitlo9c7c62a2008-10-05 16:05:19 +0000337 exec("cp ${source_files_dir}about.html $tmp_dir");
droy0b08d292008-05-28 15:18:11 +0000338 /*
339 * Generate the META-INF/MANIFEST.MF file
340 */
341 $parent_plugin_id = $plugin_name;
kitlo9c7c62a2008-10-05 16:05:19 +0000342 $project_id = $properties_file['project_id'];
kitlo5c9da712008-10-27 12:45:40 +0000343 $fragment_id = "$parent_plugin_id.nl_$language_iso";
kitlo9c7c62a2008-10-05 16:05:19 +0000344 $fragment_filename = "${fragment_id}_$train_version_timestamp.jar";
kitlo58d8a5a2008-09-24 20:08:44 +0000345
droy0b08d292008-05-28 15:18:11 +0000346 $plugins[$plugin_name]['id'] = $fragment_id;
kitlo9c7c62a2008-10-05 16:05:19 +0000347 $plugins[$plugin_name]['version'] = $train_version_timestamp;
kitlo58d8a5a2008-09-24 20:08:44 +0000348
kitlocc7ae442018-05-11 13:44:56 -0400349 exec("mkdir -p $tmp_dir/META-INF" );
kitlo58d8a5a2008-09-24 20:08:44 +0000350 $outp = fopen("$tmp_dir/META-INF/MANIFEST.MF", "w");
351 fwrite($outp, "Manifest-Version: 1.0\n");
352 fwrite($outp, "Bundle-Name: $parent_plugin_id $language_name NLS Support\n");
353 fwrite($outp, "Bundle-SymbolicName: $fragment_id ;singleton=true\n");
kitlo9c7c62a2008-10-05 16:05:19 +0000354 fwrite($outp, "Bundle-Version: $train_version_timestamp\n");
355 fwrite($outp, "Bundle-Vendor: Eclipse.org\n");
kitlo838ee402011-09-16 03:53:15 +0000356
syoshida966ef1d2016-02-14 20:24:16 +0900357 if (preg_match("/64$/", $plugin_name)) {
358
359 if (preg_match("/.gtk.linux.x86_64$/", $plugin_name)) {
360 $arr = split(".gtk.linux.x86_64", $plugin_name);
361 $parent_plugin_id = $arr[0] . "\nEclipse-PlatformFilter: (& (osgi.ws=gtk) (osgi.os=linux) (osgi.arch=x86_64))";
362 }
363 elseif (preg_match("/.linux.x86_64$/", $plugin_name)) {
364 $arr = split(".linux.x86_64", $plugin_name);
365 $parent_plugin_id = $arr[0] . "\nEclipse-PlatformFilter: (& (osgi.os=linux) (osgi.arch=x86_64))";
366 }
367 elseif (preg_match("/.gtk.linux.ppc64$/", $plugin_name)) {
368 $arr = split(".gtk.linux.ppc64", $plugin_name);
369 $parent_plugin_id = $arr[0] . "\nEclipse-PlatformFilter: (& (osgi.ws=gtk) (osgi.os=linux) (osgi.arch=ppc64))";
370 }
371 elseif (preg_match("/.gtk.aix.ppc64$/", $plugin_name)) {
372 $arr = split(".gtk.aix.ppc64", $plugin_name);
373 $parent_plugin_id = $arr[0] . "\nEclipse-PlatformFilter: (& (osgi.ws=gtk) (osgi.os=aix) (osgi.arch=ppc64))";
374 }
375 elseif (preg_match("/.cocoa.macosx.x86_64$/", $plugin_name)) {
376 $arr = split(".cocoa.macosx.x86_64", $plugin_name);
377 $parent_plugin_id = $arr[0] . "\nEclipse-PlatformFilter: (& (osgi.ws=cocoa) (osgi.os=macosx) (osgi.arch=x86_64))";
378 }
379 elseif (preg_match("/.win32.win32.x86_64$/", $plugin_name)) {
380 $arr = split(".win32.win32.x86_64", $plugin_name);
381 $parent_plugin_id = $arr[0] . "\nEclipse-PlatformFilter: (& (osgi.ws=win32) (osgi.os=win32) (osgi.arch=x86_64))";
382 }
383 elseif (preg_match("/.win32.x86_64$/", $plugin_name)) {
384 $arr = split(".win32.x86_64", $plugin_name);
385 $parent_plugin_id = $arr[0] . "\nEclipse-PlatformFilter: (& (osgi.os=win32) (osgi.arch=x86_64))";
386 }
387
kitlo838ee402011-09-16 03:53:15 +0000388 }
389
syoshida966ef1d2016-02-14 20:24:16 +0900390 elseif (preg_match("/86$/", $plugin_name)) {
391
392 if (preg_match("/.gtk.linux.x86$/", $plugin_name)) {
393 $arr = split(".gtk.linux.x86", $plugin_name);
394 $parent_plugin_id = $arr[0] . "\nEclipse-PlatformFilter: (& (osgi.ws=gtk) (osgi.os=linux) (osgi.arch=x86))";
395 }
396 elseif (preg_match("/.linux.x86$/", $plugin_name)) {
397 $arr = split(".linux.x86", $plugin_name);
398 $parent_plugin_id = $arr[0] . "\nEclipse-PlatformFilter: (& (osgi.os=linux) (osgi.arch=x86))";
399 }
400 elseif (preg_match("/.gtk.solaris.x86$/", $plugin_name)) {
401 $arr = split(".gtk.solaris.x86", $plugin_name);
402 $parent_plugin_id = $arr[0] . "\nEclipse-PlatformFilter: (& (osgi.ws=gtk) (osgi.os=solaris) (osgi.arch=x86))";
403 }
404 elseif (preg_match("/.win32.win32.x86$/", $plugin_name)) {
405 $arr = split(".win32.win32.x86", $plugin_name);
406 $parent_plugin_id = $arr[0] . "\nEclipse-PlatformFilter: (& (osgi.ws=win32) (osgi.os=win32) (osgi.arch=x86))";
407 }
408 elseif (preg_match("/.win32.x86$/", $plugin_name)) {
409 $arr = split(".win32.x86", $plugin_name);
410 $parent_plugin_id = $arr[0] . "\nEclipse-PlatformFilter: (& (osgi.os=win32) (osgi.arch=x86))";
411 }
412
kitlo838ee402011-09-16 03:53:15 +0000413 }
syoshida966ef1d2016-02-14 20:24:16 +0900414
415 elseif (preg_match("/32$/", $plugin_name)) {
416
417 if (preg_match("/.gtk.hpux.ia64_32$/", $plugin_name)) {
418 $arr = split(".gtk.hpux.ia64_32", $plugin_name);
419 $parent_plugin_id = $arr[0] . "\nEclipse-PlatformFilter: (& (osgi.ws=gtk) (osgi.os=hpux) (osgi.arch=ia64_32))";
420 }
421 elseif (preg_match("/.hpux.ia64_32$/", $plugin_name)) {
422 $arr = split(".hpux.ia64_32", $plugin_name);
423 $parent_plugin_id = $arr[0] . "\nEclipse-PlatformFilter: (& (osgi.os=hpux) (osgi.arch=ia64_32))";
424 }
425 elseif (preg_match("/^org.eclipse.compare.win32$/", $plugin_name)) {
426 $parent_plugin_id .= "\nEclipse-PlatformFilter: (osgi.os=win32)";
427 }
428 elseif (preg_match("/.win32$/", $plugin_name)) {
429 $arr = split(".win32", $plugin_name);
430 $parent_plugin_id = $arr[0] . "\nEclipse-PlatformFilter: (osgi.ws=win32)";
431 }
432
kitlo838ee402011-09-16 03:53:15 +0000433 }
syoshida966ef1d2016-02-14 20:24:16 +0900434
435 elseif (preg_match("/.macosx$/", $plugin_name)) {
436
437 if (preg_match("/.carbon.macosx$/", $plugin_name)) {
438 $arr = split(".carbon.macosx", $plugin_name);
439 $parent_plugin_id = $arr[0] . "\nEclipse-PlatformFilter: (& (osgi.ws=carbon) (osgi.os=macosx))";
440 }
441 elseif (preg_match("/.cocoa.macosx$/", $plugin_name)) {
442 $arr = split(".cocoa.macosx", $plugin_name);
443 $parent_plugin_id = $arr[0] . "\nEclipse-PlatformFilter: (& (osgi.ws=cocoa) (osgi.os=macosx))";
444 }
445 else {
446 $arr = split(".macosx", $plugin_name);
447 $parent_plugin_id = $arr[0] . "\nEclipse-PlatformFilter: (osgi.os=macosx)";
448 }
449
kitlo838ee402011-09-16 03:53:15 +0000450 }
451
452 elseif (preg_match("/.aix.ppc$/", $plugin_name)) {
syoshida966ef1d2016-02-14 20:24:16 +0900453
454 if (preg_match("/.gtk.aix.ppc$/", $plugin_name)) {
455 $arr = split(".gtk.aix.ppc", $plugin_name);
456 $parent_plugin_id = $arr[0] . "\nEclipse-PlatformFilter: (& (osgi.ws=gtk) (osgi.os=aix) (osgi.arch=ppc))";
457 }
458 else {
459 $arr = split(".aix.ppc", $plugin_name);
460 $parent_plugin_id = $arr[0] . "\nEclipse-PlatformFilter: (& (osgi.os=aix) (osgi.arch=ppc))";
461 }
462
kitlo838ee402011-09-16 03:53:15 +0000463 }
syoshida966ef1d2016-02-14 20:24:16 +0900464
kitlo838ee402011-09-16 03:53:15 +0000465 elseif (preg_match("/.solaris.sparc$/", $plugin_name)) {
syoshida966ef1d2016-02-14 20:24:16 +0900466
467 if (preg_match("/.gtk.solaris.sparc$/", $plugin_name)) {
468 $arr = split(".gtk.solaris.sparc", $plugin_name);
469 $parent_plugin_id = $arr[0] . "\nEclipse-PlatformFilter: (& (osgi.ws=gtk) (osgi.os=solaris) (osgi.arch=sparc))";
470 }
471 else {
472 $arr = split(".solaris.sparc", $plugin_name);
473 $parent_plugin_id = $arr[0] . "\nEclipse-PlatformFilter: (& (osgi.os=solaris) (osgi.arch=sparc))";
474 }
475
kitlo838ee402011-09-16 03:53:15 +0000476 }
syoshida966ef1d2016-02-14 20:24:16 +0900477
478 elseif (preg_match("/.gtk.linux.s390$/", $plugin_name)) {
479 $arr = split(".gtk.linux.s390", $plugin_name);
480 $parent_plugin_id = $arr[0] . "\nEclipse-PlatformFilter: (& (osgi.ws=gtk) (osgi.os=linux) (osgi.arch=s390))";
kitlo838ee402011-09-16 03:53:15 +0000481 }
syoshida966ef1d2016-02-14 20:24:16 +0900482 elseif (preg_match("/.gtk.linux.s390x$/", $plugin_name)) {
483 $arr = split(".gtk.linux.s390x", $plugin_name);
484 $parent_plugin_id = $arr[0] . "\nEclipse-PlatformFilter: (& (osgi.ws=gtk) (osgi.os=linux) (osgi.arch=s390x))";
kitlo838ee402011-09-16 03:53:15 +0000485 }
486
487 elseif (preg_match("/.carbon$/", $plugin_name)) {
488 $arr = split(".carbon", $plugin_name);
489 $parent_plugin_id = $arr[0] . "\nEclipse-PlatformFilter: (osgi.ws=carbon)";
490 }
491 elseif (preg_match("/.cocoa$/", $plugin_name)) {
492 $arr = split(".cocoa", $plugin_name);
493 $parent_plugin_id = $arr[0] . "\nEclipse-PlatformFilter: (osgi.ws=cocoa)";
494 }
495 elseif (preg_match("/.linux$/", $plugin_name)) {
496 $arr = split(".linux", $plugin_name);
497 $parent_plugin_id = $arr[0] . "\nEclipse-PlatformFilter: (osgi.os=linux)";
498 }
kitlo838ee402011-09-16 03:53:15 +0000499
kitlo58d8a5a2008-09-24 20:08:44 +0000500 fwrite($outp, "Fragment-Host: $parent_plugin_id\n");
501 fclose($outp);
droy0b08d292008-05-28 15:18:11 +0000502 /*
503 * Jar up this directory as the fragment plug-in jar
504 */
kitlo58d8a5a2008-09-24 20:08:44 +0000505 system("cd $tmp_dir; jar cfM ${output_dir_for_train}plugins/$fragment_filename .");
506 echo "${leader}${leader}Completed plug-in fragment $plugin_name\n";
kitlo58d8a5a2008-09-24 20:08:44 +0000507
kitlo9c7c62a2008-10-05 16:05:19 +0000508 $projects[$project_id][] = $fragment_id;
Kit Lo6d440cc2013-03-02 19:56:45 -0500509 $projects_include_orion[$project_id][] = $fragment_id;
kitlo9c7c62a2008-10-05 16:05:19 +0000510 $project_versions[$project_id] = $properties_file['version'];
droy0b08d292008-05-28 15:18:11 +0000511 }
kitlo78f97432009-03-17 22:28:58 +0000512 if (sizeof($projects) > 0) {
kitlo5110f3d2011-07-13 05:34:07 +0000513 $site_xml .= "\n\t<category-def name=\"lang_$language_iso\" label=\"Babel Language Packs in $language_name\">";
kitlo78f97432009-03-17 22:28:58 +0000514 $site_xml .= "\n\t\t<description>Babel Language Packs in $language_name</description>";
515 $site_xml .= "\n\t</category-def>";
Kit Lo6d440cc2013-03-02 19:56:45 -0500516 }
517 if (sizeof($projects_include_orion) > 0) {
kitloe3fea252010-01-25 02:13:49 +0000518 fwrite($language_pack_links_file, "\n\t\t<a href='#$language_iso'>$language_name</a>");
519 if (strcmp($language_iso, "en_AA") != 0) {
520 fwrite($language_pack_links_file, ",");
521 }
kitlob1920882010-05-12 23:33:18 +0000522 $language_pack_links_file_buffer .= "\n\t<h4>Language: <a name='$language_iso'>$language_name</a></h4>";
523 $language_pack_links_file_buffer .= "\n\t<ul>";
kitlo78f97432009-03-17 22:28:58 +0000524 }
Kit Lo6d440cc2013-03-02 19:56:45 -0500525 ksort($projects_include_orion);
526 foreach ($projects_include_orion as $project_id => $fragment_ids) {
kitlo9c7c62a2008-10-05 16:05:19 +0000527 /*
528 * Sort fragment names
529 */
530 asort($fragment_ids);
531 /*
kitlod43ec892011-06-25 23:27:28 +0000532 * Create ${babel_language_packs_dir_for_train}tmp
kitlo9c7c62a2008-10-05 16:05:19 +0000533 */
kitlod43ec892011-06-25 23:27:28 +0000534 exec("mkdir -p ${babel_language_packs_dir_for_train}tmp/eclipse/features");
535 exec("mkdir -p ${babel_language_packs_dir_for_train}tmp/eclipse/plugins");
kitlo9c7c62a2008-10-05 16:05:19 +0000536 /*
537 * Clean and create the temporary directory
538 */
539 if (file_exists($tmp_dir)) {
540 exec("rm -rf $tmp_dir; mkdir $tmp_dir");
541 } else {
542 exec("mkdir $tmp_dir");
543 }
544 /*
545 * Create the feature.xml
546 *
547 * TODO <url><update label=... url=... and <url><discovery label=... url=... are not implemented
548 *
549 * <url>
550 * <update label="%updateSiteName" url="http://update.eclipse.org/updates/3.2" />
551 * <discovery label="%updateSiteName" url="http://update.eclipse.org/updates/3.2" />
552 * </url>
553 */
kitlo5c9da712008-10-27 12:45:40 +0000554 $feature_id = "org.eclipse.babel.nls_${project_id}_$language_iso";
kitlo9c7c62a2008-10-05 16:05:19 +0000555 $feature_filename = "${feature_id}_$train_version_timestamp.jar";
556
kitlo9c7c62a2008-10-05 16:05:19 +0000557 if (strcmp($language_iso, "en_AA") == 0) {
558 $project_pct_complete = 100;
Kit Lo6d440cc2013-03-02 19:56:45 -0500559 if (strcmp($project_id, "eclipse.orion") != 0) {
560 $site_xml .= "\n\t<category-def name=\"proj_$project_id\" label=\"Babel Language Packs for $project_id\">";
561 $site_xml .= "\n\t\t<description>Babel Language Packs for $project_id</description>";
562 $site_xml .= "\n\t</category-def>";
563 }
kitlo95107b72010-07-29 05:18:34 +0000564 } else {
565 $project_version = $project_versions[$project_id];
566 $sql = "SELECT pct_complete
567 FROM project_progress
568 WHERE project_id = \"$project_id\"
569 AND version = \"$project_version\"
570 AND language_id = $language_id";
kitlo1d027092018-04-19 17:44:07 -0400571 $project_pct_complete_result = mysqli_query($dbh, $sql);
572 $project_pct_complete = mysqli_result($project_pct_complete_result, 0);
kitlo9c7c62a2008-10-05 16:05:19 +0000573 }
574
575 $outp = fopen("$tmp_dir/feature.xml", "w");
576 fwrite($outp, "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" .
577 "\n<feature" .
578 "\n\tid=\"$feature_id\"" .
579 "\n\tlabel=\"Babel Language Pack for $project_id in $language_name ($project_pct_complete%)\"" .
580 "\n\timage=\"eclipse_update_120.jpg\"" .
581 "\n\tprovider-name=\"%providerName\"" .
582 "\n\tversion=\"$train_version_timestamp\">" .
583 "\n\t<copyright>\n\t\t%copyright\n\t</copyright>" .
584 "\n\t<license url=\"%licenseURL\">\n\t\t%license\n\t</license>" .
585 "\n\t<description>Babel Language Pack for $project_id in $language_name</description>" );
586 foreach ($fragment_ids as $fragment_id) {
Kit Lo6d440cc2013-03-02 19:56:45 -0500587 if (strcmp($fragment_id, "eclipse.orion") != 0) {
588 $jar_name = "${output_dir_for_train}plugins/${fragment_id}_$train_version_timestamp.jar";
589 $size = filesize($jar_name);
590 fwrite($outp, "\n\t<plugin fragment=\"true\" id=\"$fragment_id\" unpack=\"false\" " .
591 "version=\"$train_version_timestamp\" download-size=\"$size\" install-size=\"$size\" />");
592 /*
593 * Copy the plugin to ${babel_language_packs_dir_for_train}tmp
594 */
595 exec("cp ${output_dir_for_train}plugins/${fragment_id}_$train_version_timestamp.jar ${babel_language_packs_dir_for_train}tmp/eclipse/plugins");
596 }
kitlo9c7c62a2008-10-05 16:05:19 +0000597 }
598 fwrite($outp, "\n</feature>");
599 fclose($outp);
600 /*
601 * Copy in the various legal files
602 */
603 exec("cp ${source_files_dir}about.html $tmp_dir");
604 exec("cp ${source_files_dir}eclipse_update_120.jpg $tmp_dir");
605 exec("cp ${source_files_dir}epl-v10.html $tmp_dir");
606 exec("cp ${source_files_dir}feature.properties $tmp_dir");
607 exec("cp ${source_files_dir}license.html $tmp_dir");
608 /*
609 * Copy in the Babel Pseudo Translations Index file
610 */
Kit Lo6d440cc2013-03-02 19:56:45 -0500611 if (strcmp($language_iso, "en_AA") == 0 && strcmp($project_id, "eclipse.orion") != 0) {
kitlo9c7c62a2008-10-05 16:05:19 +0000612 $pseudo_translations_index_file = fopen("${output_dir}BabelPseudoTranslationsIndex-$project_id.html", "w");
613 fwrite($pseudo_translations_index_file, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\">" .
614 "\n<html>\n<head>\n<title>Babel Pseudo Translations Index for $project_id</title>" .
615 "\n<meta http-equiv=Content-Type content=\"text/html; charset=UTF-8\">\n</head>" .
616 "\n<body>\n\t<h1>Babel Pseudo Translations Index for $project_id</h1>" .
617 "\n\t<h2>Version: $train_version_timestamp</h2>\n\t<ul>");
618 foreach ($pseudo_translations_indexes[$project_id] as $index) {
619 fwrite($pseudo_translations_index_file, $index);
620 }
droy03d5c462008-11-10 21:07:01 +0000621 fwrite($pseudo_translations_index_file, "\n\t</ul>\n</div></div></body>\n</html>");
kitlo9c7c62a2008-10-05 16:05:19 +0000622 fclose($pseudo_translations_index_file);
623 exec("cp ${output_dir}BabelPseudoTranslationsIndex-$project_id.html $tmp_dir");
624 exec("rm ${output_dir}BabelPseudoTranslationsIndex-$project_id.html");
625 }
626 /*
kitlod43ec892011-06-25 23:27:28 +0000627 * Copy the feature to ${babel_language_packs_dir_for_train}tmp before jar'ing up
kitlo9c7c62a2008-10-05 16:05:19 +0000628 */
kitlod43ec892011-06-25 23:27:28 +0000629 exec("mkdir -p ${babel_language_packs_dir_for_train}tmp/eclipse/features/${feature_id}_$train_version_timestamp");
630 exec("cd $tmp_dir; cp * ${babel_language_packs_dir_for_train}tmp/eclipse/features/${feature_id}_$train_version_timestamp");
kitlo9c7c62a2008-10-05 16:05:19 +0000631 /*
632 * Zip up language pack
633 */
634 $language_pack_name = "BabelLanguagePack-$project_id-${language_iso}_$train_version_timestamp.zip";
Kit Lo6d440cc2013-03-02 19:56:45 -0500635 if (strcmp($project_id, "eclipse.orion") != 0) {
636 exec("cd ${babel_language_packs_dir_for_train}tmp; zip -r $babel_language_packs_dir_for_train$language_pack_name eclipse");
637 }
kitlo9c7c62a2008-10-05 16:05:19 +0000638 /*
kitlod43ec892011-06-25 23:27:28 +0000639 * Clean up ${babel_language_packs_dir_for_train}tmp
kitlo9c7c62a2008-10-05 16:05:19 +0000640 */
kitlod43ec892011-06-25 23:27:28 +0000641 exec("rm -rf ${babel_language_packs_dir_for_train}tmp");
kitlo9c7c62a2008-10-05 16:05:19 +0000642 /*
643 * Add project language pack link to language pack links file
644 */
kitlob1920882010-05-12 23:33:18 +0000645 $language_pack_links_file_buffer .= "\n\t\t<li><a href=\"<?= \$language_pack_leader ?>/${language_pack_name}\">$language_pack_name ($project_pct_complete%)</a></li>";
kitlo9c7c62a2008-10-05 16:05:19 +0000646 /*
647 * Jar up this directory as the feature jar
648 */
Kit Lo6d440cc2013-03-02 19:56:45 -0500649 if (strcmp($project_id, "eclipse.orion") != 0) {
650 system("cd $tmp_dir; jar cfM ${output_dir_for_train}features/$feature_filename .");
651 }
kitlo9c7c62a2008-10-05 16:05:19 +0000652 /*
kitlof4c1d962011-06-24 13:32:40 +0000653 * Clean the temporary directory
654 */
655 exec("rm -rf $tmp_dir");
656 /*
kitlo9c7c62a2008-10-05 16:05:19 +0000657 * Register this feature with the site.xml
658 */
Kit Lo6d440cc2013-03-02 19:56:45 -0500659 if (strcmp($project_id, "eclipse.orion") != 0) {
660 $site_xml .= "\n\t<feature url=\"features/$feature_filename\" id=\"$feature_id\" version=\"$train_version_timestamp\">";
661 $site_xml .= "\n\t\t<category name=\"proj_$project_id\"/>";
662 $site_xml .= "\n\t\t<category name=\"lang_$language_iso\"/>";
663 $site_xml .= "\n\t</feature>";
664 }
droy58951f72009-05-13 18:12:20 +0000665 } /* End: foreach project */
666 echo "${leader}Completed language pack for $language_name ($language_iso)\n";
Kit Lo6d440cc2013-03-02 19:56:45 -0500667 if (sizeof($projects_include_orion) > 0) {
kitlob1920882010-05-12 23:33:18 +0000668 $language_pack_links_file_buffer .= "\n\t</ul>";
kitloe3fea252010-01-25 02:13:49 +0000669 }
gobrien1a8e02f2008-01-30 01:46:26 +0000670 }
kitlob1920882010-05-12 23:33:18 +0000671
672 fwrite($language_pack_links_file, "\n\t</p>");
673 fwrite($language_pack_links_file, $language_pack_links_file_buffer);
674
675 fwrite($language_pack_links_file, "\n\t<br />\n</body>\n</html>");
676 fclose($language_pack_links_file);
Kit Loe6c29bb2013-07-19 08:40:27 -0400677
kitloa59efea2018-05-11 12:40:40 -0400678 $dbc->disconnect($dbh);
kitlob1920882010-05-12 23:33:18 +0000679
gobrien1a8e02f2008-01-30 01:46:26 +0000680 /*
kitlob1920882010-05-12 23:33:18 +0000681 * Generate and save site.xml/content.jar/artifacts.jar with mirrorsURL
682 */
683 $outp = fopen("${output_dir_for_train}site.xml", "w");
684 fwrite($outp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" .
685 "\n<site pack200=\"true\" digestURL=\"http://download.eclipse.org/technology/babel/update-site/R$release_id/$train_id\"" .
686 "\n\tmirrorsURL=\"http://www.eclipse.org/downloads/download.php?file=/technology/babel/update-site/R$release_id/$train_id/site.xml&amp;format=xml\">" .
687 "\n\t<description url=\"http://babel.eclipse.org/\">" .
688 "\n\t\tThis update site contains user-contributed translations of the strings in all Eclipse projects." .
689 "\n\t\tPlease see the http://babel.eclipse.org/ Babel project web pages for a full how-to-use explanation of" .
690 "\n\t\tthese translations as well as how you can contribute to the translations of this and future versions of Eclipse." .
691 "\n\t</description>");
692 fwrite($outp, $site_xml);
693 fwrite($outp, "\n</site>");
694 fclose($outp);
695
696 /*
697 * Generate the metadata and add the non-greedy tags
698 * Note: Not needed for Europa and Ganymede because p2 repository was not supported
699 */
700 exec("mkdir ${output_dir_for_train}mirrors/");
701 if (file_exists(METADATA_GENERATOR_LOCATION) && strcmp($train_id, "europa") != 0 && strcmp($train_id, "ganymede") != 0) {
kitlo95107b72010-07-29 05:18:34 +0000702 echo "Running the Meta at " . dirname(__FILE__) . "/runMetadata.sh\n";
kitlo855ca862011-07-13 00:55:40 +0000703 system("/bin/sh " . dirname(__FILE__) . "/runMetadata.sh ". METADATA_GENERATOR_LOCATION . " $output_dir_for_train $train_version_timestamp");
kitlo95107b72010-07-29 05:18:34 +0000704 echo "Processing XML\n";
kitlob1920882010-05-12 23:33:18 +0000705 system("xsltproc -o ${output_dir_for_train}content.xml ". dirname(__FILE__) . "/content.xsl ${output_dir_for_train}content.xml");
706 system("cd ${output_dir_for_train} ; jar -fc content.jar content.xml ; jar -fc artifacts.jar artifacts.xml");
707 system("cd ${output_dir_for_train} ; rm content.xml ; rm artifacts.xml");
708 system("cd ${output_dir_for_train} ; mv content.jar mirrors/content.mirrors ; mv artifacts.jar mirrors/artifacts.mirrors");
709 }
710 system("cd ${output_dir_for_train} ; mv site.xml mirrors/site.mirrors");
711
712 /*
713 * Generate normal site.xml/content.jar/artifacts.jar without mirrorsURL
gobrien1a8e02f2008-01-30 01:46:26 +0000714 */
kitlo58d8a5a2008-09-24 20:08:44 +0000715 $outp = fopen("${output_dir_for_train}site.xml", "w");
kitlo9c7c62a2008-10-05 16:05:19 +0000716 fwrite($outp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" .
717 "\n<site>" .
718 "\n\t<description url=\"http://babel.eclipse.org/\">" .
719 "\n\t\tThis update site contains user-contributed translations of the strings in all Eclipse projects." .
720 "\n\t\tPlease see the http://babel.eclipse.org/ Babel project web pages for a full how-to-use explanation of" .
721 "\n\t\tthese translations as well as how you can contribute to the translations of this and future versions of Eclipse." .
722 "\n\t</description>");
kitlo58d8a5a2008-09-24 20:08:44 +0000723 fwrite($outp, $site_xml);
kitlo9c7c62a2008-10-05 16:05:19 +0000724 fwrite($outp, "\n</site>");
kitlo58d8a5a2008-09-24 20:08:44 +0000725 fclose($outp);
kitlo9c7c62a2008-10-05 16:05:19 +0000726
droye77ad172009-05-04 17:35:56 +0000727 /*
kitlob2ca7c02010-02-10 19:05:41 +0000728 * Generate the metadata and add the non-greedy tags
729 * Note: Not needed for Europa and Ganymede because p2 repository was not supported
730 */
kitloe9468742010-02-10 20:08:49 +0000731 if (file_exists(METADATA_GENERATOR_LOCATION) && strcmp($train_id, "europa") != 0 && strcmp($train_id, "ganymede") != 0) {
kitlo95107b72010-07-29 05:18:34 +0000732 echo "Running the Meta at " . dirname(__FILE__) . "/runMetadata.sh\n";
kitlo855ca862011-07-13 00:55:40 +0000733 system("/bin/sh " . dirname(__FILE__) . "/runMetadata.sh ". METADATA_GENERATOR_LOCATION . " $output_dir_for_train $train_version_timestamp");
kitlo95107b72010-07-29 05:18:34 +0000734 echo "Processing XML\n";
kitlob2ca7c02010-02-10 19:05:41 +0000735 system("xsltproc -o ${output_dir_for_train}content.xml ". dirname(__FILE__) . "/content.xsl ${output_dir_for_train}content.xml");
kitlob1920882010-05-12 23:33:18 +0000736 system("cd ${output_dir_for_train} ; jar -fc content.jar content.xml ; jar -fc artifacts.jar artifacts.xml");
737 system("cd ${output_dir_for_train} ; rm content.xml ; rm artifacts.xml");
738 system("cd ${output_dir_for_train} ; mv site.xml mirrors/site.txt");
739 } else {
740 system("cd ${output_dir_for_train} ; cp site.xml mirrors/site.txt");
kitlob2ca7c02010-02-10 19:05:41 +0000741 }
gobrien1a8e02f2008-01-30 01:46:26 +0000742}
gobrien1a8e02f2008-01-30 01:46:26 +0000743echo "Completed generating update site\n";
744
kitlo9c7c62a2008-10-05 16:05:19 +0000745
gobrien1a8e02f2008-01-30 01:46:26 +0000746/*
kitlo58d8a5a2008-09-24 20:08:44 +0000747 2. what happens if the translation feature includes plug-in fragments for
748 plug-ins that are not in the current image?
749 does it load correctly and ignore those fragments? if so, good
750 A: warnings appear in the run-time error log
751 does it fail to load? if so, then we need to generate different features, perhaps
752 one feature for each plug or else we need to know more about the project
753 distro structure to know which plug-ins to put in each feature
754 what happens if those plug-ins are later added - does it load the strings now?
755 A: probably not
756 3. need to handle different versions of each feature/plugin/platform; generate different
757 language packs for each
758 */
gobrien1a8e02f2008-01-30 01:46:26 +0000759
droyc6eb7ac2009-05-12 17:25:46 +0000760function usage() {
761 echo "\n";
762 echo "generate1.php -b <build_id> [-t <train_id>]\n";
763 echo " -b <build_id>: The Build ID for this build.\n";
kitlo3da25d52016-05-02 11:09:52 -0400764 echo " -t <train_id>: Optional: train to build (neon, mars, luna, kepler, juno, indigo, helios, galileo, ganymede, europa)";
droyc6eb7ac2009-05-12 17:25:46 +0000765 echo "\n";
766}
767
kitloe3fea252010-01-25 02:13:49 +0000768?>