-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBar.spec
273 lines (219 loc) · 7.56 KB
/
Bar.spec
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
#
# W. Cyrus Proctor
# Antonio Gomez
# 2015-08-25
#
# Important Build-Time Environment Variables (see name-defines.inc)
# NO_PACKAGE=1 -> Do Not Build/Rebuild Package RPM
# NO_MODULEFILE=1 -> Do Not Build/Rebuild Modulefile RPM
#
# Important Install-Time Environment Variables (see post-defines.inc)
# VERBOSE=1 -> Print detailed information at install time
# RPM_DBPATH -> Path To Non-Standard RPM Database Location
#
# Typical Command-Line Example:
# ./build_rpm.sh Bar.spec
# cd ../RPMS/x86_64
# rpm -i --relocate /tmprpm=/opt/apps Bar-package-1.1-1.x86_64.rpm
# rpm -i --relocate /tmpmod=/opt/apps Bar-modulefile-1.1-1.x86_64.rpm
# rpm -e Bar-package-1.1-1.x86_64 Bar-modulefile-1.1-1.x86_64
Summary: A Nice little relocatable skeleton spec file example.
# Give the package a base name
%define pkg_base_name Bar
%define MODULE_VAR BAR
# Create some macros (spec file variables)
%define major_version 1
%define minor_version 1
%define micro_version 0
%define pkg_version %{major_version}.%{minor_version}
### Toggle On/Off ###
%include rpm-dir.inc
#%include compiler-defines.inc
#%include mpi-defines.inc
########################################
### Construct name based on includes ###
########################################
%include name-defines.inc
#%include name-defines-noreloc.inc
#%include name-defines-hidden.inc
#%include name-defines-hidden-noreloc.inc
########################################
############ Do Not Remove #############
########################################
############ Do Not Change #############
Name: %{pkg_name}
Version: %{pkg_version}
BuildRoot: /var/tmp/%{pkg_name}-%{pkg_version}-buildroot
########################################
Release: 1%{?dist}
License: GPL
Group: Development/Tools
URL: http://www.gnu.org/software/bar
Packager: TACC - agomez@tacc.utexas.edu, cproctor@tacc.utexas.edu
Source: %{pkg_base_name}-%{pkg_version}.tar.gz
# Turn off debug package mode
%define debug_package %{nil}
%define dbg %{nil}
%package %{PACKAGE}
Summary: The package RPM
Group: Development/Tools
%description package
This is the long description for the package RPM...
%package %{MODULEFILE}
Summary: The modulefile RPM
Group: Lmod/Modulefiles
%description modulefile
This is the long description for the modulefile RPM...
%description
The longer-winded description of the package that will
end in up inside the rpm and is queryable if installed via:
rpm -qi <rpm-name>
#---------------------------------------
%prep
#---------------------------------------
#------------------------
%if %{?BUILD_PACKAGE}
#------------------------
# Delete the package installation directory.
rm -rf $RPM_BUILD_ROOT/%{INSTALL_DIR}
%setup -n %{pkg_base_name}-%{pkg_version}
#-----------------------
%endif # BUILD_PACKAGE |
#-----------------------
#---------------------------
%if %{?BUILD_MODULEFILE}
#---------------------------
#Delete the module installation directory.
rm -rf $RPM_BUILD_ROOT/%{MODULE_DIR}
#--------------------------
%endif # BUILD_MODULEFILE |
#--------------------------
#---------------------------------------
%build
#---------------------------------------
#---------------------------------------
%install
#---------------------------------------
# Setup modules
%include system-load.inc
module purge
# Load Compiler
#%include compiler-load.inc
# Load MPI Library
#%include mpi-load.inc
# Insert further module commands
echo "Building the package?: %{BUILD_PACKAGE}"
echo "Building the modulefile?: %{BUILD_MODULEFILE}"
#------------------------
%if %{?BUILD_PACKAGE}
#------------------------
mkdir -p $RPM_BUILD_ROOT/%{INSTALL_DIR}
#######################################
##### Create TACC Canary Files ########
#######################################
touch $RPM_BUILD_ROOT/%{INSTALL_DIR}/.tacc_install_canary
#######################################
########### Do Not Remove #############
#######################################
#========================================
# Insert Build/Install Instructions Here
#========================================
# Create some dummy directories and files for fun
mkdir -p $RPM_BUILD_ROOT/%{INSTALL_DIR}/bin
mkdir -p $RPM_BUILD_ROOT/%{INSTALL_DIR}/lib
mkdir -p $RPM_BUILD_ROOT/%{INSTALL_DIR}/include
# Copy everything from tarball over to the installation directory
cp -r * $RPM_BUILD_ROOT/%{INSTALL_DIR}
#-----------------------
%endif # BUILD_PACKAGE |
#-----------------------
#---------------------------
%if %{?BUILD_MODULEFILE}
#---------------------------
mkdir -p $RPM_BUILD_ROOT/%{MODULE_DIR}
#######################################
##### Create TACC Canary Files ########
#######################################
touch $RPM_BUILD_ROOT/%{MODULE_DIR}/.tacc_module_canary
#######################################
########### Do Not Remove #############
#######################################
# Write out the modulefile associated with the application
cat > $RPM_BUILD_ROOT/%{MODULE_DIR}/%{MODULE_FILENAME} << 'EOF'
local help_msg=[[
The %{MODULE_VAR} module defines the following environment variables:
TACC_%{MODULE_VAR}_DIR, TACC_%{MODULE_VAR}_LIB, TACC_%{MODULE_VAR}_INC and
TACC_%{MODULE_VAR}_BIN for the location of the %{MODULE_VAR} distribution, libraries,
include files, and tools respectively.
]]
--help(help_msg)
help(help_msg)
whatis("Name: bar")
whatis("Version: %{pkg_version}%{dbg}")
%if "%{is_debug}" == "1"
setenv("TACC_%{MODULE_VAR}_DEBUG","1")
%endif
-- Create environment variables.
local bar_dir = "%{INSTALL_DIR}"
family("bar")
prepend_path( "PATH", pathJoin(bar_dir, "bin"))
prepend_path( "LD_LIBRARY_PATH", pathJoin(bar_dir, "lib"))
prepend_path( "MODULEPATH", "%{MODULE_PREFIX}/bar1_1/modulefiles")
setenv( "TACC_%{MODULE_VAR}_DIR", bar_dir)
setenv( "TACC_%{MODULE_VAR}_INC", pathJoin(bar_dir, "include"))
setenv( "TACC_%{MODULE_VAR}_LIB", pathJoin(bar_dir, "lib"))
setenv( "TACC_%{MODULE_VAR}_BIN", pathJoin(bar_dir, "bin"))
EOF
cat > $RPM_BUILD_ROOT/%{MODULE_DIR}/.version.%{version} << 'EOF'
#%Module3.1.1#################################################
##
## version file for %{BASENAME}%{version}
##
set ModulesVersion "%{version}"
EOF
# Check the syntax of the generated lua modulefile only if a visible module
%if %{?VISIBLE}
%{SPEC_DIR}/checkModuleSyntax $RPM_BUILD_ROOT/%{MODULE_DIR}/%{MODULE_FILENAME}
%endif
#--------------------------
%endif # BUILD_MODULEFILE |
#--------------------------
#------------------------
%if %{?BUILD_PACKAGE}
%files package
#------------------------
%defattr(-,root,install,)
# RPM package contains files within these directories
%{INSTALL_DIR}
#-----------------------
%endif # BUILD_PACKAGE |
#-----------------------
#---------------------------
%if %{?BUILD_MODULEFILE}
%files modulefile
#---------------------------
%defattr(-,root,install,)
# RPM modulefile contains files within these directories
%{MODULE_DIR}
#--------------------------
%endif # BUILD_MODULEFILE |
#--------------------------
########################################
## Fix Modulefile During Post Install ##
########################################
%post %{PACKAGE}
export PACKAGE_POST=1
%include post-defines.inc
%post %{MODULEFILE}
export MODULEFILE_POST=1
%include post-defines.inc
%preun %{PACKAGE}
export PACKAGE_PREUN=1
%include post-defines.inc
########################################
############ Do Not Remove #############
########################################
#---------------------------------------
%clean
#---------------------------------------
rm -rf $RPM_BUILD_ROOT