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                 <http url="${@DROP@.master.bundle.url.base}"/>
  76                 <not>
  77                     <isset property="@DROP@.master.bundle.copy.exists"/>
  78                 </not>
  79             </and>
  80         </condition>
  81     </target>
  82 
  83     <!-- Download bundles from a url. -->
  84     <target name="-@DROP@-url-bundle"
  85             depends="init, -@DROP@-ready, -@DROP@-url-should-be-used"
  86             if="@DROP@.url.should.be.used"
  87             unless="@DROP@.ready">
  88         <echo message="Downloading from ${@DROP@.master.bundle.url}"/>
  89         <dirname property="@DROP@.bundle.dirname" file="${@DROP@.bundle.copy}"/>
  90         <mkdir dir="${@DROP@.bundle.dirname}"/>
  91         <delete file="${@DROP@.bundle.copy}.temp"/>
  92         <delete file="${@DROP@.bundle.copy}"/>
  93         <get src="${@DROP@.master.bundle.url}" dest="${@DROP@.bundle.copy}.temp"/>
  94         <move file="${@DROP@.bundle.copy}.temp" tofile="${@DROP@.bundle.copy}"/>
  95         <property name="@DROP@.master.bundle.found" value="true"/>
  96     </target>
  97     
  98     <!-- Fill in the drop zones, but just when needed. -->
  99     <target name="@DROP@-update"
 100             depends="init, 
 101                      -@DROP@-copy-bundle,
 102                      -@DROP@-url-bundle,
 103                      -@DROP@-ready"
 104             if="@DROP@.master.bundle.found"
 105             unless="@DROP@.ready">
 106         <delete dir="${@DROP@.root.dir}"/>
 107         <delete dir="${@DROP@.root.dir}-temp"/>
 108         <mkdir dir="${@DROP@.root.dir}-temp"/>
 109         <unzip src="${@DROP@.bundle.copy}" dest="${@DROP@.root.dir}-temp"/>
 110         <move file="${@DROP@.root.dir}-temp" tofile="${@DROP@.root.dir}"/>
 111         <touch>
 112             <fileset dir="${@DROP@.root.dir}"/>
 113         </touch>
 114         <condition property="patch.utility" value="gpatch" else="patch">
 115             <os name="SunOS"/>
 116         </condition>
 117         <apply executable="${patch.utility}"
 118                    dir="${@DROP@.root.dir}"
 119                    parallel="false"
 120                    failonerror="true"
 121                    verbose="true">
 122             <arg value="-l"/>
 123             <arg value="-p0"/>
 124             <arg value="-i"/>
 125             <filelist dir="${patches.dir}/@DROP@" files="${@DROP@.patch.list}"/>
 126         </apply>
 127         <echo file="${@DROP@.root.dir}/PATCHED"
 128               message="Patches have been applied."/>
 129     </target>
 130 
 131 </project>