blob: c6be1c1d0868ce9fbd5ca46843aa095beae7ee28 [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
Patrick Williamsc124f4f2015-09-15 14:41:29 -050026do_install () {
27 install -d -m 755 ${D}${sbindir}
28 install -o root -g root -p -m 755 ${B}/update-passwd ${D}${sbindir}/
29 install -d -m 755 ${D}${mandir}/man8 ${D}${mandir}/pl/man8
30 install -p -m 644 ${S}/man/update-passwd.8 ${D}${mandir}/man8/
31 install -p -m 644 ${S}/man/update-passwd.pl.8 \
32 ${D}${mandir}/pl/man8/update-passwd.8
33 gzip -9 ${D}${mandir}/man8/* ${D}${mandir}/pl/man8/*
34 install -d -m 755 ${D}${datadir}/base-passwd
35 install -o root -g root -p -m 644 ${S}/passwd.master ${D}${datadir}/base-passwd/
36 sed -i 's#:/root:#:${ROOT_HOME}:#' ${D}${datadir}/base-passwd/passwd.master
37 install -o root -g root -p -m 644 ${S}/group.master ${D}${datadir}/base-passwd/
38
39 install -d -m 755 ${D}${docdir}/${BPN}
40 install -p -m 644 ${S}/debian/changelog ${D}${docdir}/${BPN}/
41 gzip -9 ${D}${docdir}/${BPN}/*
42 install -p -m 644 ${S}/README ${D}${docdir}/${BPN}/
43 install -p -m 644 ${S}/debian/copyright ${D}${docdir}/${BPN}/
44}
45
Brad Bishop6e60e8b2018-02-01 10:27:11 -050046basepasswd_sysroot_postinst() {
47#!/bin/sh
48
49# Install passwd.master and group.master to sysconfdir
50install -d -m 755 ${STAGING_DIR_TARGET}${sysconfdir}
51for i in passwd group; do
52 install -p -m 644 ${STAGING_DIR_TARGET}${datadir}/base-passwd/\$i.master \
53 ${STAGING_DIR_TARGET}${sysconfdir}/\$i
54done
55
56# Run any useradd postinsts
57for script in ${STAGING_DIR_TARGET}${bindir}/postinst-useradd-*; do
58 if [ -f \$script ]; then
59 \$script
Patrick Williamsc124f4f2015-09-15 14:41:29 -050060 fi
Brad Bishop6e60e8b2018-02-01 10:27:11 -050061done
62}
63
64SYSROOT_DIRS += "${sysconfdir}"
65SYSROOT_PREPROCESS_FUNCS += "base_passwd_tweaksysroot"
66
67base_passwd_tweaksysroot () {
68 mkdir -p ${SYSROOT_DESTDIR}${bindir}
69 dest=${SYSROOT_DESTDIR}${bindir}/postinst-${PN}
70 echo "${basepasswd_sysroot_postinst}" > $dest
71 chmod 0755 $dest
Patrick Williamsc124f4f2015-09-15 14:41:29 -050072}
73
74python populate_packages_prepend() {
75 # Add in the preinst function for ${PN}
76 # We have to do this here as prior to this, passwd/group.master
77 # would be unavailable. We need to create these files at preinst
78 # time before the files from the package may be available, hence
79 # storing the data from the files in the preinst directly.
80
81 f = open(d.expand("${STAGING_DATADIR}/base-passwd/passwd.master"), 'r')
82 passwd = "".join(f.readlines())
83 f.close()
84 f = open(d.expand("${STAGING_DATADIR}/base-passwd/group.master"), 'r')
85 group = "".join(f.readlines())
86 f.close()
87
88 preinst = """#!/bin/sh
89mkdir -p $D${sysconfdir}
90if [ ! -e $D${sysconfdir}/passwd ]; then
91\tcat << 'EOF' > $D${sysconfdir}/passwd
92""" + passwd + """EOF
93fi
94if [ ! -e $D${sysconfdir}/group ]; then
95\tcat << 'EOF' > $D${sysconfdir}/group
96""" + group + """EOF
97fi
98"""
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050099 d.setVar(d.expand('pkg_preinst_${PN}'), preinst)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500100}
101
102addtask do_package after do_populate_sysroot
103
104ALLOW_EMPTY_${PN} = "1"
105
106PACKAGES =+ "${PN}-update"
107FILES_${PN}-update = "${sbindir}/* ${datadir}/${PN}"
108
109pkg_postinst_${PN}-update () {
110#!/bin/sh
111if [ -n "$D" ]; then
112 exit 0
113fi
114${sbindir}/update-passwd
115}