Add packaging files
[src/xds/xds-server.git] / conf.d / packaging / rpm / agl-xds-server.spec
diff --git a/conf.d/packaging/rpm/agl-xds-server.spec b/conf.d/packaging/rpm/agl-xds-server.spec
new file mode 100644 (file)
index 0000000..74e5b33
--- /dev/null
@@ -0,0 +1,79 @@
+#
+# spec file for package agl-xds-server
+#
+
+%define _prefix /opt/AGL
+%global debug_package %{nil}
+
+Name:           agl-xds-server
+Version:        1.1.1
+Release:        0
+License:        Apache-2.0
+Summary:        XDS-server
+Url:            https://github.com/iotbzh/xds-server.git
+Source0:        xds-server_linux-amd64-v%{version}_2018-04-05_111758.zip
+BuildRequires:  unzip
+BuildRoot:      %{_tmppath}/%{name}-%{version}-build
+
+# for now still embedded with xds
+# Requires:       syncthing
+
+%description
+xds-server is a web server that allows user to remotely cross build applications.
+
+%prep
+%setup -q -n xds-server
+
+%build
+
+%install
+mkdir -p %{?buildroot}%{_prefix}/xds/server %{?buildroot}%{_bindir}
+cp -r * %{?buildroot}%{_prefix}/xds/server/
+rm -rf %{?buildroot}%{_prefix}/xds/server/conf.d
+ln -s ../xds/server/xds-server        %{?buildroot}%{_bindir}/xds-server
+ln -s ../xds/server/syncthing         %{?buildroot}%{_bindir}/syncthing
+ln -s ../xds/server/syncthing-inotify %{?buildroot}%{_bindir}/syncthing-inotify
+mkdir -p %{?buildroot}%{_userunitdir}
+cp ./conf.d/usr/lib/systemd/user/xds-server.service %{?buildroot}%{_userunitdir}
+mkdir -p %{?buildroot}/%{_sysconfdir}/default
+cp ./conf.d/etc/default/xds-server %{?buildroot}/%{_sysconfdir}/default/
+mkdir -p %{?buildroot}/%{_sysconfdir}/xds/server
+cp ./conf.d/etc/xds/server/* %{?buildroot}/%{_sysconfdir}/xds/server/
+mkdir -p %{?buildroot}%{_userunitdir}/default.target.wants && ln -s ../xds-server.service %{?buildroot}%{_userunitdir}/default.target.wants/
+mkdir -p %{?buildroot}%{_sysconfdir}/profile.d
+sed -e "s;@XDS_INSTALL_BIN_DIR@;%{_bindir};g" ./conf.d/etc/profile.d/xds-server.sh > %{buildroot}%{_sysconfdir}/profile.d/%{name}.sh
+
+%files
+%defattr(-,root,root)
+%dir %{_prefix}
+%dir %{_bindir}
+%dir %{_prefix}/xds
+%dir %{_prefix}/xds/server
+%{_prefix}/xds/server/*
+%{_bindir}/xds-server
+%{_bindir}/syncthing
+%{_bindir}/syncthing-inotify
+%dir %{_sysconfdir}/xds
+%dir %{_sysconfdir}/xds/server
+%{_sysconfdir}/default/xds-server
+%{_sysconfdir}/xds/server/*
+%config %{_sysconfdir}/profile.d/%{name}.sh
+%dir %{_userunitdir}
+%{_userunitdir}/xds-server.service
+%dir %{_userunitdir}/default.target.wants
+%{_userunitdir}/default.target.wants/xds-server.service
+
+
+%post
+if [ "$1" -ge 2 ]; then
+  if [ -f "${_sysconfdir}/xds-server/config.json" ]; then
+    install -b -S .rpmsave ${_sysconfdir}/xds-server/config.json ${_sysconfdir}/xds/server/server-config.json
+  fi
+fi
+exit 0
+
+%preun
+if [ "$1" -ge 2 ]; then
+  rm -f %{_sysconfdir}/xds-server/*.rpm*
+fi
+exit 0