blob: 10457b2decca594cf7bf66e15689394d7789c501 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001SUMMARY = "Base system master password/group files"
2DESCRIPTION = "The master copies of the user database files (/etc/passwd and /etc/group). The update-passwd tool is also provided to keep the system databases synchronized with these master files."
3SECTION = "base"
4LICENSE = "GPLv2+"
5LIC_FILES_CHKSUM = "file://COPYING;md5=eb723b61539feef013de476e68b5c50a"
6
7RECIPE_NO_UPDATE_REASON = "Version 3.5.38 requires cdebconf for update-passwd utility"
8
9SRC_URI = "https://launchpad.net/debian/+archive/primary/+files/${BPN}_${PV}.tar.gz \
10 file://add_shutdown.patch \
11 file://nobash.patch \
12 file://noshadow.patch \
13 file://input.patch \
14 file://disable-docs.patch \
15 "
16
17SRC_URI[md5sum] = "6beccac48083fe8ae5048acd062e5421"
18SRC_URI[sha256sum] = "f0b66388b2c8e49c15692439d2bee63bcdd4bbbf7a782c7f64accc55986b6a36"
19
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050020# the package is taken from launchpad; that source is static and goes stale
21# so we check the latest upstream from a directory that does get updated
22UPSTREAM_CHECK_URI = "${DEBIAN_MIRROR}/main/b/base-passwd/"
23
Patrick Williamsc124f4f2015-09-15 14:41:29 -050024inherit autotools
25
26SSTATEPOSTINSTFUNCS += "base_passwd_sstate_postinst"
27
28do_install () {
29 install -d -m 755 ${D}${sbindir}
30 install -o root -g root -p -m 755 ${B}/update-passwd ${D}${sbindir}/
31 install -d -m 755 ${D}${mandir}/man8 ${D}${mandir}/pl/man8
32 install -p -m 644 ${S}/man/update-passwd.8 ${D}${mandir}/man8/
33 install -p -m 644 ${S}/man/update-passwd.pl.8 \
34 ${D}${mandir}/pl/man8/update-passwd.8
35 gzip -9 ${D}${mandir}/man8/* ${D}${mandir}/pl/man8/*
36 install -d -m 755 ${D}${datadir}/base-passwd
37 install -o root -g root -p -m 644 ${S}/passwd.master ${D}${datadir}/base-passwd/
38 sed -i 's#:/root:#:${ROOT_HOME}:#' ${D}${datadir}/base-passwd/passwd.master
39 install -o root -g root -p -m 644 ${S}/group.master ${D}${datadir}/base-passwd/
40
41 install -d -m 755 ${D}${docdir}/${BPN}
42 install -p -m 644 ${S}/debian/changelog ${D}${docdir}/${BPN}/
43 gzip -9 ${D}${docdir}/${BPN}/*
44 install -p -m 644 ${S}/README ${D}${docdir}/${BPN}/
45 install -p -m 644 ${S}/debian/copyright ${D}${docdir}/${BPN}/
46}
47
48base_passwd_sstate_postinst() {
49 if [ "${BB_CURRENTTASK}" = "populate_sysroot" -o "${BB_CURRENTTASK}" = "populate_sysroot_setscene" ]
50 then
51 # Staging does not copy ${sysconfdir} files into the
52 # target sysroot, so we need to do so manually. We
53 # put these files in the target sysroot so they can
54 # be used by recipes which use custom user/group
55 # permissions.
56 # Install passwd.master and group.master to sysconfdir and mv
57 # them to make sure they are atomically install.
58 install -d -m 755 ${STAGING_DIR_TARGET}${sysconfdir}
59 for i in passwd group; do
60 install -p -m 644 ${STAGING_DIR_TARGET}${datadir}/base-passwd/$i.master \
61 ${STAGING_DIR_TARGET}${sysconfdir}/
62 mv ${STAGING_DIR_TARGET}${sysconfdir}/$i.master ${STAGING_DIR_TARGET}${sysconfdir}/$i
63 done
64 fi
65}
66
67python populate_packages_prepend() {
68 # Add in the preinst function for ${PN}
69 # We have to do this here as prior to this, passwd/group.master
70 # would be unavailable. We need to create these files at preinst
71 # time before the files from the package may be available, hence
72 # storing the data from the files in the preinst directly.
73
74 f = open(d.expand("${STAGING_DATADIR}/base-passwd/passwd.master"), 'r')
75 passwd = "".join(f.readlines())
76 f.close()
77 f = open(d.expand("${STAGING_DATADIR}/base-passwd/group.master"), 'r')
78 group = "".join(f.readlines())
79 f.close()
80
81 preinst = """#!/bin/sh
82mkdir -p $D${sysconfdir}
83if [ ! -e $D${sysconfdir}/passwd ]; then
84\tcat << 'EOF' > $D${sysconfdir}/passwd
85""" + passwd + """EOF
86fi
87if [ ! -e $D${sysconfdir}/group ]; then
88\tcat << 'EOF' > $D${sysconfdir}/group
89""" + group + """EOF
90fi
91"""
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050092 d.setVar(d.expand('pkg_preinst_${PN}'), preinst)
Patrick Williamsc124f4f2015-09-15 14:41:29 -050093}
94
95addtask do_package after do_populate_sysroot
96
97ALLOW_EMPTY_${PN} = "1"
98
99PACKAGES =+ "${PN}-update"
100FILES_${PN}-update = "${sbindir}/* ${datadir}/${PN}"
101
102pkg_postinst_${PN}-update () {
103#!/bin/sh
104if [ -n "$D" ]; then
105 exit 0
106fi
107${sbindir}/update-passwd
108}