Remove Profile Build Dependency 27/92227/9
authorMyungJoo Ham <myungjoo.ham@samsung.com>
Fri, 14 Oct 2016 04:56:38 +0000 (04:56 +0000)
committerPyun DoHyun <dh79.pyun@samsung.com>
Mon, 5 Dec 2016 05:31:25 +0000 (21:31 -0800)
This commit completely removes the build dependencies
on Tizen profile.

Note:

1. This commit is not required for Tizen 3.0 release,
but for later Tizen versions. If maintainers do not feel
comfortable because of the release schedule, maintainers
may delay SR/merge this commit.

2. When maintainers submit SR, they need to submit
JIRA-TRE issues of the followings:

  - Add bluetooth-agent-profile_common for common profile if common has bluetooth-agent
  - Add bluetooth-agent-profile_mobile for mobile profile if mobile has bluetooth-agent
  - Add bluetooth-agent-profile_wearable for wearable profile if wearable has bluetooth-agent
  - Add bluetooth-agent-profile_ivi for ivi profile if ivi has bluetooth-agent
  - Add bluetooth-agent-profile_tv for tv profile if tv has bluetooth-agent

Note that you should NOT remove bluetooth-agent from the current
meta when you add these bluetooth-agent-profile_*

3. The %if / %endif with %{?profile} statements do not
deteriorate Tizen 4.0 reconfigurability because they are
written to be ignored if profile is common or "undefined".

  They may be removed after 4.0 development. However, for a vendor
