source: rtems/contrib/mingw/build-exes.sh @ 598aab1f

4.104.114.84.95
Last change on this file since 598aab1f was 598aab1f, checked in by Chris Johns <chrisj@…>, on Aug 20, 2007 at 2:12:48 AM

2007-08-20 Chris Johns <chisj@…>

  • filewrite.nsi, getparameters.nsi, instance-check.nsi, mingw-path.nsi, sm-dummy.nsi, strslash.nsi, strstr.nsi, options.nsi: Added the shared between the 2 installer scripts.
  • msys-path.nsi: Fixed the last LF bug.
  • rtems-autotools.nsi, rtems-tools.nsi: Fixed the instance check, added a start menu, remove pages from target installers.
  • rtems.ini: Fixed the URL links. Added support link.
  • rtems_logo.bmp: Trimmed a little more to get a better image.
  • ba-wrap.sh: Stop on a error.
  • build-exes.sh: Use the option parameter variables. Change the order the section appear in the installer.
  • Property mode set to 100755
File size: 12.3 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 $0 $*
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# Write target installer code.
134#
135# $1 - target
136# $2 - target section test
137# $3 - size of the tools
138# $4 - Installer output file name
139# $5 - Output file
140#
141target_installer_exec()
142{
143  local t=$1
144  local tst=$2
145  local size_in_k=$3
146  local outfile=$4
147  local of=$5
148
149  echo "" >> $of
150  echo "; Target: $t" >> $of
151  echo "Section \"${!tst}\" Section_$t" >> $of
152  echo " AddSize $size_in_k" >> $of
153  echo " StrCpy \$1 \$EXEDIR\\$outfile" >> $of
154  echo " DetailPrint \"Checking for \$1\"" >> $of
155  echo " IfFileExists \$1 ${t}_found" >> $of
156  echo " StrCpy \$1 \$INSTDIR\\Packages\\$outfile" >> $of
157  echo " DetailPrint \"Checking for \$1\"" >> $of
158  echo " IfFileExists \$1 ${t}_found" >> $of
159  echo "  SetOutPath \"\$INSTDIR\Packages\"" >> $of
160  echo "  DetailPrint \"Downloading $rtems_url/$outfile\"" >> $of
161  echo "  NSISdl::download $rtems_url/$outfile $outfile" >> $of
162  echo "  Pop \$R0" >> $of
163  echo "  StrCmp \$R0 \"success\" ${t}_found_2 ${t}_not_found_2" >> $of
164  echo " ${t}_not_found_2:" >> $of
165  echo "   SetDetailsView show" >> $of
166  echo "   DetailPrint \"Download failed: \$R0\"" >> $of
167  echo "   MessageBox MB_OK \"Download failed: \$R0\"" >> $of
168  echo "   Goto ${t}_done" >> $of
169  echo " ${t}_found_2:" >> $of
170  echo "   Strcpy \$1 \"\$INSTDIR\\Packages\\$outfile\"" >> $of
171  echo " ${t}_found:" >> $of
172  echo "  DetailPrint \"Installing: \$1\"" >> $of
173  echo "  ExecWait '\"\$1\" \$SilentOption \$DebugOption /D=\$INSTDIR' \$0" >> $of
174  echo "  BringToFront" >> $of
175  echo "  IntCmp \$0 0 +3" >> $of
176  echo "   MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 \"${!tst} install failed. Do you wish to continue ?\" IDYES +2" >> $of
177  echo "   Abort" >> $of
178  echo " ${t}_done:" >> $of
179  echo "SectionEnd" >> $of
180}
181
182#
183# Get the size if kilo-bytes of the package as the listed files.
184#
185# $1 - relocation directory of installed files.
186#
187get_size_in_k()
188{
189  if [ ! -d $1 ]; then
190    terminate "target directory not found: $1"
191  fi
192  if [ ! -f $1/files.txt ]; then
193    terminate "target files not found: $1/files.txt"
194  fi
195
196  local here=$(pwd)
197  check "getting the current directory"
198  cd $1
199  check "changing directory: $1"
200
201  local size_in_k=$(du -c -k $(cat files.txt) | grep total | sed -e "s/\t.*//g")
202  check "getting total size"
203
204  cd $here
205  check "changing directory: $here"
206
207  echo $size_in_k
208}
209
210#
211# Create the installer given the architecture and package.
212#
213# $1 - architecture/processor
214# $2 - package
215# $3 - package name
216# $4 - outfile
217#
218create_installer()
219{
220  local p=$1
221  local t=$2
222  local n=$3
223  local outfile=$4
224
225  rpm_options="--ignoreos --force --nodeps --noorder "
226
227  rpms=$(get_rpm_list $p $t)
228  check "getting the $n RPM list"
229
230  if [ -n "$rpms" ]; then
231   treloc=$relocation/$n
232   echo "Relocation path: $treloc"
233
234   if [ $rpm_install = yes ]; then
235    echo "Clean the relocation directory: $treloc"
236    $rm -rf $treloc
237    check "removing the relocation directory: $treloc"
238
239    for r in $rpms
240    do
241     echo "rpm $rpm_database --relocate $prefix=$treloc $rpm_options -i $r"
242     $rpm $rpm_database --relocate $prefix=$treloc $rpm_options -i $r
243     check "installing rpm: $r"
244    done
245   fi
246
247   files=$(find $treloc -type f -a -not \( -name \*.gch \
248                                        -o -name rtems.nsi \
249                                        -o -name rtems-files.nsi \
250                                        -o -name rtems.ini \
251                                        -o -name files.txt \) | \
252           sed -e "s/^$(echo ${treloc} | sed 's/\//\\\//g')//" -e "s/^\///" | sort)
253   check "find the file list"
254
255   echo "$files" > $treloc/files.txt
256   check "write the file list"
257
258   size_in_k=$(get_size_in_k $treloc)
259
260   of=$treloc/rtems-files.nsi
261
262   echo "!macro RTEMS_INSTALL_FILES" > $of
263   echo " !ifndef EMPTY_INSTALLER" >> $of
264
265   install_dir=
266
267   for f in $files
268   do
269    d=$(dirname $f)
270    if [ "$install_dir" != "$d" ]; then
271     id=$(echo $d | sed -e 's/\//\\/g' -e 's/\/$//')
272     echo "  SetOutPath \"\$INSTDIR\\$id\"" >> $of
273     install_dir=$d
274    fi
275    echo "  File \"$treloc/$f\"" >> $of
276   done
277
278   echo " !endif" >> $of
279   echo "!macroend" >> $of
280
281   echo "!macro RTEMS_DELETE_FILES" >> $of
282   echo " !ifndef EMPTY_INSTALLER" >> $of
283
284   #
285   # Get a list of directories so we can delete them once all
286   # the files have been deleted. We need to be selective as
287   # the directory maybe used by another installer.
288   #
289   # Once we get a list we need to also add the path down
290   # to that node and then sort them so we work from bottom up.
291   #
292
293   remove_dirs=
294
295   for f in $files
296   do
297    d=$(dirname $f)
298    found=no
299    for rd in $remove_dirs
300    do
301     if [ "$d" = "$rd" ]; then
302      found=yes
303      break;
304     fi
305    done
306    if [ $found = no ]; then
307     remove_dirs="$remove_dirs $d"
308    fi
309    rf=$(echo $f | sed -e 's/\//\\/g' -e 's/\/$//')
310    echo "  Delete \"\$INSTDIR\\$rf\"" >> $of
311   done
312
313   for d in $remove_dirs
314   do
315    while [ $d != . ]
316    do
317     found=no
318     for rd in $remove_dirs
319     do
320      if [ "$d" = "$rd" ]; then
321       found=yes
322       break
323      fi
324     done
325     if [ $found = no ]; then
326      remove_dirs="$remove_dirs $d"
327     fi
328     d=$(dirname $d)
329    done
330   done
331
332   remove_dirs=$(for r in $remove_dirs; do echo $r; done | sort -r -u)
333
334   for d in $remove_dirs
335   do
336     if [ "$d" = "." ]; then
337      d=
338     fi 
339     rd=$(echo $d | sed -e 's/\//\\/g' -e 's/\/$//')
340     echo "  RMDir \"\$INSTDIR\\$rd\"" >> $of
341   done
342
343   echo " !endif" >> $of
344   echo "!macroend" >> $of
345
346   rtems_binary=$rpm_topdir/mingw32/exe/$p
347   echo "mkdir -p $rtems_binary"
348   $mkdir -p $rtems_binary
349   check "make the RTEMS binary install point: $rtems_binary"
350
351   of=$treloc/rtems.nsi
352   echo "!define RTEMS_TARGET \"$n\"" > $of
353   echo "!define RTEMS_VERSION \"$version\"" >> $of
354   echo "!define RTEMS_BUILD_VERSION \"$tool_build\"" >> $of
355   echo "!define RTEMS_PREFIX \"rtems-tools\"" >> $of
356   echo "!define RTEMS_SOURCE \"$source\"" >> $of
357   echo "!define RTEMS_RELOCATION \"$treloc\"" >> $of
358   echo "!define RTEMS_LOGO \"$source/rtems_logo.bmp\"" >> $of
359   echo "!define RTEMS_BINARY \"$rtems_binary\"" >> $of
360   echo "!define RTEMS_LICENSE_FILE \"$source/rtems-license.rtf\"" >> $of
361   echo "!define RTEMS_OUTFILE \"$outfile\"" >> $of
362   echo "!define TOOL_PREFIX \"$prefix\"" >> $of
363   echo "!define RTEMS_TOOLS_SIZE \"$size_in_k\"" >> $of
364
365   if [ $n = $common_label ]; then
366     echo "!define COMMON_FILES" >> $of
367   fi
368
369   echo "!include \"$treloc/rtems-files.nsi\"" >> $of
370   echo "!include \"$source/options.nsi\"" >> $of
371
372   if [ $n = $common_label ]; then
373     echo "!include \"$relocation/rtems-sections.nsi\"" >> $of
374   fi
375
376   echo "!include \"$source/rtems-tools.nsi\"" >> $of
377
378   echo "cp $source/rtems.ini $treloc/rtems.ini"
379   $cp $source/rtems.ini $treloc/rtems.ini
380   check "coping the dialog definition file: $treloc/rtems.ini"
381
382   if [ $n = $common_label ]; then
383     echo "Section -SecCommon" >> $of
384     echo " SetOutPath \"\$INSTDIR"\" >> $of
385     echo " File \"\${RTEMS_SOURCE}/AUTHORS"\" >> $of
386     echo " File \"\${RTEMS_SOURCE}/COPYING\"" >> $of
387     echo " File \"\${RTEMS_SOURCE}/README\"" >> $of
388     echo "SectionEnd" >> $of
389   fi
390
391   echo "makensis $of"
392   $makensis $of
393   check "making the installer: $of"
394
395  fi
396}
397
398create_autotools_installer()
399{
400  local p=$1
401  local t=$2
402  local n=$3
403
404  treloc=$relocation/$n
405  echo "Relocation path: $treloc"
406
407  echo "Clean the relocation directory: $treloc"
408  $rm -rf $treloc
409  check "removing the relocation directory: $treloc"
410  mkdir -p $treloc
411  check "creating relocation directory: $treloc"
412
413  rtems_binary=$rpm_topdir/mingw32/exe/$p
414  echo "mkdir -p $rtems_binary"
415  $mkdir -p $rtems_binary
416  check "make the RTEMS binary install point: $rtems_binary"
417
418  size_in_k=2000
419
420  outfile=rtems$version-tools-$n-$tool_build.exe
421
422  of=$treloc/rtems.nsi
423  echo "!define RTEMS_TARGET \"$n\"" > $of
424  echo "!define RTEMS_VERSION \"$version\"" >> $of
425  echo "!define RTEMS_BUILD_VERSION \"$tool_build\"" >> $of
426  echo "!define RTEMS_PREFIX \"rtems-tools\"" >> $of
427  echo "!define RTEMS_SOURCE \"$source\"" >> $of
428  echo "!define RTEMS_PACKAGE_SOURCE \"$package_source\"" >> $of
429  echo "!define RTEMS_LOGO \"$source/rtems_logo.bmp\"" >> $of
430  echo "!define RTEMS_BINARY \"$rtems_binary\"" >> $of
431  echo "!define RTEMS_LICENSE_FILE \"$source/rtems-license.rtf\"" >> $of
432  echo "!define RTEMS_OUTFILE \"$outfile\"" >> $of
433  echo "!define TOOL_PREFIX \"$prefix\"" >> $of
434  echo "!define RTEMS_TOOLS_SIZE \"$size_in_k\"" >> $of
435
436  . $source/autoconf.def
437
438  echo "!define RTEMS_AUTOCONF \"$package_name\"" >> $of
439  echo "!define RTEMS_AUTOCONF_SOURCE \"$package_source\"" >> $of
440  echo "!macro RTEMS_AUTOCONF_PATCHES" >> $of
441  for p in $package_patches
442  do
443    echo " File \"\${RTEMS_PACKAGE_SOURCE}/$p\"" >> $of
444  done
445  echo "!macroend" >> $of 
446
447  echo "!macro RTEMS_DELETE_AUTOCONF_PATCHES" >> $of
448  for p in $package_patches
449  do
450    echo " Delete \"\$INSTDIR\\Packages\\Source\\$p\"" >> $of
451  done
452  echo "!macroend" >> $of 
453
454  . $source/automake.def
455
456  echo "!define RTEMS_AUTOMAKE \"$package_name\"" >> $of
457  echo "!define RTEMS_AUTOMAKE_SOURCE \"$package_source\"" >> $of
458  echo "!macro RTEMS_AUTOMAKE_PATCHES" >> $of
459  for p in $package_patches
460  do
461    echo " File \"\${RTEMS_PACKAGE_SOURCE}/$p\"" >> $of
462  done
463  echo "!macroend" >> $of 
464
465  echo "!macro RTEMS_DELETE_AUTOMAKE_PATCHES" >> $of
466  for p in $package_patches
467  do
468    echo " Delete \"\$INSTDIR\\Packages\\Source\\$p\"" >> $of
469  done
470  echo "!macroend" >> $of 
471
472  echo "!include \"$source/rtems-autotools.nsi\"" >> $of
473
474  echo "cp $source/rtems.ini $treloc/rtems.ini"
475  $cp $source/rtems.ini $treloc/rtems.ini
476  check "coping the dialog definition file: $treloc/rtems.ini"
477
478  echo "makensis $of"
479  $makensis $of
480  check "making the installer: $of"
481}
482
483#
484# Handle each type of host processor.
485#
486for p in $mingw32_cpu_list
487do
488 echo "; Components based on each target." > $relocation/rtems-sections.nsi
489 create_autotools_installer noarch auto autotools
490 target_installer_exec auto auto_section_text 2000 \
491                       rtems$version-tools-autotools-$tool_build.exe \
492                       $relocation/rtems-sections.nsi
493 for t in $targets
494 do
495  create_installer $p $t $t rtems$version-tools-$t-$tool_build.exe
496 done
497 for t in $(cat $source/targets)
498 do
499  target_installer_exec $t ${t}_section_text \
500                        $(get_size_in_k $relocation/$t) \
501                        rtems$version-tools-$t-$tool_build.exe \
502                        $relocation/rtems-sections.nsi
503 done
504 # Must be done last
505 create_installer $p $common_label $common_label $version-tools-$tool_build.exe
506done
Note: See TracBrowser for help on using the repository browser.