Add cache support
[platform/framework/web/download-provider.git] / packaging / download-provider.spec
index eb7e2c3..1f93da3 100755 (executable)
@@ -1,12 +1,10 @@
-%define _ux_define tizen2.3
 Name:       download-provider
 Summary:    Download the contents in background
-Version:    2.1.73
+Version:    2.3.11
 Release:    0
 Group:      Development/Libraries
 License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
-Requires(post): libdevice-node
 Requires(post): sqlite
 Requires(post): connman
 Requires: security-config
@@ -24,24 +22,22 @@ BuildRequires:  pkgconfig(capi-network-connection)
 BuildRequires:  pkgconfig(appsvc)
 BuildRequires:  pkgconfig(libcurl)
 BuildRequires:  pkgconfig(capi-content-mime-type)
-BuildRequires:  pkgconfig(libsmack)
 BuildRequires:  gettext-devel
-BuildRequires:  pkgconfig(libsystemd-daemon)
+BuildRequires:  pkgconfig(libsystemd)
 BuildRequires:  pkgconfig(capi-network-wifi-direct)
-#BuildRequires:  model-build-features T30
-BuildRequires:  pkgconfig(storage)
-%if "%{?tizen_profile_name}" == "wearable"
-BuildRequires:  pkgconfig(security-server)
-%else if "%{?tizen_profile_name}" == "mobile"
+%if "%{?profile}" != "wearable"
 BuildRequires:  pkgconfig(notification)
 %endif
-
-BuildRequires: pkgconfig(cynara-client)
-BuildRequires: pkgconfig(cynara-client-async)
-BuildRequires: pkgconfig(cynara-creds-socket)
-BuildRequires: pkgconfig(cynara-creds-dbus)
-BuildRequires: pkgconfig(tpkp-curl)
-BuildRequires: pkgconfig(libtzplatform-config)
+BuildRequires:  pkgconfig(storage)
+BuildRequires:  pkgconfig(cynara-client)
+BuildRequires:  pkgconfig(cynara-client-async)
+BuildRequires:  pkgconfig(cynara-creds-socket)
+BuildRequires:  pkgconfig(cynara-creds-dbus)
+BuildRequires:  pkgconfig(libtzplatform-config)
+
+%if 0%{?gtests:1}
+BuildRequires:  pkgconfig(gmock)
+%endif
 
 %description
 Description: Download the contents in background
@@ -65,135 +61,98 @@ Description: Download the contents in background (development files)
 %define _database_client_dir %{_databasedir}/clients
 %define _notifydir %{_data_install_path}/notify
 %define _ipc_socket /tmp/.download-provider.sock
-%define _licensedir /usr/share/license
 %define _logdump_script_dir %{TZ_SYS_ETC}/dump.d/module.d
 %define _http_lib libcurl
-%define upgrade_script_path /usr/share/upgrade/scripts
-
-%define download_booster OFF
-%define support_oma_drm OFF
-%ifarch armv7l
-%define wifi_direct ON
-%else
-%define wifi_direct OFF
-%endif
-%define support_security_privilege OFF
-%define support_companion_mode OFF
-%define support_notification ON
-%define support_knox ON
 %define _manifest_name %{name}.manifest
-
-%if 0%{?model_build_feature_wlan_p2p_disable }
-%define wifi_direct OFF
-%endif
-%if "%{?tizen_profile_name}" == "wearable"
-%define download_booster OFF
-%define support_notification OFF
-%define _manifest_name %{name}-w.manifest
-%endif
-%if 0%{?sec_product_feature_container_enable}
-%define support_knox ON
+%if "%{?tizen_profile_name}" == "tv"
+%define _ca_cert /opt/data/cert/vdca.pem
+%define _ca_path /opt/data/cert/user/
+%define max_concurrent_downloads 15
+%else
+%define max_concurrent_downloads 50
 %endif
 
