-
Notifications
You must be signed in to change notification settings - Fork 2
/
device-scanner.spec
192 lines (160 loc) · 7.03 KB
/
device-scanner.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
%define base_name device-scanner
%define prefix_name iml-%{base_name}
%define proxy_base_name scanner-proxy
%define proxy_prefix_name iml-%{proxy_base_name}
Name: %{prefix_name}
Version: 2.1.0
Release: 2%{?dist}
Summary: Maintains data of block and ZFS devices
License: MIT
Group: System Environment/Libraries
URL: https://github.com/intel-hpdd/%{base_name}
# Forcing local source because rpkg in copr does not seem to have a way
# to build source in the same way a package manager would.
Source0: %{prefix_name}-%{version}.tgz
ExclusiveArch: %{nodejs_arches}
BuildRequires: nodejs-packaging
BuildRequires: nodejs
BuildRequires: npm
BuildRequires: mono-devel
BuildRequires: %{?scl_prefix}rh-dotnet20
BuildRequires: systemd
Requires: nodejs
Requires: iml-node-libzfs
Requires: socat
%description
device-scanner-daemon builds an in-memory representation of
devices using udev and zed.
%package proxy
Summary: Forwards device-scanner updates to device-aggregator
License: MIT
Group: System Environment/Libraries
Requires: %{prefix_name} = %{version}-%{release}
%description proxy
scanner-proxy-daemon forwards device-scanner updates received
on local socket to the device aggregator over HTTPS.
%prep
%setup
%build
mozroots --import --sync
scl enable rh-dotnet20 - << EOF
set -e
export DOTNET_CLI_TELEMETRY_OPTOUT=1
npm i --ignore-scripts
npm run restore
dotnet fable npm-build
EOF
%install
mkdir -p %{buildroot}%{_unitdir}
cp dist/device-scanner-daemon/%{base_name}.socket %{buildroot}%{_unitdir}
cp dist/device-scanner-daemon/%{base_name}.service %{buildroot}%{_unitdir}
cp dist/scanner-proxy-daemon/%{proxy_base_name}.service %{buildroot}%{_unitdir}
cp dist/scanner-proxy-daemon/%{proxy_base_name}.path %{buildroot}%{_unitdir}
mkdir -p %{buildroot}%{_libdir}/%{prefix_name}-daemon
cp dist/device-scanner-daemon/device-scanner-daemon %{buildroot}%{_libdir}/%{prefix_name}-daemon
mkdir -p %{buildroot}%{_libdir}/%{proxy_prefix_name}-daemon
cp dist/scanner-proxy-daemon/scanner-proxy-daemon %{buildroot}%{_libdir}/%{proxy_prefix_name}-daemon
mkdir -p %{buildroot}/lib/udev
cp dist/listeners/udev-listener %{buildroot}/lib/udev/udev-listener
mkdir -p %{buildroot}%{_sysconfdir}/udev/rules.d
cp dist/listeners/99-iml-device-scanner.rules %{buildroot}%{_sysconfdir}/udev/rules.d
mkdir -p %{buildroot}%{_libexecdir}/zfs/zed.d/
cp dist/listeners/history_event-scanner.sh %{buildroot}%{_libexecdir}/zfs/zed.d/history_event-scanner.sh
cp dist/listeners/pool_create-scanner.sh %{buildroot}%{_libexecdir}/zfs/zed.d/pool_create-scanner.sh
cp dist/listeners/pool_destroy-scanner.sh %{buildroot}%{_libexecdir}/zfs/zed.d/pool_destroy-scanner.sh
cp dist/listeners/pool_export-scanner.sh %{buildroot}%{_libexecdir}/zfs/zed.d/pool_export-scanner.sh
cp dist/listeners/pool_import-scanner.sh %{buildroot}%{_libexecdir}/zfs/zed.d/pool_import-scanner.sh
cp dist/listeners/vdev_add-scanner.sh %{buildroot}%{_libexecdir}/zfs/zed.d/vdev_add-scanner.sh
mkdir -p %{buildroot}%{_sysconfdir}/zfs/zed.d/
ln -sf %{_libexecdir}/zfs/zed.d/history_event-scanner.sh %{buildroot}%{_sysconfdir}/zfs/zed.d/history_event-scanner.sh
ln -sf %{_libexecdir}/zfs/zed.d/pool_create-scanner.sh %{buildroot}%{_sysconfdir}/zfs/zed.d/pool_create-scanner.sh
ln -sf %{_libexecdir}/zfs/zed.d/pool_destroy-scanner.sh %{buildroot}%{_sysconfdir}/zfs/zed.d/pool_destroy-scanner.sh
ln -sf %{_libexecdir}/zfs/zed.d/pool_export-scanner.sh %{buildroot}%{_sysconfdir}/zfs/zed.d/pool_export-scanner.sh
ln -sf %{_libexecdir}/zfs/zed.d/pool_import-scanner.sh %{buildroot}%{_sysconfdir}/zfs/zed.d/pool_import-scanner.sh
ln -sf %{_libexecdir}/zfs/zed.d/vdev_add-scanner.sh %{buildroot}%{_sysconfdir}/zfs/zed.d/vdev_add-scanner.sh
%clean
rm -rf %{buildroot}
%files
%dir %{_libdir}/%{prefix_name}-daemon
%attr(0755,root,root)%{_libdir}/%{prefix_name}-daemon/device-scanner-daemon
%attr(0644,root,root)%{_unitdir}/%{base_name}.service
%attr(0644,root,root)%{_unitdir}/%{base_name}.socket
%attr(0755,root,root)/lib/udev/udev-listener
%attr(0644,root,root)%{_sysconfdir}/udev/rules.d/99-iml-device-scanner.rules
%attr(0755,root,root)%{_libexecdir}/zfs/zed.d/history_event-scanner.sh
%attr(0755,root,root)%{_libexecdir}/zfs/zed.d/pool_create-scanner.sh
%attr(0755,root,root)%{_libexecdir}/zfs/zed.d/pool_destroy-scanner.sh
%attr(0755,root,root)%{_libexecdir}/zfs/zed.d/pool_export-scanner.sh
%attr(0755,root,root)%{_libexecdir}/zfs/zed.d/pool_import-scanner.sh
%attr(0755,root,root)%{_libexecdir}/zfs/zed.d/vdev_add-scanner.sh
%{_sysconfdir}/zfs/zed.d/*.sh
%files proxy
%dir %{_libdir}/%{proxy_prefix_name}-daemon
%attr(0755,root,root)%{_libdir}/%{proxy_prefix_name}-daemon/scanner-proxy-daemon
%attr(0644,root,root)%{_unitdir}/%{proxy_base_name}.service
%attr(0644,root,root)%{_unitdir}/%{proxy_base_name}.path
%triggerin -- zfs > 0.7.4
systemctl kill -s SIGHUP zfs-zed.service
echo '{"ZedCommand":"Init"}' | socat - UNIX-CONNECT:/var/run/device-scanner.sock
%post
if [ $1 -eq 1 ]; then
systemctl enable %{base_name}.socket
systemctl start %{base_name}.socket
udevadm trigger --action=change --subsystem-match=block
elif [ $1 -eq 2 ]; then
systemctl daemon-reload
systemctl stop %{base_name}.socket
systemctl stop %{base_name}.service
systemctl start %{base_name}.socket
udevadm trigger --action=change --subsystem-match=block
fi
%post proxy
if [ $1 -eq 1 ]; then
systemctl enable %{proxy_base_name}.path
systemctl start %{proxy_base_name}.path
elif [ $1 -eq 2 ]; then
systemctl daemon-reload
systemctl stop %{proxy_base_name}.service
if [ -f "/var/lib/chroma/settings" ]; then
touch /var/lib/chroma/settings
fi
fi
%preun
if [ $1 -eq 0 ]; then
systemctl stop %{base_name}.socket
systemctl disable %{base_name}.socket
systemctl stop %{base_name}.service
systemctl disable %{base_name}.service
rm /var/run/%{base_name}.sock
fi
%preun proxy
if [ $1 -eq 0 ]; then
systemctl stop %{proxy_base_name}.path
systemctl disable %{proxy_base_name}.path
systemctl stop %{proxy_base_name}.service
systemctl disable %{proxy_base_name}.service
fi
%changelog
* Mon Feb 26 2018 Tom Nabarro <[email protected]> - 2.1.0-2
- Make scanner-proxy a sub-package (separate rpm)
- Handle upgrade scenarios
* Thu Feb 15 2018 Tom Nabarro <[email protected]> - 2.1.0-1
- Minor change, integrate scanner-proxy project
* Mon Jan 22 2018 Joe Grund <[email protected]> - 2.0.0-1
- Breaking change, the API has changed output format
* Wed Sep 27 2017 Joe Grund <[email protected]> - 1.1.1-1
- Fix bug where devices weren't removed.
- Cast empty IML_SIZE string to None.
* Thu Sep 21 2017 Joe Grund <[email protected]> - 1.1.0-1
- Exclude unneeded devices.
- Get device ro status.
- Remove manual udev parsing.
- Remove socat as dep, device-scanner will listen to change events directly.
* Mon Sep 18 2017 Joe Grund <[email protected]> - 1.0.2-1
- Fix missing keys to be option types.
- Add rules for scsi ids
- Add keys on change|add so we can `udevadm trigger` after install
- Trigger udevadm change event after install
- Read new state into scanner after install
* Tue Aug 29 2017 Joe Grund <[email protected]> - 1.0.1-1
- initial package