blob: ac9bd81d31e617c6494db850a5af069dc92e02cb [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
20inherit autotools
21
22SSTATEPOSTINSTFUNCS += "base_passwd_sstate_postinst"
23
24do_install () {
25 install -d -m 755 ${D}${sbindir}
26 install -o root -g root -p -m 755 ${B}/update-passwd ${D}${sbindir}/
27 install -d -m 755 ${D}${mandir}/man8 ${D}${mandir}/pl/man8
28 install -p -m 644 ${S}/man/update-passwd.8 ${D}${mandir}/man8/
29 install -p -m 644 ${S}/man/update-passwd.pl.8 \
30 ${D}${mandir}/pl/man8/update-passwd.8
31 gzip -9 ${D}${mandir}/man8/* ${D}${mandir}/pl/man8/*
32 install -d -m 755 ${D}${datadir}/base-passwd
33 install -o root -g root -p -m 644 ${S}/passwd.master ${D}${datadir}/base-passwd/
34 sed -i 's#:/root:#:${ROOT_HOME}:#' ${D}${datadir}/base-passwd/passwd.master
35 install -o root -g root -p -m 644 ${S}/group.master ${D}${datadir}/base-passwd/
36
37 install -d -m 755 ${D}${docdir}/${BPN}
38 install -p -m 644 ${S}/debian/changelog ${D}${docdir}/${BPN}/
39 gzip -9 ${D}${docdir}/${BPN}/*
40 install -p -m 644 ${S}/README ${D}${docdir}/${BPN}/
41 install -p -m 644 ${S}/debian/copyright ${D}${docdir}/${BPN}/
42}
43
44base_passwd_sstate_postinst() {
45 if [ "${BB_CURRENTTASK}" = "populate_sysroot" -o "${BB_CURRENTTASK}" = "populate_sysroot_setscene" ]
46 then
47 # Staging does not copy ${sysconfdir} files into the
48 # target sysroot, so we need to do so manually. We
49 # put these files in the target sysroot so they can
50 # be used by recipes which use custom user/group
51 # permissions.
52 # Install passwd.master and group.master to sysconfdir and mv
53 # them to make sure they are atomically install.
54 install -d -m 755 ${STAGING_DIR_TARGET}${sysconfdir}
55 for i in passwd group; do
56 install -p -m 644 ${STAGING_DIR_TARGET}${datadir}/base-passwd/$i.master \
57 ${STAGING_DIR_TARGET}${sysconfdir}/
58 mv ${STAGING_DIR_TARGET}${sysconfdir}/$i.master ${STAGING_DIR_TARGET}${sysconfdir}/$i
59 done
60 fi
61}
62
63python populate_packages_prepend() {
64 # Add in the preinst function for ${PN}
65 # We have to do this here as prior to this, passwd/group.master
66 # would be unavailable. We need to create these files at preinst
67 # time before the files from the package may be available, hence
68 # storing the data from the files in the preinst directly.
69
70 f = open(d.expand("${STAGING_DATADIR}/base-passwd/passwd.master"), 'r')
71 passwd = "".join(f.readlines())
72 f.close()
73 f = open(d.expand("${STAGING_DATADIR}/base-passwd/group.master"), 'r')
74 group = "".join(f.readlines())
75 f.close()
76
77 preinst = """#!/bin/sh
78mkdir -p $D${sysconfdir}
79if [ ! -e $D${sysconfdir}/passwd ]; then
80\tcat << 'EOF' > $D${sysconfdir}/passwd
81""" + passwd + """EOF
82fi
83if [ ! -e $D${sysconfdir}/group ]; then
84\tcat << 'EOF' > $D${sysconfdir}/group
85""" + group + """EOF
86fi
87"""
88 d.setVar('pkg_preinst_${PN}', preinst)
89}
90
91addtask do_package after do_populate_sysroot
92
93ALLOW_EMPTY_${PN} = "1"
94
95PACKAGES =+ "${PN}-update"
96FILES_${PN}-update = "${sbindir}/* ${datadir}/${PN}"
97
98pkg_postinst_${PN}-update () {
99#!/bin/sh
100if [ -n "$D" ]; then
101 exit 0
102fi
103${sbindir}/update-passwd
104}