blob: b5716344c3a1782234be5191864393284048fbe5 [file] [log] [blame]
david_williams42f9b242006-11-27 18:45:14 +00001<?xml version="1.0" encoding="UTF-8"?>
ndaib8cedc82005-09-13 18:00:32 +00002<!--
david_williams1cff0e92006-11-23 00:40:29 +00003
4
5 dependency
6 This script get a library from a remote repository and stores it in a local cache.
7
8 The following properties are used by this script:
9
10 local.cache.dir - the absolute path to the local repository for the libraries
11 dependency.url : Url to a remote repository that will be used to download the library
12 dependency.file: Name of the library that is used. If the library is platform dependent
13 it must have suffixes such as: file.linux.gtk.x86
david_williams42f9b242006-11-27 18:45:14 +000014 These suffixes are the same as those used by releng baseos,basews,base arch
david_williams1cff0e92006-11-23 00:40:29 +000015 baseos= linux or win32
16 basews= gtk or win32
david_williams42f9b242006-11-27 18:45:14 +000017 base arch=x86 or ppc
david_williams1cff0e92006-11-23 00:40:29 +000018 dependency.name: A short user readable name for the library.
19 dependency.description: One line description for the library.
20 dependency.autodownload: [optional] default true. Set this to false if the file cannot be
21 downloaded automatically (i.e. requies license accept click through).
22 If autodownload is false, and the library is not avaialbe in the local
23 repository (cache). User must download the library and copy it into
24 the local repository.
25 dependency.releng.url: [optional] A mirror of the original repository. Useful for libraries
26 that can get deleted from their original URLs. Releng will use
27 the local cache, original url, releng.url in that order to get the
28 the dependency. If a releng.url is not provided, the library will
29 always be requested from itrs original site.
ndaib8cedc82005-09-13 18:00:32 +000030-->
31<project name="dependency" default="default">
david_williams1cff0e92006-11-23 00:40:29 +000032 <description>
33 This script get a library from a remote repository and stores it in a
34 local cache.
ndaib8cedc82005-09-13 18:00:32 +000035 </description>
36
37
david_williams1cff0e92006-11-23 00:40:29 +000038 <!-- =================================
39 target: default
40 ================================= -->
41 <target name="default"
42 description="This script get a library from a remote repository and stores it in a local cache.">
43 <condition property="dependency.download.file">
44 <or>
45 <not>
46 <isset property="dependency.autodownload" />
47 </not>
48 <and>
49 <isset property="dependency.autodownload" />
50 <equals arg1="${dependency.autodownload}"
51 arg2="true" />
52 </and>
53 </or>
54 </condition>
55 <antcall target="get" />
56 <antcall target="checkAutoDownload" />
57 </target>
ndaib8cedc82005-09-13 18:00:32 +000058
david_williams1cff0e92006-11-23 00:40:29 +000059 <!-- - - - - - - - - - - - - - - - - -
60 target: sub tasks
61 - - - - - - - - - - - - - - - - - -->
62 <target name="get" if="dependency.download.file">
63 <mkdir dir="${local.cache.dir}" />
64 <available file="${local.cache.dir}/${dependency.file}"
65 property="local.cache.file.exists" />
66 <antcall target="download" />
67 </target>
ndaib8cedc82005-09-13 18:00:32 +000068
david_williams1cff0e92006-11-23 00:40:29 +000069 <target name="checkAutoDownload"
70 unless="dependency.download.file">
71 <fail unless="local.cache.file.exists"
72 message="The dependent file ${dependency.name}, must be manually downloaded and placed in ${local.cache.dir}." />
73 </target>
ndaib8cedc82005-09-13 18:00:32 +000074
david_williams1cff0e92006-11-23 00:40:29 +000075 <target name="download"
76 unless="local.cache.file.exists">
77 <get verbose="true"
78 src="${dependency.url}/${dependency.file}"
79 dest="${local.cache.dir}/${dependency.file}"
80 ignoreerrors="true" />
ndaib8cedc82005-09-13 18:00:32 +000081
david_williams1cff0e92006-11-23 00:40:29 +000082 <condition property="download.from.mirror">
83 <and>
84 <isset property="dependency.releng.url" />
85 <not>
86 <available file="${local.cache.dir}/${dependency.file}" />
87 </not>
88 </and>
89 </condition>
90 <antcall target="downloadMirror" />
91 </target>
92 <target name="downloadMirror" if="download.from.mirror">
93 <echo message="Using mirror repository: ${main.url.file.exists}" />
94 <echo message="Using mirror repository: ${dependency.releng.url}" />
95 <get verbose="true"
96 src="${dependency.releng.url}/${dependency.file}"
97 dest="${local.cache.dir}/${dependency.file}" />
98 </target>
ndaib8cedc82005-09-13 18:00:32 +000099
100
david_williams1cff0e92006-11-23 00:40:29 +0000101 <!-- =================================
102 target: install
103 ================================= -->
104 <target name="install">
105 <condition property="file.type" value="zip">
106 <isfileselected file="${dependency.file}">
107 <selector>
108 <filename name="**/*.zip" />
109 </selector>
110 </isfileselected>
111 </condition>
112 <condition property="file.type" value="tgz">
113 <isfileselected file="${dependency.file}">
114 <selector>
115 <filename name="**/*.tar.gz" />
116 </selector>
117 </isfileselected>
118 </condition>
119 <condition property="file.type" value="tgz">
120 <isfileselected file="${dependency.file}">
121 <selector>
122 <filename name="**/*.tgz" />
123 </selector>
124 </isfileselected>
125 </condition>
126 <condition property="file.type" value="tar">
127 <isfileselected file="${dependency.file}">
128 <selector>
129 <filename name="**/*.tar" />
130 </selector>
131 </isfileselected>
132 </condition>
david_williamsdf8c92e2007-02-17 04:55:27 +0000133 <condition property="file.type" value="map">
134 <isfileselected file="${dependency.file}">
135 <selector>
136 <filename name="**/*.map" />
137 </selector>
138 </isfileselected>
139 </condition>
david_williams948bf552007-02-26 05:17:22 +0000140 <condition property="file.type" value="jar">
141 <isfileselected file="${dependency.file}">
142 <selector>
143 <filename name="**/*.jar" />
144 </selector>
145 </isfileselected>
146 </condition>
ndaib8cedc82005-09-13 18:00:32 +0000147
david_williams1cff0e92006-11-23 00:40:29 +0000148 <antcall target="install-${file.type}" />
149 </target>
ndaib8cedc82005-09-13 18:00:32 +0000150
david_williams1cff0e92006-11-23 00:40:29 +0000151 <target name="install-tar">
152 <untar dest="${install.destination}"
153 src="${local.cache.dir}/${dependency.file}"
154 overwrite="true" />
155 </target>
156 <target name="install-tgz">
157 <untar dest="${install.destination}"
158 src="${local.cache.dir}/${dependency.file}"
159 compression="gzip"
160 overwrite="true" />
161 </target>
162 <target name="install-zip">
163 <unzip dest="${install.destination}"
164 src="${local.cache.dir}/${dependency.file}"
165 overwrite="true" />
166 </target>
david_williamsdf8c92e2007-02-17 04:55:27 +0000167 <target name="install-map">
168 <copy todir="${install.destination}"
169 file="${local.cache.dir}/${dependency.file}"
170 overwrite="true" />
171 </target>
david_williams948bf552007-02-26 05:17:22 +0000172 <target name="install-jar">
173 <copy todir="${install.destination}"
174 file="${local.cache.dir}/${dependency.file}"
175 overwrite="true" />
176 </target>
ndaib8cedc82005-09-13 18:00:32 +0000177
david_williams1cff0e92006-11-23 00:40:29 +0000178 <target name="checkDependency">
179 <dirname file="${ant.file}"
180 property="dependency.dir" />
ndaib8cedc82005-09-13 18:00:32 +0000181
david_williams1cff0e92006-11-23 00:40:29 +0000182 <copy tofile="${buildDirectory}/dependency.${groupId}.xml"
183 overwrite="true">
184 <fileset dir="${dependency.dir}">
185 <include name="template.xml" />
186 </fileset>
187 </copy>
188 <echo message="Creating dependency script: ${buildDirectory}/dependency.${groupId}.xml " />
189 <replace file="${buildDirectory}/dependency.${groupId}.xml"
190 value="${groupId}.">
191 <replacetoken>@dependencyGroupId@</replacetoken>
192 </replace>
193 <replace file="${buildDirectory}/dependency.${groupId}.xml"
194 value="${dependency.dir}">
195 <replacetoken>@dependencyDir@</replacetoken>
196 </replace>
197 <replace file="${buildDirectory}/dependency.${groupId}.xml"
198 value="${dependency.properties}">
199 <replacetoken>@dependencyProperties@</replacetoken>
200 </replace>
201 <ant antfile="${buildDirectory}/dependency.${groupId}.xml"
202 target="get" />
ndaib8cedc82005-09-13 18:00:32 +0000203
david_williams1cff0e92006-11-23 00:40:29 +0000204 <!--
205 <delete failonerror="false">
206 <fileset dir=".">
207 <include name="${buildDirectory}/dependency.${groupId}.xml" />
208 </fileset>
209 </delete>
210 -->
ndaib8cedc82005-09-13 18:00:32 +0000211
212
david_williams1cff0e92006-11-23 00:40:29 +0000213 </target>
ndaib8cedc82005-09-13 18:00:32 +0000214
david_williams1cff0e92006-11-23 00:40:29 +0000215 <target name="installDependency">
216 <dirname file="${ant.file}"
217 property="dependency.dir" />
ndaib8cedc82005-09-13 18:00:32 +0000218
david_williams1cff0e92006-11-23 00:40:29 +0000219 <copy tofile="${buildDirectory}/dependency.${groupId}.xml">
220 <fileset dir="${dependency.dir}">
221 <include name="template.xml" />
222 </fileset>
223 </copy>
224 <replace file="${buildDirectory}/dependency.${groupId}.xml"
225 value="${groupId}.">
226 <replacetoken>@dependencyGroupId@</replacetoken>
227 </replace>
228 <replace file="${buildDirectory}/dependency.${groupId}.xml"
229 value="${dependency.dir}">
230 <replacetoken>@dependencyDir@</replacetoken>
231 </replace>
232 <replace file="${buildDirectory}/dependency.${groupId}.xml"
233 value="${dependency.properties}">
234 <replacetoken>@dependencyProperties@</replacetoken>
235 </replace>
236 <ant antfile="${buildDirectory}/dependency.${groupId}.xml"
237 target="install">
238 <property name="install.destination"
239 value="${install.destination}" />
240 </ant>
ndaib8cedc82005-09-13 18:00:32 +0000241
david_williams1cff0e92006-11-23 00:40:29 +0000242 <!--
243 <delete failonerror="false">
244 <fileset dir=".">
245 <include name="${buildDirectory}/dependency.${groupId}.xml" />
246 </fileset>
247 </delete>
248 -->
249 </target>
ndaib8cedc82005-09-13 18:00:32 +0000250
251
252</project>
253