gobrien | 1a8e02f | 2008-01-30 01:46:26 +0000 | [diff] [blame] | 1 | <?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 |
droy | 133e746 | 2008-05-13 17:37:24 +0000 | [diff] [blame] | 11 | * Motoki MORT mori-m@mxa.nes.nec.co.jp - patch, bug 227366 |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 12 | * 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 |
kitlo | 7f52267 | 2008-10-21 14:15:54 +0000 | [diff] [blame] | 14 | * Kit Lo (IBM) - patch, bug 251536, newline char missing after copyright comment on first line |
kitlo | 1173dbd | 2008-10-21 15:58:36 +0000 | [diff] [blame] | 15 | * Kit Lo (IBM) - patch, bug 238580, language packs should not include strings that are marked "non-translatable" |
kitlo | 5c9da71 | 2008-10-27 12:45:40 +0000 | [diff] [blame] | 16 | * Kit Lo (IBM) - patch, bug 252140, Illegal token characters in babel fragment names |
atoulme | dbda427 | 2009-01-20 06:04:22 +0000 | [diff] [blame] | 17 | * Antoine Toulme (Intalio, Inc) - patch, bug 256430, Fragments with no host jeopardize Eclipse installation |
kitlo | 47df0c6 | 2009-01-22 15:16:18 +0000 | [diff] [blame] | 18 | * Kit Lo (IBM) - patch, bug 261739, Inconsistent use of language names |
kitlo | 8d7c053 | 2009-03-14 23:57:49 +0000 | [diff] [blame] | 19 | * Sean Flanigan (Red Hat) - patch, bug 261584, wrong output folder |
kitlo | cc40503 | 2009-04-04 01:10:30 +0000 | [diff] [blame] | 20 | * Kit Lo (IBM) - patch, bug 270456, Unable to use Babel PTT to verify PDE in the eclipse SDK |
kitlo | e3fea25 | 2010-01-25 02:13:49 +0000 | [diff] [blame] | 21 | * Kit Lo (IBM) - Bug 299402, Extract properties files from Eclipse project update sites for translation |
kitlo | b2ca7c0 | 2010-02-10 19:05:41 +0000 | [diff] [blame] | 22 | * Kit Lo (IBM) - Bug 276306, Re-enable p2 repository |
kitlo | 844140c | 2010-04-28 16:16:05 +0000 | [diff] [blame] | 23 | * Kit Lo (IBM) - Bug 310135, Babel p2 update site not using mirrors |
kitlo | af74982 | 2010-07-29 05:19:44 +0000 | [diff] [blame] | 24 | * Kit Lo (IBM) - [289376] Need to start up a Helios build |
kitlo | c2fbc88 | 2011-06-11 21:31:40 +0000 | [diff] [blame] | 25 | * Kit Lo (IBM) - [344764] Translation fragments discard the plug-in's directory structure |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 26 | *******************************************************************************/ |
gobrien | 1a8e02f | 2008-01-30 01:46:26 +0000 | [diff] [blame] | 27 | |
| 28 | /* |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 29 | * Documentation: http://wiki.eclipse.org/Babel_/_Server_Tool_Specification#Outputs |
gobrien | 1a8e02f | 2008-01-30 01:46:26 +0000 | [diff] [blame] | 30 | */ |
atoulme | 3fa5f5c | 2009-01-20 21:26:16 +0000 | [diff] [blame] | 31 | define("METADATA_GENERATOR_LOCATION", "/home/genie/eclipse"); // you might want to read this value from a config file. Not sure yet. |
gobrien | b854dcb | 2008-01-30 18:50:45 +0000 | [diff] [blame] | 32 | |
droy | aa17250 | 2009-05-06 20:50:07 +0000 | [diff] [blame] | 33 | ini_set("memory_limit", "512M"); |
atoulme | 3ac5261 | 2009-02-02 13:14:39 +0000 | [diff] [blame] | 34 | require(dirname(__FILE__) . "/../system/backend_functions.php"); |
atoulme | 12882d5 | 2009-01-26 18:39:17 +0000 | [diff] [blame] | 35 | require(dirname(__FILE__) . "/../system/dbconnection.class.php"); |
droy | 3081da0 | 2009-05-11 15:54:56 +0000 | [diff] [blame] | 36 | |
kitlo | 2247902 | 2010-01-25 03:22:33 +0000 | [diff] [blame] | 37 | # Get all release trains |
kitlo | e3fea25 | 2010-01-25 02:13:49 +0000 | [diff] [blame] | 38 | $dbc = new DBConnection(); |
| 39 | $dbh = $dbc->connect(); |
| 40 | $result = mysql_query("SELECT * FROM release_trains ORDER BY train_version DESC"); |
| 41 | $train_result = array(); |
| 42 | while ($train_row = mysql_fetch_assoc($result)) { |
| 43 | $train_result[$train_row['train_id']] = $train_row['train_version']; |
| 44 | } |
droy | 3081da0 | 2009-05-11 15:54:56 +0000 | [diff] [blame] | 45 | |
| 46 | # Command-line parameter for the release train |
| 47 | # bug 272958 |
droy | c6eb7ac | 2009-05-12 17:25:46 +0000 | [diff] [blame] | 48 | # b: build id |
| 49 | # t: (optional: train id) |
| 50 | |
| 51 | $options = getopt("b:t:"); |
droy | 3081da0 | 2009-05-11 15:54:56 +0000 | [diff] [blame] | 52 | $argv_train = ""; |
droy | c6eb7ac | 2009-05-12 17:25:46 +0000 | [diff] [blame] | 53 | if(isset($options['t'])) { |
| 54 | $argv_train = $options['t']; |
droy | 3081da0 | 2009-05-11 15:54:56 +0000 | [diff] [blame] | 55 | if(array_key_exists($argv_train, $train_result)) { |
| 56 | # Picked a valid train .. remove all others |
| 57 | foreach ($train_result as $train_id => $train_version) { |
| 58 | if($train_id != $argv_train) { |
| 59 | unset($train_result[$train_id]); |
| 60 | } |
| 61 | } |
| 62 | } |
| 63 | } |
| 64 | |
kitlo | b192088 | 2010-05-12 23:33:18 +0000 | [diff] [blame] | 65 | $build_id = ""; |
droy | c6eb7ac | 2009-05-12 17:25:46 +0000 | [diff] [blame] | 66 | if(!isset($options['b'])) { |
| 67 | usage(); |
| 68 | exit(); |
| 69 | } |
| 70 | else { |
kitlo | b192088 | 2010-05-12 23:33:18 +0000 | [diff] [blame] | 71 | $build_id = $options['b']; |
droy | c6eb7ac | 2009-05-12 17:25:46 +0000 | [diff] [blame] | 72 | } |
| 73 | |
kitlo | b192088 | 2010-05-12 23:33:18 +0000 | [diff] [blame] | 74 | $release_id = "0.8.0"; |
| 75 | |
atoulme | 3ac5261 | 2009-02-02 13:14:39 +0000 | [diff] [blame] | 76 | $work_dir = $addon->callHook('babel_working'); |
atoulme | 12882d5 | 2009-01-26 18:39:17 +0000 | [diff] [blame] | 77 | |
atoulme | 3ac5261 | 2009-02-02 13:14:39 +0000 | [diff] [blame] | 78 | global $addon; |
| 79 | $context = $addon->callHook('context'); |
gobrien | b854dcb | 2008-01-30 18:50:45 +0000 | [diff] [blame] | 80 | |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 81 | $work_context_dir = $work_dir . $context . "/"; |
| 82 | $tmp_dir = $work_context_dir . "tmp/"; |
| 83 | $babel_language_packs_dir = $work_context_dir . "babel_language_packs/"; |
| 84 | $output_dir = $work_context_dir . "output/"; |
atoulme | 3ac5261 | 2009-02-02 13:14:39 +0000 | [diff] [blame] | 85 | $source_files_dir = dirname(__FILE__) . "/source_files_for_generate/"; |
gobrien | b854dcb | 2008-01-30 18:50:45 +0000 | [diff] [blame] | 86 | |
gobrien | 1a8e02f | 2008-01-30 01:46:26 +0000 | [diff] [blame] | 87 | $leader = ". . "; |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 88 | $timestamp = date("Ymdhis"); |
gobrien | 1a8e02f | 2008-01-30 01:46:26 +0000 | [diff] [blame] | 89 | |
kitlo | 95107b7 | 2010-07-29 05:18:34 +0000 | [diff] [blame] | 90 | $rm_command = "rm -rf $tmp_dir; rm -rf $babel_language_packs_dir; rm -rf $output_dir"; |
droy | d157aac | 2008-10-07 21:14:33 +0000 | [diff] [blame] | 91 | exec($rm_command); |
droy | 082976e | 2008-10-07 21:02:23 +0000 | [diff] [blame] | 92 | exec("mkdir -p $output_dir"); |
| 93 | |
droy | 3081da0 | 2009-05-11 15:54:56 +0000 | [diff] [blame] | 94 | echo "Requested builds: "; |
kitlo | 78f9743 | 2009-03-17 22:28:58 +0000 | [diff] [blame] | 95 | foreach ($train_result as $train_id => $train_version) { |
droy | 3081da0 | 2009-05-11 15:54:56 +0000 | [diff] [blame] | 96 | echo $train_id . " "; |
| 97 | } |
| 98 | echo "\n"; |
kitlo | 78f9743 | 2009-03-17 22:28:58 +0000 | [diff] [blame] | 99 | |
droy | 3081da0 | 2009-05-11 15:54:56 +0000 | [diff] [blame] | 100 | # Loop through the trains |
| 101 | foreach ($train_result as $train_id => $train_version) { |
droy | 3081da0 | 2009-05-11 15:54:56 +0000 | [diff] [blame] | 102 | echo "Generating update site for: $train_id\n"; |
droy | 3081da0 | 2009-05-11 15:54:56 +0000 | [diff] [blame] | 103 | |
| 104 | /* |
| 105 | * Create language pack links file |
| 106 | */ |
| 107 | exec("mkdir -p $babel_language_packs_dir"); |
| 108 | $language_pack_links_file = fopen("${babel_language_packs_dir}${train_id}.php", "w"); |
droy | c6eb7ac | 2009-05-12 17:25:46 +0000 | [diff] [blame] | 109 | fwrite($language_pack_links_file, "<?php\n"); |
droy | 260639a | 2009-05-28 20:02:21 +0000 | [diff] [blame] | 110 | # Uncomment if each train is in its own directory: fwrite($language_pack_links_file, "\$language_pack_leader = \"${train_id}\";\n"); |
| 111 | fwrite($language_pack_links_file, "\$language_pack_leader = \".\";\n"); |
droy | 58951f7 | 2009-05-13 18:12:20 +0000 | [diff] [blame] | 112 | fwrite($language_pack_links_file, "?>\n"); |
droy | c6eb7ac | 2009-05-12 17:25:46 +0000 | [diff] [blame] | 113 | # copy page_header.html here |
| 114 | $header = file_get_contents("${source_files_dir}page_header.html"); |
| 115 | fwrite($language_pack_links_file, $header); |
kitlo | e3fea25 | 2010-01-25 02:13:49 +0000 | [diff] [blame] | 116 | fwrite($language_pack_links_file, "\n\t<h1>Babel Language Packs for " . ucfirst($train_id) . "</h1>" . |
kitlo | b192088 | 2010-05-12 23:33:18 +0000 | [diff] [blame] | 117 | "\n\t<h2>Build ID: $build_id</h2>" . |
droy | 3081da0 | 2009-05-11 15:54:56 +0000 | [diff] [blame] | 118 | "\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." . |
kitlo | e3fea25 | 2010-01-25 02:13:49 +0000 | [diff] [blame] | 119 | "\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>" . |
| 120 | "\n\t<p>Go to: "); |
| 121 | |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 122 | $train_version_timestamp = "$train_version.v$timestamp"; |
kitlo | e3fea25 | 2010-01-25 02:13:49 +0000 | [diff] [blame] | 123 | $language_pack_links_file_buffer = ""; |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 124 | $site_xml = ""; |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 125 | |
kitlo | 78f9743 | 2009-03-17 22:28:58 +0000 | [diff] [blame] | 126 | $output_dir_for_train = $output_dir . $train_id . "/"; |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 127 | exec("mkdir $output_dir_for_train"); |
| 128 | exec("mkdir ${output_dir_for_train}features/"); |
| 129 | exec("mkdir ${output_dir_for_train}plugins/"); |
| 130 | |
droy | 6886461 | 2009-04-14 15:44:05 +0000 | [diff] [blame] | 131 | $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"; |
| 132 | $language_result = mysql_query($sql); |
droy | b3ff274 | 2009-04-08 19:28:32 +0000 | [diff] [blame] | 133 | if($language_result === FALSE) { |
kitlo | e3fea25 | 2010-01-25 02:13:49 +0000 | [diff] [blame] | 134 | # we may have lost the database connection with our shell-outs |
droy | b3ff274 | 2009-04-08 19:28:32 +0000 | [diff] [blame] | 135 | # bug 271685 |
| 136 | $dbh = $dbc->connect(); |
droy | 6886461 | 2009-04-14 15:44:05 +0000 | [diff] [blame] | 137 | $language_result = mysql_query($sql); |
droy | b3ff274 | 2009-04-08 19:28:32 +0000 | [diff] [blame] | 138 | } |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 139 | while (($language_row = mysql_fetch_assoc($language_result)) != null) { |
droy | 0b08d29 | 2008-05-28 15:18:11 +0000 | [diff] [blame] | 140 | $language_name = $language_row['name']; |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 141 | $language_iso = $language_row['iso_code']; |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 142 | $language_id = $language_row['language_id']; |
| 143 | if (strcmp($language_iso, "en") == 0) { |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 144 | $language_name = "Pseudo Translations"; |
kitlo | e3fea25 | 2010-01-25 02:13:49 +0000 | [diff] [blame] | 145 | $language_iso = "en_AA"; |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 146 | } |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 147 | |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 148 | echo "${leader}Generating language pack for $train_id - $language_name ($language_iso) (language_id=" . $language_id . ")\n"; |
| 149 | |
gobrien | 1a8e02f | 2008-01-30 01:46:26 +0000 | [diff] [blame] | 150 | /* |
droy | 0b08d29 | 2008-05-28 15:18:11 +0000 | [diff] [blame] | 151 | * Determine which plug-ins need to be in this language pack. |
gobrien | 1a8e02f | 2008-01-30 01:46:26 +0000 | [diff] [blame] | 152 | */ |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 153 | if (strcmp($language_iso, "en_AA") == 0) { |
| 154 | $file_result = mysql_query("SELECT DISTINCT f.project_id, f.version, f.file_id, f.name |
| 155 | FROM files AS f |
| 156 | INNER JOIN strings AS s ON f.file_id = s.file_id |
| 157 | INNER JOIN release_train_projects as v ON (f.project_id = v.project_id AND f.version = v.version) |
| 158 | WHERE f.is_active |
kitlo | 78f9743 | 2009-03-17 22:28:58 +0000 | [diff] [blame] | 159 | AND v.train_id = '" . $train_id . "'"); |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 160 | } else { |
| 161 | $file_result = mysql_query("SELECT DISTINCT f.project_id, f.version, f.file_id, f.name |
| 162 | FROM files AS f |
| 163 | INNER JOIN strings AS s ON f.file_id = s.file_id |
| 164 | INNER JOIN translations AS t ON (s.string_id = t.string_id AND t.is_active) |
| 165 | INNER JOIN release_train_projects as v ON (f.project_id = v.project_id AND f.version = v.version) |
| 166 | WHERE t.language_id = " . $language_id . " |
| 167 | AND f.is_active |
kitlo | 78f9743 | 2009-03-17 22:28:58 +0000 | [diff] [blame] | 168 | AND v.train_id = '" . $train_id . "'"); |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 169 | } |
| 170 | |
droy | 0b08d29 | 2008-05-28 15:18:11 +0000 | [diff] [blame] | 171 | $plugins = array(); |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 172 | $projects = array(); |
| 173 | $project_versions = array(); |
| 174 | $pseudo_translations_indexes = array(); |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 175 | while (($file_row = mysql_fetch_assoc($file_result)) != null) { |
| 176 | # save original filename |
| 177 | $file_row['origname'] = $file_row['name']; |
| 178 | |
kitlo | c2fbc88 | 2011-06-11 21:31:40 +0000 | [diff] [blame] | 179 | # remove optional outer dirs, e.g. 'pde/ui/' |
| 180 | $pos = strripos($file_row['name'], 'org.'); |
| 181 | if ($pos !== false) { |
| 182 | $file_row['name'] = substr($file_row['name'], $pos); |
| 183 | } |
| 184 | $pos = strripos($file_row['name'], 'com.'); |
| 185 | if ($pos !== false) { |
| 186 | $file_row['name'] = substr($file_row['name'], $pos); |
| 187 | } |
| 188 | |
| 189 | $pattern = |
| 190 | '/^ |
| 191 | (.*?)? # $1 plugin name |
| 192 | \/ # slash |
| 193 | (.*?\/)? # $2 dir name |
| 194 | ([^\/]+[.]properties) # $3 file name |
| 195 | $/ix'; |
| 196 | $plugin_name_string = preg_replace($pattern, '$1', $file_row['name']); |
| 197 | $dir_name_string = preg_replace($pattern, '$2', $file_row['name']); |
| 198 | $file_name_string = preg_replace($pattern, '$3', $file_row['name']); |
| 199 | |
| 200 | # remove optional source dir, e.g. 'src' or 'src_ant' |
| 201 | $pos = stripos($dir_name_string, 'org/'); |
| 202 | if ($pos !== false) { |
kitlo | 4e649d4 | 2011-06-12 12:50:35 +0000 | [diff] [blame] | 203 | $dir_name_string = substr($dir_name_string, $pos); |
kitlo | c2fbc88 | 2011-06-11 21:31:40 +0000 | [diff] [blame] | 204 | } |
| 205 | $pos = strripos($dir_name_string, 'com/'); |
| 206 | if ($pos !== false) { |
| 207 | $dir_name_string = substr($dir_name_string, $pos); |
| 208 | } |
| 209 | |
| 210 | $file_row['plugin_name'] = $plugin_name_string; |
| 211 | $file_row['dir_name'] = $dir_name_string; |
| 212 | $file_row['file_name'] = $file_name_string; |
| 213 | |
| 214 | $plugins[$plugin_name_string][] = $file_row; |
droy | 0b08d29 | 2008-05-28 15:18:11 +0000 | [diff] [blame] | 215 | } |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 216 | |
droy | 0b08d29 | 2008-05-28 15:18:11 +0000 | [diff] [blame] | 217 | /* |
| 218 | * Generate one plug-in fragment for each plug-in |
| 219 | */ |
kitlo | bd84b75 | 2010-05-14 13:29:01 +0000 | [diff] [blame] | 220 | ksort($plugins); |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 221 | foreach ($plugins as $plugin_name => $plugin_row) { |
| 222 | echo "${leader}${leader}Generating plug-in fragment $plugin_name\n"; |
gobrien | 1a8e02f | 2008-01-30 01:46:26 +0000 | [diff] [blame] | 223 | /* |
droy | 0b08d29 | 2008-05-28 15:18:11 +0000 | [diff] [blame] | 224 | * Clean and create the temporary directory |
gobrien | 1a8e02f | 2008-01-30 01:46:26 +0000 | [diff] [blame] | 225 | */ |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 226 | if (file_exists($tmp_dir)) { |
| 227 | exec("rm -rf $tmp_dir; mkdir $tmp_dir"); |
droy | 0b08d29 | 2008-05-28 15:18:11 +0000 | [diff] [blame] | 228 | } else { |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 229 | exec("mkdir $tmp_dir"); |
droy | 0b08d29 | 2008-05-28 15:18:11 +0000 | [diff] [blame] | 230 | } |
gobrien | 1a8e02f | 2008-01-30 01:46:26 +0000 | [diff] [blame] | 231 | /* |
droy | 0b08d29 | 2008-05-28 15:18:11 +0000 | [diff] [blame] | 232 | * Generate each *.properties file |
gobrien | 1a8e02f | 2008-01-30 01:46:26 +0000 | [diff] [blame] | 233 | */ |
droy | 0b08d29 | 2008-05-28 15:18:11 +0000 | [diff] [blame] | 234 | foreach ($plugin_row as $properties_file) { |
| 235 | /* |
| 236 | * Convert the filename to *_lang.properties, e.g., foo_fr.properties |
| 237 | */ |
kitlo | c2fbc88 | 2011-06-11 21:31:40 +0000 | [diff] [blame] | 238 | $filename = $properties_file['file_name']; |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 239 | if (preg_match( "/^(.*)\.properties$/", $filename, $matches)) { |
droy | 0b08d29 | 2008-05-28 15:18:11 +0000 | [diff] [blame] | 240 | $filename = $matches[1] . '_' . $language_iso . '.properties'; |
gobrien | 1a8e02f | 2008-01-30 01:46:26 +0000 | [diff] [blame] | 241 | } |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 242 | echo "${leader}${leader}${leader}Generating properties file $filename (file_id=" . $properties_file['file_id'] . ")\n"; |
droy | 0b08d29 | 2008-05-28 15:18:11 +0000 | [diff] [blame] | 243 | /* |
| 244 | * Create any needed sub-directories |
| 245 | */ |
kitlo | c2fbc88 | 2011-06-11 21:31:40 +0000 | [diff] [blame] | 246 | exec("mkdir -p \"" . $tmp_dir . $properties_file['dir_name'] . "\""); |
droy | 0b08d29 | 2008-05-28 15:18:11 +0000 | [diff] [blame] | 247 | /* |
| 248 | * Start writing to the file |
| 249 | */ |
kitlo | c2fbc88 | 2011-06-11 21:31:40 +0000 | [diff] [blame] | 250 | $fullpath = $tmp_dir . $properties_file['dir_name'] . $filename; |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 251 | $outp = fopen($fullpath, "w"); |
kitlo | c42941d | 2008-11-20 15:33:00 +0000 | [diff] [blame] | 252 | fwrite($outp, "# Copyright by many contributors; see http://babel.eclipse.org/"); |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 253 | if (strcmp($language_iso, "en_AA") == 0) { |
| 254 | $sql = "SELECT string_id, name, value FROM strings WHERE file_id = " . $properties_file['file_id'] . |
| 255 | " AND is_active AND non_translatable = 0"; |
| 256 | $strings_result = mysql_query($sql); |
| 257 | while (($strings_row = mysql_fetch_assoc($strings_result)) != null) { |
kitlo | cc40503 | 2009-04-04 01:10:30 +0000 | [diff] [blame] | 258 | /* Check for value starting with form tag (bug 270456) */ |
| 259 | if (preg_match("/^(<form>)(.*)/i", $strings_row['value'], $matches)) { |
| 260 | $pattern = "/^(<form>)(.*)/i"; |
| 261 | $replace = "$1" . "<p>" . $properties_file['project_id'] . $strings_row['string_id'] . ":" . "</p>" . "$2"; |
| 262 | $strings_row['value'] = preg_replace($pattern, $replace, $strings_row['value']); |
| 263 | $outp_line = "\n" . $strings_row['name'] . "=" . $strings_row['value']; |
| 264 | } else { |
| 265 | $outp_line = "\n" . $strings_row['name'] . "=" . $properties_file['project_id'] . $strings_row['string_id'] . |
| 266 | ":" . $strings_row['value']; |
| 267 | } |
| 268 | fwrite($outp, $outp_line); |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 269 | |
| 270 | $value = htmlspecialchars($strings_row['value']); |
| 271 | if (strlen($value) > 100) { |
| 272 | $value = substr($value, 0, 100) . " ..."; |
| 273 | } |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 274 | $pseudo_translations_indexes[$properties_file['project_id']][] = "\n\t\t<li><a href=\"http://babel.eclipse.org/babel/translate.php?project=" . |
| 275 | $properties_file['project_id'] . "&version=" . $properties_file['version'] . "&file=" . |
| 276 | $properties_file['origname'] . "&string=" . $strings_row['name'] . "\">" . |
| 277 | $properties_file['project_id'] . $strings_row['string_id'] . "</a> " . $value . "</li>"; |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 278 | } |
| 279 | } else { |
| 280 | $sql = "SELECT |
| 281 | strings.name AS 'key', |
| 282 | strings.value AS orig, |
| 283 | translations.value AS trans |
droy | 0b08d29 | 2008-05-28 15:18:11 +0000 | [diff] [blame] | 284 | FROM strings, translations |
| 285 | WHERE strings.string_id = translations.string_id |
droy | 0b08d29 | 2008-05-28 15:18:11 +0000 | [diff] [blame] | 286 | AND strings.file_id = " . $properties_file['file_id'] . " |
kitlo | 1173dbd | 2008-10-21 15:58:36 +0000 | [diff] [blame] | 287 | AND strings.is_active |
| 288 | AND strings.non_translatable = 0 |
| 289 | AND translations.language_id = " . $language_id . " |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 290 | AND translations.is_active"; |
| 291 | $strings_result = mysql_query($sql); |
| 292 | while (($strings_row = mysql_fetch_assoc($strings_result)) != null) { |
kitlo | 7f52267 | 2008-10-21 14:15:54 +0000 | [diff] [blame] | 293 | fwrite($outp, "\n" . $strings_row['key'] . "="); |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 294 | # echo "${leader1S}${leaderS}${leaderS}${leaderS}" . $strings_row['key'] . "="; |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 295 | if ($strings_row['trans']) { |
| 296 | # json_encode returns the string with quotes fore and aft. Need to strip them. |
| 297 | # $tr_string = preg_replace('/^"(.*)"$/', '${1}', json_encode($strings_row['trans'])); |
| 298 | # $tr_string = str_replace('\\\\', '\\', $tr_string); |
| 299 | $tr_string = toescapedunicode($strings_row['trans']); |
| 300 | fwrite($outp, $tr_string); |
| 301 | # echo $strings_row['trans']; |
| 302 | } else { |
| 303 | fwrite($outp, $strings_row['orig']); |
| 304 | } |
droy | 0b08d29 | 2008-05-28 15:18:11 +0000 | [diff] [blame] | 305 | } |
droy | 0b08d29 | 2008-05-28 15:18:11 +0000 | [diff] [blame] | 306 | } |
| 307 | /* |
| 308 | * Finish the properties file |
| 309 | */ |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 310 | fclose($outp); |
| 311 | echo "${leader}${leader}${leader}Completed properties file $filename\n"; |
gobrien | 1a8e02f | 2008-01-30 01:46:26 +0000 | [diff] [blame] | 312 | } |
| 313 | /* |
droy | 0b08d29 | 2008-05-28 15:18:11 +0000 | [diff] [blame] | 314 | * Copy in the various legal files |
gobrien | 1a8e02f | 2008-01-30 01:46:26 +0000 | [diff] [blame] | 315 | */ |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 316 | exec("cp ${source_files_dir}about.html $tmp_dir"); |
droy | 0b08d29 | 2008-05-28 15:18:11 +0000 | [diff] [blame] | 317 | /* |
| 318 | * Generate the META-INF/MANIFEST.MF file |
| 319 | */ |
| 320 | $parent_plugin_id = $plugin_name; |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 321 | $project_id = $properties_file['project_id']; |
kitlo | 5c9da71 | 2008-10-27 12:45:40 +0000 | [diff] [blame] | 322 | $fragment_id = "$parent_plugin_id.nl_$language_iso"; |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 323 | $fragment_filename = "${fragment_id}_$train_version_timestamp.jar"; |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 324 | |
droy | 0b08d29 | 2008-05-28 15:18:11 +0000 | [diff] [blame] | 325 | $plugins[$plugin_name]['id'] = $fragment_id; |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 326 | $plugins[$plugin_name]['version'] = $train_version_timestamp; |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 327 | |
| 328 | exec("mkdir $tmp_dir/META-INF" ); |
| 329 | $outp = fopen("$tmp_dir/META-INF/MANIFEST.MF", "w"); |
| 330 | fwrite($outp, "Manifest-Version: 1.0\n"); |
| 331 | fwrite($outp, "Bundle-Name: $parent_plugin_id $language_name NLS Support\n"); |
| 332 | fwrite($outp, "Bundle-SymbolicName: $fragment_id ;singleton=true\n"); |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 333 | fwrite($outp, "Bundle-Version: $train_version_timestamp\n"); |
| 334 | fwrite($outp, "Bundle-Vendor: Eclipse.org\n"); |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 335 | fwrite($outp, "Fragment-Host: $parent_plugin_id\n"); |
| 336 | fclose($outp); |
droy | 0b08d29 | 2008-05-28 15:18:11 +0000 | [diff] [blame] | 337 | /* |
| 338 | * Jar up this directory as the fragment plug-in jar |
| 339 | */ |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 340 | system("cd $tmp_dir; jar cfM ${output_dir_for_train}plugins/$fragment_filename ."); |
| 341 | echo "${leader}${leader}Completed plug-in fragment $plugin_name\n"; |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 342 | |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 343 | $projects[$project_id][] = $fragment_id; |
| 344 | $project_versions[$project_id] = $properties_file['version']; |
droy | 0b08d29 | 2008-05-28 15:18:11 +0000 | [diff] [blame] | 345 | } |
kitlo | 78f9743 | 2009-03-17 22:28:58 +0000 | [diff] [blame] | 346 | if (sizeof($projects) > 0) { |
| 347 | $site_xml .= "\n\t<category-def name=\"Babel Language Packs in $language_name\" label=\"Babel Language Packs in $language_name\">"; |
| 348 | $site_xml .= "\n\t\t<description>Babel Language Packs in $language_name</description>"; |
| 349 | $site_xml .= "\n\t</category-def>"; |
| 350 | |
kitlo | e3fea25 | 2010-01-25 02:13:49 +0000 | [diff] [blame] | 351 | fwrite($language_pack_links_file, "\n\t\t<a href='#$language_iso'>$language_name</a>"); |
| 352 | if (strcmp($language_iso, "en_AA") != 0) { |
| 353 | fwrite($language_pack_links_file, ","); |
| 354 | } |
kitlo | b192088 | 2010-05-12 23:33:18 +0000 | [diff] [blame] | 355 | $language_pack_links_file_buffer .= "\n\t<h4>Language: <a name='$language_iso'>$language_name</a></h4>"; |
| 356 | $language_pack_links_file_buffer .= "\n\t<ul>"; |
kitlo | 78f9743 | 2009-03-17 22:28:58 +0000 | [diff] [blame] | 357 | } |
kitlo | bd84b75 | 2010-05-14 13:29:01 +0000 | [diff] [blame] | 358 | ksort($projects); |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 359 | foreach ($projects as $project_id => $fragment_ids) { |
| 360 | /* |
| 361 | * Sort fragment names |
| 362 | */ |
| 363 | asort($fragment_ids); |
| 364 | /* |
| 365 | * Create ${babel_language_packs_dir}tmp |
| 366 | */ |
| 367 | exec("mkdir -p ${babel_language_packs_dir}tmp/eclipse/features"); |
| 368 | exec("mkdir -p ${babel_language_packs_dir}tmp/eclipse/plugins"); |
| 369 | /* |
| 370 | * Clean and create the temporary directory |
| 371 | */ |
| 372 | if (file_exists($tmp_dir)) { |
| 373 | exec("rm -rf $tmp_dir; mkdir $tmp_dir"); |
| 374 | } else { |
| 375 | exec("mkdir $tmp_dir"); |
| 376 | } |
| 377 | /* |
| 378 | * Create the feature.xml |
| 379 | * |
| 380 | * TODO <url><update label=... url=... and <url><discovery label=... url=... are not implemented |
| 381 | * |
| 382 | * <url> |
| 383 | * <update label="%updateSiteName" url="http://update.eclipse.org/updates/3.2" /> |
| 384 | * <discovery label="%updateSiteName" url="http://update.eclipse.org/updates/3.2" /> |
| 385 | * </url> |
| 386 | */ |
kitlo | 5c9da71 | 2008-10-27 12:45:40 +0000 | [diff] [blame] | 387 | $feature_id = "org.eclipse.babel.nls_${project_id}_$language_iso"; |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 388 | $feature_filename = "${feature_id}_$train_version_timestamp.jar"; |
| 389 | |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 390 | if (strcmp($language_iso, "en_AA") == 0) { |
| 391 | $project_pct_complete = 100; |
kitlo | 95107b7 | 2010-07-29 05:18:34 +0000 | [diff] [blame] | 392 | } else { |
| 393 | $project_version = $project_versions[$project_id]; |
| 394 | $sql = "SELECT pct_complete |
| 395 | FROM project_progress |
| 396 | WHERE project_id = \"$project_id\" |
| 397 | AND version = \"$project_version\" |
| 398 | AND language_id = $language_id"; |
| 399 | $project_pct_complete_result = mysql_query($sql); |
| 400 | $project_pct_complete = mysql_result($project_pct_complete_result, 0); |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 401 | } |
| 402 | |
| 403 | $outp = fopen("$tmp_dir/feature.xml", "w"); |
| 404 | fwrite($outp, "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" . |
| 405 | "\n<feature" . |
| 406 | "\n\tid=\"$feature_id\"" . |
| 407 | "\n\tlabel=\"Babel Language Pack for $project_id in $language_name ($project_pct_complete%)\"" . |
| 408 | "\n\timage=\"eclipse_update_120.jpg\"" . |
| 409 | "\n\tprovider-name=\"%providerName\"" . |
| 410 | "\n\tversion=\"$train_version_timestamp\">" . |
| 411 | "\n\t<copyright>\n\t\t%copyright\n\t</copyright>" . |
| 412 | "\n\t<license url=\"%licenseURL\">\n\t\t%license\n\t</license>" . |
| 413 | "\n\t<description>Babel Language Pack for $project_id in $language_name</description>" ); |
| 414 | foreach ($fragment_ids as $fragment_id) { |
| 415 | $jar_name = "${output_dir_for_train}plugins/${fragment_id}_$train_version_timestamp.jar"; |
| 416 | $size = filesize($jar_name); |
| 417 | fwrite($outp, "\n\t<plugin fragment=\"true\" id=\"$fragment_id\" unpack=\"false\" " . |
| 418 | "version=\"$train_version_timestamp\" download-size=\"$size\" install-size=\"$size\" />"); |
| 419 | /* |
| 420 | * Copy the plugin to ${babel_language_packs_dir}tmp |
| 421 | */ |
| 422 | exec("cp ${output_dir_for_train}plugins/${fragment_id}_$train_version_timestamp.jar ${babel_language_packs_dir}tmp/eclipse/plugins"); |
| 423 | } |
| 424 | fwrite($outp, "\n</feature>"); |
| 425 | fclose($outp); |
| 426 | /* |
| 427 | * Copy in the various legal files |
| 428 | */ |
| 429 | exec("cp ${source_files_dir}about.html $tmp_dir"); |
| 430 | exec("cp ${source_files_dir}eclipse_update_120.jpg $tmp_dir"); |
| 431 | exec("cp ${source_files_dir}epl-v10.html $tmp_dir"); |
| 432 | exec("cp ${source_files_dir}feature.properties $tmp_dir"); |
| 433 | exec("cp ${source_files_dir}license.html $tmp_dir"); |
| 434 | /* |
| 435 | * Copy in the Babel Pseudo Translations Index file |
| 436 | */ |
| 437 | if (strcmp($language_iso, "en_AA") == 0) { |
| 438 | $pseudo_translations_index_file = fopen("${output_dir}BabelPseudoTranslationsIndex-$project_id.html", "w"); |
| 439 | fwrite($pseudo_translations_index_file, "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\">" . |
| 440 | "\n<html>\n<head>\n<title>Babel Pseudo Translations Index for $project_id</title>" . |
| 441 | "\n<meta http-equiv=Content-Type content=\"text/html; charset=UTF-8\">\n</head>" . |
| 442 | "\n<body>\n\t<h1>Babel Pseudo Translations Index for $project_id</h1>" . |
| 443 | "\n\t<h2>Version: $train_version_timestamp</h2>\n\t<ul>"); |
| 444 | foreach ($pseudo_translations_indexes[$project_id] as $index) { |
| 445 | fwrite($pseudo_translations_index_file, $index); |
| 446 | } |
droy | 03d5c46 | 2008-11-10 21:07:01 +0000 | [diff] [blame] | 447 | fwrite($pseudo_translations_index_file, "\n\t</ul>\n</div></div></body>\n</html>"); |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 448 | fclose($pseudo_translations_index_file); |
| 449 | exec("cp ${output_dir}BabelPseudoTranslationsIndex-$project_id.html $tmp_dir"); |
| 450 | exec("rm ${output_dir}BabelPseudoTranslationsIndex-$project_id.html"); |
| 451 | } |
| 452 | /* |
| 453 | * Copy the feature to ${babel_language_packs_dir}tmp before jar'ing up |
| 454 | */ |
kitlo | c42941d | 2008-11-20 15:33:00 +0000 | [diff] [blame] | 455 | exec("mkdir -p ${babel_language_packs_dir}tmp/eclipse/features/${feature_id}_$train_version_timestamp"); |
| 456 | exec("cd $tmp_dir; cp * ${babel_language_packs_dir}tmp/eclipse/features/${feature_id}_$train_version_timestamp"); |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 457 | /* |
| 458 | * Zip up language pack |
| 459 | */ |
| 460 | $language_pack_name = "BabelLanguagePack-$project_id-${language_iso}_$train_version_timestamp.zip"; |
| 461 | exec("cd ${babel_language_packs_dir}tmp; zip -r $babel_language_packs_dir$language_pack_name eclipse"); |
| 462 | /* |
| 463 | * Clean up ${babel_language_packs_dir}tmp |
| 464 | */ |
| 465 | exec("rm -rf ${babel_language_packs_dir}tmp"); |
| 466 | /* |
| 467 | * Add project language pack link to language pack links file |
| 468 | */ |
kitlo | b192088 | 2010-05-12 23:33:18 +0000 | [diff] [blame] | 469 | $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>"; |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 470 | /* |
| 471 | * Jar up this directory as the feature jar |
| 472 | */ |
| 473 | system("cd $tmp_dir; jar cfM ${output_dir_for_train}features/$feature_filename ."); |
| 474 | /* |
| 475 | * Register this feature with the site.xml |
| 476 | */ |
kitlo | c42941d | 2008-11-20 15:33:00 +0000 | [diff] [blame] | 477 | $site_xml .= "\n\t<feature url=\"features/$feature_filename\" id=\"$feature_id\" version=\"$train_version_timestamp\">"; |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 478 | $site_xml .= "\n\t\t<category name=\"Babel Language Packs in $language_name\"/>"; |
| 479 | $site_xml .= "\n\t</feature>"; |
droy | 58951f7 | 2009-05-13 18:12:20 +0000 | [diff] [blame] | 480 | |
kitlo | 78f9743 | 2009-03-17 22:28:58 +0000 | [diff] [blame] | 481 | |
droy | 58951f7 | 2009-05-13 18:12:20 +0000 | [diff] [blame] | 482 | } /* End: foreach project */ |
| 483 | echo "${leader}Completed language pack for $language_name ($language_iso)\n"; |
kitlo | e3fea25 | 2010-01-25 02:13:49 +0000 | [diff] [blame] | 484 | if (sizeof($projects) > 0) { |
kitlo | b192088 | 2010-05-12 23:33:18 +0000 | [diff] [blame] | 485 | $language_pack_links_file_buffer .= "\n\t</ul>"; |
kitlo | e3fea25 | 2010-01-25 02:13:49 +0000 | [diff] [blame] | 486 | } |
gobrien | 1a8e02f | 2008-01-30 01:46:26 +0000 | [diff] [blame] | 487 | } |
kitlo | b192088 | 2010-05-12 23:33:18 +0000 | [diff] [blame] | 488 | |
| 489 | fwrite($language_pack_links_file, "\n\t</p>"); |
| 490 | fwrite($language_pack_links_file, $language_pack_links_file_buffer); |
| 491 | |
| 492 | fwrite($language_pack_links_file, "\n\t<br />\n</body>\n</html>"); |
| 493 | fclose($language_pack_links_file); |
| 494 | |
| 495 | $dbh = $dbc->disconnect(); |
| 496 | |
gobrien | 1a8e02f | 2008-01-30 01:46:26 +0000 | [diff] [blame] | 497 | /* |
kitlo | b192088 | 2010-05-12 23:33:18 +0000 | [diff] [blame] | 498 | * Generate and save site.xml/content.jar/artifacts.jar with mirrorsURL |
| 499 | */ |
| 500 | $outp = fopen("${output_dir_for_train}site.xml", "w"); |
| 501 | fwrite($outp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" . |
| 502 | "\n<site pack200=\"true\" digestURL=\"http://download.eclipse.org/technology/babel/update-site/R$release_id/$train_id\"" . |
| 503 | "\n\tmirrorsURL=\"http://www.eclipse.org/downloads/download.php?file=/technology/babel/update-site/R$release_id/$train_id/site.xml&format=xml\">" . |
| 504 | "\n\t<description url=\"http://babel.eclipse.org/\">" . |
| 505 | "\n\t\tThis update site contains user-contributed translations of the strings in all Eclipse projects." . |
| 506 | "\n\t\tPlease see the http://babel.eclipse.org/ Babel project web pages for a full how-to-use explanation of" . |
| 507 | "\n\t\tthese translations as well as how you can contribute to the translations of this and future versions of Eclipse." . |
| 508 | "\n\t</description>"); |
| 509 | fwrite($outp, $site_xml); |
| 510 | fwrite($outp, "\n</site>"); |
| 511 | fclose($outp); |
| 512 | |
| 513 | /* |
| 514 | * Generate the metadata and add the non-greedy tags |
| 515 | * Note: Not needed for Europa and Ganymede because p2 repository was not supported |
| 516 | */ |
| 517 | exec("mkdir ${output_dir_for_train}mirrors/"); |
| 518 | if (file_exists(METADATA_GENERATOR_LOCATION) && strcmp($train_id, "europa") != 0 && strcmp($train_id, "ganymede") != 0) { |
kitlo | 95107b7 | 2010-07-29 05:18:34 +0000 | [diff] [blame] | 519 | echo "Running the Meta at " . dirname(__FILE__) . "/runMetadata.sh\n"; |
| 520 | system("/bin/sh " . dirname(__FILE__) . "/runMetadata.sh ". METADATA_GENERATOR_LOCATION . " ${output_dir_for_train} "); |
| 521 | echo "Processing XML\n"; |
kitlo | b192088 | 2010-05-12 23:33:18 +0000 | [diff] [blame] | 522 | system("xsltproc -o ${output_dir_for_train}content.xml ". dirname(__FILE__) . "/content.xsl ${output_dir_for_train}content.xml"); |
| 523 | system("cd ${output_dir_for_train} ; jar -fc content.jar content.xml ; jar -fc artifacts.jar artifacts.xml"); |
| 524 | system("cd ${output_dir_for_train} ; rm content.xml ; rm artifacts.xml"); |
| 525 | system("cd ${output_dir_for_train} ; mv content.jar mirrors/content.mirrors ; mv artifacts.jar mirrors/artifacts.mirrors"); |
| 526 | } |
| 527 | system("cd ${output_dir_for_train} ; mv site.xml mirrors/site.mirrors"); |
| 528 | |
| 529 | /* |
| 530 | * Generate normal site.xml/content.jar/artifacts.jar without mirrorsURL |
gobrien | 1a8e02f | 2008-01-30 01:46:26 +0000 | [diff] [blame] | 531 | */ |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 532 | $outp = fopen("${output_dir_for_train}site.xml", "w"); |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 533 | fwrite($outp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" . |
| 534 | "\n<site>" . |
| 535 | "\n\t<description url=\"http://babel.eclipse.org/\">" . |
| 536 | "\n\t\tThis update site contains user-contributed translations of the strings in all Eclipse projects." . |
| 537 | "\n\t\tPlease see the http://babel.eclipse.org/ Babel project web pages for a full how-to-use explanation of" . |
| 538 | "\n\t\tthese translations as well as how you can contribute to the translations of this and future versions of Eclipse." . |
| 539 | "\n\t</description>"); |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 540 | fwrite($outp, $site_xml); |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 541 | fwrite($outp, "\n</site>"); |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 542 | fclose($outp); |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 543 | |
droy | e77ad17 | 2009-05-04 17:35:56 +0000 | [diff] [blame] | 544 | /* |
kitlo | b2ca7c0 | 2010-02-10 19:05:41 +0000 | [diff] [blame] | 545 | * Generate the metadata and add the non-greedy tags |
| 546 | * Note: Not needed for Europa and Ganymede because p2 repository was not supported |
| 547 | */ |
kitlo | e946874 | 2010-02-10 20:08:49 +0000 | [diff] [blame] | 548 | if (file_exists(METADATA_GENERATOR_LOCATION) && strcmp($train_id, "europa") != 0 && strcmp($train_id, "ganymede") != 0) { |
kitlo | 95107b7 | 2010-07-29 05:18:34 +0000 | [diff] [blame] | 549 | echo "Running the Meta at " . dirname(__FILE__) . "/runMetadata.sh\n"; |
| 550 | system("/bin/sh " . dirname(__FILE__) . "/runMetadata.sh ". METADATA_GENERATOR_LOCATION . " ${output_dir_for_train} "); |
| 551 | echo "Processing XML\n"; |
kitlo | b2ca7c0 | 2010-02-10 19:05:41 +0000 | [diff] [blame] | 552 | system("xsltproc -o ${output_dir_for_train}content.xml ". dirname(__FILE__) . "/content.xsl ${output_dir_for_train}content.xml"); |
kitlo | b192088 | 2010-05-12 23:33:18 +0000 | [diff] [blame] | 553 | system("cd ${output_dir_for_train} ; jar -fc content.jar content.xml ; jar -fc artifacts.jar artifacts.xml"); |
| 554 | system("cd ${output_dir_for_train} ; rm content.xml ; rm artifacts.xml"); |
| 555 | system("cd ${output_dir_for_train} ; mv site.xml mirrors/site.txt"); |
| 556 | } else { |
| 557 | system("cd ${output_dir_for_train} ; cp site.xml mirrors/site.txt"); |
kitlo | b2ca7c0 | 2010-02-10 19:05:41 +0000 | [diff] [blame] | 558 | } |
gobrien | 1a8e02f | 2008-01-30 01:46:26 +0000 | [diff] [blame] | 559 | } |
gobrien | 1a8e02f | 2008-01-30 01:46:26 +0000 | [diff] [blame] | 560 | echo "Completed generating update site\n"; |
| 561 | |
kitlo | 9c7c62a | 2008-10-05 16:05:19 +0000 | [diff] [blame] | 562 | |
gobrien | 1a8e02f | 2008-01-30 01:46:26 +0000 | [diff] [blame] | 563 | /* |
kitlo | 58d8a5a | 2008-09-24 20:08:44 +0000 | [diff] [blame] | 564 | 2. what happens if the translation feature includes plug-in fragments for |
| 565 | plug-ins that are not in the current image? |
| 566 | does it load correctly and ignore those fragments? if so, good |
| 567 | A: warnings appear in the run-time error log |
| 568 | does it fail to load? if so, then we need to generate different features, perhaps |
| 569 | one feature for each plug or else we need to know more about the project |
| 570 | distro structure to know which plug-ins to put in each feature |
| 571 | what happens if those plug-ins are later added - does it load the strings now? |
| 572 | A: probably not |
| 573 | 3. need to handle different versions of each feature/plugin/platform; generate different |
| 574 | language packs for each |
| 575 | */ |
gobrien | 1a8e02f | 2008-01-30 01:46:26 +0000 | [diff] [blame] | 576 | |
droy | c6eb7ac | 2009-05-12 17:25:46 +0000 | [diff] [blame] | 577 | function usage() { |
| 578 | echo "\n"; |
| 579 | echo "generate1.php -b <build_id> [-t <train_id>]\n"; |
| 580 | echo " -b <build_id>: The Build ID for this build.\n"; |
kitlo | e3fea25 | 2010-01-25 02:13:49 +0000 | [diff] [blame] | 581 | echo " -t <train_id>: Optional: train to build (helios, galileo, ganymede, europa)."; |
droy | c6eb7ac | 2009-05-12 17:25:46 +0000 | [diff] [blame] | 582 | echo "\n"; |
| 583 | } |
| 584 | |
kitlo | e3fea25 | 2010-01-25 02:13:49 +0000 | [diff] [blame] | 585 | ?> |