Patchwork base-passwd: Move update-passwd into a separate package

login
register
mail settings
Submitter Richard Purdie
Date Nov. 14, 2011, 1:57 p.m.
Message ID <1321279039.26881.62.camel@ted>
Download mbox | patch
Permalink /patch/14939/
State New
Headers show

Comments

Richard Purdie - Nov. 14, 2011, 1:57 p.m.
update-passwd is the only user of the passwd/group.master files
and was never used by OE since it wasn't run.

This patch packages this separately and adds an appropriate postinst
to make the package useful so people can include it as they wish.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 LIC_FILES_CHKSUM =
"file://COPYING;md5=eb723b61539feef013de476e68b5c50a"
 
@@ -16,6 +16,11 @@ S = "${WORKDIR}/base-passwd"
 
 inherit autotools
 
+PACKAGES =+ "${PN}-update"
+FILES_${PN}-update = "${sbindir}/* ${datadir}/${PN}"
+
+ALLOW_EMPTY_${PN} = "1"
+
 SSTATEPOSTINSTFUNCS += "base_passwd_sstate_postinst"
 
 do_install () {
@@ -78,3 +83,10 @@ fi
 	d.setVar('pkg_preinst_${PN}', preinst)
 }
 
+pkg_postinst_${PN}-update () {
+#!/bin/sh
+if [ "x$D" != "x" ]; then
+	exit 0
+fi
+${sbindir}/update-passwd
+}
Phil Blundell - Nov. 14, 2011, 3:15 p.m.
On Mon, 2011-11-14 at 13:57 +0000, Richard Purdie wrote:
> +pkg_postinst_${PN}-update () {
> +#!/bin/sh
> +if [ "x$D" != "x" ]; then
> +	exit 0
> +fi
> +${sbindir}/update-passwd
> +}

Not that it really matters, but (in the interests of not perpetuating
unnecessary cruft) this "x" paradigm is unnecessary here.  If you quote
the values then empty strings are permissible, so you could have
written:

if [ "$D" != "" ]; then
   ...
fi

But, in fact, all reasonable implementations of /bin/sh support "test
-n" (it's required by POSIX) so you can write it even more concisely:

if [ -n $D ]; then
  ...
fi

Of course, it sucks fairly badly that we need to have all this scar
tissue in the installed postinsts at all.  For the opkg backend at
least, it would be fairly straightforward to add support for an "offline
postinst" as a separate script, which could be run by rootfs_ipk but
never actually installed into the rootfs.  But I don't know what the
impact on the other backends would be for that, which I guess might make
it hard to deploy in practice.

p.
Richard Purdie - Nov. 14, 2011, 5:19 p.m.
On Mon, 2011-11-14 at 15:15 +0000, Phil Blundell wrote:
> On Mon, 2011-11-14 at 13:57 +0000, Richard Purdie wrote:
> > +pkg_postinst_${PN}-update () {
> > +#!/bin/sh
> > +if [ "x$D" != "x" ]; then
> > +	exit 0
> > +fi
> > +${sbindir}/update-passwd
> > +}
> 
> Not that it really matters, but (in the interests of not perpetuating
> unnecessary cruft) this "x" paradigm is unnecessary here.  If you quote
> the values then empty strings are permissible, so you could have
> written:
> 
> if [ "$D" != "" ]; then
>    ...
> fi
> 
> But, in fact, all reasonable implementations of /bin/sh support "test
> -n" (it's required by POSIX) so you can write it even more concisely:
> 
> if [ -n $D ]; then
>   ...
> fi

Right, I picked a bad example to copy :/.

> Of course, it sucks fairly badly that we need to have all this scar
> tissue in the installed postinsts at all.  For the opkg backend at
> least, it would be fairly straightforward to add support for an "offline
> postinst" as a separate script, which could be run by rootfs_ipk but
> never actually installed into the rootfs.  But I don't know what the
> impact on the other backends would be for that, which I guess might make
> it hard to deploy in practice.

Why can't opkg just wipe the postinst's its run off the disk? Its not
like it needs them any longer...

Cheers,

Richard
Phil Blundell - Nov. 14, 2011, 5:38 p.m.
On Mon, 2011-11-14 at 17:19 +0000, Richard Purdie wrote:
> Why can't opkg just wipe the postinst's its run off the disk? Its not
> like it needs them any longer...

Yes, that's true.  In fact for my purposes I end up wiping the whole of
the opkg metadata anyway so it is a moot issue. :-)  But you're right,
"opkg configure" is a one-shot operation and it will never use the
postinst again so it might as well delete them for itself.

p.

Patch

diff --git a/meta/recipes-core/base-passwd/base-passwd_3.5.22.bb
b/meta/recipes-core/base-passwd/base-passwd_3.5.22.bb
index 05be23f..f6e17f9 100644
--- a/meta/recipes-core/base-passwd/base-passwd_3.5.22.bb
+++ b/meta/recipes-core/base-passwd/base-passwd_3.5.22.bb
@@ -1,7 +1,7 @@ 
 SUMMARY = "Base system master password/group files."
 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."
 SECTION = "base"
-PR = "r5"
+PR = "r9"
 LICENSE = "GPLv2+"