[5adb73a] | 1 | #! /bin/sh |
---|
[be77d1f] | 2 | # |
---|
| 3 | # $Id$ |
---|
| 4 | # |
---|
| 5 | # RTEMS Build Executable Installers script. |
---|
| 6 | # |
---|
| 7 | # This script takes the RPM files built using the crossrpms/build-rpms.sh |
---|
| 8 | # script. |
---|
| 9 | # |
---|
| 10 | |
---|
| 11 | terminate() |
---|
| 12 | { |
---|
| 13 | echo "error: $*" >&2 |
---|
| 14 | exit 1 |
---|
| 15 | } |
---|
| 16 | |
---|
| 17 | check() |
---|
| 18 | { |
---|
| 19 | if [ $? -ne 0 ]; then |
---|
| 20 | terminate |
---|
| 21 | fi |
---|
| 22 | } |
---|
| 23 | |
---|
| 24 | version=4.7 |
---|
[979f36f] | 25 | tool_version=20060724 |
---|
[5adb73a] | 26 | tool_build=1 |
---|
[be77d1f] | 27 | |
---|
| 28 | target_list="i386 m68k powerpc sparc arm mips" |
---|
| 29 | |
---|
| 30 | mingw32_cpu_list="i686" |
---|
| 31 | |
---|
[5adb73a] | 32 | rpm_topdir=$(rpm --eval "%{_topdir}") |
---|
[be77d1f] | 33 | |
---|
[5adb73a] | 34 | common_label="common" |
---|
[be77d1f] | 35 | local_rpm_database=yes |
---|
| 36 | targets=$target_list |
---|
| 37 | run_prefix= |
---|
| 38 | relocation= |
---|
| 39 | |
---|
| 40 | source=$(dirname $0) |
---|
| 41 | |
---|
| 42 | if [ "$source" = "." ]; then |
---|
| 43 | source=$(pwd) |
---|
| 44 | fi |
---|
| 45 | |
---|
| 46 | while [ $# -gt 0 ]; |
---|
| 47 | do |
---|
| 48 | case $1 in |
---|
| 49 | -d) |
---|
| 50 | set -x |
---|
| 51 | ;; |
---|
| 52 | -l) |
---|
| 53 | shift |
---|
| 54 | rpm_prefix=$1- |
---|
| 55 | rpm_prefix_arg="--enable-rpmprefix=$rpm_label" |
---|
| 56 | ;; |
---|
| 57 | -n) |
---|
| 58 | run_prefix="echo " |
---|
| 59 | ;; |
---|
| 60 | -p) |
---|
| 61 | shift |
---|
| 62 | prefix=$1 |
---|
| 63 | ;; |
---|
| 64 | -R) |
---|
| 65 | local_rpm_database=no |
---|
| 66 | ;; |
---|
| 67 | -r) |
---|
| 68 | shift |
---|
| 69 | relocation=$1 |
---|
| 70 | ;; |
---|
| 71 | -t) |
---|
| 72 | shift |
---|
| 73 | targets=$1 |
---|
| 74 | ;; |
---|
| 75 | -v) |
---|
| 76 | shift |
---|
| 77 | version=$1 |
---|
| 78 | ;; |
---|
| 79 | --help) |
---|
| 80 | echo "$0 -??" |
---|
| 81 | exit 2 |
---|
| 82 | ;; |
---|
| 83 | *) |
---|
| 84 | terminate "error: invalid option (try --help): $1" |
---|
| 85 | ;; |
---|
| 86 | esac |
---|
| 87 | shift |
---|
| 88 | done |
---|
| 89 | |
---|
| 90 | cd=${run_prefix}cd |
---|
| 91 | cp=${run_prefix}cp |
---|
| 92 | make=${run_prefix}make |
---|
| 93 | makensis=${run_prefix}makensis |
---|
| 94 | mkdir=${run_prefix}mkdir |
---|
| 95 | rm=${run_prefix}rm |
---|
| 96 | rpmbuild=${run_prefix}rpmbuild |
---|
| 97 | rpm=${run_prefix}rpm |
---|
| 98 | |
---|
| 99 | if [ -z "$relocation" ]; then |
---|
| 100 | terminate "error: a relocation path needs to be specified" |
---|
| 101 | fi |
---|
| 102 | |
---|
| 103 | if [ $local_rpm_database = yes ]; then |
---|
| 104 | rpm_database="--dbpath $prefix/var/lib/rpm" |
---|
| 105 | else |
---|
| 106 | rpm_database= |
---|
| 107 | fi |
---|
| 108 | |
---|
| 109 | get_rpm_list() |
---|
| 110 | { |
---|
[5adb73a] | 111 | echo $(ls $rpm_topdir/mingw32/RPMS/$1/*.rpm | grep -v "debuginfo" | grep $2 | grep $3) |
---|
[be77d1f] | 112 | } |
---|
| 113 | |
---|
| 114 | # |
---|
| 115 | # Handle each type of host processor. |
---|
| 116 | # |
---|
| 117 | for p in $mingw32_cpu_list |
---|
| 118 | do |
---|
[5adb73a] | 119 | common_rpms=$(get_rpm_list $p $common_label "$tool_version.$tool_build") |
---|
| 120 | check "getting the common RPM list" |
---|
[be77d1f] | 121 | |
---|
| 122 | rpm_options="--ignoreos --force --nodeps --noorder " |
---|
| 123 | |
---|
| 124 | for t in $targets |
---|
| 125 | do |
---|
[5adb73a] | 126 | rpms=$(get_rpm_list $p $t "$tool_version.$tool_build") |
---|
| 127 | check "getting the RPM list" |
---|
[be77d1f] | 128 | if [ -n "$rpms" ]; then |
---|
| 129 | echo "Clean the relocation directory" |
---|
| 130 | $rm -rf $relocation |
---|
[5adb73a] | 131 | check "removing the relocation directory: $relocation" |
---|
[be77d1f] | 132 | |
---|
| 133 | for r in $common_rpms $rpms |
---|
| 134 | do |
---|
| 135 | echo "rpm $rpm_database --relocate $prefix=$relocation $rpm_options -i $r" |
---|
| 136 | $rpm $rpm_database --relocate $prefix=$relocation $rpm_options -i $r |
---|
[5adb73a] | 137 | check "installing rpm: $r" |
---|
[be77d1f] | 138 | done |
---|
| 139 | |
---|
| 140 | files=$(find $relocation -type f | sed -e "s/^$(echo ${relocation} | sed 's/\//\\\//g')//" -e "s/^\///" | sort) |
---|
[5adb73a] | 141 | check "find the file list" |
---|
[be77d1f] | 142 | |
---|
| 143 | of=$relocation/rtems-files.nsi |
---|
| 144 | |
---|
| 145 | echo "!macro RTEMS_INSTALL_FILES" > $of |
---|
| 146 | echo " !ifndef EMPTY_INSTALLER" >> $of |
---|
| 147 | |
---|
| 148 | install_dir= |
---|
| 149 | |
---|
| 150 | for f in $files |
---|
| 151 | do |
---|
| 152 | d=$(dirname $f) |
---|
| 153 | if [ "$install_dir" != "$d" ]; then |
---|
| 154 | id=$(echo $d | sed -e 's/\//\\/g' -e 's/\/$//') |
---|
| 155 | echo " SetOutPath \"\$INSTDIR\\$id\"" >> $of |
---|
| 156 | install_dir=$d |
---|
| 157 | fi |
---|
| 158 | echo " File \"$relocation/$f\"" >> $of |
---|
| 159 | done |
---|
| 160 | |
---|
| 161 | echo " !endif" >> $of |
---|
| 162 | echo "!macroend" >> $of |
---|
| 163 | |
---|
| 164 | echo "!macro RTEMS_DELETE_FILES" >> $of |
---|
| 165 | echo " !ifndef EMPTY_INSTALLER" >> $of |
---|
| 166 | |
---|
| 167 | remove_dirs= |
---|
| 168 | remove_dir= |
---|
| 169 | |
---|
| 170 | for f in $files |
---|
| 171 | do |
---|
| 172 | d=$(dirname $f) |
---|
| 173 | if [ "$remove_dir" != "$d" ]; then |
---|
| 174 | remove_dirs="$remove_dirs $d" |
---|
| 175 | remove_dir=$d |
---|
| 176 | fi |
---|
| 177 | rf=$(echo $f | sed -e 's/\//\\/g' -e 's/\/$//') |
---|
| 178 | echo " Delete \"\$INSTDIR\\$rf\"" >> $of |
---|
| 179 | done |
---|
| 180 | |
---|
| 181 | remove_dirs=$(for r in $remove_dirs; do echo $r; done | sort -r -u) |
---|
| 182 | |
---|
| 183 | for d in $remove_dirs |
---|
| 184 | do |
---|
| 185 | if [ "$d" = "." ]; then |
---|
| 186 | d= |
---|
| 187 | fi |
---|
| 188 | rd=$(echo $d | sed -e 's/\//\\/g' -e 's/\/$//') |
---|
| 189 | echo " RMDir \"\$INSTDIR\\$rd\"" >> $of |
---|
| 190 | done |
---|
| 191 | |
---|
| 192 | echo " !endif" >> $of |
---|
| 193 | echo "!macroend" >> $of |
---|
| 194 | |
---|
[5adb73a] | 195 | rtems_binary=$rpm_topdir/mingw32/exe/$p |
---|
| 196 | echo "mkdir -p $rtems_binary" |
---|
| 197 | $mkdir -p $rtems_binary |
---|
| 198 | check "make the RTEMS binary install point: $rtems_binary" |
---|
| 199 | |
---|
[be77d1f] | 200 | of=$relocation/rtems.nsi |
---|
| 201 | echo "!define RTEMS_TARGET \"$t\"" > $of |
---|
| 202 | echo "!define RTEMS_VERSION \"$version\"" >> $of |
---|
[5adb73a] | 203 | echo "!define RTEMS_BUILD_VERSION \"$tool_version-$tool_build\"" >> $of |
---|
[be77d1f] | 204 | echo "!define RTEMS_PREFIX \"rtems-tools\"" >> $of |
---|
[5adb73a] | 205 | echo "!define RTEMS_SOURCE \"$source\"" >> $of |
---|
| 206 | echo "!define RTEMS_RELOCATION \"$relocation\"" >> $of |
---|
[be77d1f] | 207 | echo "!define RTEMS_LOGO \"$source/rtems_logo.bmp\"" >> $of |
---|
[5adb73a] | 208 | echo "!define RTEMS_BINARY \"$rtems_binary\"" >> $of |
---|
| 209 | echo "!define RTEMS_LICENSE_FILE \"$source/rtems-license.rtf\"" >> $of |
---|
[be77d1f] | 210 | echo "!include \"$relocation/rtems-files.nsi\"" >> $of |
---|
| 211 | echo "!include \"$source/rtems-tools.nsi\"" >> $of |
---|
| 212 | |
---|
| 213 | echo "cp $source/rtems.ini $relocation/rtems.ini" |
---|
| 214 | $cp $source/rtems.ini $relocation/rtems.ini |
---|
[5adb73a] | 215 | check "coping the dialog definition file: $relocation/rtems.ini" |
---|
[be77d1f] | 216 | |
---|
| 217 | echo "makensis $of" |
---|
| 218 | $makensis $of |
---|
[5adb73a] | 219 | check "making the installer: $of" |
---|
[be77d1f] | 220 | |
---|
| 221 | fi |
---|
| 222 | done |
---|
| 223 | done |
---|