source: main/trunk/release-kits/kits/rk2/ant-scripts/wrap.xml@ 21593

Last change on this file since 21593 was 21593, checked in by oranfry, 12 years ago

fixes to rk2 for linux and mac

File size: 8.4 KB
Line 
1<?xml version="1.0" encoding="utf-8" ?>
2<project name="rk2-wrap" default="wrap">
3
4 <target name="wrap" depends="init,gs2-init">
5
6 <mkdir dir="products"/>
7
8 <!-- windows -->
9 <if><bool><equals arg1="${rk.os}" arg2="windows"/></bool>
10
11 <!--create a directory to build the wrapped installer in -->
12 <mkdir dir="${basedir}/wrapped-installer"/>
13
14 <!-- copy wrapper source into place -->
15 <copy todir="wrapped-installer" overwrite="true">
16 <fileset dir="${rk.home}/shared/windows/wrapper"/>
17 <fileset dir="${rk.home}/shared/greenstone2/wrapper" includes="*.bmp"/>
18 <fileset dir="${rk.home}/shared/greenstone2/icon" includes="icon.ico"/>
19 <fileset dir="${rk.home}/shared/core/search4j" includes="libsearch4j.cpp,libsearch4j.h"/>
20 </copy>
21
22 <!-- tweak files for wrapping -->
23 <rsr file="${basedir}/wrapped-installer/wrapper.cpp">
24 <job pattern="@java.installer@" replacement="${windows-java.installer}"/>
25 <job pattern="@java.min.version@" replacement="${java.min.version}"/>
26 <job pattern="@bundled.version.java@" replacement="${bundled.version.windows-java}"/>
27 <job pattern="@java.extracted@" replacement="${java.extracted}"/>
28 </rsr>
29
30 <!-- split the resources into chunks, creating a resource script of the chunks -->
31 <copy todir="${basedir}/wrapped-installer" file="${rk.home}/shared/windows/wrapper/wrapper.rc" overwrite="true"/>
32 <rsplit
33 resource="${rk.home}/shared/windows/wrapper/${windows-java.installer}"
34 outputDir="${basedir}/wrapped-installer"
35 resourceScript="${basedir}/wrapped-installer/wrapper.rc"
36 resourceName="JAVA"
37 resourceType="EXE"
38 chunkSize="${resources.chunksize}"/>
39 <rsplit
40 resource="${basedir}/installer/Greenstone-${version}-${os.suffix}.jar"
41 outputDir="${basedir}/wrapped-installer"
42 resourceScript="${basedir}/wrapped-installer/wrapper.rc"
43 resourceName="JAR"
44 resourceType="JAR"
45 chunkSize="${resources.chunksize}"
46 />
47
48 <!-- compile the resources -->
49 <exec executable="rc" dir="${basedir}/wrapped-installer">
50 <arg line="wrapper.rc"/>
51 </exec>
52
53 <!-- compile the wrapper -->
54 <exec executable="cl" dir="${basedir}/wrapped-installer">
55 <arg line="/c -GX /DWINDOWS=yes libsearch4j.cpp /out:libsearch4j.obj"/>
56 </exec>
57
58 <exec executable="cl" dir="${basedir}/wrapped-installer">
59 <arg line="/c -GX /DWINDOWS=yes wrapper.cpp /out:wrapper.obj"/>
60 </exec>
61
62 <!-- link the wrapper -->
63 <exec executable="link" dir="${basedir}/wrapped-installer">
64 <arg line="/OUT:..\products\Greenstone-${version}-${os.suffix}.exe gdi32.lib advapi32.lib shell32.lib user32.lib libsearch4j.obj wrapper.obj wrapper.res"/>
65 </exec>
66
67 <!-- linux -->
68 <else><if><bool><equals arg1="${rk.os}" arg2="linux"/></bool>
69 <!-- create and setup the build directory -->
70 <mkdir dir="${basedir}/wrapped-installer"/>
71 <copy todir="${basedir}/wrapped-installer" file="${rk.home}/shared/linux/wrapper.cpp"/>
72 <copy todir="${basedir}/wrapped-installer" file="${rk.home}/shared/core/search4j/libsearch4j.cpp"/>
73 <copy todir="${basedir}/wrapped-installer" file="${rk.home}/shared/core/search4j/libsearch4j.h"/>
74
75 <!-- copy bundled files -->
76 <copy todir="${basedir}/wrapped-installer" file="${rk.home}/shared/linux/${linux-java.installer}"/>
77 <copy tofile="${basedir}/wrapped-installer/greenstone2.jar" file="${basedir}/installer/Greenstone-${version}-linux.jar"/>
78
79 <!-- substitute in real values -->
80 <rsr file="${basedir}/wrapped-installer/wrapper.cpp">
81 <job pattern="@java.installer@" replacement="${linux-java.installer}"/>
82 <job pattern="@installer.name@" replacement="greenstone2"/>
83 <job pattern="@java.extracted@" replacement="${java.extracted}"/>
84 <job pattern="@java.min.version@" replacement="${java.min.version}"/>
85 </rsr>
86
87 <!-- create an object file (extension .o) for each file to bundle -->
88 <exec executable="/usr/bin/objcopy" dir="${basedir}/wrapped-installer">
89 <arg line="-I binary -O elf32-i386 -B i386 --redefine-sym _binary_greenstone2_jar_start=greenstone2jar --readonly-text greenstone2.jar greenstone2.jar.o"/>
90 </exec>
91 <exec executable="/usr/bin/objcopy" dir="${basedir}/wrapped-installer">
92 <arg line="-I binary -O elf32-i386 -B i386 --redefine-sym _binary_${linux-java.installer}_start=java --readonly-text ${linux-java.installer} java.o"/>
93 </exec>
94
95 <!-- compile libsearch4j -->
96 <exec executable="g++" dir="wrapped-installer">
97 <arg line="-Wall -static -static-libgcc -c -o libsearch4j.o libsearch4j.cpp"/>
98 </exec>
99
100 <!-- figure out jar size (web jar) -->
101 <exec executable="ls" dir="wrapped-installer" outputproperty="greenstone2.jar.ls"><arg line="-l greenstone2.jar"/></exec>
102 <exec executable="sed" inputstring="${greenstone2.jar.ls}" outputproperty="greenstone2.jar.size"><arg line="-e 's/^[^\ ]*\ *[^\ ]*\ *[^\ ]*\ *[^\ ]*\ *\([0-9]*\).*$/\1/g'"/></exec>
103
104 <!-- figure out java size -->
105 <exec executable="ls" dir="wrapped-installer" outputproperty="java.ls"><arg line="-l ${linux-java.installer}"/></exec>
106 <exec executable="sed" inputstring="${java.ls}" outputproperty="java.size"><arg line="-e 's/^[^\ ]*\ *[^\ ]*\ *[^\ ]*\ *[^\ ]*\ *\([0-9]*\).*$/\1/g'"/></exec>
107
108 <!-- creating wrapper header file -->
109 <delete file="wrapper.h"/>
110 <exec executable="echo" output="${basedir}/wrapped-installer/wrapper.h"><arg line="extern const char greenstone2jar[${greenstone2.jar.size}];"/></exec>
111 <exec executable="echo" output="${basedir}/wrapped-installer/wrapper.h" append="true"><arg line="extern const char java[${java.size}];"/></exec>
112 <exec executable="echo" output="${basedir}/wrapped-installer/wrapper.h" append="true"><arg line="#define java_is_bundled yes"/></exec>
113
114 <!-- compile the wrapper program -->
115 <exec executable="g++" dir="wrapped-installer">
116 <arg line="-Wall -static -static-libgcc -c -o wrapper.o wrapper.cpp"/>
117 </exec>
118
119 <!-- link the compiled code and bundled files -->
120 <exec executable="g++" dir="${basedir}/wrapped-installer">
121 <arg line="-static -static-libgcc -o ../products/Greenstone-${version}-linux wrapper.o libsearch4j.o greenstone2.jar.o java.o"/>
122 </exec>
123
124 <!-- mac -->
125 <else><if><bool><equals arg1="${rk.os}" arg2="mac"/></bool>
126
127 <!-- create and setup the build directory -->
128 <delete dir="${basedir}/wrapped-installer"/>
129 <mkdir dir="${basedir}/wrapped-installer"/>
130
131 <!-- create app for main installer -->
132 <copy todir="${basedir}/wrapped-installer/Greenstone${version}.app"><fileset dir="${rk.home}/shared/mac/Wrapper.app"/></copy>
133 <copy todir="${basedir}/wrapped-installer/Greenstone${version}.app/Contents/Resources" file="${rk.home}/shared/greenstone2/icon/icon.icns"/>
134 <chmod file="${basedir}/wrapped-installer/Greenstone${version}.app/Contents/MacOS/JavaApplicationStub" perm="ug+x"/>
135
136 <!-- copy bundled files -->
137 <copy todir="${basedir}/wrapped-installer/Greenstone${version}.app/Contents/Resources/Java" file="${basedir}/installer/Greenstone-${version}-MacOS-${processor}.jar"/>
138
139 <!-- substitute in real values -->
140 <rsr file="${basedir}/wrapped-installer/Greenstone${version}.app/Contents/Info.plist" pattern="@jar@" replacement="Greenstone-${version}-MacOS-${processor}.jar"/>
141 <rsr file="${basedir}/wrapped-installer/Greenstone${version}.app/Contents/Info.plist" pattern="@version@" replacement="${version}"/>
142
143 <!-- turn app into a dmg -->
144
145 <!-- get size of app -->
146 <exec executable="du" dir="${basedir}/wrapped-installer" outputproperty="app.du"><arg line="-ks Greenstone${version}.app"/></exec>
147 <echo>app.du: ${app.du}</echo>
148 <exec executable="sed" inputstring="${app.du}" outputproperty="app.size"><arg line="-e 's/^\([0-9]*\).*$/\1/g'"/></exec>
149 <echo>app.size: ${app.size}</echo>
150 <math result="dmg.size" operand1="${app.size}" operation="+" operand2="${dmg.overhead}" datatype="int"/>
151 <echo>dmg.size: ${dmg.size}</echo>
152
153
154 <!-- create disk image -->
155 <property name="dmg.name" value="Greenstone-${version}-${os.suffix}"/>
156 <exec dir="${basedir}/products" executable="hdiutil"><arg line="create -ov -size ${dmg.size}k -fs HFS+ -volname ${dmg.name} ${dmg.name}.dmg"/></exec>
157 <!-- mount it -->
158 <exec executable="hdiutil" dir="${basedir}/products"><arg line="attach ${dmg.name}.dmg"/></exec>
159 <!-- copy file into it -->
160 <exec executable="cp"><arg line="-r ${basedir}/wrapped-installer/Greenstone${version}.app /Volumes/${dmg.name}"/></exec>
161 <!-- unmount it-->
162 <exec executable="hdiutil"><arg line="detach /Volumes/${dmg.name}"/></exec>
163 </if></else></if></else></if>
164
165 </target>
166
167
168</project>
Note: See TracBrowser for help on using the repository browser.