summaryrefslogtreecommitdiff
path: root/recipes-support/libpwquality/libpwquality_%.bbappend
blob: 910929e88d08687f149d214f637396c114469ea9 (plain)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
SUMMARY = "Library for password quality checking and generating random passwords"
HOMEPAGE = "https://launchpad.net/libpwquality"
LICENSE = "GPLv2+"
LIC_FILES_CHKSUM = "file://COPYING;md5=6bd2f1386df813a459a0c34fde676fc2"
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"

SRC_URI += "\
	   file://pwquality_conf.patch \
	   file://pam.configure \
	  "

do_install_append() {
    install -d -m755 ${D}/${datadir_native}/${PN}
    install ${WORKDIR}/pam.configure ${D}/${datadir_native}/${PN}
}

# The postinstall installs libpwquality into PAM.
# The prerm removes libpwquatlity from PAM.
# The file we change is /etc/pam.d/common-password,
# which is a configuration file for libpam-runtime.
# We ignore failures in the post-install and pre-remove.
# so if the patch does not apply, pam will not use us.
pkg_postinst_${PN}() {
    PAM_CONFIGURE="/${datadir_native}/${PN}/pam.configure"
    if [[ -n $D ]] ; then
        LOG='printf %s\n'
        PAM_CONFIGURE="$D${PAM_CONFIGURE}"
        cd $D
    else
        LOG="logger -s -p user.info -t opkg\ libpwquality"
        cd /
    fi
    # -N busybox option for patch is broken
    if patch --dry-run -p1 < "$PAM_CONFIGURE" ; then
        logsave=$(patch -p1 < "$PAM_CONFIGURE" 2>&1 || true)
        if [[ -n ${logsave} ]] ; then
            ${LOG} "In directory $(pwd)"
            ${LOG} "patch -p1 < $PAM_CONFIGURE"
            ${LOG} "${PN} patch: ${logsave}"
        fi
    fi
}

pkg_prerm_${PN}() {
    PAM_CONFIGURE="/${datadir_native}/${PN}/pam.configure"
    if [[ -n $D ]] ; then
        LOG='printf %s\n'
        PAM_CONFIGURE="$D${PAM_CONFIGURE}"
        cd $D
    else
        LOG="logger -s -p user.info -t opkg\ libpwquality"
        cd /
    fi
    logsave=$(patch -p1 -R < "$PAM_CONFIGURE" 2>&1 || true)
    if [[ -n ${logsave} ]] ; then
        ${LOG} "In directory $(pwd)"
        ${LOG} "patch -p1 -R < "$PAM_CONFIGURE""
        ${LOG} "${PN} remove patch: ${logsave}"
    fi
}