1 <?xml version="1.0"?>
   2 <!--
   3  Copyright (c) 2009, Oracle and/or its affiliates. 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.  Oracle designates this
   9  particular file as subject to the "Classpath" exception as provided
  10  by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  23  or visit www.oracle.com if you need additional information or have any
  24  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.expanded.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             <or>
  47                 <available file="${drop.included.dir}" type="dir"/>
  48                 <and>
  49                     <available file="${@DROP@.root.dir}" type="dir"/>
  50                     <available file="${@DROP@.root.dir}/PATCHED" type="file"/>
  51                 </and>
  52             </or>
  53         </condition>
  54     </target>
  55 
  56     <!-- Copy over bundles from some shared master area. -->
  57     <condition property="@DROP@.master.bundle.copy.exists">
  58         <available file="${@DROP@.master.bundle.copy}" type="file"/>
  59     </condition>
  60     <target name="-@DROP@-copy-bundle"
  61             depends="init, -@DROP@-ready"
  62             if="@DROP@.master.bundle.copy.exists"
  63             unless="@DROP@.ready">
  64         <echo message="Copying from ${@DROP@.master.bundle.copy}"/>
  65         <dirname property="@DROP@.bundle.dirname" file="${@DROP@.bundle.copy}"/>
  66         <mkdir dir="${@DROP@.bundle.dirname}"/>
  67         <delete file="${@DROP@.bundle.copy}.temp"/>
  68         <delete file="${@DROP@.bundle.copy}"/>
  69         <copy file="${@DROP@.master.bundle.copy}" tofile="${@DROP@.bundle.copy}.temp"/>
  70         <move file="${@DROP@.bundle.copy}.temp" tofile="${@DROP@.bundle.copy}"/>
  71         <property name="@DROP@.master.bundle.found" value="true"/>
  72     </target>
  73 
  74     <!-- Determine if the master url download should be used. -->
  75     <target name="-@DROP@-url-should-be-used" unless="@DROP@.url.should.be.used">
  76         <condition property="@DROP@.url.should.be.used">
  77             <and>
  78                 <not>
  79                     <isset property="@DROP@.master.bundle.copy.exists"/>
  80                 </not>
  81             </and>
  82         </condition>
  83     </target>
  84 
  85     <!-- Download bundles from a url. -->
  86     <target name="-@DROP@-url-bundle"
  87             depends="init, -@DROP@-ready, -@DROP@-url-should-be-used"
  88             if="@DROP@.url.should.be.used"
  89             unless="@DROP@.ready">
  90         <echo message="Downloading from ${@DROP@.master.bundle.url}"/>
  91         <dirname property="@DROP@.bundle.dirname" file="${@DROP@.bundle.copy}"/>
  92         <mkdir dir="${@DROP@.bundle.dirname}"/>
  93         <delete file="${@DROP@.bundle.copy}.temp"/>
  94         <delete file="${@DROP@.bundle.copy}"/>
  95         <get src="${@DROP@.master.bundle.url}" dest="${@DROP@.bundle.copy}.temp"/>
  96         <move file="${@DROP@.bundle.copy}.temp" tofile="${@DROP@.bundle.copy}"/>
  97         <property name="@DROP@.master.bundle.found" value="true"/>
  98     </target>
  99     
 100     <!-- Fill in the drop zones, but just when needed. -->
 101     <target name="@DROP@-update"
 102             depends="init, 
 103                      -@DROP@-copy-bundle,
 104                      -@DROP@-url-bundle,
 105                      -@DROP@-ready"
 106             if="@DROP@.master.bundle.found"
 107             unless="@DROP@.ready">
 108         <delete dir="${@DROP@.root.dir}"/>
 109         <delete dir="${@DROP@.root.dir}-temp"/>
 110         <mkdir dir="${@DROP@.root.dir}-temp"/>
 111         <checksum file="${@DROP@.bundle.copy}" 
 112                   property="@DROP@.bundle.md5.checksum.is"/>
 113         <condition property="@DROP@.bundle.md5.checksum.good">
 114             <equals arg1="${@DROP@.bundle.md5.checksum}"
 115                     arg2="${@DROP@.bundle.md5.checksum.is}"/>
 116         </condition>
 117         <fail unless="@DROP@.bundle.md5.checksum.good">
 118               Checksum on file ${@DROP@.bundle.copy} is 
 119               ${@DROP@.bundle.md5.checksum.is}, not ${@DROP@.bundle.md5.checksum}
 120         </fail>
 121         <unzip src="${@DROP@.bundle.copy}" dest="${@DROP@.root.dir}-temp"/>
 122         <move file="${@DROP@.root.dir}-temp" tofile="${@DROP@.root.dir}"/>
 123         <touch>
 124             <fileset dir="${@DROP@.root.dir}"/>
 125         </touch>
 126         <condition property="patch.utility" value="gpatch" else="patch">
 127             <os name="SunOS"/>
 128         </condition>
 129         <apply executable="${patch.utility}"
 130                    dir="${@DROP@.root.dir}"
 131                    parallel="false"
 132                    failonerror="true"
 133                    verbose="true">
 134             <arg value="-l"/>
 135             <arg value="-p0"/>
 136             <arg value="-i"/>
 137             <filelist dir="${patches.dir}/@DROP@" files="${@DROP@.patch.list}"/>
 138         </apply>
 139         <echo file="${@DROP@.root.dir}/PATCHED"
 140               message="Patches have been applied."/>
 141     </target>
 142 
 143 </project>