Add the service files to run bt-stack-down*.sh via file activation
[platform/core/connectivity/bluetooth-tools.git] / packaging / bluetooth-tools.spec
index c8a4ade..79ccf1e 100644 (file)
@@ -5,15 +5,54 @@ Release:    0
 Group:      Network & Connectivity/Bluetooth
 License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
-Source1001: bluetooth-address.service
+#Source1001: bluetooth-address.service
 BuildRequires:  cmake
 Suggests:       bluetooth-share
 Requires:       tizen-platform-config-tools
 Requires:      bluetooth-scripts
+Requires:   %{name}-compat = %{version}-%{release}
+Recommends:   %{name}-profile_common = %{version}-%{release}
 
 %description
 Tools fo bluetooth run/stop and set address
 
+%package profile_common
+Summary:    Bluetooth-tools extension for common/tv
+Provides:   %{name}-compat = %{version}-%{release}
+Provides:   %{name}-profile_tv = %{version}-%{release}
+Conflicts:  %{name}-profile_mobile = %{version}-%{release}
+Conflicts:  %{name}-profile_wearable = %{version}-%{release}
+Conflicts:  %{name}-profile_ivi = %{version}-%{release}
+%description profile_common
+Bluetooth-tools extension for Tizen common / tv profile.
+
+%package profile_mobile
+Summary:    Bluetooth-tools extension for mobile/tv
+Provides:   %{name}-compat = %{version}-%{release}
+Conflicts:  %{name}-profile_common = %{version}-%{release}
+Conflicts:  %{name}-profile_wearable = %{version}-%{release}
+Conflicts:  %{name}-profile_ivi = %{version}-%{release}
+%description profile_mobile
+Bluetooth-tools extension for Tizen mobile profile.
+
+%package profile_wearable
+Summary:    Bluetooth-tools extension for wearable/tv
+Provides:   %{name}-compat = %{version}-%{release}
+Conflicts:  %{name}-profile_common = %{version}-%{release}
+Conflicts:  %{name}-profile_mobile = %{version}-%{release}
+Conflicts:  %{name}-profile_ivi = %{version}-%{release}
+%description profile_wearable
+Bluetooth-tools extension for Tizen wearable profile.
+
+%package profile_ivi
+Summary:    Bluetooth-tools extension for ivi/tv
+Provides:   %{name}-compat = %{version}-%{release}
+Conflicts:  %{name}-profile_common = %{version}-%{release}
+Conflicts:  %{name}-profile_mobile = %{version}-%{release}
+Conflicts:  %{name}-profile_wearable = %{version}-%{release}
+%description profile_ivi
+Bluetooth-tools extension for Tizen ivi profile.
+
 %package no-firmware
 Summary:    On/Off Bluetooth adapter
 Group:      Network & Connectivity/Bluetooth
@@ -33,88 +72,176 @@ export CFLAGS+=" -fpie -fvisibility=hidden"
 export CXXFLAGS+=" -fpie -fvisibility=hidden"
 export LDFLAGS+=" -Wl,--rpath=/usr/lib -Wl,--as-needed -Wl,--unresolved-symbols=ignore-in-shared-libs -pie"
 
-%if "%{profile}" == "mobile"
-export CFLAGS="$CFLAGS -DTIZEN_MOBILE"
+%cmake
+%cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} \
+%if 0%{?tizen_build_binary_release_type_eng}
+       -DBT_HCI_LOG_SIZE=10
 %else
-%if "%{profile}" == "wearable"
-export CFLAGS="$CFLAGS -DTIZEN_WEARABLE"
-%endif
+       -DBT_HCI_LOG_SIZE=5
 %endif
 
-%cmake \
-%if "%{profile}" == "mobile"
-       -DTIZEN_MOBILE=YES \
-       -DTIZEN_WEARABLE=NO \
-       -DTIZEN_IVI=NO \
-%else
-%if "%{profile}" == "wearable"
-       -DTIZEN_MOBILE=NO \
-        -DTIZEN_WEARABLE=YES \
-       -DTIZEN_IVI=NO \
-%else
-%if "%{profile}" == "ivi"
-        -DTIZEN_MOBILE=NO \
-        -DTIZEN_WEARABLE=NO \
-       -DTIZEN_IVI=YES \
-%else
-        -DTIZEN_MOBILE=NO \
-        -DTIZEN_WEARABLE=NO \
-       -DTIZEN_IVI=NO \
-%endif
-%endif
-%endif
-
-%cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix}
 %__make %{?_smp_mflags}
-#cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix}
-#make %{?jobs:-j%jobs}
 
 %install
 rm -rf %{buildroot}
 %make_install
 
