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." |
| 3 | SECTION = "base" |
| 4 | LICENSE = "GPLv2+" |
| 5 | LIC_FILES_CHKSUM = "file://COPYING;md5=eb723b61539feef013de476e68b5c50a" |
| 6 | |
| 7 | RECIPE_NO_UPDATE_REASON = "Version 3.5.38 requires cdebconf for update-passwd utility" |
| 8 | |
| 9 | SRC_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 Bishop | c342db3 | 2019-05-15 21:57:59 -0400 | [diff] [blame] | 15 | file://kvm.patch \ |
| 16 | " |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 17 | |
| 18 | SRC_URI[md5sum] = "6beccac48083fe8ae5048acd062e5421" |
| 19 | SRC_URI[sha256sum] = "f0b66388b2c8e49c15692439d2bee63bcdd4bbbf7a782c7f64accc55986b6a36" |
| 20 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 21 | # 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 |
| 23 | UPSTREAM_CHECK_URI = "${DEBIAN_MIRROR}/main/b/base-passwd/" |
| 24 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 25 | inherit autotools |
| 26 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 27 | do_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 Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 47 | basepasswd_sysroot_postinst() { |
| 48 | #!/bin/sh |
| 49 | |
| 50 | # Install passwd.master and group.master to sysconfdir |
| 51 | install -d -m 755 ${STAGING_DIR_TARGET}${sysconfdir} |
| 52 | for i in passwd group; do |
| 53 | install -p -m 644 ${STAGING_DIR_TARGET}${datadir}/base-passwd/\$i.master \ |
| 54 | ${STAGING_DIR_TARGET}${sysconfdir}/\$i |
| 55 | done |
| 56 | |
| 57 | # Run any useradd postinsts |
| 58 | for script in ${STAGING_DIR_TARGET}${bindir}/postinst-useradd-*; do |
| 59 | if [ -f \$script ]; then |
| 60 | \$script |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 61 | fi |
Brad Bishop | 6e60e8b | 2018-02-01 10:27:11 -0500 | [diff] [blame] | 62 | done |
| 63 | } |
| 64 | |
| 65 | SYSROOT_DIRS += "${sysconfdir}" |
| 66 | SYSROOT_PREPROCESS_FUNCS += "base_passwd_tweaksysroot" |
| 67 | |
| 68 | base_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 Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 73 | } |
| 74 | |
| 75 | python 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 |
| 90 | mkdir -p $D${sysconfdir} |
| 91 | if [ ! -e $D${sysconfdir}/passwd ]; then |
| 92 | \tcat << 'EOF' > $D${sysconfdir}/passwd |
| 93 | """ + passwd + """EOF |
| 94 | fi |
| 95 | if [ ! -e $D${sysconfdir}/group ]; then |
| 96 | \tcat << 'EOF' > $D${sysconfdir}/group |
| 97 | """ + group + """EOF |
| 98 | fi |
| 99 | """ |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 100 | d.setVar(d.expand('pkg_preinst_${PN}'), preinst) |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | addtask do_package after do_populate_sysroot |
| 104 | |
| 105 | ALLOW_EMPTY_${PN} = "1" |
| 106 | |
| 107 | PACKAGES =+ "${PN}-update" |
| 108 | FILES_${PN}-update = "${sbindir}/* ${datadir}/${PN}" |
| 109 | |
| 110 | pkg_postinst_${PN}-update () { |
| 111 | #!/bin/sh |
| 112 | if [ -n "$D" ]; then |
| 113 | exit 0 |
| 114 | fi |
| 115 | ${sbindir}/update-passwd |
| 116 | } |