[Mapbender-commits] r2825 - in trunk/build: . lib php

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Fri Aug 15 10:41:22 EDT 2008


Author: christoph
Date: 2008-08-15 10:41:19 -0400 (Fri, 15 Aug 2008)
New Revision: 2825

Added:
   trunk/build/build_2.6.sh
   trunk/build/lib/
   trunk/build/lib/jsmin-1.1.0.php
   trunk/build/lib/jsmin.php
   trunk/build/php/
   trunk/build/php/1_createMySqlDump.php
   trunk/build/php/2_convertDataDumps.php
   trunk/build/php/3_addHeaderToDataDumps.php
   trunk/build/php/commandLine.inc
Log:
updated build script for 2.6

Added: trunk/build/build_2.6.sh
===================================================================
--- trunk/build/build_2.6.sh	                        (rev 0)
+++ trunk/build/build_2.6.sh	2008-08-15 14:41:19 UTC (rev 2825)
@@ -0,0 +1,138 @@
+#!/bin/bash
+#
+# expecting three input params
+# $1 - the name of the release branch at 
+#      https://svn.osgeo.org/mapbender/branches, for example 2.4.5
+# $2 - the SVN username for https://svn.osgeo.org/mapbender
+# $3 - the SVN password for https://svn.osgeo.org/mapbender
+
+# requires 
+# - subversion
+# - perl
+# - php5
+# - tedia2sql
+#
+
+#
+#set constants
+#
+
+# the name of the folder where the build process happens
+TODAY=`date +%Y-%m-%d_%H.%M.%S`
+FOLDER="build_$TODAY"
+
+# URL to version that is being built
+SVN_URL="https://svn.osgeo.org/mapbender/branches"
+
+# path to jsdoc.pl
+JSDOC_PATH="JSDoc"
+
+# path to "javascript" folder in Mapbender
+JS_PATH="http/javascripts"
+
+# path to "extension" folder in Mapbender
+EXT_PATH="http/extensions"
+
+# string containing javascript files for JSDoc
+JSDOC_F="$JS_PATH/geometry.js $JS_PATH/point.js $JS_PATH/map.js $JS_PATH/map_obj.js $EXT_PATH/wz_jsgraphics.js"
+
+# array of javascript files for JSMin
+JSMIN_F=("$JS_PATH/geometry.js" "$JS_PATH/point.js" "$JS_PATH/map.js" "$JS_PATH/map_obj.js" "$EXT_PATH/jquery.js" "$EXT_PATH/wz_jsgraphics.js")
+
+
+# ------------------------
+#
+# ACTUAL BUILD BEGINS HERE
+#
+# ------------------------
+
+echo "Building Mapbender $1 ... let's see if this works ..."
+
+# create folder for build
+mkdir $FOLDER 2>/dev/null
+
+#check out from SVN
+echo "checking out from $SVN_URL/$1 ..."
+svn co -q $SVN_URL/$1 $FOLDER/
+
+#compile JSDoc
+echo "compiling JSDoc ..."
+perl $JSDOC_PATH/jsdoc.pl $FOLDER/$JSDOC_F
+
+#move JSDoc to folder
+mkdir $FOLDER/documents 2>/dev/null
+mkdir $FOLDER/documents/jsdoc 2>/dev/null
+mv js_docs_out/* $FOLDER/documents/jsdoc/ 2>/dev/null
+rm -rf js_docs_out 2>/dev/null
+
+#check in JSDOC
+echo "committing JSDoc ..."
+svn add -q $FOLDER/documents/
+# set property svn:mime-type text/html for all html files
+for file in `dir -d $FOLDER/documents/jsdoc/*.html`
+do
+	svn propset svn:mime-type text/html $file 2>/dev/null
+done
+
+svn commit -q -m updated_documentation --username $2 --password $3 $FOLDER/documents/
+
+#compile PHPDoc
+# (to do)
+
+#check in PHPDoc
+# (to do)
+
+# compress JS files
+echo "compressing JS ..."
+for name in ${JSMIN_F[@]}
+do
+	echo "minifying $FOLDER/$name ..."
+	ORIG=$name"_orig"
+	mv $FOLDER/$name $FOLDER/$ORIG 2>/dev/null
+	php5 lib/jsmin.php $FOLDER/$ORIG > $FOLDER/$name
+	rm $FOLDER/$ORIG 2>/dev/null
+done
+
+# remove SVN metadata
+echo "deleting SVN metadata ..."
+cd $FOLDER 2>/dev/null
+rm -rf `find . -type d -name .svn` 2>/dev/null
+cd .. 2>/dev/null
+
+# move tools folder out of http
+echo "moving folder 'tools'..." 
+mv $FOLDER/http/tools $FOLDER/ 2>/dev/null
+
+# create pgsql database schema
+echo "creating PostgreSQL database schema..." 
+mkdir temp_sql 
+tedia2sql -t postgres -d -s -o temp_sql/pgsql.sql -i $FOLDER/resources/db/schema_2.5.dia 
+cat $FOLDER/resources/db/pgsql/pgsql_gettext.sql temp_sql/pgsql-50-schemaCreate.sql temp_sql/pgsql-90-constraintsCreate.sql temp_sql/pgsql-30-specialPreStatements.sql > $FOLDER/resources/db/pgsql/pgsql_schema.sql 
+cp temp_sql/pgsql-60-specialPostStatements.sql $FOLDER/resources/db/pgsql/pgsql_set_sequences.sql 
+rm -rf temp_sql
+
+# create mysql database schema
+echo "creating MySQL database schema..." 
+mkdir temp_sql 
+tedia2sql -t innodb -d -s -o temp_sql/mysql.sql -i $FOLDER/resources/db/schema_2.5.dia 
+cat $FOLDER/resources/db/mysql/mysql_gettext.sql temp_sql/mysql-50-schemaCreate.sql temp_sql/mysql-90-constraintsCreate.sql temp_sql/mysql-30-specialPreStatements.sql > $FOLDER/resources/db/mysql/mysql_schema.sql 
+rm -rf temp_sql
+
+# create database dump
+echo "creating MySQL data dump..."
+php5 php/1_createMySqlDump.php ../$FOLDER
+echo "converting UTF-8 data dumps to ISO-8859-1..."
+php5 php/2_convertDataDumps.php ../$FOLDER
+echo "add headers to all dump files..."
+php5 php/3_addHeaderToDataDumps.php ../$FOLDER
+
+# rename folder
+mv $FOLDER mapbender_$1
+
+# zip build folder
+echo "creating zip file ..."
+ZIP_FILENAME="mapbender_$1.zip"
+zip -rq $ZIP_FILENAME mapbender_$1/*
+
+# remove build folder
+rm -rf mapbender_$1 2>/dev/null
\ No newline at end of file


Property changes on: trunk/build/build_2.6.sh
___________________________________________________________________
Name: svn:executable
   + *

Copied: trunk/build/lib/jsmin-1.1.0.php (from rev 2663, trunk/build/jsmin-1.1.0.php)
===================================================================
--- trunk/build/lib/jsmin-1.1.0.php	                        (rev 0)
+++ trunk/build/lib/jsmin-1.1.0.php	2008-08-15 14:41:19 UTC (rev 2825)
@@ -0,0 +1,296 @@
+<?php
+/**
+ * jsmin.php - PHP implementation of Douglas Crockford's JSMin.
+ *
+ * This is pretty much a direct port of jsmin.c to PHP with just a few
+ * PHP-specific performance tweaks. Also, whereas jsmin.c reads from stdin and
+ * outputs to stdout, this library accepts a string as input and returns another
+ * string as output.
+ *
+ * PHP 5 or higher is required.
+ *
+ * Permission is hereby granted to use this version of the library under the
+ * same terms as jsmin.c, which has the following license:
+ *
+ * --
+ * Copyright (c) 2002 Douglas Crockford  (www.crockford.com)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
+ * this software and associated documentation files (the "Software"), to deal in
+ * the Software without restriction, including without limitation the rights to
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is furnished to do
+ * so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * The Software shall be used for Good, not Evil.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ * --
+ *
+ * @package JSMin
+ * @author Ryan Grove <ryan at wonko.com>
+ * @copyright 2002 Douglas Crockford <douglas at crockford.com> (jsmin.c)
+ * @copyright 2007 Ryan Grove <ryan at wonko.com> (PHP port)
+ * @license http://opensource.org/licenses/mit-license.php MIT License
+ * @version 1.1.0 (2007-06-01)
+ * @link http://code.google.com/p/jsmin-php/
+ */
+
+class JSMin {
+  const ORD_LF    = 10;
+  const ORD_SPACE = 32;
+
+  protected $a           = '';
+  protected $b           = '';
+  protected $input       = '';
+  protected $inputIndex  = 0;
+  protected $inputLength = 0;
+  protected $lookAhead   = null;
+  protected $output      = array();
+
+  // -- Public Static Methods --------------------------------------------------
+
+  public static function minify($js) {
+    $jsmin = new JSMin($js);
+    return $jsmin->min();
+  }
+
+  // -- Public Instance Methods ------------------------------------------------
+
+  public function __construct($input) {
+    $this->input       = str_replace("\r\n", "\n", $input);
+    $this->inputLength = strlen($this->input);
+  }
+
+  // -- Protected Instance Methods ---------------------------------------------
+
+  protected function action($d) {
+    switch($d) {
+      case 1:
+        $this->output[] = $this->a;
+
+      case 2:
+        $this->a = $this->b;
+
+        if ($this->a === "'" || $this->a === '"') {
+          for (;;) {
+            $this->output[] = $this->a;
+            $this->a        = $this->get();
+
+            if ($this->a === $this->b) {
+              break;
+            }
+
+            if (ord($this->a) <= self::ORD_LF) {
+              throw new JSMinException('Unterminated string literal.');
+            }
+
+            if ($this->a === '\\') {
+              $this->output[] = $this->a;
+              $this->a        = $this->get();
+            }
+          }
+        }
+
+      case 3:
+        $this->b = $this->next();
+
+        if ($this->b === '/' && (
+            $this->a === '(' || $this->a === ',' || $this->a === '=' ||
+            $this->a === ':' || $this->a === '[' || $this->a === '!' ||
+            $this->a === '&' || $this->a === '|' || $this->a === '?')) {
+
+          $this->output[] = $this->a;
+          $this->output[] = $this->b;
+
+          for (;;) {
+            $this->a = $this->get();
+
+            if ($this->a === '/') {
+              break;
+            }
+            elseif ($this->a === '\\') {
+              $this->output[] = $this->a;
+              $this->a        = $this->get();
+            }
+            elseif (ord($this->a) <= self::ORD_LF) {
+              throw new JSMinException('Unterminated regular expression '.
+                  'literal.');
+            }
+
+            $this->output[] = $this->a;
+          }
+
+          $this->b = $this->next();
+        }
+    }
+  }
+
+  protected function get() {
+    $c = $this->lookAhead;
+    $this->lookAhead = null;
+
+    if ($c === null) {
+      if ($this->inputIndex < $this->inputLength) {
+        $c = $this->input[$this->inputIndex];
+        $this->inputIndex += 1;
+      }
+      else {
+        $c = null;
+      }
+    }
+
+    if ($c === "\r") {
+      return "\n";
+    }
+
+    if ($c === null || $c === "\n" || ord($c) >= self::ORD_SPACE) {
+      return $c;
+    }
+
+    return ' ';
+  }
+
+  protected function isAlphaNum($c) {
+    return ord($c) > 126 || $c === '\\' || preg_match('/^[\w\$]$/', $c) === 1;
+  }
+
+  protected function min() {
+    $this->a = "\n";
+    $this->action(3);
+
+    while ($this->a !== null) {
+      switch ($this->a) {
+        case ' ':
+          if ($this->isAlphaNum($this->b)) {
+            $this->action(1);
+          }
+          else {
+            $this->action(2);
+          }
+          break;
+
+        case "\n":
+          switch ($this->b) {
+            case '{':
+            case '[':
+            case '(':
+            case '+':
+            case '-':
+              $this->action(1);
+              break;
+
+            case ' ':
+              $this->action(3);
+              break;
+
+            default:
+              if ($this->isAlphaNum($this->b)) {
+                $this->action(1);
+              }
+              else {
+                $this->action(2);
+              }
+          }
+          break;
+
+        default:
+          switch ($this->b) {
+            case ' ':
+              if ($this->isAlphaNum($this->a)) {
+                $this->action(1);
+                break;
+              }
+
+              $this->action(3);
+              break;
+
+            case "\n":
+              switch ($this->a) {
+                case '}':
+                case ']':
+                case ')':
+                case '+':
+                case '-':
+                case '"':
+                case "'":
+                  $this->action(1);
+                  break;
+
+                default:
+                  if ($this->isAlphaNum($this->a)) {
+                    $this->action(1);
+                  }
+                  else {
+                    $this->action(3);
+                  }
+              }
+              break;
+
+            default:
+              $this->action(1);
+              break;
+          }
+      }
+    }
+
+    return implode('', $this->output);
+  }
+
+  protected function next() {
+    $c = $this->get();
+
+    if ($c === '/') {
+      switch($this->peek()) {
+        case '/':
+          for (;;) {
+            $c = $this->get();
+
+            if (ord($c) <= self::ORD_LF) {
+              return $c;
+            }
+          }
+
+        case '*':
+          $this->get();
+
+          for (;;) {
+            switch($this->get()) {
+              case '*':
+                if ($this->peek() === '/') {
+                  $this->get();
+                  return ' ';
+                }
+                break;
+
+              case null:
+                throw new JSMinException('Unterminated comment.');
+            }
+          }
+
+        default:
+          return $c;
+      }
+    }
+
+    return $c;
+  }
+
+  protected function peek() {
+    $this->lookAhead = $this->get();
+    return $this->lookAhead;
+  }
+}
+
+// -- Exceptions ---------------------------------------------------------------
+class JSMinException extends Exception {}
+?>
\ No newline at end of file

