Don't enable xds-agent service during install
[src/xds/xds-agent.git] / conf.d / packaging / rpm / agl-xds-agent.spec
1 #
2 # spec file for package agl-xds-agent
3 #
4
5 %define _prefix /opt/AGL
6 %global debug_package %{nil}
7
8 Name:           agl-xds-agent
9 Version:        1.1.1
10 Release:        0
11 License:        Apache-2.0
12 Summary:        XDS agent/client tool
13 Url:            https://github.com/iotbzh/xds-agent.git
14 Source0:        xds-agent_linux-amd64-v%{version}_2018-04-05_112625.zip
15 BuildRequires:  unzip
16 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
17
18 # currently embedded with xds
19 # Requires:       syncthing
20
21
22 %description
23 XDS-agent is an client tool that must run on your local machine when you use XDS
24
25 %prep
26 %setup -q -n xds-agent
27
28 %build
29
30 %install
31 mkdir -p %{?buildroot}%{_prefix}/xds/agent %{?buildroot}%{_bindir}
32 cp -r * %{?buildroot}%{_prefix}/xds/agent
33 rm -rf %{?buildroot}%{_prefix}/xds/agent/conf.d
34 ln -s ../xds/agent/xds-agent %{?buildroot}%{_bindir}/xds-agent
35
36 mkdir -p %{?buildroot}%{_userunitdir}
37 cp ./conf.d/usr/lib/systemd/user/xds-agent.service %{?buildroot}%{_userunitdir}
38
39 mkdir -p %{?buildroot}/%{_sysconfdir}/default
40 cp ./conf.d/etc/default/xds-agent %{?buildroot}/%{_sysconfdir}/default/
41
42 mkdir -p %{?buildroot}/%{_sysconfdir}/xds/agent
43 cp ./conf.d/etc/xds/agent/* %{?buildroot}/%{_sysconfdir}/xds/agent/
44
45 mkdir -p %{?buildroot}%{_sysconfdir}/profile.d
46 sed -e "s;@XDS_INSTALL_BIN_DIR@;%{_bindir};g" ./conf.d/etc/profile.d/xds-agent.sh > %{buildroot}%{_sysconfdir}/profile.d/%{name}.sh
47
48
49 %files
50 %defattr(-,root,root)
51 %dir %{_prefix}
52 %dir %{_bindir}
53 %dir %{_prefix}/xds
54 %dir %{_prefix}/xds/agent
55 %{_prefix}/xds/agent/*
56 %{_bindir}/xds-agent
57 %dir %{_sysconfdir}/xds
58 %dir %{_sysconfdir}/xds/agent
59 %config %{_sysconfdir}/default/xds-agent
60 %config %{_sysconfdir}/xds/agent/agent-config.json
61 %config %{_sysconfdir}/profile.d/%{name}.sh
62 %dir %{_userunitdir}
63 %{_userunitdir}/xds-agent.service
64
65 %post
66 if [ "$1" -ge 2 ]; then
67   if [ -f "${_sysconfdir}/xds-agent/config.json" ]; then
68     install -b -S .rpmsave ${_sysconfdir}/xds-agent/config.json ${_sysconfdir}/xds/agent/agent-config.json
69   fi
70 fi
71 exit 0
72
73 %preun
74 if [ "$1" -ge 2 ]; then
75   rm -f %{_sysconfdir}/xds-agent/*.rpm*
76 fi
77 exit 0