Skip to content

Commit bd1828c

Browse files
authored
Merge pull request #2451 from martinkontsek/master
master: Add arguments to rpmbuild script and update README.
2 parents 49328eb + 30d076a commit bd1828c

File tree

3 files changed

+242
-13
lines changed

3 files changed

+242
-13
lines changed

AUTHORS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ Mark Santcroos, Rutgers University
201201
202202
Mark Taylor, Los Alamos National Laboratory
203203
204+
Martin Kontsek, Cisco
205+
204206
Matias A Cabral, Intel
205207
206208
Matthias Jurenz, Technische Universitaet Dresden

contrib/dist/linux/README

Lines changed: 60 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Copyright (c) 2004-2006 High Performance Computing Center Stuttgart,
88
University of Stuttgart. All rights reserved.
99
Copyright (c) 2004-2006 The Regents of the University of California.
1010
All rights reserved.
11-
Copyright (c) 2006-2009 Cisco Systems, Inc. All rights reserved.
11+
Copyright (c) 2006-2016 Cisco Systems, Inc. All rights reserved.
1212
$COPYRIGHT$
1313

1414
Additional copyrights may follow
@@ -24,9 +24,9 @@ version after the dash in the SRPM filename. For example,
2424
v1.6.3. Subsequent releases of SRPMs typically contain bug fixes for
2525
the RPM packaging, but not Open MPI itself.
2626

27-
The buildrpm.sh script takes a single argument -- a filename pointing
28-
to an Open MPI tarball (may be either .gz or .bz2). It will create
29-
one or more RPMs from this tarball:
27+
The buildrpm.sh script takes a single mandatory argument -- a filename
28+
pointing to an Open MPI tarball (may be either .gz or .bz2). It will
29+
create one or more RPMs from this tarball:
3030

3131
1. Source RPM
3232
2. "All in one" RPM, where all of Open MPI is put into a single RPM.
@@ -36,8 +36,62 @@ one or more RPMs from this tarball:
3636
- openmpi-devel
3737
- openmpi-docs
3838

39-
The prefix, target architecture, and choice of RPM(s) to build are all
40-
currently hard-coded in the beginning of the buildrpm.sh script.
39+
The folowing arguments could be used to affect script behaviour.
40+
Please, do NOT set the same settings with parameters and config vars.
41+
42+
-b
43+
If you specify this option, only the all-in-one binary RPM will
44+
be built. By default, only the source RPM (SRPM) is built. Other
45+
parameters that affect the all-in-one binary RPM will be ignored
46+
unless this option is specified.
47+
48+
-n name
49+
This option will change the name of the produced RPM to the "name".
50+
It is useful to use with "-o" and "-m" options if you want to have
51+
multiple Open MPI versions installed simultaneously in the same
52+
enviroment. Requires use of option "-b".
53+
54+
-o
55+
With this option the install path of the binary RPM will be changed
56+
to /opt/_NAME_/_VERSION_. Requires use of option "-b".
57+
58+
-m
59+
This option causes the RPM to also install modulefiles
60+
to the location specified in the specfile. Requires use of option "-b".
61+
62+
-i
63+
Also build a debuginfo RPM. By default, the debuginfo RPM is not built.
64+
Requires use of option "-b".
65+
66+
-f lf_location
67+
Include support for Libfabric. "lf_location" is Libfabric install
68+
path. Requires use of option "-b".
69+
70+
-t tm_location
71+
Include support for Torque/PBS Pro. "tm_location" is path of the
72+
Torque/PBS Pro header files. Requires use of option "-b".
73+
74+
-d
75+
Build with debugging support. By default,
76+
the RPM is built without debugging support.
77+
78+
-c parameter
79+
Add custom configure parameter.
80+
81+
-r parameter
82+
Add custom RPM build parameter.
83+
84+
-s
85+
If specified, the script will try to unpack the openmpi.spec
86+
file from the tarball specified on the command line. By default,
87+
the script will look for the specfile in the current directory.
88+
89+
-h
90+
Prints script usage information.
91+
92+
93+
Target architecture is currently hard-coded in the beginning
94+
of the buildrpm.sh script.
4195

4296
Alternatively, you can build directly from the openmpi.spec spec file
4397
or SRPM directly. Many options can be passed to the building process

contrib/dist/linux/buildrpm.sh

Lines changed: 180 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,70 @@
33
# Copyright (c) 2004-2006 The Trustees of Indiana University and Indiana
44
# University Research and Technology
55
# 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.
763
#
864

965
#
1066
# General config vars
1167
# The following vars can be set from outside and will affect script behave:
1268
# prefix,rpmbuild_options,configure_options,build_srpm,build_single,build_multiple,rpmtopdir
1369
#
14-
15-
1670
specfile="openmpi.spec"
1771
prefix=${prefix:-"/opt/openmpi"}
1872
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"}
4498
# You should not need to change anything below this line
4599
#########################################################################
46100

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+
47191
#
48192
# get the tarball name
49193
#
50194

51195
tarball="$1"
52196
if test "$tarball" = ""; then
53-
echo "Usage: buildrpm.sh <tarball>"
197+
echo "$usage"
54198
exit 1
55199
fi
56200
if test ! -f $tarball; then
@@ -79,16 +223,45 @@ version="`echo $first | sed -e 's/\.tar\.'$extension'//'`"
79223
unset first
80224
echo "--> Found Open MPI version: $version"
81225

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+
82234
#
83235
# do we have the spec files?
84236
#
85237

86-
if test ! -f $specfile; then
238+
if test ! -r $specfile; then
87239
echo "can't find $specfile"
88240
exit 1
89241
fi
90242
echo "--> Found specfile: $specfile"
91243

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+
92265
#
93266
# Find where the top RPM-building directory is
94267
#
@@ -127,9 +300,9 @@ echo "--> Found RPM top dir: $rpmtopdir"
127300
#
128301

129302
if test "$need_root" = "1" -a "`whoami`" != "root"; then
130-
echo "--> Trying to sudo: \"$0 $*\""
303+
echo "--> Trying to sudo: \"$0 $orig_param\""
131304
echo "------------------------------------------------------------"
132-
sudo -u root sh -c "$0 $tarball"
305+
sudo -u root sh -c "$0 $orig_param"
133306
echo "------------------------------------------------------------"
134307
echo "--> sudo finished"
135308
exit 0

0 commit comments

Comments
 (0)