On 6/25/19 10:14 PM, Richard Purdie wrote:
On Tue, 2019-06-25 at 20:44 +0800, Robert Yang wrote:
Recipes like postfix run command newaliases in postinst, but newaliases is
installed as newaliases.postfix, it needs run update-alternatives to update it
to newaliases, so there was an error when installed postinst on target.

Fixed:
$ opkg install postfix
Configuring postfix.
///var/lib/opkg/info/postfix.postinst: line 4: newaliases: command not found

Run update-alternatives firstly will fix the problem. And handle busybox as an
exception since it needs set basic tools such as sed command firstly, otherwise
update-alternatives doesn't work.

Signed-off-by: Robert Yang <[email protected]>
---
  meta/classes/update-alternatives.bbclass | 13 +++++++++++--
  1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/meta/classes/update-alternatives.bbclass 
b/meta/classes/update-alternatives.bbclass
index b702e77..9ab9298 100644
--- a/meta/classes/update-alternatives.bbclass
+++ b/meta/classes/update-alternatives.bbclass
@@ -265,6 +265,7 @@ python populate_packages_updatealternatives () {
      if not update_alternatives_enabled(d):
          return
+ bpn = d.getVar('BPN')
      # Do actual update alternatives processing
      for pkg in (d.getVar('PACKAGES') or "").split():
          # Create post install/removal scripts
@@ -284,8 +285,16 @@ python populate_packages_updatealternatives () {
bb.note('adding update-alternatives calls to postinst/prerm for %s' % pkg)
              bb.note('%s' % alt_setup_links)
-            postinst = d.getVar('pkg_postinst_%s' % pkg) or '#!/bin/sh\n'
-            postinst += alt_setup_links
+            postinst = d.getVar('pkg_postinst_%s' % pkg)
+            if postinst:
+                # Busybox needs handle basic tools such as sed command
+                # firstly, otherwise, update-alternatives doesn't work.
+                if bpn == 'busybox':
+                    postinst += alt_setup_links
+                else:
+                    postinst = alt_setup_links + postinst
+            else:
+                postinst = '#!/bin/sh\n' + alt_setup_links
              d.setVar('pkg_postinst_%s' % pkg, postinst)
bb.note('%s' % alt_remove_links)

We don't write classes like this. We could just keep piling special
cases one on top of the other and it becomes a horrible unmaintainable
mess. I therefore don't want to see recipes "special cased" like this
in core code and we need to find another, better way to handle this.

Yes, make sense, I was also worried about. My first fix was in busybox.inc,
but looks a little tricky (Add a populate_packages_updatealternatives_append()
in busybox.inc) to make it work. Please see the V3.

// Robert


Cheers,

Richard




--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

Reply via email to