diff options
author | Patrick McCarty <patrick.mccarty@linux.intel.com> | 2012-06-22 12:48:27 -0700 |
---|---|---|
committer | Patrick McCarty <patrick.mccarty@linux.intel.com> | 2012-06-22 17:37:35 -0700 |
commit | 4a95e692f2a57a0c273b2ce1f255be9a7ba1d2e3 (patch) | |
tree | ae17cb71a6d5373cd6475461b2521e3ba6ac816a | |
parent | 84f968378c03b36d672c2325d6bcb30502f79f88 (diff) | |
download | email-service-4a95e692f2a57a0c273b2ce1f255be9a7ba1d2e3.tar.gz email-service-4a95e692f2a57a0c273b2ce1f255be9a7ba1d2e3.tar.bz2 email-service-4a95e692f2a57a0c273b2ce1f255be9a7ba1d2e3.zip |
Add systemd service file; create initscripts and db in %install1.0_post
Signed-off-by: Patrick McCarty <patrick.mccarty@linux.intel.com>
Change-Id: Ib7f8f3eff8f4b33d0b04d24e34abeb7108fc2a07
-rw-r--r-- | packaging/email-service.changes | 4 | ||||
-rw-r--r-- | packaging/email-service.spec | 547 | ||||
-rw-r--r-- | packaging/email.service | 12 |
3 files changed, 257 insertions, 306 deletions
diff --git a/packaging/email-service.changes b/packaging/email-service.changes new file mode 100644 index 0000000..869f5e1 --- /dev/null +++ b/packaging/email-service.changes @@ -0,0 +1,4 @@ +* Fri Jun 22 2012 Patrick McCarty <patrick.mccarty@linux.intel.com> 0a6646f +- Add a service file for systemd support +- Create the initscripts and db in %install section + diff --git a/packaging/email-service.spec b/packaging/email-service.spec index cc242bb..645c617 100644 --- a/packaging/email-service.spec +++ b/packaging/email-service.spec @@ -5,11 +5,15 @@ Release: 1 Group: System/Libraries License: TBD Source0: %{name}-%{version}.tar.gz +Source1: email.service Source1001: packaging/email-service.manifest Requires(post): /sbin/ldconfig +Requires(post): systemd Requires(post): /usr/bin/sqlite3 Requires(post): /usr/bin/vconftool +Requires(preun): systemd Requires(postun): /sbin/ldconfig +Requires(postun): systemd BuildRequires: cmake BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(gthread-2.0) @@ -37,8 +41,6 @@ BuildRequires: pkgconfig(libxml-2.0) BuildRequires: pkgconfig(gconf-2.0) -BuildRoot: %{_tmppath}/%{name}-%{version}-build - %description E-mail Framework Middleware Library/Binary package @@ -64,19 +66,239 @@ export LDFLAGS="${LDFLAGS} -Wl,--hash-style=both -Wl,--rpath=%{_prefix}/lib -Wl, cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -# Call make instruction with smp support -#make %{?jobs:-j%jobs} -make +make %{?_smp_mflags} %install %make_install -%clean -rm -rf %{buildroot} +mkdir -p %{buildroot}%{_libdir}/systemd/user/tizen-middleware.target.wants +install -m 0644 %SOURCE1 %{buildroot}%{_libdir}/systemd/user/ +ln -sf ../email.service %{buildroot}%{_libdir}/systemd/user/tizen-middleware.target.wants/ + +rm -f %{buildroot}%{_bindir}/email-test-app + +# FIXME: remove initscripts after systemd is ready +mkdir -p %{buildroot}%{_sysconfdir}/rc.d/init.d +cat << EOF > %{buildroot}%{_sysconfdir}/rc.d/init.d/email-service +#!/bin/sh +/usr/bin/email-service & +EOF + +mkdir -p %{buildroot}%{_sysconfdir}/rc.d/rc3.d +mkdir -p %{buildroot}%{_sysconfdir}/rc.d/rc5.d +ln -sf ../init.d/email-service %{buildroot}%{_sysconfdir}/rc.d/rc3.d/S70email-service +ln -sf ../init.d/email-service %{buildroot}%{_sysconfdir}/rc.d/rc5.d/S70email-service + +# Remove installed DB files; these are not the ones we want +rm -f %{buildroot}/opt/dbspace/.email-service.db +rm -f %{buildroot}/opt/dbspace/.email-service.db-journal + +################################################################# +# Create DB file and tables. +################################################################# +sqlite3 %{buildroot}/opt/dbspace/.email-service.db 'PRAGMA journal_mode = PERSIST; +CREATE TABLE mail_account_tbl +( + account_bind_type INTEGER, + account_name VARCHAR(51), + receiving_server_type INTEGER, + receiving_server_addr VARCHAR(51), + email_addr VARCHAR(129), + user_name VARCHAR(51), + password VARCHAR(51), + retrieval_mode INTEGER, + port_num INTEGER, + use_security INTEGER, + sending_server_type INTEGER, + sending_server_addr VARCHAR(51), + sending_port_num INTEGER, + sending_auth INTEGER, + sending_security INTEGER, + sending_user VARCHAR(51), + sending_password VARCHAR(51), + display_name VARCHAR(31), + reply_to_addr VARCHAR(129), + return_addr VARCHAR(129), + account_id INTEGER PRIMARY KEY, + keep_on_server INTEGER, + flag1 INTEGER, + flag2 INTEGER, + pop_before_smtp INTEGER, + apop INTEGER, + logo_icon_path VARCHAR(256), + preset_account INTEGER, + target_storage INTEGER, + check_interval INTEGER, + priority INTEGER, + keep_local_copy INTEGER, + req_delivery_receipt INTEGER, + req_read_receipt INTEGER, + download_limit INTEGER, + block_address INTEGER, + block_subject INTEGER, + display_name_from VARCHAR(256), + reply_with_body INTEGER, + forward_with_files INTEGER, + add_myname_card INTEGER, + add_signature INTEGER, + signature VARCHAR(256), + add_my_address_to_bcc INTEGER, + my_account_id INTEGER, + index_color INTEGER, + sync_status INTEGER +); + +CREATE TABLE mail_attachment_tbl +( + attachment_id INTEGER PRIMARY KEY, + attachment_name VARCHAR(257), + attachment_path VARCHAR(257), + attachment_size INTEGER, + mail_id INTEGER, + account_id INTEGER, + mailbox_name VARCHAR(129), + attachment_save_status INTEGER, + attachment_drm_type INTEGER, + attachment_drm_method INTEGER, + attachment_inline_content_status INTEGER, + attachment_mime_type VARCHAR(257) +); + +CREATE TABLE mail_box_tbl +( + mailbox_id INTEGER, + account_id INTEGER, + local_yn INTEGER, + mailbox_name VARCHAR(256), + mailbox_type INTEGER, + alias VARCHAR(256), + sync_with_server_yn INTEGER, + modifiable_yn INTEGER, + total_mail_count_on_server INTEGER, + has_archived_mails INTEGER, + mail_slot_size INTEGER +); +CREATE TABLE mail_read_mail_uid_tbl +( + account_id INTEGER , + local_mbox VARCHAR(129) , + local_uid INTEGER , + mailbox_name VARCHAR(129) , + s_uid VARCHAR(129) , + data1 INTEGER , + data2 VARCHAR(257) , + flag INTEGER , + idx_num INTEGER PRIMARY KEY +); +CREATE TABLE mail_rule_tbl +( + account_id INTEGER , + rule_id INTEGER PRIMARY KEY, + type INTEGER , + value VARCHAR(257) , + action_type INTEGER , + dest_mailbox VARCHAR(129), + flag1 INTEGER , + flag2 INTEGER +); +CREATE TABLE mail_tbl +( + mail_id INTEGER PRIMARY_KEY, + account_id INTEGER, + mailbox_id INTEGER, + mailbox_name VARCHAR(129), + mailbox_type INTEGER, + subject TEXT, + date_time DATETIME, + server_mail_status INTEGER, + server_mailbox_name VARCHAR(129), + server_mail_id VARCHAR(129), + message_id VARCHAR(257), + full_address_from TEXT, + full_address_reply TEXT, + full_address_to TEXT, + full_address_cc TEXT, + full_address_bcc TEXT, + full_address_return TEXT, + email_address_sender TEXT collation user1, + email_address_recipient TEXT collation user1, + alias_sender TEXT, + alias_recipient TEXT, + body_download_status INTEGER, + file_path_plain VARCHAR(257), + file_path_html VARCHAR(257), + mail_size INTEGER, + flags_seen_field BOOLEAN, + flags_deleted_field BOOLEAN, + flags_flagged_field BOOLEAN, + flags_answered_field BOOLEAN, + flags_recent_field BOOLEAN, + flags_draft_field BOOLEAN, + flags_forwarded_field BOOLEAN, + DRM_status INTEGER, + priority INTEGER, + save_status INTEGER, + lock_status INTEGER, + report_status INTEGER, + attachment_count INTEGER, + inline_content_count INTEGER, + thread_id INTEGER, + thread_item_count INTEGER, + preview_text TEXT, + meeting_request_status INTEGER, + FOREIGN KEY(account_id) REFERENCES mail_account_tbl(account_id) +); +CREATE TABLE mail_meeting_tbl +( + mail_id INTEGER PRIMARY KEY, + account_id INTEGER, + mailbox_name TEXT , + meeting_response INTEGER, + start_time INTEGER, + end_time INTEGER, + location TEXT , + global_object_id TEXT , + offset INTEGER, + standard_name TEXT , + standard_time_start_date INTEGER, + standard_bias INTEGER, + daylight_name TEXT , + daylight_time_start_date INTEGER, + daylight_bias INTEGER +); +CREATE TABLE mail_local_activity_tbl +( + activity_id INTEGER, + account_id INTEGER, + mail_id INTEGER, + activity_type INTEGER, + server_mailid VARCHAR(129), + src_mbox VARCHAR(129), + dest_mbox VARCHAR(129) +); + + +CREATE UNIQUE INDEX mail_account_idx1 ON mail_account_tbl (account_bind_type, account_id); +CREATE UNIQUE INDEX mail_attachment_idx1 ON mail_attachment_tbl (mail_id, attachment_id); +CREATE UNIQUE INDEX mail_box_idx1 ON mail_box_tbl (account_id, local_yn, mailbox_name); +CREATE UNIQUE INDEX mail_idx1 ON mail_tbl (mail_id, account_id); +CREATE UNIQUE INDEX mail_read_mail_uid_idx1 ON mail_read_mail_uid_tbl (account_id, local_mbox, local_uid, mailbox_name, s_uid); +CREATE UNIQUE INDEX mail_meeting_idx1 ON mail_meeting_tbl (mail_id); +CREATE INDEX mail_idx_date_time ON mail_tbl (date_time); +CREATE INDEX mail_idx_thread_item_count ON mail_tbl (thread_item_count); +' + +%preun +if [ $1 == 0]; then + systemctl stop email.service +fi %post /sbin/ldconfig - +systemctl daemon-reload +if [ $1 == 1 ]; then + systemctl restart email.service +fi ################################################################# # Add preset account information @@ -341,313 +563,26 @@ vconftool set -t int db/badge/com.samsung.email "0" echo "[EMAIL-SERVICE] Finish adding preset account information" -################################################################# -# Set executin script -################################################################# -echo "[EMAIL-SERVICE] Set executing script ..." -EMAIL_SERVICE_EXEC_SCRIPT=/etc/rc.d/init.d/email-service -EMAIL_SERVICE_BOOT_SCRIPT=/etc/rc.d/rc3.d/S70email-service -EMAIL_SERVICE_FASTBOOT_SCRIPT=/etc/rc.d/rc5.d/S70email-service -echo '#!/bin/sh' > ${EMAIL_SERVICE_EXEC_SCRIPT} -echo '/usr/bin/email-service &' >> ${EMAIL_SERVICE_EXEC_SCRIPT} -chmod 755 ${EMAIL_SERVICE_EXEC_SCRIPT} -rm -rf ${EMAIL_SERVICE_BOOT_SCRIPT} -rm -rf ${EMAIL_SERVICE_FASTBOOT_SCRIPT} -ln -s ${EMAIL_SERVICE_EXEC_SCRIPT} ${EMAIL_SERVICE_BOOT_SCRIPT} -ln -s ${EMAIL_SERVICE_EXEC_SCRIPT} ${EMAIL_SERVICE_FASTBOOT_SCRIPT} -echo "[EMAIL-SERVICE] Finish executing script ..." - -################################################################# -# Create DB file and tables. -################################################################# -echo "[EMAIL-SERVICE] Creating Email Tables ..." -sqlite3 /opt/dbspace/.email-service.db 'PRAGMA journal_mode = PERSIST; -CREATE TABLE mail_account_tbl -( - account_bind_type INTEGER, - account_name VARCHAR(51), - receiving_server_type INTEGER, - receiving_server_addr VARCHAR(51), - email_addr VARCHAR(129), - user_name VARCHAR(51), - password VARCHAR(51), - retrieval_mode INTEGER, - port_num INTEGER, - use_security INTEGER, - sending_server_type INTEGER, - sending_server_addr VARCHAR(51), - sending_port_num INTEGER, - sending_auth INTEGER, - sending_security INTEGER, - sending_user VARCHAR(51), - sending_password VARCHAR(51), - display_name VARCHAR(31), - reply_to_addr VARCHAR(129), - return_addr VARCHAR(129), - account_id INTEGER PRIMARY KEY, - keep_on_server INTEGER, - flag1 INTEGER, - flag2 INTEGER, - pop_before_smtp INTEGER, - apop INTEGER, - logo_icon_path VARCHAR(256), - preset_account INTEGER, - target_storage INTEGER, - check_interval INTEGER, - priority INTEGER, - keep_local_copy INTEGER, - req_delivery_receipt INTEGER, - req_read_receipt INTEGER, - download_limit INTEGER, - block_address INTEGER, - block_subject INTEGER, - display_name_from VARCHAR(256), - reply_with_body INTEGER, - forward_with_files INTEGER, - add_myname_card INTEGER, - add_signature INTEGER, - signature VARCHAR(256), - add_my_address_to_bcc INTEGER, - my_account_id INTEGER, - index_color INTEGER, - sync_status INTEGER -); - -CREATE TABLE mail_attachment_tbl -( - attachment_id INTEGER PRIMARY KEY, - attachment_name VARCHAR(257), - attachment_path VARCHAR(257), - attachment_size INTEGER, - mail_id INTEGER, - account_id INTEGER, - mailbox_name VARCHAR(129), - attachment_save_status INTEGER, - attachment_drm_type INTEGER, - attachment_drm_method INTEGER, - attachment_inline_content_status INTEGER, - attachment_mime_type VARCHAR(257) -); - -CREATE TABLE mail_box_tbl -( - mailbox_id INTEGER, - account_id INTEGER, - local_yn INTEGER, - mailbox_name VARCHAR(256), - mailbox_type INTEGER, - alias VARCHAR(256), - sync_with_server_yn INTEGER, - modifiable_yn INTEGER, - total_mail_count_on_server INTEGER, - has_archived_mails INTEGER, - mail_slot_size INTEGER -); -CREATE TABLE mail_read_mail_uid_tbl -( - account_id INTEGER , - local_mbox VARCHAR(129) , - local_uid INTEGER , - mailbox_name VARCHAR(129) , - s_uid VARCHAR(129) , - data1 INTEGER , - data2 VARCHAR(257) , - flag INTEGER , - idx_num INTEGER PRIMARY KEY -); -CREATE TABLE mail_rule_tbl -( - account_id INTEGER , - rule_id INTEGER PRIMARY KEY, - type INTEGER , - value VARCHAR(257) , - action_type INTEGER , - dest_mailbox VARCHAR(129), - flag1 INTEGER , - flag2 INTEGER -); -CREATE TABLE mail_tbl -( - mail_id INTEGER PRIMARY_KEY, - account_id INTEGER, - mailbox_id INTEGER, - mailbox_name VARCHAR(129), - mailbox_type INTEGER, - subject TEXT, - date_time DATETIME, - server_mail_status INTEGER, - server_mailbox_name VARCHAR(129), - server_mail_id VARCHAR(129), - message_id VARCHAR(257), - full_address_from TEXT, - full_address_reply TEXT, - full_address_to TEXT, - full_address_cc TEXT, - full_address_bcc TEXT, - full_address_return TEXT, - email_address_sender TEXT collation user1, - email_address_recipient TEXT collation user1, - alias_sender TEXT, - alias_recipient TEXT, - body_download_status INTEGER, - file_path_plain VARCHAR(257), - file_path_html VARCHAR(257), - mail_size INTEGER, - flags_seen_field BOOLEAN, - flags_deleted_field BOOLEAN, - flags_flagged_field BOOLEAN, - flags_answered_field BOOLEAN, - flags_recent_field BOOLEAN, - flags_draft_field BOOLEAN, - flags_forwarded_field BOOLEAN, - DRM_status INTEGER, - priority INTEGER, - save_status INTEGER, - lock_status INTEGER, - report_status INTEGER, - attachment_count INTEGER, - inline_content_count INTEGER, - thread_id INTEGER, - thread_item_count INTEGER, - preview_text TEXT, - meeting_request_status INTEGER, - FOREIGN KEY(account_id) REFERENCES mail_account_tbl(account_id) -); -CREATE TABLE mail_meeting_tbl -( - mail_id INTEGER PRIMARY KEY, - account_id INTEGER, - mailbox_name TEXT , - meeting_response INTEGER, - start_time INTEGER, - end_time INTEGER, - location TEXT , - global_object_id TEXT , - offset INTEGER, - standard_name TEXT , - standard_time_start_date INTEGER, - standard_bias INTEGER, - daylight_name TEXT , - daylight_time_start_date INTEGER, - daylight_bias INTEGER -); -CREATE TABLE mail_local_activity_tbl -( - activity_id INTEGER, - account_id INTEGER, - mail_id INTEGER, - activity_type INTEGER, - server_mailid VARCHAR(129), - src_mbox VARCHAR(129), - dest_mbox VARCHAR(129) -); - - -CREATE UNIQUE INDEX mail_account_idx1 ON mail_account_tbl (account_bind_type, account_id); -CREATE UNIQUE INDEX mail_attachment_idx1 ON mail_attachment_tbl (mail_id, attachment_id); -CREATE UNIQUE INDEX mail_box_idx1 ON mail_box_tbl (account_id, local_yn, mailbox_name); -CREATE UNIQUE INDEX mail_idx1 ON mail_tbl (mail_id, account_id); -CREATE UNIQUE INDEX mail_read_mail_uid_idx1 ON mail_read_mail_uid_tbl (account_id, local_mbox, local_uid, mailbox_name, s_uid); -CREATE UNIQUE INDEX mail_meeting_idx1 ON mail_meeting_tbl (mail_id); -CREATE INDEX mail_idx_date_time ON mail_tbl (date_time); -CREATE INDEX mail_idx_thread_item_count ON mail_tbl (thread_item_count); -' - -echo "[EMAIL-SERVICE] Finish Creating Email Tables." - - -################################################################# -# Change file permission -################################################################# -#echo "[EMAIL-SERVICE] Start setting permission ..." -# 1. libraries -#chmod 644 /usr/lib/libemail-ipc.so.0.0.0 -#chmod 644 /usr/lib/libemail-core.so.0.0.0 -#chmod 644 /usr/lib/libemail-emn-storage.so.0.0.0 -#chmod 644 /usr/lib/libemail-base.so.0.0.0 -#chmod 644 /usr/lib/libem-storage.so.0.0.0 -#chmod 644 /usr/lib/libem-network.so.0.0.0 -#chmod 644 /usr/lib/libemail-mapi.so.0.0.0 -#chmod 644 /usr/lib/libem-storage.so -#chmod 644 /usr/lib/libemail-base.so.0 -#chmod 644 /usr/lib/libem-network.so.0 -#chmod 644 /usr/lib/libemail-core.so.0 -#chmod 644 /usr/lib/libemail-emn-storage.so -#chmod 644 /usr/lib/libemail-ipc.so -#chmod 644 /usr/lib/libemail-mapi.so.0 -#chmod 644 /usr/lib/libem-storage.so.0 -#chmod 644 /usr/lib/libem-network.so -#chmod 644 /usr/lib/libemail-ipc.so.0 -#chmod 644 /usr/lib/libemail-core.so -#chmod 644 /usr/lib/libemail-base.so -#chmod 644 /usr/lib/libemail-mapi.so -#chmod 644 /usr/lib/libemail-emn-storage.so.0 - -# 2. executables -#chmod 700 /usr/bin/email-service_initDB -#chmod 700 /usr/bin/email-service - -# 3. DB files -chmod 644 /opt/dbspace/.email-service.db -chmod 644 /opt/dbspace/.email-service.db-journal - - -################################################################# -# Change file owner -################################################################# -#echo "[EMAIL-SERVICE] Start setting owner ..." - - # 1. libraries -# chown root:root /usr/lib/libemail-ipc.so.0.0.0 -# chown root:root /usr/lib/libemail-core.so.0.0.0 -# chown root:root /usr/lib/libemail-emn-storage.so.0.0.0 -# chown root:root /usr/lib/libemail-base.so.0.0.0 -# chown root:root /usr/lib/libem-storage.so.0.0.0 -# chown root:root /usr/lib/libem-network.so.0.0.0 -# chown root:root /usr/lib/libemail-mapi.so.0.0.0 -# chown root:root /usr/lib/libem-storage.so -# chown root:root /usr/lib/libemail-base.so.0 -# chown root:root /usr/lib/libem-network.so.0 -# chown root:root /usr/lib/libemail-core.so.0 -# chown root:root /usr/lib/libemail-emn-storage.so -# chown root:root /usr/lib/libemail-ipc.so -# chown root:root /usr/lib/libemail-mapi.so.0 -# chown root:root /usr/lib/libem-storage.so.0 -# chown root:root /usr/lib/libem-network.so -# chown root:root /usr/lib/libemail-ipc.so.0 -# chown root:root /usr/lib/libemail-core.so -# chown root:root /usr/lib/libemail-base.so -# chown root:root /usr/lib/libemail-mapi.so -# chown root:root /usr/lib/libemail-emn-storage.so.0 - - # 2. executables -# chown root:root /usr/bin/email-service_initDB -# chown root:root /usr/bin/email-service - - # 3. DB files -#if [ ${USER} = "root" ] -#then - chown root:root /opt/dbspace/.email-service.db - chown root:root /opt/dbspace/.email-service.db-journal -#fi - -%postun -p /sbin/ldconfig +%postun +/sbin/ldconfig +systemctl daemon-reload %files %manifest email-service.manifest -%exclude /opt/dbspace/.email-service.db -%exclude /opt/dbspace/.email-service.db-journal -%exclude /usr/bin/email-test-app -%{_libdir}/lib*.so.* +%attr(0755,root,root) %{_sysconfdir}/rc.d/init.d/email-service +%{_sysconfdir}/rc.d/rc3.d/S70email-service +%{_sysconfdir}/rc.d/rc5.d/S70email-service +%config(noreplace) %attr(0644,root,root) /opt/dbspace/.email-service.db +%config(noreplace) %attr(0644,root,root) /opt/dbspace/.email-service.db-journal %{_bindir}/email-service - +%{_libdir}/lib*.so.* +%{_libdir}/systemd/user/email.service +%{_libdir}/systemd/user/tizen-middleware.target.wants/email.service %files devel %manifest email-service.manifest %{_includedir}/email-service/*.h %{_libdir}/lib*.so %{_libdir}/pkgconfig/*.pc - - diff --git a/packaging/email.service b/packaging/email.service new file mode 100644 index 0000000..8d0cf15 --- /dev/null +++ b/packaging/email.service @@ -0,0 +1,12 @@ + +[Unit] +Description=Start the Email service + +[Service] +ExecStart=/usr/bin/email-service +Nice=5 +OOMScoreAdjust=100 + +[Install] +WantedBy=tizen-middleware.target + |