-%define cmake \
-       CFLAGS="${CFLAGS:-%optflags} -fPIC -D_REENTRANT -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fvisibility=hidden"; export CFLAGS \
-       FFLAGS="${FFLAGS:-%optflags} -fPIC -fvisibility=hidden"; export FFLAGS \
-       LDFLAGS+=" -Wl,--as-needed -Wl,--hash-style=both"; export LDFLAGS \
-       %__cmake \\\
-               -DCMAKE_INSTALL_PREFIX:PATH=%{_prefix} \\\
-               -DBIN_INSTALL_DIR:PATH=%{_bindir} \\\
-               -DLIB_INSTALL_DIR:PATH=%{_libdir} \\\
-               %ifarch aarch64 x86_64 \
-               -DLIB_AGENT_PATH="/usr/lib64/libdownloadagent2.so" \\\
-               %else \
-               -DLIB_AGENT_PATH="/usr/lib/libdownloadagent2.so" \\\
-               %endif \
-               -DINCLUDE_INSTALL_DIR:PATH=%{_includedir} \\\
-               -DPKG_NAME=%{name} \\\
-               -DPKG_VERSION=%{version} \\\
-               -DPKG_RELEASE=%{release} \\\
-               -DIPC_SOCKET:PATH=%{_ipc_socket} \\\
-               -DPROVIDER_DIR:PATH=%{_data_install_path} \\\
-               -DNOTIFY_DIR:PATH=%{_notifydir} \\\
-               -DDATABASE_DIR:PATH=%{_databasedir} \\\
-               -DDATABASE_CLIENT_DIR:PATH=%{_database_client_dir} \\\
-               -DIMAGE_DIR:PATH=%{_imagedir} \\\
-               -DLOCALE_DIR:PATH=%{_localedir} \\\
-               -DLICENSE_DIR:PATH=%{_licensedir} \\\
-               -DSUPPORT_WIFI_DIRECT:BOOL=OFF \\\
-               %if "%{?download_booster}" == "ON" \
-               -DSUPPORT_DOWNLOAD_BOOSTER:BOOL=ON \\\
-               %else \
-               -DSUPPORT_DOWNLOAD_BOOSTER:BOOL=OFF \\\
-               %endif \
-               %if "%{?support_notification}" == "ON" \
-               -DSUPPORT_NOTIFICATION:BOOL=ON \\\
-               %else \
-               -DSUPPORT_NOTIFICATION:BOOL=OFF \\\
-               %endif \
-               -DSUPPORT_LOG_MESSAGE:BOOL=ON \\\
-               %if "%{?support_oma_drm}" == "ON" \
-               -DSUPPORT_OMA_DRM:BOOL=ON \\\
-               %else \
-               -DSUPPORT_OMA_DRM:BOOL=OFF \\\
-               %endif \
-               %if "%{?support_security_privilege}" == "ON" \
-               -DSUPPORT_SECURITY_PRIVILEGE:BOOL=ON \\\
-               %else \
-               -DSUPPORT_SECURITY_PRIVILEGE:BOOL=OFF \\\
-               %endif \
-               %if "%{?support_companion_mode}" == "ON" \
-               -DSUPPORT_COMPANION_MODE:BOOL=ON \\\
-               %else \
-               -DSUPPORT_COMPANION_MODE:BOOL=OFF \\\
-               %endif \
-               %if "%{?support_knox}" == "ON" \
-               -DSUPPORT_KNOX:BOOL=ON \\\
-               %else \
-               -DSUPPORT_KNOX:BOOL=OFF \\\
-               %endif \
-               %if "%{?_ux_define}" == "tizen2.3" \
-               -DTIZEN_2_3_UX:BOOL=ON \\\
-               %endif \
-               -DCMAKE_LOG_DUMP_SCRIPT_DIR=%{_logdump_script_dir} \\\
-               -DHTTP_LIB=%{_http_lib} \\\
-               %if "%{?_lib}" == "lib64" \
-               %{?_cmake_lib_suffix64} \\\
-               %endif \
-               %{?_cmake_skip_rpath} \\\
-               -DBUILD_SHARED_LIBS:BOOL=ON
-
 %build
 export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE"
 export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE"
 export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE"