-mkdir -p %{buildroot}%{_sysconfdir}/rc.d/rc3.d
-mkdir -p %{buildroot}%{_sysconfdir}/rc.d/rc5.d
-ln -s %{_sysconfdir}/rc.d/init.d/bluetooth-address %{buildroot}%{_sysconfdir}/rc.d/rc3.d/S60bluetooth-address
-ln -s %{_sysconfdir}/rc.d/init.d/bluetooth-address %{buildroot}%{_sysconfdir}/rc.d/rc5.d/S60bluetooth-address
-
-mkdir -p %{buildroot}%{_unitdir}/multi-user.target.wants
-install -m 0644 %{SOURCE1001} %{buildroot}%{_unitdir}
-ln -s ../bluetooth-address.service %{buildroot}%{_unitdir}/multi-user.target.wants/bluetooth-address.service
-
 mkdir -p %{buildroot}%{_prefix}/etc/bluetooth/
+mkdir -p %{buildroot}/run/bluetooth
 install -m 0755 scripts/bt-dev-start.sh %{buildroot}%{_prefix}/etc/bluetooth/bt-dev-start.sh
 install -m 0755 scripts/bt-dev-end.sh %{buildroot}%{_prefix}/etc/bluetooth/bt-dev-end.sh
-install -D -m 0644 LICENSE.APLv2 %{buildroot}%{_datadir}/license/bluetooth-tools
+
+install -D -m 0644 packaging/bluetooth-hci-logger.service %{buildroot}%{_libdir}/systemd/system/bluetooth-hci-logger.service
+install -D -m 0644 packaging/bluetooth-hci-logger.path %{buildroot}%{_libdir}/systemd/system/bluetooth-hci-logger.path
+
+install -D -m 0644 packaging/bluetooth-hci-logger-stop.service %{buildroot}%{_libdir}/systemd/system/bluetooth-hci-logger-stop.service
+install -D -m 0644 packaging/bluetooth-hci-logger-stop.path %{buildroot}%{_libdir}/systemd/system/bluetooth-hci-logger-stop.path
+
+install -D -m 0644 packaging/bluez-start.service %{buildroot}%{_libdir}/systemd/system/bluez-start.service
+install -D -m 0644 packaging/bluez-start.path %{buildroot}%{_libdir}/systemd/system/bluez-start.path
+
+install -D -m 0644 packaging/bluetooth-share-start.service %{buildroot}%{_libdir}/systemd/system/bluetooth-share-start.service
+install -D -m 0644 packaging/bluetooth-share-start.path %{buildroot}%{_libdir}/systemd/system/bluetooth-share-start.path
+
+install -D -m 0644 packaging/bluetooth-stack-down.service %{buildroot}%{_libdir}/systemd/system/bluetooth-stack-down.service
+install -D -m 0644 packaging/bluetooth-stack-down.path %{buildroot}%{_libdir}/systemd/system/bluetooth-stack-down.path
+
+install -D -m 0644 packaging/bluetooth-force-hci-logger.service %{buildroot}%{_libdir}/systemd/system/bluetooth-force-hci-logger.service
+install -D -m 0644 packaging/bluetooth-hci-dump@.service %{buildroot}%{_libdir}/systemd/system/bluetooth-hci-dump@.service
+
+%post
+mkdir -p %{_sysconfdir}/systemd/default-extra-dependencies/ignore-units.d/
+mkdir -p %{_libdir}/systemd/system/multi-user.target.wants/
+ln -sf %{_libdir}/systemd/system/bluetooth-hci-logger.service %{_sysconfdir}/systemd/default-extra-dependencies/ignore-units.d/
+ln -sf %{_libdir}/systemd/system/bluetooth-hci-logger.path %{_libdir}/systemd/system/multi-user.target.wants/bluetooth-hci-logger.path
+ln -sf %{_libdir}/systemd/system/bluetooth-hci-logger.path %{_sysconfdir}/systemd/default-extra-dependencies/ignore-units.d/
+
+ln -sf %{_libdir}/systemd/system/bluetooth-hci-logger-stop.service %{_sysconfdir}/systemd/default-extra-dependencies/ignore-units.d/
+ln -sf %{_libdir}/systemd/system/bluetooth-hci-logger-stop.path %{_libdir}/systemd/system/multi-user.target.wants/bluetooth-hci-logger-stop.path
+ln -sf %{_libdir}/systemd/system/bluetooth-hci-logger-stop.path %{_sysconfdir}/systemd/default-extra-dependencies/ignore-units.d/
+
+ln -sf %{_libdir}/systemd/system/bluez-start.service %{_sysconfdir}/systemd/default-extra-dependencies/ignore-units.d/
+ln -sf %{_libdir}/systemd/system/bluez-start.path %{_libdir}/systemd/system/multi-user.target.wants/bluez-start.path
+ln -sf %{_libdir}/systemd/system/bluez-start.path %{_sysconfdir}/systemd/default-extra-dependencies/ignore-units.d/
+
+ln -sf %{_libdir}/systemd/system/bluetooth-share-start.service %{_sysconfdir}/systemd/default-extra-dependencies/ignore-units.d/
+ln -sf %{_libdir}/systemd/system/bluetooth-share-start.path %{_libdir}/systemd/system/multi-user.target.wants/bluetooth-share-start.path
+ln -sf %{_libdir}/systemd/system/bluetooth-share-start.path %{_sysconfdir}/systemd/default-extra-dependencies/ignore-units.d/
+
+ln -sf %{_libdir}/systemd/system/bluetooth-stack-down.service %{_sysconfdir}/systemd/default-extra-dependencies/ignore-units.d/
+ln -sf %{_libdir}/systemd/system/bluetooth-stack-down.path %{_libdir}/systemd/system/multi-user.target.wants/bluetooth-stack-down.path
+ln -sf %{_libdir}/systemd/system/bluetooth-stack-down.path %{_sysconfdir}/systemd/default-extra-dependencies/ignore-units.d/
+
+ln -sf %{_libdir}/systemd/system/bluetooth-force-hci-logger.service %{_sysconfdir}/systemd/default-extra-dependencies/ignore-units.d/
+
 
 %files
 %manifest %{name}.manifest
