|
3 | 3 | # Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana
|
4 | 4 | # University Research and Technology
|
5 | 5 | # Corporation. All rights reserved.
|
6 |
| -# Copyright (c) 2006 Cisco Systems, Inc. All rights reserved. |
| 6 | +# Copyright (c) 2006-2016 Cisco Systems, Inc. All rights reserved. |
| 7 | +# |
| 8 | + |
| 9 | +# |
| 10 | +# External script parameters |
| 11 | +# The folowing parameters could be used to affect script behaviour. |
| 12 | +# Please, do NOT set the same settings with parameters and config vars. |
| 13 | +# |
| 14 | +# -b |
| 15 | +# If you specify this option, only the all-in-one binary RPM will |
| 16 | +# be built. By default, only the source RPM (SRPM) is built. Other |
| 17 | +# parameters that affect the all-in-one binary RPM will be ignored |
| 18 | +# unless this option is specified. |
| 19 | +# |
| 20 | +# -n name |
| 21 | +# This option will change the name of the produced RPM to the "name". |
| 22 | +# It is useful to use with "-o" and "-m" options if you want to have |
| 23 | +# multiple Open MPI versions installed simultaneously in the same |
| 24 | +# enviroment. Requires use of option "-b". |
| 25 | +# |
| 26 | +# -o |
| 27 | +# With this option the install path of the binary RPM will be changed |
| 28 | +# to /opt/_NAME_/_VERSION_. Requires use of option "-b". |
| 29 | +# |
| 30 | +# -m |
| 31 | +# This option causes the RPM to also install modulefiles |
| 32 | +# to the location specified in the specfile. Requires use of option "-b". |
| 33 | +# |
| 34 | +# -i |
| 35 | +# Also build a debuginfo RPM. By default, the debuginfo RPM is not built. |
| 36 | +# Requires use of option "-b". |
| 37 | +# |
| 38 | +# -f lf_location |
| 39 | +# Include support for Libfabric. "lf_location" is Libfabric install |
| 40 | +# path. Requires use of option "-b". |
| 41 | +# |
| 42 | +# -t tm_location |
| 43 | +# Include support for Torque/PBS Pro. "tm_location" is path of the |
| 44 | +# Torque/PBS Pro header files. Requires use of option "-b". |
| 45 | +# |
| 46 | +# -d |
| 47 | +# Build with debugging support. By default, |
| 48 | +# the RPM is built without debugging support. |
| 49 | +# |
| 50 | +# -c parameter |
| 51 | +# Add custom configure parameter. |
| 52 | +# |
| 53 | +# -r parameter |
| 54 | +# Add custom RPM build parameter. |
| 55 | +# |
| 56 | +# -s |
| 57 | +# If specified, the script will try to unpack the openmpi.spec |
| 58 | +# file from the tarball specified on the command line. By default, |
| 59 | +# the script will look for the specfile in the current directory. |
| 60 | +# |
| 61 | +# -h |
| 62 | +# Prints script usage information. |
7 | 63 | #
|
8 | 64 |
|
9 | 65 | #
|
10 | 66 | # General config vars
|
11 | 67 | # The following vars can be set from outside and will affect script behave:
|
12 | 68 | # prefix,rpmbuild_options,configure_options,build_srpm,build_single,build_multiple,rpmtopdir
|
13 | 69 | #
|
14 |
| - |
15 |
| - |
16 | 70 | specfile="openmpi.spec"
|
17 | 71 | prefix=${prefix:-"/opt/openmpi"}
|
18 | 72 | rpmbuild_options=${rpmbuild_options:-"--define 'mflags -j4' --define '_source_filedigest_algorithm md5' --define '_binary_filedigest_algorithm md5'"}
|
@@ -44,13 +98,103 @@ build_multiple=${build_multiple:-"no"}
|
44 | 98 | # You should not need to change anything below this line
|
45 | 99 | #########################################################################
|
46 | 100 |
|
| 101 | +# |
| 102 | +# save original parameters |
| 103 | +# |
| 104 | +orig_param="$@" |
| 105 | + |
| 106 | +# |
| 107 | +# usage information |
| 108 | +# |
| 109 | +usage="Usage: $0 [-b][-o][-m][-d][-u][-s][-h] [-n name][-f lf_location][-t tm_location] tarball |
| 110 | +
|
| 111 | + -b |
| 112 | + build all-in-one binary RPM only (required for all other flags to work) |
| 113 | + {default: build only SRPM} |
| 114 | +
|
| 115 | + -n name |
| 116 | + name of the resulting RPM package set to name. Requires -b flag. |
| 117 | + {default: openmpi} |
| 118 | +
|
| 119 | + -o install in /opt/_NAME_/_VERSION_. Requires -b flag. |
| 120 | + {default: install in /usr} |
| 121 | +
|
| 122 | + -m install modulefiles during RPM installation. Requires -b flag. |
| 123 | + {default: modulefiles will NOT be installed} |
| 124 | +
|
| 125 | + -i build debuginfo RPM. Requires -b flag. |
| 126 | + {default: do NOT build debuginfo RPM} |
| 127 | +
|
| 128 | + -f lf_location |
| 129 | + include Libfabric support from <lf_location>. Requires -b flag. |
| 130 | + {default: try to build with Libfabric support} |
| 131 | +
|
| 132 | + -t tm_location |
| 133 | + include Torque/PBS Pro support from tm_location. Requires -b flag. |
| 134 | + {default: try to build with Torque/PBS Pro} |
| 135 | +
|
| 136 | + -d build with Debugging support |
| 137 | + {default: without debugging support} |
| 138 | +
|
| 139 | + -s try to unpack openmpi.spec file from tarball |
| 140 | + {default: search for openmpi.spec in current directory} |
| 141 | +
|
| 142 | + -c parameter |
| 143 | + add custom configure parameter |
| 144 | +
|
| 145 | + -r parameter |
| 146 | + add custom RPM build parameter |
| 147 | +
|
| 148 | + -h print this message and exit |
| 149 | +
|
| 150 | + tarball path to Open MPI source tarball |
| 151 | + " |
| 152 | + |
| 153 | +# |
| 154 | +# parse args |
| 155 | +# |
| 156 | +libfabric_path="" |
| 157 | + |
| 158 | +while getopts bn:omif:t:dc:r:sh flag; do |
| 159 | + case "$flag" in |
| 160 | + b) build_srpm="no" |
| 161 | + build_single="yes" |
| 162 | + ;; |
| 163 | + n) rpmbuild_options="$rpmbuild_options --define '_name $OPTARG'" |
| 164 | + ;; |
| 165 | + o) rpmbuild_options="$rpmbuild_options --define 'install_in_opt 1'" |
| 166 | + configure_options="$configure_options --enable-mpirun-prefix-by-default" |
| 167 | + ;; |
| 168 | + m) rpmbuild_options="$rpmbuild_options --define 'install_modulefile 1'" |
| 169 | + ;; |
| 170 | + i) rpmbuild_options="$rpmbuild_options --define 'build_debuginfo_rpm 1'" |
| 171 | + ;; |
| 172 | + f) libfabric_path="$OPTARG" |
| 173 | + ;; |
| 174 | + t) configure_options="$configure_options --with-tm=$OPTARG" |
| 175 | + ;; |
| 176 | + d) configure_options="$configure_options --enable-debug" |
| 177 | + ;; |
| 178 | + c) configure_options="$configure_options $OPTARG" |
| 179 | + ;; |
| 180 | + r) configure_options="$rpmbuild_options $OPTARG" |
| 181 | + ;; |
| 182 | + s) unpack_spec="1" |
| 183 | + ;; |
| 184 | + h) echo "$usage" 1>&2 |
| 185 | + exit 0 |
| 186 | + ;; |
| 187 | + esac |
| 188 | +done |
| 189 | +shift $(( OPTIND - 1 )); |
| 190 | + |
47 | 191 | #
|
48 | 192 | # get the tarball name
|
49 | 193 | #
|
50 | 194 |
|
51 | 195 | tarball="$1"
|
52 | 196 | if test "$tarball" = ""; then
|
53 |
| - echo "Usage: buildrpm.sh <tarball>" |
| 197 | + echo "$usage" |
54 | 198 | exit 1
|
55 | 199 | fi
|
56 | 200 | if test ! -f $tarball; then
|
@@ -79,16 +223,45 @@ version="`echo $first | sed -e 's/\.tar\.'$extension'//'`"
|
79 | 223 | unset first
|
80 | 224 | echo "--> Found Open MPI version: $version"
|
81 | 225 |
|
| 226 | +# |
| 227 | +# Try to unpack spec file from tarball |
| 228 | +# |
| 229 | + |
| 230 | +if test $unpack_spec -eq 1; then |
| 231 | + tar -xf $tarball --wildcards --no-anchored 'openmpi.spec' --strip=4 |
| 232 | +fi |
| 233 | + |
82 | 234 | #
|
83 | 235 | # do we have the spec files?
|
84 | 236 | #
|
85 | 237 |
|
86 |
| -if test ! -f $specfile; then |
| 238 | +if test ! -r $specfile; then |
87 | 239 | echo "can't find $specfile"
|
88 | 240 | exit 1
|
89 | 241 | fi
|
90 | 242 | echo "--> Found specfile: $specfile"
|
91 | 243 |
|
| 244 | +# |
| 245 | +# try to find Libfabric lib subir |
| 246 | +# |
| 247 | +if test -n $libfabric_path; then |
| 248 | + # does lib64 exist? |
| 249 | + if test -d $libfabric_path/lib64; then |
| 250 | + # yes, so I will use lib64 as include dir |
| 251 | + configure_options="$configure_options --with-libfabric=$libfabric_path \"LDFLAGS=-Wl,--build-id -Wl,-rpath -Wl,$libfabric_path/lib64 -Wl,--enable-new-dtags\"" |
| 252 | + echo "--> Found Libfabric lib dir: $libfabric_path/lib64" |
| 253 | + # does lib exist? |
| 254 | + elif test -d $libfabric_path/lib; then |
| 255 | + # yes, so I will use lib as include dir |
| 256 | + configure_options="$configure_options --with-libfabric=$libfabric_path \"LDFLAGS=-Wl,--build-id -Wl,-rpath -Wl,$libfabric_path/lib -Wl,--enable-new-dtags\"" |
| 257 | + echo "--> Found Libfabric lib dir: $libfabric_path/lib" |
| 258 | + else |
| 259 | + # I give up, there is no lib64 or lib subdir |
| 260 | + echo "ERROR: Can't find Libfabric lib64/lib dir in $libfabric_path" |
| 261 | + exit 1 |
| 262 | + fi |
| 263 | +fi |
| 264 | + |
92 | 265 | #
|
93 | 266 | # Find where the top RPM-building directory is
|
94 | 267 | #
|
@@ -127,9 +300,9 @@ echo "--> Found RPM top dir: $rpmtopdir"
|
127 | 300 | #
|
128 | 301 |
|
129 | 302 | if test "$need_root" = "1" -a "`whoami`" != "root"; then
|
130 |
| - echo "--> Trying to sudo: \"$0 $*\"" |
| 303 | + echo "--> Trying to sudo: \"$0 $orig_param\"" |
131 | 304 | echo "------------------------------------------------------------"
|
132 |
| - sudo -u root sh -c "$0 $tarball" |
| 305 | + sudo -u root sh -c "$0 $orig_param" |
133 | 306 | echo "------------------------------------------------------------"
|
134 | 307 | echo "--> sudo finished"
|
135 | 308 | exit 0
|
|
0 commit comments