Update/fix rpm and deb packaging
[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:        0.0.0
10 Release:        0
11 License:        Apache-2.0
12 Summary:        XDS agent/client tool
13 Url:            https://gerrit.automotivelinux.org/gerrit/p/src/xds/xds-agent.git
14 Source0:        xds-agent_linux-amd64-%{version}.zip
15 BuildRequires:  unzip
16 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
17 Group:          Development/Tools/Debuggers
18
19 # currently embedded with xds
20 # Requires:       syncthing
21
22
23 %description
24 XDS-agent is an client tool that must run on your local machine when you use XDS
25
26 %prep
27 %setup -q -n xds-agent
28
29 %build
30
31 %install
32 mkdir -p %{?buildroot}%{_prefix}/xds/agent %{?buildroot}%{_bindir}
33 cp -r * %{?buildroot}%{_prefix}/xds/agent
34 rm -rf %{?buildroot}%{_prefix}/xds/agent/conf.d
35 ln -s ../xds/agent/xds-agent %{?buildroot}%{_bindir}/xds-agent
36
37 mkdir -p %{?buildroot}%{_userunitdir}
38 cp ./conf.d/usr/lib/systemd/user/xds-agent.service %{?buildroot}%{_userunitdir}
39
40 mkdir -p %{?buildroot}/%{_sysconfdir}/default
41 cp ./conf.d/etc/default/xds-agent %{?buildroot}/%{_sysconfdir}/default/
42
43 mkdir -p %{?buildroot}/%{_sysconfdir}/xds/agent
44 cp ./conf.d/etc/xds/agent/* %{?buildroot}/%{_sysconfdir}/xds/agent/
45
46 mkdir -p %{?buildroot}%{_sysconfdir}/profile.d
47 sed -e "s;@XDS_INSTALL_BIN_DIR@;%{_bindir};g" ./conf.d/etc/profile.d/xds-agent.sh > %{buildroot}%{_sysconfdir}/profile.d/%{name}.sh
48
49
50 %files
51 %defattr(-,root,root)
52 %dir %{_prefix}
53 %dir %{_bindir}
54 %dir %{_prefix}/xds
55 %dir %{_prefix}/xds/agent
56 %{_prefix}/xds/agent/*
57 %{_bindir}/xds-agent
58 %dir %{_sysconfdir}/xds
59 %dir %{_sysconfdir}/xds/agent
60 %config %{_sysconfdir}/default/xds-agent
61 %config %{_sysconfdir}/xds/agent/agent-config.json
62 %config %{_sysconfdir}/profile.d/%{name}.sh
63 %dir %{_userunitdir}
64 %{_userunitdir}/xds-agent.service
65
66 %post
67 if [ "$1" -ge 2 ]; then
68   if [ -f "${_sysconfdir}/xds-agent/config.json" ]; then
69     install -b -S .rpmsave ${_sysconfdir}/xds-agent/config.json ${_sysconfdir}/xds/agent/agent-config.json
70   fi
71 fi
72 exit 0
73
74 %preun
75 if [ "$1" -ge 2 ]; then
76   rm -f %{_sysconfdir}/xds-agent/*.rpm*
77 fi
78 exit 0