+%license LICENSE.APLv2
 %defattr(-,root,root,-)
-%if "%{profile}" == "mobile" || "%{profile}" == "wearable" || "%{profile}" == "ivi"
-%exclude %{_sysconfdir}/rc.d/init.d/bluetooth-address
-%else
-%{_sysconfdir}/rc.d/init.d/bluetooth-address
-%endif
-%{_sysconfdir}/rc.d/rc3.d/S60bluetooth-address
-%{_sysconfdir}/rc.d/rc5.d/S60bluetooth-address
-%attr(0755,-,-) %{_prefix}/etc/bluetooth/bt-stack-up.sh
-%attr(0755,-,-) %{_prefix}/etc/bluetooth/bt-stack-down.sh
-%attr(0755,-,-) %{_prefix}/etc/bluetooth/bt-reset-env.sh
+#%exclude %{_sysconfdir}/rc.d/init.d/bluetooth-address
+#%{_sysconfdir}/rc.d/rc3.d/S60bluetooth-address
+#%{_sysconfdir}/rc.d/rc5.d/S60bluetooth-address
 %attr(0755,-,-) %{_prefix}/etc/bluetooth/bt-edutm-on.sh
 %attr(0755,-,-) %{_prefix}/etc/bluetooth/bt-edutm-dev-up.sh
 %attr(0755,-,-) %{_prefix}/etc/bluetooth/bt-edutm-mode-on.sh
 %attr(0755,-,-) %{_prefix}/etc/bluetooth/bt-edutm-off.sh
 %attr(0755,-,-) %{_prefix}/etc/bluetooth/bt-hci-logdump.sh
