-Name: net-config
-Summary: TIZEN Network Configuration Module
-Version: 0.1.90_33
-Release: 1
-Group: System/Network
-License: Apache-2.0
-Source0: %{name}-%{version}.tar.gz
-Source1001: net-config.manifest
-
-BuildRequires: cmake
-BuildRequires: pkgconfig(glib-2.0)
-BuildRequires: pkgconfig(dbus-glib-1)
-BuildRequires: pkgconfig(dlog)
-BuildRequires: pkgconfig(vconf)
-BuildRequires: pkgconfig(capi-network-wifi-direct)
-BuildRequires: pkgconfig(tapi)
-Requires(post): /usr/bin/vconftool
-BuildRequires: pkgconfig(libsystemd-daemon)
-%{?systemd_requires}
+Name: net-config
+Summary: TIZEN Network Configuration service
+Version: 1.1.135
+Release: 3
+Group: System/Network
+License: Apache-2.0
+Source0: %{name}-%{version}.tar.gz
+BuildRequires: pkgconfig(dlog)
+BuildRequires: pkgconfig(vconf)
+BuildRequires: pkgconfig(gio-2.0)
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(capi-system-info)
+BuildRequires: pkgconfig(capi-vpnsvc)
+BuildRequires: cmake
+BuildRequires: pkgconfig(sqlite3)
+BuildRequires: pkgconfig(libtzplatform-config)
+BuildRequires: pkgconfig(key-manager)
+BuildRequires: pkgconfig(libnl-2.0)
+Requires: vconf
+Requires: connman
+Requires: systemd
+Requires: security-config
+Requires: iproute2
+Requires: iptables
+Requires(post): systemd
+Requires(preun): systemd
+Requires(postun): systemd
+Provides: %{name}-profile_common = %{version}-%{release}
+Provides: %{name}-profile_mobile = %{version}-%{release}
+Provides: %{name}-profile_wearable = %{version}-%{release}
+Provides: %{name}-profile_ivi = %{version}-%{release}
%description
-TIZEN Network Configuration Module
+TIZEN Network Configuration service
+
+%package profile_tv
+Summary: net-config extension for TV profile
+Requires: %{name} = %{version}-%{release}
+%description profile_tv
+TIZEN Network Configuration service extension for Tizen TV profile.
+
+%package profile_wearable
+Summary: net-config extension for wearable profile
+Requires: %{name} = %{version}-%{release}
+%description profile_wearable
+TIZEN Network Configuration service extension for Tizen wearable profile.
+
+%package plugin-headed
+Summary: net-config extension for headed profile
+BuildRequires: pkgconfig(bundle)
+BuildRequires: pkgconfig(eventsystem)
+BuildRequires: pkgconfig(alarm-service)
+BuildRequires: pkgconfig(syspopup-caller)
+BuildRequires: pkgconfig(capi-appfw-application)
+Requires: %{name} = %{version}-%{release}
+%description plugin-headed
+TIZEN Network Configuration service extension for headed profile.
+
+%package plugin-telephony
+Summary: net-config extension for telephony FW
+BuildRequires: pkgconfig(tapi)
+Requires: %{name} = %{version}-%{release}
+%description plugin-telephony
+TIZEN Network Configuration service extension for telephony FW.
+
+%package haltests
+Summary: net-config extension for HAL test
+BuildRequires: pkgconfig(gmock)
+BuildRequires: pkgconfig(capi-network-wifi-manager)
+BuildRequires: pkgconfig(capi-network-wifi-direct)
+BuildRequires: pkgconfig(capi-network-softap)
+Requires: %{name} = %{version}-%{release}
+%description haltests
+TIZEN Network Configuration service extension for HAL test.
%prep
%setup -q
-cp %{SOURCE1001} .
-
%build
-%cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix}
+# Build for wearable
+cmake -DCMAKE_INSTALL_PREFIX=%{_prefix} \
+ -DTIZEN_WLAN_PASSPOINT=1 \
+ -DTIZEN_WLAN_USE_P2P_INTERFACE=1 \
+ -DTIZEN_DEBUG_ENABLE=1 \
+ -DTIZEN_WEARABLE=1 \
+ -DTIZEN_CAPTIVE_PORTAL=1 \
+ -DLIB_PATH=%{_lib} \
+ -DBIN_DIR=%{_bindir} \
+ -DBUILD_GTESTS=%{?gtests:1}%{!?gtests:0} \
+ -DBUILD_GCOV=%{?gcov:1}%{!?gcov:0} \
+ .
+
+%make_install
+mv %{buildroot}%{_bindir}/net-config %{_builddir}/%{name}-%{version}/net-config.wearable
+
+make %{?_smp_mflags}
+
+
+# Build for common packages
+cmake -DCMAKE_INSTALL_PREFIX=%{_prefix} \
+ -DTIZEN_WLAN_PASSPOINT=1 \
+ -DTIZEN_WLAN_USE_P2P_INTERFACE=1 \
+ -DTIZEN_DEBUG_ENABLE=1 \
+ -DTIZEN_WEARABLE=0 \
+ -DTIZEN_CAPTIVE_PORTAL=0 \
+ -DLIB_PATH=%{_lib} \
+ -DBIN_DIR=%{_bindir} \
+ -DBUILD_GTESTS=%{?gtests:1}%{!?gtests:0} \
+ -DBUILD_GCOV=%{?gcov:1}%{!?gcov:0} \
+ .
make %{?_smp_mflags}
%install
%make_install
-mkdir -p %{buildroot}%{_datadir}/dbus-1/system-services
-cp resources/usr/share/dbus-1/services/net.netconfig.service %{buildroot}%{_datadir}/dbus-1/system-services/net.netconfig.service
-mkdir -p %{buildroot}%{_sysconfdir}/dbus-1/system.d
-cp resources/etc/dbus-1/system.d/net-config.conf %{buildroot}%{_sysconfdir}/dbus-1/system.d/net-config.conf
-
-# Systemd service file
+#Systemd service file
+mkdir -p %{buildroot}%{_libdir}/systemd/system/
+%if "%{?_lib}" == "lib64"
mkdir -p %{buildroot}%{_unitdir}
+%endif
+
+cp resources/usr/lib/systemd/system/net-config_tv.service %{buildroot}%{_libdir}/systemd/system/net-config.service.tv
+mkdir -p %{buildroot}%{_libdir}/udev/rules.d/
+cp resources/usr/lib/udev/rules.d/99-wifiusb-dev.rules %{buildroot}%{_libdir}/udev/rules.d/99-wifiusb-dev.rules
+%if "%{?_lib}" == "lib64"
+cp resources/usr/lib/systemd/system/net-config_tv.service %{buildroot}%{_unitdir}/net-config.service.tv
+%endif
+cp resources/usr/lib/systemd/system/net-config.service %{buildroot}%{_libdir}/systemd/system/net-config.service
+%if "%{?_lib}" == "lib64"
cp resources/usr/lib/systemd/system/net-config.service %{buildroot}%{_unitdir}/net-config.service
+%endif
+
+mkdir -p %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants/
+ln -s ../net-config.service %{buildroot}%{_libdir}/systemd/system/multi-user.target.wants/net-config.service
+%if "%{?_lib}" == "lib64"
mkdir -p %{buildroot}%{_unitdir}/multi-user.target.wants/
ln -s ../net-config.service %{buildroot}%{_unitdir}/multi-user.target.wants/net-config.service
+%endif
-#License
-mkdir -p %{buildroot}%{_datadir}/license
-cp LICENSE.APLv2 %{buildroot}%{_datadir}/license/net-config
+mkdir -p %{buildroot}%{_datadir}/dbus-1/system-services/
+cp resources/usr/share/dbus-1/system-services/net.netconfig.service %{buildroot}%{_datadir}/dbus-1/system-services/net.netconfig.service
-%post
+mkdir -p %{buildroot}%{TZ_SYS_ETC}
+cp resources/etc/resolv.conf %{buildroot}%{TZ_SYS_ETC}/resolv.conf
-vconftool set -t int memory/dnet/state 0 -i
-vconftool set -t int memory/wifi/state 0 -i
-vconftool set -t int memory/wifi/transfer_state 0 -i
-vconftool set -t int memory/wifi/strength 0 -i
-vconftool set -t int memory/wifi/bgscan_mode 0 -i
+mkdir -p %{buildroot}%{_sysconfdir}
+ln -s %{TZ_SYS_ETC}/resolv.conf %{buildroot}%{_sysconfdir}/resolv.conf
-vconftool set -t int memory/dnet/wifi 0 -i
-vconftool set -t int memory/dnet/network_config 0 -i
-vconftool set -t int memory/dnet/status 0 -i
-vconftool set -t string memory/dnet/ip "" -i
-vconftool set -t string memory/dnet/proxy "" -i
+#DBus DAC (net-config.manifest enables DBus SMACK)
+mkdir -p %{buildroot}%{_sysconfdir}/dbus-1/system.d
+cp resources/etc/dbus-1/system.d/net-config.conf %{buildroot}%{_sysconfdir}/dbus-1/system.d/net-config.conf
-vconftool set -t string memory/wifi/connected_ap_name "" -i
+#log dump
+mkdir -p %{buildroot}/opt/etc/dump.d/module.d/
+cp resources/opt/etc/dump.d/module.d/network_dump.sh %{buildroot}/opt/etc/dump.d/module.d/network_dump.sh
+mkdir -p %{buildroot}/opt/var/lib/net-config/
+cp resources/opt/etc/dump.d/module.d/network_dump.sh %{buildroot}/opt/var/lib/net-config/network_dump.sh
-vconftool set -t string db/wifi/bssid_address ""
+#softreset scripts
+mkdir -p %{buildroot}/usr/system/RestoreDir/softreset
+cp resources/usr/system/RestoreDir/softreset/network_softreset.sh %{buildroot}/usr/system/RestoreDir/softreset/network_softreset.sh
-#Default Call Statistics
-vconftool set -t int db/dnet/statistics/cellular/totalsnt "0"
-vconftool set -t int db/dnet/statistics/cellular/totalrcv "0"
-vconftool set -t int db/dnet/statistics/cellular/lastsnt "0"
-vconftool set -t int db/dnet/statistics/cellular/lastrcv "0"
-vconftool set -t int db/dnet/statistics/wifi/totalsnt "0"
-vconftool set -t int db/dnet/statistics/wifi/totalrcv "0"
-vconftool set -t int db/dnet/statistics/wifi/lastsnt "0"
-vconftool set -t int db/dnet/statistics/wifi/lastrcv "0"
+mv %{_builddir}/%{name}-%{version}/net-config.wearable %{buildroot}%{_bindir}
-vconftool set -t int file/private/wifi/last_power_state "0"
+%post
+chsmack -a 'System::Shared' %{_sysconfdir}/resolv.conf
+chsmack -a 'System::Shared' %{TZ_SYS_ETC}/resolv.conf
-systemctl daemon-reload
-if [ "$1" == "1" ]; then
- systemctl restart net-config.service
-fi
+#Network logs
+mkdir -p /opt/usr/data/network
+chmod 755 /opt/usr/data/network
+chown network_fw:network_fw /opt/usr/data/network
+#chsmack -a 'System' /opt/usr/data/network
+
+#Add net-config.service to systemd extra default dependency ignore list
+mkdir -p %{_sysconfdir}/systemd/default-extra-dependencies/ignore-units.d/
+ln -sf %{_libdir}/systemd/system/net-config.service %{_sysconfdir}/systemd/default-extra-dependencies/ignore-units.d/
+%if "%{?_lib}" == "lib64"
+ln -sf %{_unitdir}/net-config.service %{_sysconfdir}/systemd/default-extra-dependencies/ignore-units.d/
+%endif
+
+#systemctl daemon-reload
+#systemctl restart net-config.service
%preun
-if [ "$1" == "0" ]; then
- systemctl stop net-config.service
-fi
+#systemctl stop net-config.service
%postun
-systemctl daemon-reload
-if [ "$1" == "1" ]; then
- systemctl restart net-config.service
-fi
+#systemctl daemon-reload
+
%files
-%manifest %{name}.manifest
-%{_sbindir}/*
-%{_datadir}/dbus-1/system-services/*
-%{_sysconfdir}/dbus-1/system.d/*
-%{_unitdir}/net-config.service
-%{_unitdir}/multi-user.target.wants/net-config.service
-%{_datadir}/license/net-config
+%manifest net-config.manifest
+%attr(500,network_fw,network_fw) %{_bindir}/*
+%exclude %{_bindir}/net-config.wearable
+%attr(644,network_fw,network_fw) %{_sysconfdir}/resolv.conf
+%attr(644,network_fw,network_fw) %{TZ_SYS_ETC}/resolv.conf
+%attr(644,root,root) %{_datadir}/dbus-1/system-services/*
+#DBus DAC
+%attr(644,root,root) %{_sysconfdir}/dbus-1/system.d/*
+%attr(644,root,root) %{_libdir}/systemd/system/net-config.service
+%attr(644,root,root) %{_libdir}/systemd/system/multi-user.target.wants/net-config.service
+%attr(644,root,root) /usr/lib/tmpfiles.d/security-network-config.conf
+%if "%{?_lib}" == "lib64"
+%attr(644,root,root) %{_unitdir}/net-config.service
+%attr(644,root,root) %{_unitdir}/multi-user.target.wants/net-config.service
+%endif
+%license LICENSE
+%attr(500,root,root) /opt/etc/dump.d/module.d/network_dump.sh
+%attr(500,network_fw,network_fw) /opt/var/lib/net-config/network_dump.sh
+
+#### tv profile ####
+%post profile_tv
+mv %{_libdir}/systemd/system/net-config.service.tv %{_libdir}/systemd/system/net-config.service
+%if "%{?_lib}" == "lib64"
+mv %{_unitdir}/net-config.service.tv %{_unitdir}/net-config.service
+%endif
+
+%files profile_tv
+%attr(644,network_fw,network_fw) %{_libdir}/udev/rules.d/99-wifiusb-dev.rules
+%attr(644,root,root) %{_libdir}/systemd/system/net-config.service.tv
+%if "%{?_lib}" == "lib64"
+%attr(644,root,root) %{_unitdir}/net-config.service.tv
+%endif
+
+#### wearable profile ####
+%preun profile_wearable
+rm %{_bindir}/net-config
+
+%post profile_wearable
+pushd %{_bindir}
+mv net-config.wearable net-config
+
+%files profile_wearable
+%attr(500,network_fw,network_fw) %{_bindir}/net-config.wearable
+%attr(644,network_fw,network_fw) /usr/system/RestoreDir/softreset/network_softreset.sh
+
+#### plugin ####
+%files plugin-headed
+%manifest net-config.manifest
+%attr(500,network_fw,network_fw) %{_libdir}/net-config-plugin-headed.so
+
+%files plugin-telephony
+%manifest net-config.manifest
+%attr(500,network_fw,network_fw) %{_libdir}/net-config-plugin-telephony.so
+
+%files haltests
+%manifest net-config.manifest
+%{_bindir}/*hal_tc
+