post: dbus: add script for dbus policy serializer
[platform/upstream/meta-generic.git] / scripts / generic-dbus-policychecker.post
1 #!/bin/sh
2 echo "#################### generic-dbus-policychecker.post ####################"
3 if [ -x /usr/bin/dbus-policychecker ] ; then
4         fail_cnt=0
5         for f in /etc/dbus-1/system.d/*.conf; do
6                 echo
7                 echo "$0: Checking D-Bus policy file: $f"
8                 result=$(/usr/bin/dbus-policychecker "$f")
9                 fail=$(echo "$result" | grep FAILED | wc -l)
10                 echo "$result"
11                 if [ $fail -gt 0 ]; then
12                         echo "Found $fail Fails"
13                         echo "Remove conf file : mv $f $f.fail"
14                         mv "$f" "${f}.fail"
15                         fail_cnt=$(( ${fail_cnt} + 1 ))
16                 fi
17         done
18         if [ $fail_cnt -gt 0 ]; then
19                 echo "Error: MIC build exits due to failed cases on dbus policy checker.(${fail_cnt} errors)"
20                 exit 1
21         fi
22
23 fi
24
25 if [ -x /usr/bin/dbuspolicyserializer ] ; then
26         echo "#################### generic-dbus-policyserializer ####################"
27         echo
28         echo "$0: Serializing system.conf:"
29         dbuspolicyserializer --system
30         echo "$0: Serializing session.conf:"
31         dbuspolicyserializer --session
32 fi