simplify install script

Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/f123166c
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/f123166c
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/f123166c

Branch: refs/heads/develop
Commit: f123166c3b5be8667529d3f00ffd29ed3e78b0ba
Parents: 215e767
Author: Justin Mclean <jmcl...@apache.org>
Authored: Thu Oct 9 13:53:52 2014 +1100
Committer: Justin Mclean <jmcl...@apache.org>
Committed: Thu Oct 9 13:53:52 2014 +1100

----------------------------------------------------------------------
 TourDeFlex/TourDeFlex3/installer.xml | 152 +++++++++++-------------------
 1 file changed, 54 insertions(+), 98 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/f123166c/TourDeFlex/TourDeFlex3/installer.xml
----------------------------------------------------------------------
diff --git a/TourDeFlex/TourDeFlex3/installer.xml 
b/TourDeFlex/TourDeFlex3/installer.xml
index 797493b..02a26a6 100644
--- a/TourDeFlex/TourDeFlex3/installer.xml
+++ b/TourDeFlex/TourDeFlex3/installer.xml
@@ -18,7 +18,7 @@
 
 -->
 
-<project name="tour_de_flex_install" default="install" basedir=".">
+<project name="tour-de-flex_install" default="install" basedir=".">
     
     <!-- Required for OSX 10.6 / Snow Leopard Performance. -->
     <!-- Java 7 on Mac requires OSX 10.7.3 or higher and is 64-bit only -->
@@ -31,140 +31,96 @@
             <equals arg1="${ant.java.version}" arg2="1.6"/>
         </and>
     </condition>
-
+       
+    <condition property="isMacOrLinux" value="mac">
+       <or>
+               <os family="mac" />
+               <os family="unix" />
+       </or>
+    </condition>
+    <condition property="isWindows" value="windows">
+        <os family="windows" />
+    </condition>
+               
        <property environment="env"/>
     <condition property="FLEX_HOME" value="${env.FLEX_HOME}">
         <isset property="env.FLEX_HOME" />
     </condition>
-       <echo>${env.FLEX_HOME}</echo>
+
     <property file="${FLEX_HOME}/local.properties"/>
     <property file="${FLEX_HOME}/build.properties"/>
-       
     <property file="${basedir}/${bundle}.properties"/>
 
        <property name="download.dir" value="${FLEX_HOME}/in"/>
-       <property name="unpack.dir" value="${FLEX_HOME}/tourdeflex"/>
-
+       <property name="unpack.dir" value="${FLEX_HOME}/tour-de-flex"/>
        <property name="mirror.url" 
value="http://flex.apache.org/single-mirror-url.cgi"; />
        
-    <property name="tourdeflex.url.folder" value="flex/tourdeflex/1.0" />
-    <condition property="tourdeflex.url.file" 
value="apache-flex-tour-de-flex-component-explorer-1.0-src.zip">
-       <os family="windows" />
-    </condition>
-    <condition property="tourdeflex.url.file" 
value="apache-flex-tour-de-flex-component-explorer-1.0-src.tar.gz">
-       <or>
-               <os family="mac" />
-               <os family="unix" />
-       </or>
-    </condition>
-    <condition property="tourdeflex.url.md5" 
value="2509291d41cc325ba21ed6b9cf4306f2">
-       <os family="windows" />
-    </condition>
-    <condition property="tourdeflex.url.md5" 
value="2509291d41cc325ba21ed6b9cf4306f2">
-       <or>
-               <os family="mac" />
-               <os family="unix" />
-       </or>
-    </condition>
+    <property name="tour-de-flex.url.folder" value="flex/tourdeflex/1.1" />
+   
+    <target name="file-setup-win" if="isWindows">
+       <property name="tour-de-flex.url.file" 
value="apache-flex-tour-de-flex-component-explorer-1.1-src.zip" />
+       <property name="tour-de-flex.url.md5" 
value="95b9895120eebac1f2cd09929629ba2c" />
+    </target>
+       
+    <target name="file-setup-unix" if="isMacOrLinux">
+       <property name="tour-de-flex.url.file" 
value="apache-flex-tour-de-flex-component-explorer-1.1-src.tar.gz" />
+       <property name="tour-de-flex.url.md5" 
value="95b9895120eebac1f2cd09929629ba2c" />
+    </target>
 
-    <target name="install" depends="tourdeflex-download-unpack" 
description="Adds TourDeFlex to SDK">
+    <target name="install" 
depends="file-setup-win,file-setup-unix,tour-de-flex-download-unpack" 
description="Adds tour-de-flex to an Apache Flex SDK">
         <delete dir="${download.dir}" />
-        <echo>${install.complete.echo}</echo>
+        <echo>Tour De Flex installed</echo>
     </target>
     
-    <target name="tourdeflex-download-unpack" description="Downloads Tour De 
Flex and copies into SDK">
+    <target name="tour-de-flex-download-unpack" description="Downloads 
tour-de-flex and copies into the Apache Flex SDK">
         <mkdir dir="${download.dir}"/>
        
        <get src="${mirror.url}" dest="${download.dir}/mirror.txt" />
        <replace file="${download.dir}/mirror.txt" token="&lt;p&gt;" />
        <replace file="${download.dir}/mirror.txt" token="&lt;/p&gt;" />
-       <loadfile property="tourdeflex.url.server" 
srcFile="${download.dir}/mirror.txt" />
+       <loadfile property="tour-de-flex.url.server" 
srcFile="${download.dir}/mirror.txt" />
        
