forked from pol/tacc-sci-life
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgit.spec
286 lines (225 loc) · 7.99 KB
/
git.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
273
274
275
276
277
278
279
280
281
282
283
284
285
#
# W. Cyrus Proctor
# 2015-11-08
#
# 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 git
%define MODULE_VAR GIT
# Create some macros (spec file variables)
%define major_version 2
%define minor_version 6
%define micro_version 3
%define pkg_version %{major_version}.%{minor_version}.%{micro_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
########################################
############ Do Not Remove #############
########################################
############ Do Not Change #############
Name: %{pkg_name}
Version: %{pkg_version}
BuildRoot: /var/tmp/%{pkg_name}-%{pkg_version}-buildroot
########################################
Release: 1
License: GPLv2
Group: System Environment/Base
URL: https://git-scm.com
Packager: TACC - [email protected]
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
Git is a free and open source distributed version control system designed to
handle everything from small to very large projects with speed and efficiency.
Git is easy to learn and has a tiny footprint with lightning fast performance.
#---------------------------------------
%prep
#---------------------------------------
#------------------------
%if %{?BUILD_PACKAGE}
#------------------------
# Delete the package installation directory.
rm -rf $RPM_BUILD_ROOT/%{INSTALL_DIR}
#-----------------------
%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
# Insert necessary module commands
module purge
module load gcc/4.9.3
echo "Building the package?: %{BUILD_PACKAGE}"
echo "Building the modulefile?: %{BUILD_MODULEFILE}"
#------------------------
%if %{?BUILD_PACKAGE}
#------------------------
mkdir -p $RPM_BUILD_ROOT/%{INSTALL_DIR}
mkdir -p %{INSTALL_DIR}
mount -t tmpfs tmpfs %{INSTALL_DIR}
#######################################
##### Create TACC Canary Files ########
#######################################
touch $RPM_BUILD_ROOT/%{INSTALL_DIR}/.tacc_install_canary
#######################################
########### Do Not Remove #############
#######################################
#========================================
# Insert Build/Install Instructions Here
#========================================
export ncores=16
export git=`pwd`
export git_install=%{INSTALL_DIR}
export git_version=%{pkg_version}
export CC=gcc
wget https://www.kernel.org/pub/software/scm/git/git-${git_version}.tar.gz
tar xvfz git-${git_version}.tar.gz
cd git-${git_version}
${git}/git-${git_version}/configure \
--prefix=${git_install}
make all -j ${ncores}
make install -j ${ncores}
if [ ! -d $RPM_BUILD_ROOT/%{INSTALL_DIR} ]; then
mkdir -p $RPM_BUILD_ROOT/%{INSTALL_DIR}
fi
echo "ID %{INSTALL_DIR}"
echo "RID $RPM_BUILD_ROOT/%{INSTALL_DIR}"
cp -r %{INSTALL_DIR}/ $RPM_BUILD_ROOT/%{INSTALL_DIR}/..
umount %{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}/%{version}.lua << 'EOF'
help([[
Git is a free and open source distributed version control system designed to
handle everything from small to very large projects with speed and efficiency.
Git is easy to learn and has a tiny footprint with lightning fast performance.
The %{MODULE_VAR} module file defines the following environment variables:
TACC_%{MODULE_VAR}_DIR, TACC_%{MODULE_VAR}_BIN, TACC_%{MODULE_VAR}_LIB for the
location of the %{MODULE_VAR} distribution, binaries, and libraries
respectively. GIT_EXEC_PATH, which is also defined, determines where Git looks
for its sub-programs. You can check the current setting by running
"git --exec-path".
Version %{version}
]])
whatis("Name: Git")
whatis("Version: %{version}")
whatis("Category: library, tools")
whatis("Keywords: System, Source Control Management, Tools")
whatis("URL: http://git-scm.com")
whatis("Description: Fast Version Control System")
prepend_path( "PATH" , "%{INSTALL_DIR}/bin" )
prepend_path( "MANPATH" , "%{INSTALL_DIR}/share/man" )
setenv ( "TACC_%{MODULE_VAR}_DIR" , "%{INSTALL_DIR}" )
setenv ( "TACC_%{MODULE_VAR}_LIB" , "%{INSTALL_DIR}/lib" )
setenv ( "TACC_%{MODULE_VAR}_BIN" , "%{INSTALL_DIR}/bin" )
setenv ( "GIT_EXEC_PATH" , "%{INSTALL_DIR}/libexec/git-core" )
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
%{SPEC_DIR}/checkModuleSyntax $RPM_BUILD_ROOT/%{MODULE_DIR}/%{MODULE_FILENAME}
#--------------------------
%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