forked from Mellanox/nv_peer_memory
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nvidia_peer_memory.spec
129 lines (108 loc) · 3.22 KB
/
nvidia_peer_memory.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
%define debug_package %{nil}
%{!?_release: %define _release 0}
%{!?KVERSION: %define KVERSION %(uname -r)}
%define MODPROBE %(if ( /sbin/modprobe -c | grep -q '^allow_unsupported_modules *0'); then echo -n "/sbin/modprobe --allow-unsupported-modules"; else echo -n "/sbin/modprobe"; fi )
Summary: nvidia_peer_memory
Name: nvidia_peer_memory
Version: 1.1
Release: %{_release}
License: GPL
Group: System Environment/Libraries
Source: %{name}-%{version}.tar.gz
BuildRequires: gcc kernel-headers
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
URL: http://www.mellanox.com
Prefix: %{prefix}
Packager: <[email protected]>
%description
nvidia peer memory kernel module.
%prep
%setup -n %{name}-%{version}
%build
export KVER=%{KVERSION}
make KVER=$KVER all
%install
#install kernel module
export KVER=%{KVERSION}
make DESTDIR=$RPM_BUILD_ROOT KVER=$KVER install
# Copy configuration file
install -d $RPM_BUILD_ROOT/etc/infiniband
install -m 0644 $RPM_BUILD_DIR/%{name}-%{version}/nv_peer_mem.conf $RPM_BUILD_ROOT/etc/infiniband
# Install nv_peer_mem service script
install -d $RPM_BUILD_ROOT/etc/init.d
install -m 0755 $RPM_BUILD_DIR/%{name}-%{version}/nv_peer_mem $RPM_BUILD_ROOT/etc/init.d
%post
depmod -a
%{MODPROBE} -rq nv_peer_mem||:
%{MODPROBE} nv_peer_mem||:
if [[ -f /etc/redhat-release || -f /etc/rocks-release ]]; then
perl -i -ne 'if (m@^#!/bin/bash@) {
print q@#!/bin/bash
#
# Bring up/down nv_peer_mem
#
# chkconfig: 2345 05 95
# description: Activates/Deactivates nv_peer_mem module to \
# start at boot time.
#
### BEGIN INIT INFO
# Provides: nv_peer_mem
# Required-Start: openibd
# Required-Stop:
### END INIT INFO
@;
} else {
print;
}' /etc/init.d/nv_peer_mem
if ! ( /sbin/chkconfig --del nv_peer_mem > /dev/null 2>&1 ); then
true
fi
if ! ( /sbin/chkconfig --add nv_peer_mem > /dev/null 2>&1 ); then
true
fi
fi
if [ -f /etc/SuSE-release ]; then
perl -i -ne "if (m@^#!/bin/bash@) {
print q@#!/bin/bash
### BEGIN INIT INFO
# Provides: nv_peer_mem
# Required-Start: openibd
# Required-Stop:
# Default-Start: 2 3 5
# Default-Stop: 0 1 2 6
# Description: Activates/Deactivates nv_peer_mem module to \
# start at boot time.
### END INIT INFO
@;
} else {
print;
}" /etc/init.d/nv_peer_mem
if ! ( /sbin/insserv nv_peer_mem > /dev/null 2>&1 ); then
true
fi
fi
%preun
%{MODPROBE} -rq nv_peer_mem
if [[ -f /etc/redhat-release || -f /etc/rocks-release ]]; then
if ! ( /sbin/chkconfig --del nv_peer_mem > /dev/null 2>&1 ); then
true
fi
fi
if [ -f /etc/SuSE-release ]; then
if ! ( /sbin/insserv -r nv_peer_mem > /dev/null 2>&1 ); then
true
fi
fi
%clean
# We may be in the directory that we're about to remove, so cd out of
# there before we remove it
cd /tmp
# Remove installed driver after rpm build finished
chmod -R o+w $RPM_BUILD_DIR/%{name}-%{version}
rm -rf $RPM_BUILD_DIR/%{name}-%{version}
test "x$RPM_BUILD_ROOT" != "x" && rm -rf $RPM_BUILD_ROOT
%files
%defattr(-, root, root)
/lib/modules/%{KVERSION}/
/etc/init.d/nv_peer_mem
/etc/infiniband/nv_peer_mem.conf