blob: 2926a377c6f44f1bacb6465518e7be970a4fdbcc [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 Geissler82c905d2020-04-13 13:39:40 -05005LICENSE = "GPLv2"
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 \
17 "
Patrick Williamsc124f4f2015-09-15 14:41:29 -050018
19SRC_URI[md5sum] = "6beccac48083fe8ae5048acd062e5421"
20SRC_URI[sha256sum] = "f0b66388b2c8e49c15692439d2bee63bcdd4bbbf7a782c7f64accc55986b6a36"
21
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050022# the package is taken from launchpad; that source is static and goes stale
23# so we check the latest upstream from a directory that does get updated
24UPSTREAM_CHECK_URI = "${DEBIAN_MIRROR}/main/b/base-passwd/"
25
Patrick Williamsc124f4f2015-09-15 14:41:29 -050026inherit autotools
27
Patrick Williamsc124f4f2015-09-15 14:41:29 -050028do_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
Brad Bishop6e60e8b2018-02-01 10:27:11 -050048basepasswd_sysroot_postinst() {
49#!/bin/sh
50
51# Install passwd.master and group.master to sysconfdir
52install -d -m 755 ${STAGING_DIR_TARGET}${sysconfdir}
53for i in passwd group; do
54 install -p -m 644 ${STAGING_DIR_TARGET}${datadir}/base-passwd/\$i.master \
55 ${STAGING_DIR_TARGET}${sysconfdir}/\$i
56done
57
58# Run any useradd postinsts
59for script in ${STAGING_DIR_TARGET}${bindir}/postinst-useradd-*; do
60 if [ -f \$script ]; then
61 \$script
Patrick Williamsc124f4f2015-09-15 14:41:29 -050062 fi
Brad Bishop6e60e8b2018-02-01 10:27:11 -050063done
64}
65
66SYSROOT_DIRS += "${sysconfdir}"
67SYSROOT_PREPROCESS_FUNCS += "base_passwd_tweaksysroot"
68
69base_passwd_tweaksysroot () {
70 mkdir -p ${SYSROOT_DESTDIR}${bindir}
71 dest=${SYSROOT_DESTDIR}${bindir}/postinst-${PN}
72 echo "${basepasswd_sysroot_postinst}" > $dest
73 chmod 0755 $dest
Patrick Williamsc124f4f2015-09-15 14:41:29 -050074}
75
Patrick Williams213cb262021-08-07 19:21:33 -050076python populate_packages:prepend() {
Patrick Williamsc124f4f2015-09-15 14:41:29 -050077 # Add in the preinst function for ${PN}
78 # We have to do this here as prior to this, passwd/group.master
79 # would be unavailable. We need to create these files at preinst
80 # time before the files from the package may be available, hence
81 # storing the data from the files in the preinst directly.
82
83 f = open(d.expand("${STAGING_DATADIR}/base-passwd/passwd.master"), 'r')
84 passwd = "".join(f.readlines())
85 f.close()
86 f = open(d.expand("${STAGING_DATADIR}/base-passwd/group.master"), 'r')
87 group = "".join(f.readlines())
88 f.close()
89
90 preinst = """#!/bin/sh
91mkdir -p $D${sysconfdir}
92if [ ! -e $D${sysconfdir}/passwd ]; then
93\tcat << 'EOF' > $D${sysconfdir}/passwd
94""" + passwd + """EOF
95fi
96if [ ! -e $D${sysconfdir}/group ]; then
97\tcat << 'EOF' > $D${sysconfdir}/group
98""" + group + """EOF
99fi
100"""
Patrick Williams213cb262021-08-07 19:21:33 -0500101 d.setVar(d.expand('pkg_preinst:${PN}'), preinst)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500102}
103
104addtask do_package after do_populate_sysroot
105
Patrick Williams213cb262021-08-07 19:21:33 -0500106ALLOW_EMPTY:${PN} = "1"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500107
108PACKAGES =+ "${PN}-update"
Patrick Williams213cb262021-08-07 19:21:33 -0500109FILES:${PN}-update = "${sbindir}/* ${datadir}/${PN}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500110
Patrick Williams213cb262021-08-07 19:21:33 -0500111pkg_postinst:${PN}-update () {
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500112#!/bin/sh
113if [ -n "$D" ]; then
114 exit 0
115fi
116${sbindir}/update-passwd
117}