blob: 92496f0c277697fdb751c8cbb906e747dd99d8ee [file] [log] [blame]
ndaib8cedc82005-09-13 18:00:32 +00001<?xml version="1.0"?>
2<!--
3
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
14 These suffixes are the same as those useb by releng baseos,basews,basearch
15 baseos= linux or win32
16 basews= gtk or win32
17 basearch=x86
18 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.
30-->
31<project name="dependency" default="default">
32 <description>
33 This script get a library from a remote repository and stores it in a local cache.
34 </description>
35
36
37 <!-- =================================
38 target: default
39 ================================= -->
40 <target name="default" description="This script get a library from a remote repository and stores it in a local cache.">
41 <condition property="dependency.download.file">
42 <or>
43 <not>
44 <isset property="dependency.autodownload" />
45 </not>
46 <and>
47 <isset property="dependency.autodownload" />
48 <equals arg1="${dependency.autodownload}" arg2="true" />
49 </and>
50 </or>
51 </condition>
52 <antcall target="get" />
53 <antcall target="checkAutoDownload" />
54 </target>
55
56 <!-- - - - - - - - - - - - - - - - - -
57 target: sub tasks
58 - - - - - - - - - - - - - - - - - -->
59 <target name="get" if="dependency.download.file">
60 <mkdir dir="${local.cache.dir}"/>
61 <available file="${local.cache.dir}/${dependency.file}" property="local.cache.file.exists" />
62 <antcall target="download" />
63 </target>
64
65 <target name="checkAutoDownload" unless="dependency.download.file">
66 <fail unless="local.cache.file.exists" message="The dependent file ${dependency.name}, must be manually downloaded and placed in ${local.cache.dir}." />
67 </target>
68
69 <target name="download" unless="local.cache.file.exists">
70 <get verbose="true" src="${dependency.url}/${dependency.file}" dest="${local.cache.dir}/${dependency.file}" ignoreerrors="true" />
71
72 <condition property="download.from.mirror">
73 <and>
74 <isset property="dependency.releng.url" />
75 <not>
76 <available file="${local.cache.dir}/${dependency.file}" />
77 </not>
78 </and>
79 </condition>
80 <antcall target="downloadMirror" />
81 </target>
82 <target name="downloadMirror" if="download.from.mirror">
83 <echo message="Using mirror repository: ${main.url.file.exists}" />
84 <echo message="Using mirror repository: ${dependency.releng.url}" />
85 <get verbose="true" src="${dependency.releng.url}/${dependency.file}" dest="${local.cache.dir}/${dependency.file}" />
86 </target>
87
88
89 <!-- =================================
90 target: install
91 ================================= -->
92 <target name="install">
93 <condition property="file.type" value="zip">
94 <isfileselected file="${dependency.file}">
95 <selector>
96 <filename name="**/*.zip" />
97 </selector>
98 </isfileselected>
99 </condition>
100 <condition property="file.type" value="tgz">
101 <isfileselected file="${dependency.file}">
102 <selector>
ndai69dc6452005-09-13 18:45:46 +0000103 <filename name="**/*.tar.gz" />
ndaib8cedc82005-09-13 18:00:32 +0000104 </selector>
105 </isfileselected>
106 </condition>
ndaicbc58212005-09-14 16:45:49 +0000107 <condition property="file.type" value="tgz">
108 <isfileselected file="${dependency.file}">
109 <selector>
110 <filename name="**/*.tgz" />
111 </selector>
112 </isfileselected>
113 </condition>
ndaib8cedc82005-09-13 18:00:32 +0000114 <condition property="file.type" value="tar">
115 <isfileselected file="${dependency.file}">
116 <selector>
117 <filename name="**/*.tar" />
118 </selector>
119 </isfileselected>
120 </condition>
121
122
123 <antcall target="install-${file.type}" />
124 </target>
125
126 <target name="install-tar">
127 <untar dest="${install.destination}" src="${local.cache.dir}/${dependency.file}" overwrite="true" />
128 </target>
129 <target name="install-tgz">
130 <untar dest="${install.destination}" src="${local.cache.dir}/${dependency.file}" compression="gzip" overwrite="true" />
131 </target>
132 <target name="install-zip">
133 <unzip dest="${install.destination}" src="${local.cache.dir}/${dependency.file}" overwrite="true" />
134 </target>
135
136 <target name="checkDependency">
137 <dirname file="${ant.file}" property="dependency.dir" />
138
139 <copy tofile="dependency.${groupId}.xml" overwrite="true">
140 <fileset dir="${dependency.dir}">
141 <include name="template.xml" />
142 </fileset>
143 </copy>
144 <echo message="Creating: dependency.${groupId}.xml " />
145 <replace file="dependency.${groupId}.xml" value="${groupId}.">
146 <replacetoken>@dependencyGroupId@</replacetoken>
147 </replace>
148 <replace file="dependency.${groupId}.xml" value="${dependency.dir}">
149 <replacetoken>@dependencyDir@</replacetoken>
150 </replace>
151 <replace file="dependency.${groupId}.xml" value="${dependency.properties}">
152 <replacetoken>@dependencyProperties@</replacetoken>
153 </replace>
154 <ant antfile="dependency.${groupId}.xml" target="get" />
155
156 <delete failonerror="false">
157 <fileset dir=".">
158 <include name="dependency.${groupId}.xml" />
159 </fileset>
160 </delete>
161
162
163
164 </target>
165
166 <target name="installDependency">
167 <dirname file="${ant.file}" property="dependency.dir" />
168
169 <copy tofile="dependency.${groupId}.xml">
170 <fileset dir="${dependency.dir}">
171 <include name="template.xml" />
172 </fileset>
173 </copy>
174 <replace file="dependency.${groupId}.xml" value="${groupId}.">
175 <replacetoken>@dependencyGroupId@</replacetoken>
176 </replace>
177 <replace file="dependency.${groupId}.xml" value="${dependency.dir}">
178 <replacetoken>@dependencyDir@</replacetoken>
179 </replace>
180 <replace file="dependency.${groupId}.xml" value="${dependency.properties}">
181 <replacetoken>@dependencyProperties@</replacetoken>
182 </replace>
183 <ant antfile="dependency.${groupId}.xml" target="install">
184 <property name="install.destination" value="${install.destination}" />
185 </ant>
186
187 <delete failonerror="false">
188 <fileset dir=".">
189 <include name="dependency.${groupId}.xml" />
190 </fileset>
191 </delete>
192 </target>
193
194
195</project>
196