Copied: trunk/build/lib/jsmin.php (from rev 2663, trunk/build/jsmin.php)
===================================================================
--- trunk/build/lib/jsmin.php	                        (rev 0)
+++ trunk/build/lib/jsmin.php	2008-08-15 14:41:19 UTC (rev 2825)
@@ -0,0 +1,6 @@
+<?php
+require("jsmin-1.1.0.php");
+
+$file = $_SERVER["argv"][1];
+echo JSMin::minify(file_get_contents($file));
+?>
\ No newline at end of file

Added: trunk/build/php/1_createMySqlDump.php
===================================================================
--- trunk/build/php/1_createMySqlDump.php	                        (rev 0)
+++ trunk/build/php/1_createMySqlDump.php	2008-08-15 14:41:19 UTC (rev 2825)
@@ -0,0 +1,65 @@
+<?php
+	require_once(dirname(__FILE__) . "/commandLine.inc");
+	
+	$mpbnFolder = $_SERVER["argv"][1];
+	
+	$fileArray = array(
+		"mysql" => 
+			array(	"from" => dirname(__FILE__) . "/" . $mpbnFolder . "/resources/db/pgsql/UTF-8/pgsql_data.sql",
+					"to" => dirname(__FILE__) . "/" . $mpbnFolder . "/resources/db/mysql/UTF-8/mysql_data.sql")
+	);
+	
+	function saveAsFile($filename, $data) {
+		if ($h = fopen($filename, "w")) {
+			if (!fwrite($h, $data)) {
+				return false;
+			}
+			fclose($h);
+		}
+		return true;
+	}
+	
+	// load file
+	$from = $fileArray["mysql"]["from"];
+	$to = $fileArray["mysql"]["to"];
+
+	if (file_exists($from)) {
+		$data = file_get_contents($from);
+	}
+	else {
+		echo "Fatal error: File not found ('" . $from . "').\n";
+		exit(1);
+	}
+
+	// replace postgresql's string escape syntax
+	$pattern = "/, E'/";
+	$data = preg_replace($pattern, ", '", $data);
+
+	// disable foreign keys
+	$pattern = "/UPDATE pg_catalog\.pg_class SET reltriggers = 0;/";
+	if (preg_match($pattern, $data)) {
+		$data = preg_replace($pattern, "SET FOREIGN_KEY_CHECKS=0;", $data);
+	}
+	else {
+		echo "Fatal error: Didn't find expression (pattern: " . $pattern . ").\n";
+		exit(1);
+	}
+	
+	// enable foreign keys
+	$pattern = 	"/UPDATE pg_catalog\.pg_class SET reltriggers = \(SELECT pg_catalog\.count\(\*\) FROM pg_catalog\.pg_trigger where pg_class\.oid = tgrelid\);/";
+	if (preg_match($pattern, $data)) {
+		$data = preg_replace($pattern, "SET FOREIGN_KEY_CHECKS=1;", $data);
+	}
+	else {
+		echo "Fatal error: Didn't find expression (pattern: " . $pattern . ").\n";
+		exit(1);
+	}
+	
+	// save mysql file
+	if (!saveAsFile($to, $data)) {
+		echo "Fatal error: File could not be saved ('" . $to . "').\n";
+		exit(1);
+	}
+	echo "Finished.\n\n";
+	exit(0);
+?>
\ No newline at end of file