-%cmake . -DTZ_SYS_GLOBALUSER_DATA=%TZ_SYS_GLOBALUSER_DATA
+
+%if 0%{?gcov:1}
+export CFLAGS+=" -fprofile-arcs -ftest-coverage"
+export CXXFLAGS+=" -fprofile-arcs -ftest-coverage"
+export FFLAGS+=" -fprofile-arcs -ftest-coverage"
+export LDFLAGS+=" -lgcov"
+%endif
+
+%cmake -DTZ_SYS_GLOBALUSER_DATA=%TZ_SYS_GLOBALUSER_DATA \
+       -DCMAKE_INSTALL_PREFIX:PATH=%{_prefix} \
+       -DBIN_INSTALL_DIR:PATH=%{_bindir} \
+       -DLIB_INSTALL_DIR:PATH=%{_libdir} \
+       -DLIB_AGENT_PATH="/usr/%{?_lib}/libdownloadagent2.so.0.1.0" \
+       -DLIB_CACHE_AGENT_PATH="/usr/%{?_lib}/libcacheagent.so.0.1.0" \
+       -DINCLUDE_INSTALL_DIR:PATH=%{_includedir} \
+       -DPKG_NAME=%{name} \
+       -DPKG_VERSION=%{version} \
+       -DPKG_RELEASE=%{release} \
+       -DIPC_SOCKET:PATH=%{_ipc_socket} \
+       -DPROVIDER_DIR:PATH=%{_data_install_path} \
+       -DNOTIFY_DIR:PATH=%{_notifydir} \
+       -DDATABASE_DIR:PATH=%{_databasedir} \
+       -DDATABASE_CLIENT_DIR:PATH=%{_database_client_dir} \
+       -DIMAGE_DIR:PATH=%{_imagedir} \
+       -DLOCALE_DIR:PATH=%{_localedir} \
+       -DSUPPORT_WIFI_DIRECT:BOOL=OFF \
+       -DSUPPORT_DOWNLOAD_BOOSTER:BOOL=OFF \
+%if "%{?profile}" == "wearable"
+       -DSUPPORT_NOTIFICATION:BOOL=OFF \
+%else
+       -DSUPPORT_NOTIFICATION:BOOL=ON \
+%endif
+       -DSUPPORT_LOG_MESSAGE:BOOL=ON \
+       -DSUPPORT_OMA_DRM:BOOL=OFF \
+       -DSUPPORT_COMPANION_MODE:BOOL=OFF \
+%if "%{?profile}" == "wearable"
+       -DSUPPORT_MULTILINGUAL:BOOL=ON \
+%else
+       -DSUPPORT_MULTILINGUAL:BOOL=OFF \
+       -DMAX_CONCURRENT_DOWNLOADS=%{?max_concurrent_downloads}\
+%endif
+       -DCMAKE_LOG_DUMP_SCRIPT_DIR=%{_logdump_script_dir} \
+       -DHTTP_LIB=%{_http_lib} \
+%if "%{?_lib}" == "lib64"
+       %{?_cmake_lib_suffix64} \
+%endif
+       %{?_cmake_skip_rpath} \
+       -DBUILD_SHARED_LIBS:BOOL=ON \
+       -DBUILD_GTESTS=%{?gtests:1}%{!?gtests:0} \
+       -DBUILD_GCOV=%{?gcov:1}%{!?gcov:0} \
+       -DSUPPORT_LARGE_FILE:BOOL=ON \
+%if "%{?tizen_profile_name}" == "tv"
+       -DCA_CERT=%{_ca_cert} \
+       -DCA_PATH=%{_ca_path} \
+%endif
+       .
 
 make %{?jobs:-j%jobs}
 
 %install
 rm -rf %{buildroot}
 %make_install
-%if ("%{VD_PRODUCT_TYPE}" == "AUDIO") || ("%{VD_PRODUCT_TYPE}" == "TV") || ("%{VD_PRODUCT_TYPE}" == "LFD") || ("%{VD_PRODUCT_TYPE}" == "HTV") || ("%{VD_PRODUCT_TYPE}" == "AV")
+%if "%{?tizen_profile_name}" == "tv"
 mkdir -p %{buildroot}/etc/notstrip/
 install -m 644 packaging/download-provider.notstrip %{buildroot}/etc/notstrip/download-provider.notstrip
 %endif
 