-%attr(0755,-,-) %{_prefix}/etc/bluetooth/bt-run-hcidump.sh
-%if "%{profile}" == "mobile"
-%attr(0755,-,-) %{_prefix}/etc/bluetooth/bt-stack-down-with-radio.sh
-%endif
-%{_datadir}/license/bluetooth-tools
-%{_unitdir}/multi-user.target.wants/bluetooth-address.service
-%{_unitdir}/bluetooth-address.service
+%attr(0755,-,-) %{_prefix}/etc/bluetooth/bt-run-hci-logger.sh
+#%{_unitdir}/multi-user.target.wants/bluetooth-address.service
+#%{_unitdir}/bluetooth-address.service
+%{_libdir}/systemd/system/bluetooth-hci-logger.service
+%{_libdir}/systemd/system/bluetooth-hci-logger.path
+%{_libdir}/systemd/system/bluetooth-hci-logger-stop.service
+%{_libdir}/systemd/system/bluetooth-hci-logger-stop.path
+%{_libdir}/systemd/system/bluez-start.service
+%{_libdir}/systemd/system/bluez-start.path
+%{_libdir}/systemd/system/bluetooth-share-start.service
+%{_libdir}/systemd/system/bluetooth-share-start.path
+%{_libdir}/systemd/system/bluetooth-force-hci-logger.service
+%{_libdir}/systemd/system/bluetooth-hci-dump@.service
+%{_libdir}/systemd/system/bluetooth-stack-down.service
+%{_libdir}/systemd/system/bluetooth-stack-down.path
+
+%post profile_common
+pushd %{_prefix}/etc/bluetooth/
+ln -sf common/bt-stack-up.sh bt-stack-up.sh
+ln -sf common/bt-stack-down.sh bt-stack-down.sh
+ln -sf common/bt-reset-env.sh bt-reset-env.sh
+popd
+%preun profile_common
+pushd %{_prefix}/etc/bluetooth/
+rm bt-stack-up.sh
+rm bt-stack-down.sh
+rm bt-reset-env.sh
+popd
+%files profile_common
+%license LICENSE.APLv2
+#%{_sysconfdir}/rc.d/init.d/bluetooth-address
+%attr(0755,-,-) %{_prefix}/etc/bluetooth/common/bt-stack-up.sh
+%attr(0755,-,-) %{_prefix}/etc/bluetooth/common/bt-stack-down.sh
+%attr(0755,-,-) %{_prefix}/etc/bluetooth/common/bt-reset-env.sh
+
+%post profile_mobile
+pushd %{_prefix}/etc/bluetooth/
+ln -sf mobile/bt-stack-up.sh bt-stack-up.sh
+ln -sf mobile/bt-stack-down.sh bt-stack-down.sh
+ln -sf mobile/bt-stack-down-with-radio.sh bt-stack-down-with-radio.sh
+ln -sf mobile/bt-reset-env.sh bt-reset-env.sh
+popd
+%preun profile_mobile
+pushd %{_prefix}/etc/bluetooth/
+rm bt-stack-up.sh
+rm bt-stack-down.sh
+rm bt-stack-down-with-radio.sh
+rm bt-reset-env.sh
+popd
+%files profile_mobile
+%license LICENSE.APLv2
+%attr(0755,-,-) %{_prefix}/etc/bluetooth/mobile/bt-stack-up.sh
+%attr(0755,-,-) %{_prefix}/etc/bluetooth/mobile/bt-stack-down.sh
+%attr(0755,-,-) %{_prefix}/etc/bluetooth/mobile/bt-reset-env.sh
+%attr(0755,-,-) %{_prefix}/etc/bluetooth/mobile/bt-stack-down-with-radio.sh
+
+%post profile_ivi
+pushd %{_prefix}/etc/bluetooth/
+ln -sf ivi/bt-stack-up.sh bt-stack-up.sh
+ln -sf ivi/bt-stack-down.sh bt-stack-down.sh
+ln -sf ivi/bt-reset-env.sh bt-reset-env.sh
+popd
+%preun profile_ivi
+pushd %{_prefix}/etc/bluetooth/
+rm bt-stack-up.sh
+rm bt-stack-down.sh
+rm bt-reset-env.sh
+popd
+%files profile_ivi
+%license LICENSE.APLv2
+%attr(0755,-,-) %{_prefix}/etc/bluetooth/ivi/bt-stack-up.sh
+%attr(0755,-,-) %{_prefix}/etc/bluetooth/ivi/bt-stack-down.sh
+%attr(0755,-,-) %{_prefix}/etc/bluetooth/ivi/bt-reset-env.sh
+
+%post profile_wearable
+pushd %{_prefix}/etc/bluetooth/
+ln -sf wearable/bt-stack-up.sh bt-stack-up.sh
+ln -sf wearable/bt-stack-down.sh bt-stack-down.sh
+ln -sf wearable/bt-reset-env.sh bt-reset-env.sh
+popd
+%preun profile_wearable
+pushd %{_prefix}/etc/bluetooth/
+rm bt-stack-up.sh
+rm bt-stack-down.sh
+rm bt-reset-env.sh
+popd
+%files profile_wearable
+%license LICENSE.APLv2
+%attr(0755,-,-) %{_prefix}/etc/bluetooth/wearable/bt-stack-up.sh
+%attr(0755,-,-) %{_prefix}/etc/bluetooth/wearable/bt-stack-down.sh
+%attr(0755,-,-) %{_prefix}/etc/bluetooth/wearable/bt-reset-env.sh
 
 %files no-firmware
 %manifest %{name}.manifest
+%license LICENSE.APLv2
 %defattr(-, root, root)
 %attr(755,-,-) %{_prefix}/etc/bluetooth/bt-dev-end.sh
 %attr(755,-,-) %{_prefix}/etc/bluetooth/bt-dev-start.sh