blob: ef7792ae49c73d86b8237157ce140b7f3f9e9f56 [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."
Andrew Geissler90fd73c2021-03-05 15:25:55 -06003HOMEPAGE = "https://launchpad.net/base-passwd"
Patrick Williamsc124f4f2015-09-15 14:41:29 -05004SECTION = "base"
Andrew Geissler7e0e3c02022-02-25 20:34:39 +00005LICENSE = "GPL-2.0-only"
Patrick Williamsc124f4f2015-09-15 14:41:29 -05006LIC_FILES_CHKSUM = "file://COPYING;md5=eb723b61539feef013de476e68b5c50a"
7
8RECIPE_NO_UPDATE_REASON = "Version 3.5.38 requires cdebconf for update-passwd utility"
9
10SRC_URI = "https://launchpad.net/debian/+archive/primary/+files/${BPN}_${PV}.tar.gz \
11 file://add_shutdown.patch \
12 file://nobash.patch \
13 file://noshadow.patch \
14 file://input.patch \
15 file://disable-docs.patch \
Brad Bishopc342db32019-05-15 21:57:59 -040016 file://kvm.patch \
Patrick Williams03907ee2022-05-01 06:28:52 -050017 file://disable-shell.patch \
Brad Bishopc342db32019-05-15 21:57:59 -040018 "
Patrick Williamsc124f4f2015-09-15 14:41:29 -050019
20SRC_URI[md5sum] = "6beccac48083fe8ae5048acd062e5421"
21SRC_URI[sha256sum] = "f0b66388b2c8e49c15692439d2bee63bcdd4bbbf7a782c7f64accc55986b6a36"
22
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050023# the package is taken from launchpad; that source is static and goes stale
24# so we check the latest upstream from a directory that does get updated
25UPSTREAM_CHECK_URI = "${DEBIAN_MIRROR}/main/b/base-passwd/"
26
Patrick Williamsc124f4f2015-09-15 14:41:29 -050027inherit autotools
28
Patrick Williamsc124f4f2015-09-15 14:41:29 -050029do_install () {
30 install -d -m 755 ${D}${sbindir}
31 install -o root -g root -p -m 755 ${B}/update-passwd ${D}${sbindir}/
32 install -d -m 755 ${D}${mandir}/man8 ${D}${mandir}/pl/man8
33 install -p -m 644 ${S}/man/update-passwd.8 ${D}${mandir}/man8/
34 install -p -m 644 ${S}/man/update-passwd.pl.8 \
35 ${D}${mandir}/pl/man8/update-passwd.8
36 gzip -9 ${D}${mandir}/man8/* ${D}${mandir}/pl/man8/*
37 install -d -m 755 ${D}${datadir}/base-passwd
38 install -o root -g root -p -m 644 ${S}/passwd.master ${D}${datadir}/base-passwd/
39 sed -i 's#:/root:#:${ROOT_HOME}:#' ${D}${datadir}/base-passwd/passwd.master
40 install -o root -g root -p -m 644 ${S}/group.master ${D}${datadir}/base-passwd/
41
42 install -d -m 755 ${D}${docdir}/${BPN}
43 install -p -m 644 ${S}/debian/changelog ${D}${docdir}/${BPN}/
44 gzip -9 ${D}${docdir}/${BPN}/*
45 install -p -m 644 ${S}/README ${D}${docdir}/${BPN}/
46 install -p -m 644 ${S}/debian/copyright ${D}${docdir}/${BPN}/
47}
48
Brad Bishop6e60e8b2018-02-01 10:27:11 -050049basepasswd_sysroot_postinst() {
50#!/bin/sh
51
52# Install passwd.master and group.master to sysconfdir
53install -d -m 755 ${STAGING_DIR_TARGET}${sysconfdir}
54for i in passwd group; do
55 install -p -m 644 ${STAGING_DIR_TARGET}${datadir}/base-passwd/\$i.master \
56 ${STAGING_DIR_TARGET}${sysconfdir}/\$i
57done
58
59# Run any useradd postinsts
60for script in ${STAGING_DIR_TARGET}${bindir}/postinst-useradd-*; do
61 if [ -f \$script ]; then
62 \$script
Patrick Williamsc124f4f2015-09-15 14:41:29 -050063 fi
Brad Bishop6e60e8b2018-02-01 10:27:11 -050064done
65}
66
67SYSROOT_DIRS += "${sysconfdir}"
68SYSROOT_PREPROCESS_FUNCS += "base_passwd_tweaksysroot"
69
70base_passwd_tweaksysroot () {
71 mkdir -p ${SYSROOT_DESTDIR}${bindir}
72 dest=${SYSROOT_DESTDIR}${bindir}/postinst-${PN}
73 echo "${basepasswd_sysroot_postinst}" > $dest
74 chmod 0755 $dest
Patrick Williamsc124f4f2015-09-15 14:41:29 -050075}
76
Patrick Williams213cb262021-08-07 19:21:33 -050077python populate_packages:prepend() {
Patrick Williamsc124f4f2015-09-15 14:41:29 -050078 # Add in the preinst function for ${PN}
79 # We have to do this here as prior to this, passwd/group.master
80 # would be unavailable. We need to create these files at preinst
81 # time before the files from the package may be available, hence
82 # storing the data from the files in the preinst directly.
83
84 f = open(d.expand("${STAGING_DATADIR}/base-passwd/passwd.master"), 'r')
85 passwd = "".join(f.readlines())
86 f.close()
87 f = open(d.expand("${STAGING_DATADIR}/base-passwd/group.master"), 'r')
88 group = "".join(f.readlines())
89 f.close()
90
91 preinst = """#!/bin/sh
92mkdir -p $D${sysconfdir}
93if [ ! -e $D${sysconfdir}/passwd ]; then
94\tcat << 'EOF' > $D${sysconfdir}/passwd
95""" + passwd + """EOF
96fi
97if [ ! -e $D${sysconfdir}/group ]; then
98\tcat << 'EOF' > $D${sysconfdir}/group
99""" + group + """EOF
100fi
101"""
Patrick Williams213cb262021-08-07 19:21:33 -0500102 d.setVar(d.expand('pkg_preinst:${PN}'), preinst)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500103}
104
105addtask do_package after do_populate_sysroot
106
Patrick Williams213cb262021-08-07 19:21:33 -0500107ALLOW_EMPTY:${PN} = "1"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500108
109PACKAGES =+ "${PN}-update"
Patrick Williams213cb262021-08-07 19:21:33 -0500110FILES:${PN}-update = "${sbindir}/* ${datadir}/${PN}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500111
Patrick Williams213cb262021-08-07 19:21:33 -0500112pkg_postinst:${PN}-update () {
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500113#!/bin/sh
114if [ -n "$D" ]; then
115 exit 0
116fi
117${sbindir}/update-passwd
118}