From 2add0179587f8c9bf8e6e5ac976a52ab70aa9374 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20Ekstr=C3=B6m?= Date: Mon, 12 Jan 2015 13:54:51 +0200 Subject: [PATCH] packaging: add AMB configuration that enables the plugin - During package build, the configuration is generated with correct library paths. - When installing, backup the original configuration and symlink config.tizen to examples/config.tizen-ico. - When removing, if config.tizen is a symlink and the backup is available, the backup is put back as config.tizen. - When upgrading the package, no changes are made. Change-Id: I55f760c541c93db4a1210b2ef9020807693358f8 Bug-Tizen: TC-2346 --- packaging.in/config.tizen-ico | 23 ++++++++++++++++++++++ packaging/ico-vic-amb-plugin.spec | 41 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 packaging.in/config.tizen-ico diff --git a/packaging.in/config.tizen-ico b/packaging.in/config.tizen-ico new file mode 100644 index 0000000..11a218f --- /dev/null +++ b/packaging.in/config.tizen-ico @@ -0,0 +1,23 @@ +{ +"sources" : + [ + { + "name" : "Murphy Source", + "path" : "LIBDIR/automotive-message-broker/murphysourceplugin.so", + "address" : "unxs:/tmp/murphy/amb" + }, + { + "name" : "VehicleSource", + "path" : "LIBDIR/automotive-message-broker/vehicleplugin.so", + "configfile" : "/etc/ambd/AMBformat.conf" + } + ], +"sinks": + [ + { + "name" : "DBusSink", + "path" : "LIBDIR/automotive-message-broker/dbussinkplugin.so" + } + ] +} + diff --git a/packaging/ico-vic-amb-plugin.spec b/packaging/ico-vic-amb-plugin.spec index b87eb06..ca7a838 100644 --- a/packaging/ico-vic-amb-plugin.spec +++ b/packaging/ico-vic-amb-plugin.spec @@ -18,6 +18,7 @@ BuildRequires: ico-uxf-utilities-devel >= 0.9.04 BuildRequires: ico-uxf-utilities >= 0.9.04 BuildRequires: pkgconfig(elementary) BuildRequires: pkgconfig(appcore-efl) +BuildRequires: sed %description Automotive Message Broker is a vehicle network abstraction system @@ -26,6 +27,7 @@ Collection of plugins for automotive-message-broker %prep %setup -q -n %{name}-%{version} cp %{SOURCE1001} . +sed -i 's#LIBDIR#%{_libdir}/#' packaging.in/config.tizen-ico %build %cmake @@ -34,18 +36,51 @@ cp %{SOURCE1001} . %install rm -rf %{buildroot} %make_install -mkdir -p %{buildroot}/%{_sysconfdir}/ambd +mkdir -p %{buildroot}%{_sysconfdir}/ambd/examples/ cp src/AMBformat.conf %{buildroot}/%{_sysconfdir}/ambd/ +cp packaging.in/config.tizen-ico %{buildroot}%{_sysconfdir}/ambd/examples/config.tizen-ico mkdir -p %{buildroot}%{_bindir} cp tool/ico_set_vehicleinfo %{buildroot}%{_bindir}/ico_set_vehicleinfo -%post -p /sbin/ldconfig -%postun -p /sbin/ldconfig +%post +/sbin/ldconfig + +# When installing ($1 == 1) +if [ $1 -eq 1 ] ; then + # Back up the original configuration and create a symlink + # to ours if the configuration file exists. + if [ -f "%{_sysconfdir}/ambd/config.tizen" ]; then + echo "moving original AMB config.tizen -> config.tizen.orig" + mv "%{_sysconfdir}/ambd/config.tizen" "%{_sysconfdir}/ambd/config.tizen.orig" + echo "creating symlink AMB config.tizen -> examples/config.tizen-ico" + ln -sf "%{_sysconfdir}/ambd/examples/config.tizen-ico" "%{_sysconfdir}/ambd/config.tizen" + fi +fi + +/bin/systemctl restart ambd + +%postun +/sbin/ldconfig + +# When uninstalling ($1 == 0) +if [ $1 -eq 0 ] ; then + # Return the original file if a symlink exists and + # we have the backup around + if [ -L "%{_sysconfdir}/ambd/config.tizen" ]; then + if [ -f "%{_sysconfdir}/ambd/config.tizen.orig" ]; then + echo "restoring AMB config file config.tizen.orig as config.tizen" + mv "%{_sysconfdir}/ambd/config.tizen.orig" "%{_sysconfdir}/ambd/config.tizen" + fi + fi +fi + +/bin/systemctl restart ambd %files %defattr(-,root,root,-) %manifest %{name}.manifest %{_libdir}/automotive-message-broker/*.so %config %{_sysconfdir}/ambd/AMBformat.conf +%config %{_sysconfdir}/ambd/examples/config.tizen-ico %{_datadir}/doc/automotive-message-broker/%{name}/README %{_bindir}/ico_set_vehicleinfo -- 2.7.4