Added: trunk/build/php/2_convertDataDumps.php
===================================================================
--- trunk/build/php/2_convertDataDumps.php	                        (rev 0)
+++ trunk/build/php/2_convertDataDumps.php	2008-08-15 14:41:19 UTC (rev 2825)
@@ -0,0 +1,48 @@
+<?php
+	require_once(dirname(__FILE__) . "/commandLine.inc");
+	
+	$mpbnFolder = $_SERVER["argv"][1];
+	
+	// needs to be set, otherwise the iconv option //TRANSLIT
+	// won't work
+	setlocale(LC_CTYPE, "de_DE.utf8");
+
+	$fileArray = array(
+		"mysql" => 
+			array(	"from" => dirname(__FILE__) . "/" . $mpbnFolder . "/resources/db/mysql/UTF-8/mysql_data.sql",
+					"to" => dirname(__FILE__) . "/" . $mpbnFolder . "/resources/db/mysql/ISO-8859-1/mysql_data.sql"),
+		"pgsql" => 
+			array(	"from" => dirname(__FILE__) . "/" . $mpbnFolder . "/resources/db/pgsql/UTF-8/pgsql_data.sql",
+					"to" => dirname(__FILE__) . "/" . $mpbnFolder . "/resources/db/pgsql/ISO-8859-1/pgsql_data.sql")
+	);
+
+	function saveAsFile($filename, $data) {
+		if ($h = fopen($filename, "w")) {
+			if (!fwrite($h, $data)) {
+				return false;
+			}
+			fclose($h);
+		}
+		return true;
+	}
+	
+
+	foreach ($fileArray as $file) {
+		$from = $file["from"];
+		$to = $file["to"];
+		
+		if (file_exists($from)) {
+			$data = file_get_contents($from);
+		}
+		else {
+			echo "Fatal error: File not found ('" . $from . "').\n";
+		}
+
+		$dataConverted = iconv("UTF-8", "ASCII//TRANSLIT", $data);
+	
+		if (!saveAsFile($to, $dataConverted)) {
+			echo "Fatal error: File could not be saved ('" . $to . "').\n";
+		}
+	}		
+	echo "Finished.\n\n";
+?>
\ No newline at end of file

