1 <?xml version="1.0"?>
   2 <!--
   3  Copyright 2009 Sun Microsystems, Inc.  All Rights Reserved.
   4  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   5 
   6  This code is free software; you can redistribute it and/or modify it
   7  under the terms of the GNU General Public License version 2 only, as
   8  published by the Free Software Foundation.  Sun designates this
   9  particular file as subject to the "Classpath" exception as provided
  10  by Sun in the LICENSE file that accompanied this code.
  11 
  12  This code is distributed in the hope that it will be useful, but WITHOUT
  13  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  15  version 2 for more details (a copy is included in the LICENSE file that
  16  accompanied this code).
  17 
  18  You should have received a copy of the GNU General Public License version
  19  2 along with this work; if not, write to the Free Software Foundation,
  20  Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  21 
  22  Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  23  CA 95054 USA or visit www.sun.com if you need additional information or
  24  have any questions.
  25 -->
  26 
  27 <project name="@DROP@-drop" default="all" basedir=".">
  28 
  29     <!-- Locations of master drop bundles. -->
  30     <property name="@DROP@.master.bundle.copy"
  31               value="${@DROP@.master.bundle.dir}/${@DROP@.bundle.name}"/>
  32     <property name="@DROP@.master.bundle.url"
  33               value="${@DROP@.master.bundle.url.base}/${@DROP@.bundle.name}"/>
  34 
  35     <!-- Location where the copied bundle lands. -->
  36     <property name="@DROP@.bundle.copy"
  37               value="${drop.dir}/bundles/${@DROP@.bundle.name}"/>
  38 
  39     <!-- Root of exploded area. -->
  40     <property name="@DROP@.root.dir" value="${drop.dir}/@DROP@"/>
  41     <property name="@DROP@.src.dir" value="${@DROP@.root.dir}/src"/>
  42 
  43     <!-- To see if the drop areas are ready. (ignoring bundles) -->
  44     <target name="-@DROP@-ready">
  45         <condition property="@DROP@.ready">
  46             <and>
  47                 <available file="${@DROP@.root.dir}" type="dir"/>
  48                 <available file="${@DROP@.root.dir}/PATCHED" type="file"/>
  49             </and>
  50         </condition>
  51     </target>
  52 
  53     <!-- Copy over bundles from some shared master area. -->
  54     <condition property="@DROP@.master.bundle.copy.exists">
  55         <available file="${@DROP@.master.bundle.copy}" type="file"/>
  56     </condition>
  57     <target name="-@DROP@-copy-bundle"
  58             depends="init, -@DROP@-ready"
  59             if="@DROP@.master.bundle.copy.exists"
  60             unless="@DROP@.ready">
  61         <echo message="Copying from ${@DROP@.master.bundle.copy}"/>
  62         <dirname property="@DROP@.bundle.dirname" file="${@DROP@.bundle.copy}"/>
  63         <mkdir dir="${@DROP@.bundle.dirname}"/>
  64         <delete file="${@DROP@.bundle.copy}.temp"/>
  65         <delete file="${@DROP@.bundle.copy}"/>
  66         <copy file="${@DROP@.master.bundle.copy}" tofile="${@DROP@.bundle.copy}.temp"/>
  67         <move file="${@DROP@.bundle.copy}.temp" tofile="${@DROP@.bundle.copy}"/>
  68         <property name="@DROP@.master.bundle.found" value="true"/>
  69     </target>
  70 
  71     <!-- Determine if the master url download should be used. -->
  72     <target name="-@DROP@-url-should-be-used" unless="@DROP@.url.should.be.used">
  73         <condition property="@DROP@.url.should.be.used">
  74             <and>
  75                 <not>
  76                     <isset property="@DROP@.master.bundle.copy.exists"/>
  77                 </not>
  78             </and>
  79         </condition>
  80     </target>
  81 
  82     <!-- Download bundles from a url. -->
  83     <target name="-@DROP@-url-bundle"
  84             depends="init, -@DROP@-ready, -@DROP@-url-should-be-used"
  85             if="@DROP@.url.should.be.used"
  86             unless="@DROP@.ready">
  87         <echo message="Downloading from ${@DROP@.master.bundle.url}"/>
  88         <dirname property="@DROP@.bundle.dirname" file="${@DROP@.bundle.copy}"/>
  89         <mkdir dir="${@DROP@.bundle.dirname}"/>
  90         <delete file="${@DROP@.bundle.copy}.temp"/>
  91         <delete file="${@DROP@.bundle.copy}"/>
  92         <get src="${@DROP@.master.bundle.url}" dest="${@DROP@.bundle.copy}.temp"/>
  93         <move file="${@DROP@.bundle.copy}.temp" tofile="${@DROP@.bundle.copy}"/>
  94         <property name="@DROP@.master.bundle.found" value="true"/>
  95     </target>
  96     
  97     <!-- Fill in the drop zones, but just when needed. -->
  98     <target name="@DROP@-update"
  99             depends="init, 
 100                      -@DROP@-copy-bundle,
 101                      -@DROP@-url-bundle,
 102                      -@DROP@-ready"
 103             if="@DROP@.master.bundle.found"
 104             unless="@DROP@.ready">
 105         <delete dir="${@DROP@.root.dir}"/>
 106         <delete dir="${@DROP@.root.dir}-temp"/>
 107         <mkdir dir="${@DROP@.root.dir}-temp"/>
 108         <checksum file="${@DROP@.bundle.copy}" 
 109                   property="@DROP@.bundle.md5.checksum.is"/>
 110         <condition property="@DROP@.bundle.md5.checksum.good">
 111             <equals arg1="${@DROP@.bundle.md5.checksum}"
 112                     arg2="${@DROP@.bundle.md5.checksum.is}"/>
 113         </condition>
 114         <fail unless="@DROP@.bundle.md5.checksum.good">
 115               Checksum on file ${@DROP@.bundle.copy} is 
 116               ${@DROP@.bundle.md5.checksum.is}, not ${@DROP@.bundle.md5.checksum}
 117         </fail>
 118         <unzip src="${@DROP@.bundle.copy}" dest="${@DROP@.root.dir}-temp"/>
 119         <move file="${@DROP@.root.dir}-temp" tofile="${@DROP@.root.dir}"/>
 120         <touch>
 121             <fileset dir="${@DROP@.root.dir}"/>
 122         </touch>
 123         <condition property="patch.utility" value="gpatch" else="patch">
 124             <os name="SunOS"/>
 125         </condition>
 126         <apply executable="${patch.utility}"
 127                    dir="${@DROP@.root.dir}"
 128                    parallel="false"
 129                    failonerror="true"
 130                    verbose="true">
 131             <arg value="-l"/>
 132             <arg value="-p0"/>
 133             <arg value="-i"/>
 134             <filelist dir="${patches.dir}/@DROP@" files="${@DROP@.patch.list}"/>
 135         </apply>
 136         <echo file="${@DROP@.root.dir}/PATCHED"
 137               message="Patches have been applied."/>
 138     </target>
 139 
 140 </project>