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