[Groonga-mysql-commit] mroonga/mroonga [master] [debian] fix install error on Lucid.

アーカイブの一覧に戻る

null+****@clear***** null+****@clear*****
2011年 9月 3日 (土) 18:57:33 JST


Kouhei Sutou	2011-09-03 09:57:33 +0000 (Sat, 03 Sep 2011)

  New Revision: f64e63f04c8aa9fd0e707633f9aeb92f66fee85a

  Log:
    [debian] fix install error on Lucid.
    
    Reported by Isao Sugimoto. Thanks!!!

  Modified files:
    debian/mysql-server-groonga.postinst
    debian/mysql-server-groonga.postrm

  Modified: debian/mysql-server-groonga.postinst (+49 -28)
===================================================================
--- debian/mysql-server-groonga.postinst    2011-09-02 01:47:31 +0000 (6442261)
+++ debian/mysql-server-groonga.postinst    2011-09-03 09:57:33 +0000 (42fe364)
@@ -6,38 +6,42 @@ prevver="$2"
 
 install_plugin() {
     cat <<EOS | mysql --defaults-file=/etc/mysql/debian.cnf || true
-if (!`SELECT 1 FROM information_schema.plugins WHERE plugin_name="groonga"`)
-{
-  INSTALL PLUGIN groonga SONAME 'ha_groonga.so';
-  CREATE FUNCTION last_insert_grn_id RETURNS INTEGER soname 'ha_groonga.so';
-}
+INSTALL PLUGIN groonga SONAME 'ha_groonga.so';
+CREATE FUNCTION last_insert_grn_id RETURNS INTEGER soname 'ha_groonga.so';
 EOS
 }
 
-case "$1" in
-    configure)
-        install_plugin
-        ;;
-    abort-upgrade|abort-deconfigure|abort-remove)
-        :
-        ;;
-    *)
-        echo "Called with unknown argument $1, bailing out."
-        exit 1
-        ;;
-esac
-
-mysql_apparmor_profile_name=usr.sbin.mysqld
-mysql_apparmor_profile=/etc/apparmor.d/${mysql_apparmor_profile_name}
-mysql_local_apparmor_profile=/etc/apparmor.d/local/${mysql_apparmor_profile_name}
-if test -f "${mysql_local_apparmor_profile}"; then
+install_apparmor() {
+    mysql_apparmor_profile_name=usr.sbin.mysqld
+    mysql_apparmor_profile=/etc/apparmor.d/${mysql_apparmor_profile_name}
+    mysql_local_apparmor_profile=/etc/apparmor.d/local/${mysql_apparmor_profile_name}
     apparmor_profile_name=mysql-server-groonga
     include_profile="#include <abstractions/${apparmor_profile_name}>"
-    if ! grep -q "${include_profile}" "${mysql_local_apparmor_profile}"; then
-	echo >> "${mysql_local_apparmor_profile}"
-	echo "${include_profile}" >> "${mysql_local_apparmor_profile}"
-    fi
     local_apparmor_profile=/etc/apparmor.d/local/${apparmor_profile_name}
+    if test -f "${mysql_local_apparmor_profile}"; then
+	if ! grep -q "${include_profile}" "${mysql_local_apparmor_profile}"; then
+	    echo >> "${mysql_local_apparmor_profile}"
+	    echo "${include_profile}" >> "${mysql_local_apparmor_profile}"
+	fi
+    else
+	mysql_abstraction_apparmor_profile=/etc/apparmor.d/abstractions/mysql
+	mysql_plugin_dir=/usr/lib/mysql/plugin
+	if test -f "${mysql_abstraction_apparmor_profile}" && \
+	    ! grep -q "${mysql_plugin_dir}" \
+	      "${mysql_abstraction_apparmor_profile}"; then
+            # For Lucid.
+	    cat <<EOF >> "${mysql_abstraction_apparmor_profile}"
+
+# ${apparmor_profile_name}: START
+# Added by mysql-server-groonga.
+${mysql_plugin_dir}/ r,
+${mysql_plugin_dir}/*.so* mr,
+${include_profile}
+# ${apparmor_profile_name}: END
+EOF
+	fi
+    fi
+
     if ! test -e "$local_apparmor_profile"; then
 	mkdir -p $(dirname "$local_apparmor_profile")
 	cat <<EOF > "$local_apparmor_profile"
@@ -45,9 +49,26 @@ if test -f "${mysql_local_apparmor_profile}"; then
 # For more details, please see /etc/apparmor.d/local/README.
 EOF
     fi
+
     if aa-status --enabled 2>/dev/null; then
-        apparmor_parser -r -T -W "${mysql_apparmor_profile}" || true
+	apparmor_parser -r -T -W "${mysql_apparmor_profile}" || true
     fi
-fi
+
+    true
+}
+
+case "$1" in
+    configure)
+	install_apparmor
+        install_plugin
+        ;;
+    abort-upgrade|abort-deconfigure|abort-remove)
+        :
+        ;;
+    *)
+        echo "Called with unknown argument $1, bailing out."
+        exit 1
+        ;;
+esac
 
 #DEBHELPER#

  Modified: debian/mysql-server-groonga.postrm (+12 -5)
===================================================================
--- debian/mysql-server-groonga.postrm    2011-09-02 01:47:31 +0000 (cc47aad)
+++ debian/mysql-server-groonga.postrm    2011-09-03 09:57:33 +0000 (fc14bb5)
@@ -3,17 +3,15 @@
 set -e
 
 cat <<EOS | mysql --defaults-file=/etc/mysql/debian.cnf || true
-if (`SELECT 1 FROM information_schema.plugins WHERE plugin_name="groonga"`)
-{
-  DROP FUNCTION last_insert_grn_id;
-  UNINSTALL PLUGIN groonga;
-}
+DROP FUNCTION last_insert_grn_id;
+UNINSTALL PLUGIN groonga;
 EOS
 
 if [ "$1" = "purge" ]; then
     mysql_apparmor_profile_name=usr.sbin.mysqld
     mysql_apparmor_profile=/etc/apparmor.d/${mysql_apparmor_profile_name}
     mysql_local_apparmor_profile=/etc/apparmor.d/local/${mysql_apparmor_profile_name}
+    mysql_abstraction_apparmor_profile=/etc/apparmor.d/abstractions/mysql
     apparmor_profile_name=mysql-server-groonga
     if test -f "${mysql_local_apparmor_profile}"; then
 	include_profile="#include <abstractions/${apparmor_profile_name}>"
@@ -21,6 +19,15 @@ if [ "$1" = "purge" ]; then
 	    sed -i'' -e "s,${include_profile},," \
 		"${mysql_local_apparmor_profile}"
 	fi
+    else
+	start_marker_re="^# ${apparmor_profile_name}: START$"
+	end_marker_re="^# ${apparmor_profile_name}: END$"
+	if test -f "${mysql_abstraction_apparmor_profile}" && \
+	    grep -q "${start_marker_re}" \
+	      "${mysql_abstraction_apparmor_profile}"; then
+	    sed -i'' -e "/${start_marker_re}/,/${end_marker_re}/d" \
+		"${mysql_abstraction_apparmor_profile}"
+	fi
     fi
 
     rm -f "/etc/apparmor.d/local/${apparmor_profile_name}" || true




Groonga-mysql-commit メーリングリストの案内
アーカイブの一覧に戻る