blob: f89752c07710d147545b4b25ccc4ddb12a05d078 [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
Andrew Geisslerd5838332022-05-27 11:33:10 -05008SRC_URI = "https://launchpad.net/debian/+archive/primary/+files/${BPN}_${PV}.tar.xz \
9 file://0001-Add-a-shutdown-group.patch \
10 file://0002-Use-bin-sh-instead-of-bin-bash-for-the-root-user.patch \
11 file://0003-Remove-for-root-since-we-do-not-have-an-etc-shadow.patch \
12 file://0004-Add-an-input-group-for-the-dev-input-devices.patch \
13 file://0005-Add-kvm-group.patch \
14 file://0006-Make-it-possible-to-build-without-debconf-support.patch \
15 file://0007-Make-it-possible-to-disable-the-generation-of-the-do.patch \
Brad Bishopc342db32019-05-15 21:57:59 -040016 "
Patrick Williamsc124f4f2015-09-15 14:41:29 -050017
Andrew Geisslerd5838332022-05-27 11:33:10 -050018SRC_URI[sha256sum] = "5dfec6556b5a16ecf14dd3f7c95b591d929270289268123f31a3d6317f95ccea"
Patrick Williamsc124f4f2015-09-15 14:41:29 -050019
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
Andrew Geisslerd5838332022-05-27 11:33:10 -050024S = "${WORKDIR}/work"
25
Patrick Williamsc124f4f2015-09-15 14:41:29 -050026inherit autotools
27
Andrew Geisslerd5838332022-05-27 11:33:10 -050028EXTRA_OECONF += "--disable-debconf --disable-docs"
29
30NOLOGIN ?= "${base_sbindir}/nologin"
31
Patrick Williamsc124f4f2015-09-15 14:41:29 -050032do_install () {
33 install -d -m 755 ${D}${sbindir}
34 install -o root -g root -p -m 755 ${B}/update-passwd ${D}${sbindir}/
35 install -d -m 755 ${D}${mandir}/man8 ${D}${mandir}/pl/man8
36 install -p -m 644 ${S}/man/update-passwd.8 ${D}${mandir}/man8/
37 install -p -m 644 ${S}/man/update-passwd.pl.8 \
38 ${D}${mandir}/pl/man8/update-passwd.8
39 gzip -9 ${D}${mandir}/man8/* ${D}${mandir}/pl/man8/*
40 install -d -m 755 ${D}${datadir}/base-passwd
41 install -o root -g root -p -m 644 ${S}/passwd.master ${D}${datadir}/base-passwd/
42 sed -i 's#:/root:#:${ROOT_HOME}:#' ${D}${datadir}/base-passwd/passwd.master
Andrew Geisslerd5838332022-05-27 11:33:10 -050043 sed -i 's#/usr/sbin/nologin#${NOLOGIN}#' ${D}${datadir}/base-passwd/passwd.master
Patrick Williamsc124f4f2015-09-15 14:41:29 -050044 install -o root -g root -p -m 644 ${S}/group.master ${D}${datadir}/base-passwd/
45
46 install -d -m 755 ${D}${docdir}/${BPN}
47 install -p -m 644 ${S}/debian/changelog ${D}${docdir}/${BPN}/
48 gzip -9 ${D}${docdir}/${BPN}/*
49 install -p -m 644 ${S}/README ${D}${docdir}/${BPN}/
50 install -p -m 644 ${S}/debian/copyright ${D}${docdir}/${BPN}/
51}
52
Brad Bishop6e60e8b2018-02-01 10:27:11 -050053basepasswd_sysroot_postinst() {
54#!/bin/sh
55
56# Install passwd.master and group.master to sysconfdir
57install -d -m 755 ${STAGING_DIR_TARGET}${sysconfdir}
58for i in passwd group; do
59 install -p -m 644 ${STAGING_DIR_TARGET}${datadir}/base-passwd/\$i.master \
60 ${STAGING_DIR_TARGET}${sysconfdir}/\$i
61done
62
63# Run any useradd postinsts
64for script in ${STAGING_DIR_TARGET}${bindir}/postinst-useradd-*; do
65 if [ -f \$script ]; then
66 \$script
Patrick Williamsc124f4f2015-09-15 14:41:29 -050067 fi
Brad Bishop6e60e8b2018-02-01 10:27:11 -050068done
69}
70
71SYSROOT_DIRS += "${sysconfdir}"
72SYSROOT_PREPROCESS_FUNCS += "base_passwd_tweaksysroot"
73
74base_passwd_tweaksysroot () {
75 mkdir -p ${SYSROOT_DESTDIR}${bindir}
76 dest=${SYSROOT_DESTDIR}${bindir}/postinst-${PN}
77 echo "${basepasswd_sysroot_postinst}" > $dest
78 chmod 0755 $dest
Patrick Williamsc124f4f2015-09-15 14:41:29 -050079}
80
Patrick Williams213cb262021-08-07 19:21:33 -050081python populate_packages:prepend() {
Patrick Williamsc124f4f2015-09-15 14:41:29 -050082 # Add in the preinst function for ${PN}
83 # We have to do this here as prior to this, passwd/group.master
84 # would be unavailable. We need to create these files at preinst
85 # time before the files from the package may be available, hence
86 # storing the data from the files in the preinst directly.
87
88 f = open(d.expand("${STAGING_DATADIR}/base-passwd/passwd.master"), 'r')
89 passwd = "".join(f.readlines())
90 f.close()
91 f = open(d.expand("${STAGING_DATADIR}/base-passwd/group.master"), 'r')
92 group = "".join(f.readlines())
93 f.close()
94
95 preinst = """#!/bin/sh
96mkdir -p $D${sysconfdir}
97if [ ! -e $D${sysconfdir}/passwd ]; then
98\tcat << 'EOF' > $D${sysconfdir}/passwd
99""" + passwd + """EOF
100fi
101if [ ! -e $D${sysconfdir}/group ]; then
102\tcat << 'EOF' > $D${sysconfdir}/group
103""" + group + """EOF
104fi
105"""
Patrick Williams213cb262021-08-07 19:21:33 -0500106 d.setVar(d.expand('pkg_preinst:${PN}'), preinst)
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500107}
108
109addtask do_package after do_populate_sysroot
110
Patrick Williams213cb262021-08-07 19:21:33 -0500111ALLOW_EMPTY:${PN} = "1"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500112
113PACKAGES =+ "${PN}-update"
Patrick Williams213cb262021-08-07 19:21:33 -0500114FILES:${PN}-update = "${sbindir}/* ${datadir}/${PN}"
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500115
Patrick Williams213cb262021-08-07 19:21:33 -0500116pkg_postinst:${PN}-update () {
Patrick Williamsc124f4f2015-09-15 14:41:29 -0500117#!/bin/sh
118if [ -n "$D" ]; then
119 exit 0
120fi
121${sbindir}/update-passwd
122}