Add packaging files
[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}%{_userunitdir}/default.target.wants && ln -s ../xds-agent.service %{?buildroot}%{_userunitdir}/default.target.wants/
46
47 mkdir -p %{?buildroot}%{_sysconfdir}/profile.d
48 sed -e "s;@XDS_INSTALL_BIN_DIR@;%{_bindir};g" ./conf.d/etc/profile.d/xds-agent.sh > %{buildroot}%{_sysconfdir}/profile.d/%{name}.sh
49
50
51 %files
52 %defattr(-,root,root)
53 %dir %{_prefix}
54 %dir %{_bindir}
55 %dir %{_prefix}/xds
56 %dir %{_prefix}/xds/agent
57 %{_prefix}/xds/agent/*
58 %{_bindir}/xds-agent
59 %dir %{_sysconfdir}/xds
60 %dir %{_sysconfdir}/xds/agent
61 %config %{_sysconfdir}/default/xds-agent
62 %config %{_sysconfdir}/xds/agent/agent-config.json
63 %config %{_sysconfdir}/profile.d/%{name}.sh
64 %dir %{_userunitdir}
65 %{_userunitdir}/xds-agent.service
66 %dir %{_userunitdir}/default.target.wants
67 %{_userunitdir}/default.target.wants/xds-agent.service
68
69 %post
70 if [ "$1" -ge 2 ]; then
71   if [ -f "${_sysconfdir}/xds-agent/config.json" ]; then
72     install -b -S .rpmsave ${_sysconfdir}/xds-agent/config.json ${_sysconfdir}/xds/agent/agent-config.json
73   fi
74 fi
75 exit 0
76
77 %preun
78 if [ "$1" -ge 2 ]; then
79   rm -f %{_sysconfdir}/xds-agent/*.rpm*
80 fi
81 exit 0