source: rtems/contrib/mingw/build-exes.sh @ 26ccaab0

4.104.114.84.95
Last change on this file since 26ccaab0 was f6cd0db, checked in by Chris Johns <chrisj@…>, on 07/28/07 at 08:31:57

2007-07-28 Chris Johns <chisj@…>

  • README, build-rpms.sh, rtems.ini, build-exes.sh, rtems-tools.nsi: Updated to the new 4.8 build plus a new installer.
  • autoconf.def, automake.def, ba-wrap.sh, build-autotools.sh, msys-path.nsi, rtems-autotools.nsi, target-section-text, upload.sh, version: New to version 4.8. Autotools is built when installing.
  • Property mode set to 100755
File size: 11.6 KB
Line 
1#! /bin/sh
2#
3# $Id$
4#
5# RTEMS Build Executable Installers script.
6#
7# This script takes the RPM files built using the mingw/build-rpms.sh
8# script.
9#
10
11echo $*
12
13source=$(dirname $0)
14
15terminate()
16{
17  echo "error: $*" >&2
18  exit 1
19}
20
21check()
22{
23 if [ $? -ne 0 ]; then
24  terminate
25 fi
26}
27
28. $source/version
29
30target_list=$(cat $source/targets)
31
32. $source/target-section-text
33
34mingw32_cpu_list="i686"
35
36rpm_topdir=$(rpm --eval "%{_topdir}")
37
38rtems_url="http://www.rtems.org/ftp/pub/rtems/windows/${version}/build-${tool_build}"
39
40common_label="common"
41local_rpm_database=yes
42targets=$target_list
43run_prefix=
44relocation=
45rpm_install=yes
46
47package_source=$(cat $HOME/.rpmmacros | grep "^%_topdir" | sed -e "s/^.* //g")/SOURCES
48
49if [ "$source" = "." ]; then
50 source=$(pwd)
51fi
52
53while [ $# -gt 0 ];
54do
55 case $1 in
56  -d)
57   set -x
58   ;;
59  -i)
60   rpm_install=no
61   ;;
62  -l)
63   shift
64   rpm_prefix=$1-
65   rpm_prefix_arg="--enable-rpmprefix=$rpm_label"
66   ;;
67  -n)
68   run_prefix="echo "
69   ;;
70  -p)
71   shift
72   prefix=$1
73   ;;
74  -R)
75   local_rpm_database=no
76   ;;
77  -r)
78   shift
79   relocation=$1
80   ;;
81  -t)
82   shift
83   targets=$1
84   ;;
85  -v)
86   shift
87   version=$1
88   ;;
89  --help)
90   echo "$0 -??"
91   exit 2
92   ;;
93  *)
94   terminate "error: invalid option (try --help): $1"
95   ;;
96 esac
97 shift
98done
99
100cd=${run_prefix}cd
101cp=${run_prefix}cp
102make=${run_prefix}make
103makensis=${run_prefix}makensis
104mkdir=${run_prefix}mkdir
105rm=${run_prefix}rm
106rpmbuild=${run_prefix}rpmbuild
107rpm=${run_prefix}rpm
108
109if [ -z "$relocation" ]; then
110 terminate "error: a relocation path needs to be specified"
111fi
112
113if [ $local_rpm_database = yes ]; then
114  rpm_database="--dbpath $prefix/var/lib/rpm"
115else
116  rpm_database=
117fi
118
119#
120# Get the RPM list given the architecture and the package.
121#
122# $1 - architecture
123# $2 - package
124#
125get_rpm_list()
126{
127  if [ -d $rpm_topdir/mingw32/RPMS/$1 ]; then
128   echo $(ls $rpm_topdir/mingw32/RPMS/$1/*.rpm | grep -v "debuginfo" | grep $2)
129  fi
130}
131
132#
133# Create the installer given the architecture and package.
134#
135# $1 - architecture/processor
136# $2 - package
137# $3 - package name
138create_installer()
139{
140  local p=$1
141  local t=$2
142  local n=$3
143
144  rpm_options="--ignoreos --force --nodeps --noorder "
145
146  rpms=$(get_rpm_list $p $t)
147  check "getting the $n RPM list"
148
149  if [ -n "$rpms" ]; then
150   treloc=$relocation/$n
151   echo "Relocation path: $treloc"
152
153   if [ $rpm_install = yes ]; then
154    echo "Clean the relocation directory: $treloc"
155    $rm -rf $treloc
156    check "removing the relocation directory: $treloc"
157
158    for r in $rpms
159    do
160     echo "rpm $rpm_database --relocate $prefix=$treloc $rpm_options -i $r"
161     $rpm $rpm_database --relocate $prefix=$treloc $rpm_options -i $r
162     check "installing rpm: $r"
163    done
164   fi
165
166   files=$(find $treloc -type f -a -not \( -name \*.gch \
167                                        -o -name rtems.nsi \
168                                        -o -name rtems-files.nsi \
169                                        -o -name rtems.ini \
170                                        -o -name files.txt \) | \
171           sed -e "s/^$(echo ${treloc} | sed 's/\//\\\//g')//" -e "s/^\///" | sort)
172   check "find the file list"
173
174   echo "$files" > $treloc/files.txt
175   check "write the file list"
176
177   of=$treloc/rtems-files.nsi
178
179   echo "!macro RTEMS_INSTALL_FILES" > $of
180   echo " !ifndef EMPTY_INSTALLER" >> $of
181
182   install_dir=
183
184   for f in $files
185   do
186    d=$(dirname $f)
187    if [ "$install_dir" != "$d" ]; then
188     id=$(echo $d | sed -e 's/\//\\/g' -e 's/\/$//')
189     echo "  SetOutPath \"\$INSTDIR\\$id\"" >> $of
190     install_dir=$d
191    fi
192    echo "  File \"$treloc/$f\"" >> $of
193   done
194
195   echo " !endif" >> $of
196   echo "!macroend" >> $of
197
198   echo "!macro RTEMS_DELETE_FILES" >> $of
199   echo " !ifndef EMPTY_INSTALLER" >> $of
200
201   #
202   # Get a list of directories so we can delete them once all
203   # the files have been deleted. We need to be selective as
204   # the directory maybe used by another installer.
205   #
206   # Once we get a list we need to also add the path down
207   # to that node and then sort them so we work from bottom up.
208   #
209
210   remove_dirs=
211
212   for f in $files
213   do
214    d=$(dirname $f)
215    found=no
216    for rd in $remove_dirs
217    do
218     if [ "$d" = "$rd" ]; then
219      found=yes
220      break;
221     fi
222    done
223    if [ $found = no ]; then
224     remove_dirs="$remove_dirs $d"
225    fi
226    rf=$(echo $f | sed -e 's/\//\\/g' -e 's/\/$//')
227    echo "  Delete \"\$INSTDIR\\$rf\"" >> $of
228   done
229
230   for d in $remove_dirs
231   do
232    while [ $d != . ]
233    do
234     found=no
235     for rd in $remove_dirs
236     do
237      if [ "$d" = "$rd" ]; then
238       found=yes
239       break
240      fi
241     done
242     if [ $found = no ]; then
243      remove_dirs="$remove_dirs $d"
244     fi
245     d=$(dirname $d)
246    done
247   done
248
249   remove_dirs=$(for r in $remove_dirs; do echo $r; done | sort -r -u)
250
251   for d in $remove_dirs
252   do
253     if [ "$d" = "." ]; then
254      d=
255     fi
256     rd=$(echo $d | sed -e 's/\//\\/g' -e 's/\/$//')
257     echo "  RMDir \"\$INSTDIR\\$rd\"" >> $of
258   done
259
260   echo " !endif" >> $of
261   echo "!macroend" >> $of
262
263   rtems_binary=$rpm_topdir/mingw32/exe/$p
264   echo "mkdir -p $rtems_binary"
265   $mkdir -p $rtems_binary
266   check "make the RTEMS binary install point: $rtems_binary"
267
268   outfile=rtems$version-tools-$n-$tool_build.exe
269
270   of=$treloc/rtems.nsi
271   echo "!define RTEMS_TARGET \"$n\"" > $of
272   echo "!define RTEMS_VERSION \"$version\"" >> $of
273   echo "!define RTEMS_BUILD_VERSION \"$tool_build\"" >> $of
274   echo "!define RTEMS_PREFIX \"rtems-tools\"" >> $of
275   echo "!define RTEMS_SOURCE \"$source\"" >> $of
276   echo "!define RTEMS_RELOCATION \"$treloc\"" >> $of
277   echo "!define RTEMS_LOGO \"$source/rtems_logo.bmp\"" >> $of
278   echo "!define RTEMS_BINARY \"$rtems_binary\"" >> $of
279   echo "!define RTEMS_LICENSE_FILE \"$source/rtems-license.rtf\"" >> $of
280   echo "!define RTEMS_OUTFILE \"$outfile\"" >> $of
281   echo "!define TOOL_PREFIX \"$prefix\"" >> $of
282
283   if [ $n = $common_label ]; then
284     echo "!define COMMON_FILES" >> $of
285   fi
286
287   echo "!include \"$treloc/rtems-files.nsi\"" >> $of
288   echo "!include \"$source/rtems-tools.nsi\"" >> $of
289
290   if [ $n = $common_label ]; then
291     echo "!include \"$relocation/rtems-sections.nsi\"" >> $of
292   fi
293
294   echo "cp $source/rtems.ini $treloc/rtems.ini"
295   $cp $source/rtems.ini $treloc/rtems.ini
296   check "coping the dialog definition file: $treloc/rtems.ini"
297
298   echo "makensis $of"
299   $makensis $of
300   check "making the installer: $of"
301
302   if [ $n != $common_label ]; then
303     of=$relocation/rtems-sections.nsi
304     tst=${t}_section_text
305     echo "" >> $of
306     echo "; Target: $t" >> $of
307     echo "Section \"${!tst}\" Section_$t" >> $of
308     echo " StrCpy \$1 \$EXEDIR\\$outfile" >> $of
309     echo " DetailPrint \"Checking for \$1\"" >> $of
310     echo " IfFileExists \$1 ${t}_found" >> $of
311     echo " StrCpy \$1 \$INSTDIR\\Packages\\$outfile" >> $of
312     echo " DetailPrint \"Checking for \$1\"" >> $of
313     echo " IfFileExists \$1 ${t}_found" >> $of
314     echo "  SetOutPath \"\$INSTDIR\\Packages\"" >> $of
315     echo "  DetailPrint \"Downloading $rtems_url/$outfile\"" >> $of
316     echo "  NSISdl::download $rtems_url/$outfile $outfile" >> $of
317     echo "  Pop \$R0" >> $of
318     echo "  StrCmp \$R0 \"success\" ${t}_found_2 ${t}_not_found_2" >> $of
319     echo " ${t}_not_found_2:" >> $of
320     echo "   SetDetailsView show" >> $of
321     echo "   DetailPrint \"Download failed: \$R0\"" >> $of
322     echo "   MessageBox MB_OK \"Download failed: \$R0\"" >> $of
323     echo "   Goto ${t}_done" >> $of
324     echo " ${t}_found_2:" >> $of
325     echo "   Strcpy \$1 \"\$INSTDIR\\Packages\\$outfile\"" >> $of
326     echo " ${t}_found:" >> $of
327     echo "  DetailPrint \"Installing: \$1\"" >> $of
328     echo "  ExecWait '\"\$1\" /S'" >> $of
329     echo "  BringToFront" >> $of
330     echo " ${t}_done:" >> $of
331     echo "SectionEnd" >> $of
332   else
333     echo "Section -SecCommon" >> $of
334     echo " SetOutPath \"\$INSTDIR"\" >> $of
335     echo " File \"\${RTEMS_SOURCE}/AUTHORS"\" >> $of
336     echo " File \"\${RTEMS_SOURCE}/COPYING\"" >> $of
337     echo " File \"\${RTEMS_SOURCE}/README\"" >> $of
338     echo "SectionEnd" >> $of
339   fi
340  fi
341}
342
343create_autotools_installer()
344{
345  local p=$1
346  local t=$2
347  local n=$3
348
349  treloc=$relocation/$n
350  echo "Relocation path: $treloc"
351
352  echo "Clean the relocation directory: $treloc"
353  $rm -rf $treloc
354  check "removing the relocation directory: $treloc"
355  mkdir -p $treloc
356  check "creating relocation directory: $treloc"
357
358  rtems_binary=$rpm_topdir/mingw32/exe/$p
359  echo "mkdir -p $rtems_binary"
360  $mkdir -p $rtems_binary
361  check "make the RTEMS binary install point: $rtems_binary"
362
363  outfile=rtems$version-tools-$n-$tool_build.exe
364
365  of=$treloc/rtems.nsi
366  echo "!define RTEMS_TARGET \"$n\"" > $of
367  echo "!define RTEMS_VERSION \"$version\"" >> $of
368  echo "!define RTEMS_BUILD_VERSION \"$tool_build\"" >> $of
369  echo "!define RTEMS_PREFIX \"rtems-tools\"" >> $of
370  echo "!define RTEMS_SOURCE \"$source\"" >> $of
371  echo "!define RTEMS_PACKAGE_SOURCE \"$package_source\"" >> $of
372  echo "!define RTEMS_LOGO \"$source/rtems_logo.bmp\"" >> $of
373  echo "!define RTEMS_BINARY \"$rtems_binary\"" >> $of
374  echo "!define RTEMS_LICENSE_FILE \"$source/rtems-license.rtf\"" >> $of
375  echo "!define RTEMS_OUTFILE \"$outfile\"" >> $of
376  echo "!define TOOL_PREFIX \"$prefix\"" >> $of
377
378  . $source/autoconf.def
379
380  echo "!define RTEMS_AUTOCONF \"$package_name\"" >> $of
381  echo "!define RTEMS_AUTOCONF_SOURCE \"$package_source\"" >> $of
382  echo "!macro RTEMS_AUTOCONF_PATCHES" >> $of
383  for p in $package_patches
384  do
385    echo " File \"\${RTEMS_PACKAGE_SOURCE}/$p\"" >> $of
386  done
387  echo "!macroend" >> $of
388
389  echo "!macro RTEMS_DELETE_AUTOCONF_PATCHES" >> $of
390  for p in $package_patches
391  do
392    echo " Delete \"\$INSTDIR\\Packages\\Source\\$p\"" >> $of
393  done
394  echo "!macroend" >> $of
395
396  . $source/automake.def
397
398  echo "!define RTEMS_AUTOMAKE \"$package_name\"" >> $of
399  echo "!define RTEMS_AUTOMAKE_SOURCE \"$package_source\"" >> $of
400  echo "!macro RTEMS_AUTOMAKE_PATCHES" >> $of
401  for p in $package_patches
402  do
403    echo " File \"\${RTEMS_PACKAGE_SOURCE}/$p\"" >> $of
404  done
405  echo "!macroend" >> $of
406
407  echo "!macro RTEMS_DELETE_AUTOMAKE_PATCHES" >> $of
408  for p in $package_patches
409  do
410    echo " Delete \"\$INSTDIR\\Packages\\Source\\$p\"" >> $of
411  done
412  echo "!macroend" >> $of
413
414  echo "!include \"$source/rtems-autotools.nsi\"" >> $of
415
416  echo "cp $source/rtems.ini $treloc/rtems.ini"
417  $cp $source/rtems.ini $treloc/rtems.ini
418  check "coping the dialog definition file: $treloc/rtems.ini"
419
420  echo "makensis $of"
421  $makensis $of
422  check "making the installer: $of"
423
424  of=$relocation/rtems-sections.nsi
425  tst=${t}_section_text
426  echo "" >> $of
427  echo "; Target: $t" >> $of
428  echo "Section \"${!tst}\" Section_$t" >> $of
429  echo " StrCpy \$1 \$EXEDIR\\$outfile" >> $of
430  echo " IfFileExists \$1 ${t}_found" >> $of
431  echo "  SetOutPath \"\$INSTDIR\Packages\"" >> $of
432  echo "  DetailPrint \"Downloading $rtems_url/$outfile\"" >> $of
433  echo "  NSISdl::download $rtems_url/$outfile $outfile" >> $of
434  echo "  Pop \$R0" >> $of
435  echo "  StrCmp \$R0 \"success\" ${t}_found_2 ${t}_not_found_2" >> $of
436  echo " ${t}_not_found_2:" >> $of
437  echo "   SetDetailsView show" >> $of
438  echo "   DetailPrint \"Download failed: \$R0\"" >> $of
439  echo "   MessageBox MB_OK \"Download failed: \$R0\"" >> $of
440  echo "   Goto ${t}_done" >> $of
441  echo " ${t}_found_2:" >> $of
442  echo "   Strcpy \$1 \"\$INSTDIR\\Packages\\$outfile\"" >> $of
443  echo " ${t}_found:" >> $of
444  echo "  DetailPrint \"Installing: \$1\"" >> $of
445  echo "  ExecWait '\"\$1\" /S'" >> $of
446  echo "  BringToFront" >> $of
447  echo " ${t}_done:" >> $of
448  echo "SectionEnd" >> $of
449}
450
451#
452# Handle each type of host processor.
453#
454for p in $mingw32_cpu_list
455do
456 echo "; Components based on each target." > $relocation/rtems-sections.nsi
457 create_autotools_installer noarch auto autotools
458 for t in $targets
459 do
460  create_installer $p $t $t
461 done
462 # Must be done last
463 create_installer $p $common_label $common_label
464done
Note: See TracBrowser for help on using the repository browser.