blob: d01cd7e2977ff3f15842241cdb8f0ec7ed9655f9 [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"
Andrew Geissler82c905d2020-04-13 13:39:40 -05004LICENSE = "GPLv2"
Patrick Williamsc124f4f2015-09-15 14:41:29 -05005LIC_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 \
Brad Bishopc342db32019-05-15 21:57:59 -040015 file://kvm.patch \
16 "
Patrick Williamsc124f4f2015-09-15 14:41:29 -050017
18SRC_URI[md5sum] = "6beccac48083fe8ae5048acd062e5421"
19SRC_URI[sha256sum] = "f0b66388b2c8e49c15692439d2bee63bcdd4bbbf7a782c7f64accc55986b6a36"
20
Patrick Williamsd8c66bc2016-06-20 12:57:21 -050021# the package is taken from launchpad; that source is static and goes stale
22# so we check the latest upstream from a directory that does get updated
23UPSTREAM_CHECK_URI = "${DEBIAN_MIRROR}/main/b/base-passwd/"
24
Patrick Williamsc124f4f2015-09-15 14:41:29 -050025inherit autotools
26
Patrick Williamsc124f4f2015-09-15 14:41:29 -050027do_install () {
28 install -d -m 755 ${D}${sbindir}
29 install -o root -g root -p -m 755 ${B}/update-passwd ${D}${sbindir}/
30 install -d -m 755 ${D}${mandir}/man8 ${D}${mandir}/pl/man8
31 install -p -m 644 ${S}/man/update-passwd.8 ${D}${mandir}/man8/
32 install -p -m 644 ${S}/man/update-passwd.pl.8 \
33 ${D}${mandir}/pl/man8/update-passwd.8
34 gzip -9 ${D}${mandir}/man8/* ${D}${mandir}/pl/man8/*
35 install -d -m 755 ${D}${datadir}/base-passwd
36 install -o root -g root -p -m 644 ${S}/passwd.master ${D}${datadir}/base-passwd/
37 sed -i 's#:/root:#:${ROOT_HOME}:#' ${D}${datadir}/base-passwd/passwd.master
38 install -o root -g root -p -m 644 ${S}/group.master ${D}${datadir}/base-passwd/
39
40 install -d -m 755 ${D}${docdir}/${BPN}
41 install -p -m 644 ${S}/debian/changelog ${D}${docdir}/${BPN}/
42 gzip -9 ${D}${docdir}/${BPN}/*
43 install -p -m 644 ${S}/README ${D}${docdir}/${BPN}/
44 install -p -m 644 ${S}/debian/copyright ${D}${docdir}/${BPN}/
45}
46
Brad Bishop6e60e8b2018-02-01 10:27:11 -050047basepasswd_sysroot_postinst() {
48#!/bin/sh
49
50# Install passwd.master and group.master to sysconfdir
51install -d -m 755 ${STAGING_DIR_TARGET}${sysconfdir}
52for i in passwd group; do
53 install -p -m 644 ${STAGING_DIR_TARGET}${datadir}/base-passwd/\$i.master \
54 ${STAGING_DIR_TARGET}${sysconfdir}/\$i
55done
56
57# Run any useradd postinsts
58for script in ${STAGING_DIR_TARGET}${bindir}/postinst-useradd-*; do
59 if [ -f \$script ]; then
60 \$script
Patrick Williamsc124f4f2015-09-15 14:41:29 -050061 fi
Brad Bishop6e60e8b2018-02-01 10:27:11 -050062done
63}
64
65SYSROOT_DIRS += "${sysconfdir}"
66SYSROOT_PREPROCESS_FUNCS += "base_passwd_tweaksysroot"
67
68base_passwd_tweaksysroot () {
69 mkdir -p ${SYSROOT_DESTDIR}${bindir}
70 dest=${SYSROOT_DESTDIR}${bindir}/postinst-${PN}
71 echo "${basepasswd_sysroot_postinst}" > $dest
72 chmod 0755 $dest
Patrick Williamsc124f4f2015-09-15 14:41:29 -050073}
74
75python populate_packages_prepend() {
76 # Add in the preinst function for ${PN}
77 # We have to do this here as prior to this, passwd/group.master
78 # would be unavailable. We need to create these files at preinst
79 # time before the files from the package may be available, hence
80 # storing the data from the files in the preinst directly.
81
82 f = open(d.expand("${STAGING_DATADIR}/base-passwd/passwd.master"), 'r')
83 passwd = "".join(f.readlines())
84 f.close()
85 f = open(d.expand("${STAGING_DATADIR}/base-passwd/group.master"), 'r')
86 group = "".join(f.readlines())
87 f.close()
88
89 preinst = """#!/bin/sh
90mkdir -p $D${sysconfdir}
91if [ ! -e $D${sysconfdir}/passwd ]; then
92\tcat << 'EOF' > $D${sysconfdir}/passwd
93""" + passwd + """EOF
94fi
95if [ ! -e $D${sysconfdir}/group ]; then
96\tcat << 'EOF' > $D${sysconfdir}/group
97""" + group + """EOF
98fi
99"""
Patrick Williamsd8c66bc2016-06-20 12:57:21 -0500100 d.setVar(d.expand('pkg_preinst_${PN}'), preinst)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500101}
102
103addtask do_package after do_populate_sysroot
104
105ALLOW_EMPTY_${PN} = "1"
106
107PACKAGES =+ "${PN}-update"
108FILES_${PN}-update = "${sbindir}/* ${datadir}/${PN}"
109
110pkg_postinst_${PN}-update () {
111#!/bin/sh
112if [ -n "$D" ]; then
113 exit 0
114fi
115${sbindir}/update-passwd
116}