-#%if 0%{?sec_product_feature_container_enable}
+mkdir -p %{buildroot}/var/lib/download-provider/
+install -m 600 res/var/lib/download-provider/settings %{buildroot}/var/lib/download-provider/settings
+
+## container_enable
 mkdir -p %{buildroot}/etc/vasum/vsmzone.resource/
 mv %{buildroot}/usr/share/download-provider/download-provider.res %{buildroot}/etc/vasum/vsmzone.resource/
-#%endif
 
-mkdir -p %{buildroot}%{_licensedir}
-mkdir -p %{buildroot}/lib/systemd/system/graphical.target.wants
 mkdir -p %{buildroot}/lib/systemd/system/sockets.target.wants
-ln -s ../download-provider.service %{buildroot}/lib/systemd/system/graphical.target.wants/
 ln -s ../download-provider.socket %{buildroot}/lib/systemd/system/sockets.target.wants/
 
-#OS Upgrade
-mkdir -p %{buildroot}%{upgrade_script_path}
-cp -f 500.download-provider_upgrade.sh %{buildroot}%{upgrade_script_path}
-
 %post
 #make notify dir in post section for smack
 mkdir %{TZ_SYS_GLOBALUSER_DATA}/download-provider
@@ -208,36 +167,42 @@ mkdir -p --mode=0700 %{_database_client_dir}
 chsmack -a 'System' %{_database_client_dir}
 chown -R web_fw:web_fw %{_database_client_dir}
 chown -R web_fw:web_fw %{_data_install_path}
+chown -R web_fw:web_fw /var/lib/download-provider/
+mkdir -p /opt/usr/data/download_cache
+chown -R web_fw:web_fw /opt/usr/data/download_cache
 
 %files
 %defattr(-,root,root,-)
 %manifest %{_manifest_name}
 %{_imagedir}/*.png
 %{_localedir}/*/*/download-provider.mo
-%{_libdir}/libdownloadagent2.so.0.1.0
-%{_libdir}/libdownloadagent2.so
+%{_libdir}/*.so.*
+%attr(0600,web_fw,web_fw) /var/lib/download-provider/settings
 /lib/systemd/system/download-provider.service
-/lib/systemd/system/graphical.target.wants/download-provider.service
 /lib/systemd/system/download-provider.socket
 /lib/systemd/system/sockets.target.wants/download-provider.socket
-%{_libdir}/libdownload-provider-interface.so.%{version}
-%{_libdir}/libdownload-provider-interface.so.0
 %{_bindir}/%{name}
-%{_licensedir}/%{name}
 %attr(0544,root,root) %{_logdump_script_dir}/dump-%{name}.sh
-#%if 0%{?sec_product_feature_container_enable}
+## container_enable
 %attr(0644,root,root) /etc/vasum/vsmzone.resource/download-provider.res
-#%endif
-%{upgrade_script_path}/500.download-provider_upgrade.sh
-%if ("%{VD_PRODUCT_TYPE}" == "AUDIO") || ("%{VD_PRODUCT_TYPE}" == "TV") || ("%{VD_PRODUCT_TYPE}" == "LFD") || ("%{VD_PRODUCT_TYPE}" == "HTV") || ("%{VD_PRODUCT_TYPE}" == "AV")
+%if "%{?tizen_profile_name}" == "tv"
 /etc/notstrip/download-provider.notstrip
 %endif
+%license LICENSE.APLv2
 
 %files devel
 %defattr(-,root,root,-)
-%{_libdir}/libdownload-provider-interface.so
-%{_includedir}/download-provider/download-provider.h
-%{_includedir}/download-provider/download-provider-interface.h
 %{_bindir}/%{name}
+%{_libdir}/*.so
 %{_libdir}/pkgconfig/download-provider.pc
 %{_libdir}/pkgconfig/download-provider-interface.pc
+%{_libdir}/pkgconfig/download-agent.pc
+%{_libdir}/pkgconfig/cache-agent.pc
+%{_includedir}/download-provider/download-provider.h
+%{_includedir}/download-provider/download-provider-interface.h
+%{_includedir}/download-provider/download-agent-interface.h
+%{_includedir}/download-provider/cache-agent-interface.h
+
+%if 0%{?gtests:1}
+%{_bindir}/gtest*
+%endif