File: sa-compile.postinst

package info (click to toggle)
spamassassin 4.0.2-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 25,724 kB
  • sloc: perl: 89,143; ansic: 5,193; sh: 3,737; javascript: 339; sql: 295; makefile: 209; python: 49
file content (46 lines) | stat: -rw-r--r-- 1,186 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/sh

set -e

umask 022
output_dir="/var/lib/spamassassin/compiled"

sa_compile() {
    OWNER=$(stat -c '%U' /var/lib/spamassassin)
    GROUP=$(stat -c '%G' /var/lib/spamassassin)
    if [ -x /usr/bin/re2c -a -x /usr/bin/sa-compile ]; then
        echo "Running sa-compile (may take a long time)"
        if [ -d "$output_dir" ]; then
            rm -rf "$output_dir"
        fi

        env -i LANG="$LANG" PATH="$PATH" http_proxy="$http_proxy" \
            OWNER="$OWNER" GROUP="$GROUP" \
            runuser -u "$OWNER" --group "$GROUP" -- \
            /usr/bin/sa-compile --quiet
        # Fixup perms -- group and other should be able to
        # read and execute, but never write.  Works around
        # sa-compile's failure to obey umask.
        if [ -d "$output_dir" ]; then
            runuser -u $OWNER -- \
                chmod -R go-w,go+rX "$output_dir"
        fi
        dpkg-trigger --no-await sa-compile-upgrade
    fi
}

if [ "$1" = "configure" ]; then
    sa_compile
fi

if [ "$1" = "triggered" ] && [ "$2" = "perl-major-upgrade" ]; then
    sa_compile
fi

#DEBHELPER#

# Local variables:
# mode: shell-script
# tab-width: 4
# indent-tabs-mode: nil
# end: