Merge "Change db owner root to app_fw" into tizen
[platform/core/appfw/badge.git] / packaging / badge.spec
1 Name:       badge
2 Summary:    Badge library
3 Version:    0.0.16
4 Release:    1
5 Group:      Applications/Core Applications
6 License:    Apache-2.0
7 Source0:    %{name}-%{version}.tar.gz
8 BuildRequires: pkgconfig(aul)
9 BuildRequires: pkgconfig(dbus-1)
10 BuildRequires: pkgconfig(dbus-glib-1)
11 BuildRequires: pkgconfig(dlog)
12 BuildRequires: pkgconfig(vconf)
13 BuildRequires: pkgconfig(capi-appfw-package-manager)
14 BuildRequires: pkgconfig(db-util)
15 BuildRequires: pkgconfig(libtzplatform-config)
16 BuildRequires: cmake
17 Requires(post): /sbin/ldconfig
18 requires(postun): /sbin/ldconfig
19 %description
20 Client/Server library for updating badge information
21
22 %prep
23 %setup -q
24
25 %package devel
26 Summary:    Badge library (devel)
27 Group:      Development/Libraries
28 Requires:   %{name} = %{version}-%{release}
29
30 %description devel
31 Development files needed to build software that needs to system a system badge.
32
33 %package service-devel
34 Summary:    Badge library (service-devel)
35 Group:      Development/Libraries
36 Requires:   %{name} = %{version}-%{release}
37
38 %description service-devel
39 Development files needed to build badge service
40
41 %build
42 %if 0%{?tizen_build_binary_release_type_eng}
43 export CFLAGS="$CFLAGS -DTIZEN_ENGINEER_MODE"
44 export CXXFLAGS="$CXXFLAGS -DTIZEN_ENGINEER_MODE"
45 export FFLAGS="$FFLAGS -DTIZEN_ENGINEER_MODE"
46 %endif
47 %if 0%{?sec_build_binary_debug_enable}
48 export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE"
49 export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE"
50 export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE"
51 %endif
52 export LDFLAGS+="-Wl,--rpath=%{_prefix}/lib -Wl,--as-needed"
53 LDFLAGS="$LDFLAGS" %cmake .
54 make %{?jobs:-j%jobs}
55
56 %install
57 %make_install
58
59 mkdir -p %{buildroot}/usr/share/license
60 cp -f LICENSE %{buildroot}/usr/share/license/%{name}
61
62
63 %post
64 /sbin/ldconfig
65
66 if [ ! -d %{TZ_SYS_DB} ]
67 then
68         mkdir -p %{TZ_SYS_DB}
69 fi
70
71 if [ ! -f %{TZ_SYS_DB}/.%{name}.db ]
72 then
73         sqlite3 %{TZ_SYS_DB}/.%{name}.db 'PRAGMA journal_mode = PERSIST;
74                 create table if not exists badge_data (
75                         pkgname TEXT NOT NULL,
76                         writable_pkgs TEXT,
77                         badge INTEGER default 0,
78                         rowid INTEGER PRIMARY KEY AUTOINCREMENT,
79                         UNIQUE (pkgname)
80                 );
81                 create table if not exists badge_option (
82                         pkgname TEXT NOT NULL,
83                         display INTEGER default 1,
84                         UNIQUE (pkgname)
85                 );
86         '
87 fi
88
89 chown app_fw:app_fw %{TZ_SYS_DB}/.%{name}.db
90 chown app_fw:app_fw %{TZ_SYS_DB}/.%{name}.db-journal
91 chmod 644 %{TZ_SYS_DB}/.%{name}.db
92 chmod 644 %{TZ_SYS_DB}/.%{name}.db-journal
93
94 %postun -p /sbin/ldconfig
95
96 %files
97 %manifest badge.manifest
98 %defattr(-,root,root,-)
99 %{_libdir}/libbadge.so*
100 %{_datarootdir}/license/%{name}
101 %{_includedir}/badge/badge.h
102 %{_includedir}/badge/badge_error.h
103 %{_includedir}/badge/badge_internal.h
104
105 %files devel
106 %defattr(-,root,root,-)
107 %{_includedir}/badge/badge.h
108 %{_includedir}/badge/badge_error.h
109 %{_includedir}/badge/badge_internal.h
110 %{_includedir}/badge/badge_db.h
111 %{_includedir}/badge/badge_setting_service.h
112 %{_libdir}/pkgconfig/%{name}.pc