that does want only ONE profile at any case, this may increase the build
time by a few seconds. If they are that much desperate to reduce a few
seconds of build time (in my PC, it's about 4 seconds), they may keep
the %if/%endif statements. However, for public, doing this saves
about N minutes of build time.

  These statements are added because some of current Tizen profile OBS
projects do not have BuildRequired packages. Thus, this commit is not
suitable as a model for other packages to refactor spec files.

Change-Id: Ia28e511765b11e27135d647684d6511406e99033
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
packaging/bluetooth-agent.spec

index f8579bf..2fe1339 100644 (file)
@@ -11,11 +11,21 @@ Source1001:         bluetooth-agent.manifest
 
 BuildRequires:  pkgconfig(aul)
 BuildRequires:  pkgconfig(bluetooth-api)
-%if "%{?profile}" == "wearable" || "%{?profile}" == "ivi"
+
+# The profile macro usage with the following comments may be removed after
+# Tizen OBS build projects are merged. However, each vendor may keep using
+# such if/endif statement to skip building profiles not interested
+
+# This usage of profile macro does NOT conflict 4.0 configurability.
+%if "%{?profile}" != "mobile" && "%{?profile}" != "tv"
+# Original: wearable, ivi. Added: common, "undefined"
 BuildRequires:  pkgconfig(alarm-service)
 BuildRequires:  pkgconfig(capi-appfw-app-manager)
 BuildRequires:  pkgconfig(capi-system-device)
-%else
+%endif
+# This usage of profile macro does NOT conflict 4.0 configurability.
+%if "%{?profile}" != "wearable" && "%{?profile}" != "ivi"
+# Original: common, mobile, tv. Added: "undefined"
 BuildRequires:  pkgconfig(contacts-service2)
 BuildRequires:  pkgconfig(msg-service)
 BuildRequires:  pkgconfig(email-service)
@@ -33,10 +43,38 @@ BuildRequires:  pkgconfig(libexif)
 BuildRequires:  pkgconfig(gio-2.0)
 BuildRequires:  cmake
 Requires: security-config
+Requires:      %{name}-compat = %{version}-%{release}
+Recommends:    %{name}-profile_common = %{version}-%{release}
 
 %description
 Bluetooth agent packages that support various external profiles
 
+%package profile_common
+Summary:       Bluetooth agent for common/tv/mobile
+Provides:      %{name}-compat = %{version}-%{release}
+Provides:      %{name}-profile_mobile = %{version}-%{release}
+Provides:      %{name}-profile_tv = %{version}-%{release}
+Conflicts:     %{name}-profile_ivi
+Conflicts:     %{name}-profile_wearable
+%description profile_common
+Bluetooth agent binary compiled for common, tv, mobile profiles
+
+%package profile_ivi
+Summary:       Bluetooth agent for ivi
+Provides:      %{name}-compat = %{version}-%{release}
+Conflicts:     %{name}-profile_common
+Conflicts:     %{name}-profile_wearable
+%description profile_ivi
+Bluetooth agent binary compiled for ivi profile
+
+%package profile_wearable
+Summary:       Bluetooth agent for wearable
+Provides:      %{name}-compat = %{version}-%{release}
+Conflicts:     %{name}-profile_common
+Conflicts:     %{name}-profile_ivi
+%description profile_wearable
+Bluetooth agent binary compiled for wearable profile
+
 %prep
 %setup -q
 cp %{SOURCE1001} .
@@ -62,48 +100,87 @@ export CXXFLAGS+=" -DARCH64"
 export FFLAGS+=" -DARCH64"
 %endif
 
-%if "%{?profile}" == "wearable"
-export CFLAGS="$CFLAGS -DTIZEN_PROFILE_WEARABLE"
+export CFLAGS+=" -fpie -DTIZEN_FEATURE_BP_PBAP_SIM -fvisibility=hidden "
+export CXXFLAGS+=" -fpie -DTIZEN_FEATURE_BP_PBAP_SIM -fvisibility=hidden "
+
+export LDFLAGS+=" -Wl,--rpath=/usr/lib -Wl,--as-needed -Wl,--unresolved-symbols=ignore-in-shared-libs -pie"
+
+export CFLAGS_DEFAULT="$CFLAGS"
+
+# This usage of profile macro does NOT conflict 4.0 configurability.
+%if "%{?profile}" != "mobile" && "%{?profile}" != "tv"
+# Original: wearable, ivi. Added: common, "undefined"
+
+# Build Wearable
+export CFLAGS="$CFLAGS_DEFAULT -DTIZEN_PROFILE_WEARABLE"
 export CFLAGS="$CFLAGS -DTIZEN_FEATURE_BT_LUNAR_DEVICE"
-%else
-export CFLAGS="$CFLAGS -DTIZEN_FEATURE_BT_KIRAN_DEVICE"
-%endif
+mkdir -p wearable_build
+pushd wearable_build
+cmake .. -DCMAKE_INSTALL_PREFIX=/usr/wearable -DTIZEN_PROFILE_WEARABLE=1 -DTIZEN_FEATURE_BT_HFP_AG=1
+make VERBOSE=1
+popd
+
 
-%if "%{?profile}" == "ivi"
+# Build IVI
+# TODO: BT-Agent Developers, Please Check if TIZEN_KIRAN is really need for ALL NON-WEARABLES.
+export CFLAGS="$CFLAGS_DEFAULT -DTIZEN_FEATURE_BT_KIRAN_DEVICE"
 export CFLAGS="$CFLAGS -DTIZEN_PROFILE_IVI"
+mkdir -p ivi_build
+pushd ivi_build
+cmake .. -DCMAKE_INSTALL_PREFIX=/usr/ivi -DTIZEN_PROFILE_WEARABLE=0 -DTIZEN_PROFILE_IVI=1 -DTIZEN_FEATURE_BT_HFP_AG=1
+make VERBOSE=1
+popd
+
 %endif
 
-export CFLAGS+=" -fpie -DTIZEN_FEATURE_BT_PBAP_SIM -fvisibility=hidden "
-export CXXFLAGS+=" -fpie -DTIZEN_FEATURE_BT_PBAP_SIM -fvisibility=hidden "
 
-export LDFLAGS+=" -Wl,--rpath=/usr/lib -Wl,--as-needed -Wl,--unresolved-symbols=ignore-in-shared-libs -pie"
-
-cmake . -DCMAKE_INSTALL_PREFIX=/usr \
-%if "%{?profile}" == "wearable"
-        -DTIZEN_PROFILE_WEARABLE=1 \
-%else
-        -DTIZEN_PROFILE_WEARABLE=0 \
-%endif
-%if "%{?profile}" == "ivi"
-        -DTIZEN_PROFILE_IVI=1 \
-%endif
-        -DTIZEN_FEATURE_BT_HFP_AG=1
+# This usage of profile macro does NOT conflict 4.0 configurability.
+%if "%{?profile}" != "wearable" && "%{?profile}" != "ivi"
+# Original: common, mobile, tv. Added: "undefined"
 
+# Build All Others (common/tv/mobile)
+# TODO: BT-Agent Developers, Please Check if TIZEN_KIRAN is really need for ALL NON-WEARABLES.
+export CFLAGS="$CFLAGS_DEFAULT -DTIZEN_FEATURE_BT_KIRAN_DEVICE"
+mkdir -p common_build
+pushd common_build
+cmake .. -DCMAKE_INSTALL_PREFIX=/usr -DTIZEN_PROFILE_WEARABLE=0 -DTIZEN_FEATURE_BT_HFP_AG=1
 make VERBOSE=1
+popd
+
+%endif
 
 %install
 rm -rf %{buildroot}
+# This usage of profile macro does NOT conflict 4.0 configurability.
+%if "%{?profile}" != "mobile" && "%{?profile}" != "tv"
+# Original: wearable, ivi. Added: common, "undefined"
+pushd wearable_build
+%make_install
+popd
+pushd ivi_build
 %make_install
+popd
+%endif
+
+# This usage of profile macro does NOT conflict 4.0 configurability.
+%if "%{?profile}" != "wearable" && "%{?profile}" != "ivi"
+# Original: common, mobile, tv. Added: "undefined"
+pushd common_build
+%make_install
+popd
+%endif
 
 install -D -m 0644 LICENSE %{buildroot}%{_datadir}/license/bluetooth-agent
-#mkdir -p %{buildroot}%{_unitdir}/multi-user.target.wants
-#%if "%{?profile}" != "wearable"
-#install -m 0644 packaging/bluetooth-ag-agent.service %{buildroot}%{_unitdir}/
-#ln -s ../bluetooth-ag-agent.service %{buildroot}%{_unitdir}/multi-user.target.wants/bluetooth-ag-agent.service
-#%endif
-#%if 0%{?sec_product_feature_bt_map_server_enable}
 install -D -m 0644 packaging/bluetooth-map-agent.service %{buildroot}%{_libdir}/systemd/user/bluetooth-map-agent.service
-#%endif
+# This usage of profile macro does NOT conflict 4.0 configurability.
+%if "%{?profile}" != "mobile" && "%{?profile}" != "tv"
+# Original: wearable, ivi. Added: common, "undefined"
+mv %{buildroot}/usr/wearable/share/dbus-1/system-services/org.bluez.hf_agent.service %{buildroot}%{_datadir}/dbus-1/system-services/
+mv %{buildroot}/usr/wearable/bin/bluetooth-hf-agent %{buildroot}%{_bindir}/
+mv %{buildroot}/usr/ivi/bin/bluetooth-hf-agent %{buildroot}%{_bindir}/bluetooth-hf-agent.ivi
+rm -Rf %{buildroot}/usr/ivi
+rm -Rf %{buildroot}/usr/wearable
+%endif
 install -D -m 0644 packaging/bluetooth-pbap-agent.service %{buildroot}%{_libdir}/systemd/system/bluetooth-pbap-agent.service
 
 %post
@@ -112,26 +189,48 @@ ln -sf %{_libdir}/systemd/user/bluetooth-map-agent.service %{_sysconfdir}/system
 %endif
 ln -sf %{_libdir}/systemd/system/bluetooth-pbap-agent.service %{_sysconfdir}/systemd/default-extra-dependencies/ignore-units.d/
 
+# This usage of profile macro does NOT conflict 4.0 configurability.
+%if "%{?profile}" != "mobile" && "%{?profile}" != "tv"
+# Original: wearable, ivi. Added: common, "undefined"
+%post profile_ivi
+ln -sf bluetooth-hf-agent.ivi %{_bindir}/bluetooth-hf-agent
+%preun profile_ivi
+rm %{_bindir}/bluetooth-hf-agent
+%endif
+
 %files
 %manifest %{name}.manifest
 %defattr(-, root, root)
-%if "%{?profile}" == "wearable" || "%{?profile}" == "ivi"
+%{_datadir}/license/bluetooth-agent
+
+# This usage of profile macro does NOT conflict 4.0 configurability.
+%if "%{?profile}" != "mobile" && "%{?profile}" != "tv"
+# Original: wearable, ivi. Added: common, "undefined"
+%files profile_wearable
 %{_bindir}/bluetooth-hf-agent
 %{_datadir}/dbus-1/system-services/org.bluez.hf_agent.service
 %exclude %{_libdir}/systemd/user/bluetooth-map-agent.service
 %exclude %{_libdir}/systemd/system/bluetooth-pbap-agent.service
-%else
+
+%files profile_ivi
+%{_bindir}/bluetooth-hf-agent.ivi
+%{_datadir}/dbus-1/system-services/org.bluez.hf_agent.service
+%exclude %{_libdir}/systemd/user/bluetooth-map-agent.service
+%exclude %{_libdir}/systemd/system/bluetooth-pbap-agent.service
+%endif
+
+# This usage of profile macro does NOT conflict 4.0 configurability.
+%if "%{?profile}" != "wearable" && "%{?profile}" != "ivi"
+# Original: common, mobile, tv. Added: "undefined"
+%files profile_common
 %{_bindir}/bluetooth-ag-agent
 %{_bindir}/bluetooth-map-agent
 %{_bindir}/bluetooth-pb-agent
 %{_datadir}/dbus-1/system-services/org.bluez.pb_agent.service
 %{_datadir}/dbus-1/services/org.bluez.map_agent.service
 %{_datadir}/dbus-1/system-services/org.bluez.ag_agent.service
-#%{_usrlibdir}/systemd/system/bluetooth-ag-agent.service
-#%{_usrlibdir}/systemd/system/multi-user.target.wants/bluetooth-ag-agent.service
 %attr(0666,-,-) /var/lib/bluetooth/voice-recognition-blacklist
 %{_sysconfdir}/dbus-1/system.d/bluetooth-ag-agent.conf
 %{_libdir}/systemd/user/bluetooth-map-agent.service
 %{_libdir}/systemd/system/bluetooth-pbap-agent.service
 %endif
-%{_datadir}/license/bluetooth-agent