-       <echo>Downloading 
${tourdeflex.url.server}/${tourdeflex.url.folder}/${tourdeflex.url.file}</echo>
+       <echo>Downloading 
${tour-de-flex.url.server}/${tour-de-flex.url.folder}/${tour-de-flex.url.file}</echo>
         
-       <antcall target="download_tourdeflex_with_md5">
-            <param name="srcDomain" value="${tourdeflex.url.server}" />
-            <param name="srcFolder" value="${tourdeflex.url.folder}" />
-            <param name="srcFile" value="${tourdeflex.url.file}" />
-            <param name="dest" value="${download.dir}/${tourdeflex.url.file}"/>
-                       <param name="message" 
value="${INFO_INSTALLING_TOURDEFLEX} 
${tourdeflex.url.server}/${tourdeflex.url.folder}/${tourdeflex.url.file}" />
+       <antcall target="download-check-md5">
+            <param name="domain" value="${tour-de-flex.url.server}" />
+            <param name="folder" value="${tour-de-flex.url.folder}" />
+            <param name="file" value="${tour-de-flex.url.file}" />
+            <param name="dest" 
value="${download.dir}/${tour-de-flex.url.file}"/>
                        <param name="failmessage" value="Tour De Flex download 
failed" />
-                       <param name="md5" value="${tourdeflex.url.md5}" />
+                       <param name="md5" value="${tour-de-flex.url.md5}" />
         </antcall>
        
        <mkdir dir="${unpack.dir}"/>
-       <condition property="platform" value="windows">
-               <unzip dest="${unpack.dir}">
-                       <fileset file="${download.dir}/${tourdeflex.url.file" />
-               </unzip>
-       </condition>
-       <condition property="platform" value="mac">
-               <tar-ungzip dest="${unpack.dir}">
-                       <fileset file="${download.dir}/${tourdeflex.url.file" />
-               </tar-ungzip>
-       </condition>
-               <condition property="platform" value="linux">
-               <tar-ungzip dest="${unpack.dir}">
-                       <fileset file="${download.dir}/${tourdeflex.url.file" />
-               </tar-ungzip>
-               </condition>
+       <antcall target="files-unzip" />
+       <antcall target="files-untar" />
+    </target>
+                       
+    <target name="files-unzip" if="isWindows">
+       <unzip dest="${unpack.dir}">
+               <fileset file="${download.dir}/${tour-de-flex.url.file}" />
+       </unzip>
     </target>
        
-    <target name="download_tourdeflex_with_md5">
-        <antcall target="download_using_get" />
+    <target name="files-untar" if="isMacOrLinux">
+       <untar dest="${unpack.dir}" compression="gzip">
+               <fileset file="${download.dir}/${tour-de-flex.url.file}" />
+       </untar>
     </target>
 
-    <target name="download_using_get"
-        description="Downloads file, and optionally verifies checksum.">
-        
+    <target name="download-check-md5" description="Downloads file, and 
verifies checksum.">     
        <tstamp />
        <property name="ts" value="${DSTAMP}${TSTAMP}" />
-       
-        <antcall target="get">
-        </antcall>
-    </target>
-    
-    <target name="get">
-               <antcall target="get-with-params" />
-        <antcall target="check-sum" />
+        <get src="${domain}/${folder}/${file}?ts=${ts}" dest="${dest}" 
verbose="true" />
+        <antcall target="check-md5" />
     </target>
-    
-       <target name="check-params" >
-               <condition property="has-params">
-                       <and>
-                               <contains 
string="${srcDomain}/${srcFolder}/${srcFile}" substring="?" />
-                               <not>
-                                       <contains 
string="${srcDomain}/${srcFolder}/${srcFile}" substring="file://" />
-                               </not>
-                       </and>
-               </condition>
-               <condition property="is-local">
-                       <contains string="${srcDomain}/${srcFolder}/${srcFile}" 
substring="file://" />
-               </condition>
-               <condition property="not-local-no-params">
-                       <and>
-                               <not>
-                                       <contains 
string="${srcDomain}/${srcFolder}/${srcFile}" substring="file://" />
-                               </not>
-                               <not>
-                                       <contains 
string="${srcDomain}/${srcFolder}/${srcFile}" substring="?" />
-                               </not>
-                       </and>
-               </condition>
-       </target>
 
-       <target name="get-with-params" depends="check-params" if="has-params" >
-        <get src="${srcDomain}/${srcFolder}/${srcFile}&amp;ts=${ts}" 
dest="${dest}"/>
-       </target>
-    
-    <target name="check-sum" if="md5"
-        description="Verifies MD5 checksum, and fails if checksum doesn't 
match">
-        
+    <target name="check-md5" description="Verifies MD5 checksum, and fails if 
checksum doesn't match">
         <echo>Checking ${dest} matches ${md5}</echo>
-        <checksum file="${dest}" algorithm="MD5" verifyproperty="we.failed" 
property="${md5}" />
+        <checksum file="${dest}" algorithm="MD5" verifyproperty="md5.failed" 
property="${md5}" />
         <fail message="${failmessage}">
             <condition>
-                <equals arg1="${we.failed}" arg2="false" />
+                <equals arg1="${md5.failed}" arg2="false" />
             </condition>
         </fail>
     </target>

Reply via email to