-
Notifications
You must be signed in to change notification settings - Fork 79
/
lbnl-nhc.spec.in
123 lines (103 loc) · 5.13 KB
/
lbnl-nhc.spec.in
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
%global name @PACKAGE@
%global version @VERSION@
%global release %{rel}%{?dist}
### Macros to populate RPM %{RELEASE} field with useful info
# {gitrelease} holds the ./configure-generated version of the same
# info that's calculated for {spec_rel} below. This allows us to
# build out-of-tree with the same Git info.
%global gitrelease @GITRELEASE@
# {gd_rel_delta} uses "git describe" to return a string in the form
# "<commits>.g<hash>[.1]?" to be used in {spec_rel} below.
%{expand:%%global gd_rel_delta %(GD1=`git describe --abbrev=4 --always --tags --long --match '[[:digit:]][[:alnum:].]*[[:alnum:]]' --dirty=.1 2>/dev/null` ; test -n "${GD1}" && echo "${GD1}" | cut -d- -f 2- | tr '-' '.')%%{nil}}
# {rel_pre_post} gets set to either "1." or "0." based on whether the
# source was built from a commit before ("0.") or after ("1.") the
# tagged release specified by {version} above.
%{expand:%%global rel_pre_post %(GD2=`git describe --tags HEAD 2>/dev/null` ; if test -n "${GD2}" ; then echo "${GD2}" | grep -Eq '^%{version}' >&/dev/null && echo 1. || echo 0. ; fi)%%{nil}}
# {spec_rel} combines the two values above into a single string for
# use in the "Release:" field. The resulting string, when used at the
# beginning of the "Release:" header value, not only guarantees
# correct RPM NEVR ordering (i.e., newer packages will always upgrade
# older ones) but also shows how many <commits> were made since the
# last tagged release, the Git commit <hash> from which the source
# tarball ("Source:" below) was built, and whether the tarball also
# contains some uncommitted changes from a "dirty" working tree (".1"
# on the end).
%{expand:%%global spec_rel %{?rel_pre_post}%{?gd_rel_delta}%%{nil}}
# {rel} ultimately determines what the release string will be; only
# the disttag gets appended to it. If the user specifies their own
# value (e.g., "rpmbuild --define 'rel 1'"), that value is used
# instead. If not, the string described above is pulled either from
# {spec_rel} (if building from Git repo) or {gitrelease} (if building
# from SRPM or source tarball).
# As a special case, if the commit being built exactly matches the Git
# tag for the specified version, {rel} is set to either "1" (clean
# working directory) or "1.1" (dirty working directory).
%{!?rel:%{expand:%%global rel %(REL="%{?spec_rel}%{!?spec_rel:%{gitrelease}}" ; if (echo "${REL:-nope}" | grep -Fq "1.0.g" 2>/dev/null) ; then if (echo "${REL:-nope}" | grep -q '\.1$' 2>/dev/null) ; then echo "1.1" ; else echo 1 ; fi ; elif test -z "%{spec_rel}" ; then echo "%{gitrelease}" ; else echo "%{spec_rel}" ; fi)%{nil}}}
%{!?sname:%global sname nhc}
%{!?nhc_script_dir:%global nhc_script_dir %{_sysconfdir}/%{sname}/scripts}
%{!?nhc_helper_dir:%global nhc_helper_dir %{_libexecdir}/%{sname}}
Summary: LBNL Node Health Check
Name: %{name}
Version: %{version}
Release: %{release}
#Release: 1%{?dist}
# LBNL Open Source License: https://opensource.org/BSD-3-Clause-LBNL
License: BSD-3-Clause-LBNL
Group: Applications/System
URL: https://github.com/mej/nhc/
Source: https://github.com/mej/nhc/archive/%{name}-%{version}.tar.gz
Packager: %{?_packager}%{!?_packager:Michael Jennings <[email protected]>}
Vendor: %{?_vendorinfo}%{!?_vendorinfo:LBNL NHC Project (https://github.com/mej/nhc/)}
Requires: bash
Obsoletes: warewulf-nhc <= 1.4.2-1
BuildArch: noarch
BuildRoot: %{?_tmppath}%{!?_tmppath:/var/tmp}/%{name}-%{version}-%{release}-root
%description
This package contains the LBNL Node Health Check (NHC) system.
Originally written to serve a very specific niche in validating
compute nodes of High-Performance Computing (HPC) clusters, its unique
combination of extensibility, portability, simplicity, and efficiency
have made it a popular general-purpose system health monitoring and
management tool.
Complete documentation and example use cases are available on the
project home page at https://github.com/mej/nhc
%prep
%setup
%build
%{configure}
%{__make} %{?mflags}
%install
umask 0077
%{__make} install DESTDIR=$RPM_BUILD_ROOT %{?mflags_install}
%check
%{__make} test
%triggerpostun -p /bin/bash -- warewulf-nhc <= 1.4.2-1
if [ $1 -gt 0 -a $2 -eq 0 ]; then
cd %{_sysconfdir}/%{sname}/scripts
for SCRIPT in ww_*.nhc.rpmsave ; do
if [ -e $SCRIPT ]; then
NEWSCRIPT=lbnl${SCRIPT##ww}
NEWSCRIPT=${NEWSCRIPT%%.rpmsave}
echo warning: Auto-fixing script naming due to modified script ${SCRIPT%%.rpmsave}
mv -v $NEWSCRIPT $NEWSCRIPT.rpmnew && mv -v $SCRIPT $NEWSCRIPT
fi
done 2>/dev/null
fi
%clean
test "$RPM_BUILD_ROOT" != "/" && %{__rm} -rf $RPM_BUILD_ROOT
%files
%defattr(-, root, root)
%doc COPYING ChangeLog LICENSE nhc.conf contrib/nhc.cron
%dir %{_sysconfdir}/%{sname}/
%dir %{_localstatedir}/lib/%{sname}/
%dir %{_localstatedir}/run/%{sname}/
%dir %{nhc_script_dir}/
%dir %{nhc_helper_dir}/
%ghost %dir %{_sysconfdir}/%{sname}/sysconfig/
%config(noreplace) %{_sysconfdir}/%{sname}/%{sname}.conf
%config(noreplace) %{_sysconfdir}/logrotate.d/%{sname}
%config(noreplace) %{nhc_script_dir}/*.nhc
%config(noreplace) %{nhc_helper_dir}/*
%config(noreplace) %{_sbindir}/%{sname}
%config(noreplace) %{_sbindir}/%{sname}-genconf
%config(noreplace) %{_sbindir}/%{sname}-wrapper