Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | SUMMARY = "Base system master password/group files" |
| 2 | DESCRIPTION = "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 Geissler | 90fd73c | 2021-03-05 15:25:55 -0600 | [diff] [blame] | 3 | HOMEPAGE = "https://launchpad.net/base-passwd" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 4 | SECTION = "base" |
Andrew Geissler | 7e0e3c0 | 2022-02-25 20:34:39 +0000 | [diff] [blame] | 5 | LICENSE = "GPL-2.0-only" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 6 | LIC_FILES_CHKSUM = "file://COPYING;md5=eb723b61539feef013de476e68b5c50a" |
| 7 | |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 8 | SRC_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 \ |
Patrick Williams | 2390b1b | 2022-11-03 13:47:49 -0500 | [diff] [blame] | 14 | file://0006-Make-it-possible-to-configure-whether-to-use-SELinux.patch \ |
Brad Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 15 | " |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 16 | |
Patrick Williams | 2390b1b | 2022-11-03 13:47:49 -0500 | [diff] [blame] | 17 | SRC_URI[sha256sum] = "6ff369be59d586ba63c0c5fcb00f75f9953fe49db88bc6c6428f2c92866f79af" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 18 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 19 | # the package is taken from launchpad; that source is static and goes stale |
| 20 | # so we check the latest upstream from a directory that does get updated |
| 21 | UPSTREAM_CHECK_URI = "${DEBIAN_MIRROR}/main/b/base-passwd/" |
| 22 | |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 23 | S = "${WORKDIR}/work" |
| 24 | |
Patrick Williams | 2390b1b | 2022-11-03 13:47:49 -0500 | [diff] [blame] | 25 | PACKAGECONFIG = "${@bb.utils.filter('DISTRO_FEATURES', 'selinux', d)}" |
| 26 | PACKAGECONFIG[selinux] = "--enable-selinux, --disable-selinux, libselinux" |
| 27 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 28 | inherit autotools |
| 29 | |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 30 | EXTRA_OECONF += "--disable-debconf --disable-docs" |
| 31 | |
| 32 | NOLOGIN ?= "${base_sbindir}/nologin" |
| 33 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 34 | do_install () { |
| 35 | install -d -m 755 ${D}${sbindir} |
| 36 | install -o root -g root -p -m 755 ${B}/update-passwd ${D}${sbindir}/ |
| 37 | install -d -m 755 ${D}${mandir}/man8 ${D}${mandir}/pl/man8 |
| 38 | install -p -m 644 ${S}/man/update-passwd.8 ${D}${mandir}/man8/ |
| 39 | install -p -m 644 ${S}/man/update-passwd.pl.8 \ |
| 40 | ${D}${mandir}/pl/man8/update-passwd.8 |
| 41 | gzip -9 ${D}${mandir}/man8/* ${D}${mandir}/pl/man8/* |
| 42 | install -d -m 755 ${D}${datadir}/base-passwd |
| 43 | install -o root -g root -p -m 644 ${S}/passwd.master ${D}${datadir}/base-passwd/ |
| 44 | sed -i 's#:/root:#:${ROOT_HOME}:#' ${D}${datadir}/base-passwd/passwd.master |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 45 | sed -i 's#/usr/sbin/nologin#${NOLOGIN}#' ${D}${datadir}/base-passwd/passwd.master |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 46 | install -o root -g root -p -m 644 ${S}/group.master ${D}${datadir}/base-passwd/ |
| 47 | |
| 48 | install -d -m 755 ${D}${docdir}/${BPN} |
| 49 | install -p -m 644 ${S}/debian/changelog ${D}${docdir}/${BPN}/ |
| 50 | gzip -9 ${D}${docdir}/${BPN}/* |
| 51 | install -p -m 644 ${S}/README ${D}${docdir}/${BPN}/ |
| 52 | install -p -m 644 ${S}/debian/copyright ${D}${docdir}/${BPN}/ |
| 53 | } |
| 54 | |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 55 | basepasswd_sysroot_postinst() { |
| 56 | #!/bin/sh |
| 57 | |
| 58 | # Install passwd.master and group.master to sysconfdir |
| 59 | install -d -m 755 ${STAGING_DIR_TARGET}${sysconfdir} |
| 60 | for i in passwd group; do |
| 61 | install -p -m 644 ${STAGING_DIR_TARGET}${datadir}/base-passwd/\$i.master \ |
| 62 | ${STAGING_DIR_TARGET}${sysconfdir}/\$i |
| 63 | done |
| 64 | |
| 65 | # Run any useradd postinsts |
| 66 | for script in ${STAGING_DIR_TARGET}${bindir}/postinst-useradd-*; do |
| 67 | if [ -f \$script ]; then |
| 68 | \$script |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 69 | fi |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 70 | done |
| 71 | } |
| 72 | |
| 73 | SYSROOT_DIRS += "${sysconfdir}" |
| 74 | SYSROOT_PREPROCESS_FUNCS += "base_passwd_tweaksysroot" |
| 75 | |
| 76 | base_passwd_tweaksysroot () { |
| 77 | mkdir -p ${SYSROOT_DESTDIR}${bindir} |
| 78 | dest=${SYSROOT_DESTDIR}${bindir}/postinst-${PN} |
| 79 | echo "${basepasswd_sysroot_postinst}" > $dest |
| 80 | chmod 0755 $dest |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 81 | } |
| 82 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 83 | python populate_packages:prepend() { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 84 | # Add in the preinst function for ${PN} |
| 85 | # We have to do this here as prior to this, passwd/group.master |
| 86 | # would be unavailable. We need to create these files at preinst |
| 87 | # time before the files from the package may be available, hence |
| 88 | # storing the data from the files in the preinst directly. |
| 89 | |
| 90 | f = open(d.expand("${STAGING_DATADIR}/base-passwd/passwd.master"), 'r') |
| 91 | passwd = "".join(f.readlines()) |
| 92 | f.close() |
| 93 | f = open(d.expand("${STAGING_DATADIR}/base-passwd/group.master"), 'r') |
| 94 | group = "".join(f.readlines()) |
| 95 | f.close() |
| 96 | |
| 97 | preinst = """#!/bin/sh |
| 98 | mkdir -p $D${sysconfdir} |
| 99 | if [ ! -e $D${sysconfdir}/passwd ]; then |
| 100 | \tcat << 'EOF' > $D${sysconfdir}/passwd |
| 101 | """ + passwd + """EOF |
| 102 | fi |
| 103 | if [ ! -e $D${sysconfdir}/group ]; then |
| 104 | \tcat << 'EOF' > $D${sysconfdir}/group |
| 105 | """ + group + """EOF |
| 106 | fi |
| 107 | """ |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 108 | d.setVar(d.expand('pkg_preinst:${PN}'), preinst) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | addtask do_package after do_populate_sysroot |
| 112 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 113 | ALLOW_EMPTY:${PN} = "1" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 114 | |
| 115 | PACKAGES =+ "${PN}-update" |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 116 | FILES:${PN}-update = "${sbindir}/* ${datadir}/${PN}" |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 117 | |
Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 118 | pkg_postinst:${PN}-update () { |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 119 | #!/bin/sh |
| 120 | if [ -n "$D" ]; then |
| 121 | exit 0 |
| 122 | fi |
| 123 | ${sbindir}/update-passwd |
| 124 | } |