aboutsummaryrefslogtreecommitdiffstats
path: root/conf.d/packaging/rpm/agl-xds-agent.spec
blob: 0d493a40d05713ac5a4dbd3e669ee681b0722b55 (plain)
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
#
# spec file for package agl-xds-agent
#

%define _prefix /opt/AGL
%global debug_package %{nil}

Name:           agl-xds-agent
Version:        1.1.1
Release:        0
License:        Apache-2.0
Summary:        XDS agent/client tool
Url:            https://github.com/iotbzh/xds-agent.git
Source0:        xds-agent_linux-amd64-v%{version}_2018-04-05_112625.zip
BuildRequires:  unzip
BuildRoot:      %{_tmppath}/%{name}-%{version}-build

# currently embedded with xds
# Requires:       syncthing


%description
XDS-agent is an client tool that must run on your local machine when you use XDS

%prep
%setup -q -n xds-agent

%build

%install
mkdir -p %{?buildroot}%{_prefix}/xds/agent %{?buildroot}%{_bindir}
cp -r * %{?buildroot}%{_prefix}/xds/agent
rm -rf %{?buildroot}%{_prefix}/xds/agent/conf.d
ln -s ../xds/agent/xds-agent %{?buildroot}%{_bindir}/xds-agent

mkdir -p %{?buildroot}%{_userunitdir}
cp ./conf.d/usr/lib/systemd/user/xds-agent.service %{?buildroot}%{_userunitdir}

mkdir -p %{?buildroot}/%{_sysconfdir}/default
cp ./conf.d/etc/default/xds-agent %{?buildroot}/%{_sysconfdir}/default/

mkdir -p %{?buildroot}/%{_sysconfdir}/xds/agent
cp ./conf.d/etc/xds/agent/* %{?buildroot}/%{_sysconfdir}/xds/agent/

mkdir -p %{?buildroot}%{_sysconfdir}/profile.d
sed -e "s;@XDS_INSTALL_BIN_DIR@;%{_bindir};g" ./conf.d/etc/profile.d/xds-agent.sh > %{buildroot}%{_sysconfdir}/profile.d/%{name}.sh


%files
%defattr(-,root,root)
%dir %{_prefix}
%dir %{_bindir}
%dir %{_prefix}/xds
%dir %{_prefix}/xds/agent
%{_prefix}/xds/agent/*
%{_bindir}/xds-agent
%dir %{_sysconfdir}/xds
%dir %{_sysconfdir}/xds/agent
%config %{_sysconfdir}/default/xds-agent
%config %{_sysconfdir}/xds/agent/agent-config.json
%config %{_sysconfdir}/profile.d/%{name}.sh
%dir %{_userunitdir}
%{_userunitdir}/xds-agent.service

%post
if [ "$1" -ge 2 ]; then
  if [ -f "${_sysconfdir}/xds-agent/config.json" ]; then
    install -b -S .rpmsave ${_sysconfdir}/xds-agent/config.json ${_sysconfdir}/xds/agent/agent-config.json
  fi
fi
exit 0

%preun
if [ "$1" -ge 2 ]; then
  rm -f %{_sysconfdir}/xds-agent/*.rpm*
fi
exit 0