Added: trunk/build/php/3_addHeaderToDataDumps.php
===================================================================
--- trunk/build/php/3_addHeaderToDataDumps.php	                        (rev 0)
+++ trunk/build/php/3_addHeaderToDataDumps.php	2008-08-15 14:41:19 UTC (rev 2825)
@@ -0,0 +1,64 @@
+<?php
+	require_once(dirname(__FILE__) . "/commandLine.inc");
+	
+	$mpbnFolder = $_SERVER["argv"][1];
+	
+	if (!file_exists(dirname(__FILE__) . "/" . $mpbnFolder . "/core/system.php")) {
+		echo "File not found: " . dirname(__FILE__) . "/" . $mpbnFolder . "/core/system.php";
+		exit(1);		
+	}
+	else {
+		require_once(dirname(__FILE__) . "/" . $mpbnFolder . "/core/system.php");
+	}
+	
+	setlocale(LC_TIME, "de_DE.utf8");
+
+	$fileArray = array(
+		"mysql" => 
+			array(	"iso" => dirname(__FILE__) . "/" . $mpbnFolder . "/resources/db/mysql/ISO-8859-1/mysql_data.sql",
+					"utf8" => dirname(__FILE__) . "/" . $mpbnFolder . "/resources/db/mysql/UTF-8/mysql_data.sql"),
+		"postgresql" => 
+			array(	"iso" => dirname(__FILE__) . "/" . $mpbnFolder . "/resources/db/pgsql/ISO-8859-1/pgsql_data.sql",
+					"utf8" => dirname(__FILE__) . "/" . $mpbnFolder . "/resources/db/pgsql/UTF-8/pgsql_data.sql")
+	);
+	
+	function saveAsFile($filename, $data) {
+		if ($h = fopen($filename, "w")) {
+			if (!fwrite($h, $data)) {
+				return false;
+			}
+			fclose($h);
+		}
+		return true;
+	}
+	
+	foreach ($fileArray as $dbType => $files) {
+		foreach ($files as $characterSet => $file) {
+			if (file_exists($file)) {
+				$data = file_get_contents($file);
+			}
+			else {
+				echo "Fatal error: File not found ('" . $file . "').\n";
+				exit(1);
+			}
+			
+			// add header to file
+			$header = 	"--\n" .
+						"-- " . $dbType . " " . $characterSet . " data dump\n" . 
+						"-- \n" .
+						"-- Mapbender " . MB_VERSION_NUMBER . " " . MB_VERSION_APPENDIX . "\n" .
+						"-- \n" .
+						"-- " . date("Y/m/d", MB_RELEASE_DATE) . "\n" . 
+						"--\n\n";
+			$data = $header . $data;
+
+			if (!saveAsFile($file, $data)) {
+				echo "Fatal error: File could not be saved ('" . $file . "').\n";
+				exit(1);
+			}
+
+		}
+	}
+	echo "Finished.\n\n";
+	exit(0);
+?>
\ No newline at end of file

Added: trunk/build/php/commandLine.inc
===================================================================
--- trunk/build/php/commandLine.inc	                        (rev 0)
+++ trunk/build/php/commandLine.inc	2008-08-15 14:41:19 UTC (rev 2825)
@@ -0,0 +1,38 @@
+<?php
+
+#Mapbender Updater File
+#Author: Siddharth Prakash Singh(spsneo)
+#Google Summer Of Code Project 2008
+# Copyright (C) 2002 CCGIS 
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# This file tests whether the update script has been called from command line or browser.
+# Aborts the update process if called from a web browser
+
+
+if ( isset( $_SERVER ) && array_key_exists( 'REQUEST_METHOD', $_SERVER ) ) {
+	echo "This script must be executed from the command line ";
+	exit();
+}
+
+if (PHP_SAPI != 'cli') {
+	echo "This script must be executed from the command line.";
+	exit();
+}
+
+#Set the execution time to infinity
+ at set_time_limit( 0 );
+?>
\ No newline at end of file



More information about the Mapbender_commits mailing list