From 605fec8877021a9a5da91a99c047ebcd1e688cd9 Mon Sep 17 00:00:00 2001
From: Michael Vogt <michael.vogt@ubuntu.com>
Date: Mon, 1 Jun 2015 12:54:27 +0200
Subject: [PATCH] * live-build/ubuntu-core/hooks/90_pecompile-apparmor.chroot: 
  - generate /etc/apparmod.d/cache files during image build to     avoid
 out-of-sync issue with profiles and cache (LP: #1460152)

---
 debian/changelog                                    |  8 ++++++++
 .../ubuntu-core/hooks/90_precompile-apparmor.chroot | 13 +++++++++++++
 2 files changed, 21 insertions(+)
 create mode 100644 live-build/ubuntu-core/hooks/90_precompile-apparmor.chroot

diff --git a/debian/changelog b/debian/changelog
index 8d9d2cc8..4e92bb78 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+livecd-rootfs (2.307) UNRELEASED; urgency=low
+
+  * live-build/ubuntu-core/hooks/90_pecompile-apparmor.chroot:
+    - generate /etc/apparmod.d/cache files during image build to
+      avoid out-of-sync issue with profiles and cache (LP: #1460152)
+
+ -- Michael Vogt <michael.vogt@ubuntu.com>  Mon, 01 Jun 2015 12:53:22 +0200
+
 livecd-rootfs (2.306) wily; urgency=medium
 
   * Create hooks and image build config for the ubuntu-desktop-next
diff --git a/live-build/ubuntu-core/hooks/90_precompile-apparmor.chroot b/live-build/ubuntu-core/hooks/90_precompile-apparmor.chroot
new file mode 100644
index 00000000..7a3771d1
--- /dev/null
+++ b/live-build/ubuntu-core/hooks/90_precompile-apparmor.chroot
@@ -0,0 +1,13 @@
+#!/bin/sh
+#
+# similar to
+#   live-build/ubuntu-touch/hooks/90-precompile-apparmor-policies.chroot 
+# but we only care about the system apparmor (see LP: #1460152)
+
+set -e
+
+FEATURES=/var/cache/apparmor/.features
+
+echo "I: precompiling deb apparmor policies"
+/sbin/apparmor_parser -M ${FEATURES} -Q --write-cache --cache-loc=/etc/apparmor.d/cache/ $(find /etc/apparmor.d/ -maxdepth 1 -type f -not -path '*/\.*')
+