Skip to contentSkip to conversation

meta: Fixes for update-alternatives.bbclass and gtk-icon-cache.bbclass

PATCH New Robert Yang 1 participant 4 messages Jun 26, 2019

lore
Share & tools
lore
#0 lore raw

v3 cover meta: Fixes for update-alternatives.bbclass and gtk-icon-cache.bbclass

* V3
- Rather make the exception in update-alternatives.bbclass, but add a populate_packages_updatealternatives_append() in busybox.inc to make busybox's postinst runs firstly.

* V2
- The patch for update-alternatives.bbclass makes update-alternatives runs firstly before other postinst scripts, since other postinst may run the tool which is installed by the package itself (e.g., newaliases is installed as newaliases.postfix, and update-alternatives will update it to newaliases). But this broke busybox' on target install, since update-alternatives requires some basic tools such as sed, there was a neat way in busybox' postinst to fix this problem, the v2 makes busybox' postinst script run firstly before update-alternatives.

Testinfo:
MACHINE = "qemux86"
PACKAGE_CLASSES = "package_ipk package_rpm" (or "package_rpm package_ipk") TESTIMAGE_AUTO = "1"

$ bitbake core-image-sato core-image-minimal

The tests are OK.

* V1
- Initial version

// Robert

The following changes since commit 4bb3e8f98e2bbfcb20f1b32d2b7674d1a6cb47be:

local.conf.sample.extended: remove redundant RUNTIMETARGET assignment (2019-06-24 17:32:37 +0100)

are available in the git repository at:

git://git.openembedded.org/openembedded-core-contrib rbt/post
http://cgit.openembedded.org//log/?h=rbt/post

Robert Yang (3):
update-alternatives.bbclass: run update-alternatives firstly in
postinst script
busybox: make postinst run firstly before update-alternatives gtk-icon-cache.bbclass: Depends on gtk+3

 meta/classes/gtk-icon-cache.bbclass      | 14 +++++---
 meta/classes/update-alternatives.bbclass |  7 ++--
 meta/recipes-core/busybox/busybox.inc    | 62 +++++++++++++++++---------------
 3 files changed, 49 insertions(+), 34 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH v3 1/3 update-alternatives.bbclass: run update-alternatives firstly in postinst script

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.

---
 meta/classes/update-alternatives.bbclass | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
meta/classes/update-alternatives.bbclass +5 -2
index b702e77..8c2b66e 100644
@@ -284,8 +284,11 @@ 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:
+                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)
Signature · 1 line
2.7.4
#2 lore raw

PATCH v3 2/3 busybox: make postinst run firstly before update-alternatives

In reply to Robert Yang

The update-alternatives.bbclass' postinst script runs firstly before other postinst, but busybox needs set basic tools such as sed command firstly, otherwise, update-alternatives doesn't work, so run busybox' postinst firstly to fix the problem.

---
 meta/recipes-core/busybox/busybox.inc | 62 +++++++++++++++++++----------------
 1 file changed, 34 insertions(+), 28 deletions(-)
meta/recipes-core/busybox/busybox.inc +34 -28
index 174ce5a..49165d7 100644
@@ -392,34 +392,40 @@ python do_package_prepend () {
         set_alternative_vars("${sysconfdir}/busybox.links.suid", "${base_bindir}/busybox.suid")
 }
 
-pkg_postinst_${PN} () {
-	# This part of code is dedicated to the on target upgrade problem.
-	# It's known that if we don't make appropriate symlinks before update-alternatives calls,
-	# there will be errors indicating missing commands such as 'sed'.
-	# These symlinks will later be updated by update-alternatives calls.
-	test -n 2 > /dev/null || alias test='busybox test'
-	if test "x$D" = "x"; then
-		# Remove busybox.nosuid if it's a symlink, because this situation indicates
-		# that we're installing or upgrading to a one-binary busybox.
-		if test -h ${base_bindir}/busybox.nosuid; then
-			rm -f ${base_bindir}/busybox.nosuid
-		fi
-		for suffix in "" ".nosuid" ".suid"; do
-			if test -e ${sysconfdir}/busybox.links$suffix; then
-				while read link; do
-					if test ! -e "$link"; then
-						# we can use busybox here because even if we are using splitted busybox
-						# we've made a symlink from /bin/busybox to /bin/busybox.nosuid.
-						busybox rm -f $link
-						busybox ln -s "${base_bindir}/busybox$suffix" $link
-					fi
-				done < ${sysconfdir}/busybox.links$suffix
-			fi
-		done
-	fi
-	if grep -q "^${base_bindir}/bash$" $D${sysconfdir}/busybox.links*; then
-		grep -q "^${base_bindir}/bash$" $D${sysconfdir}/shells || echo ${base_bindir}/bash >> $D${sysconfdir}/shells
-	fi
+# This part of code is dedicated to the on target upgrade problem.  It's known
+# that if we don't make appropriate symlinks before update-alternatives calls,
+# there will be errors indicating missing commands such as 'sed'.
+# These symlinks will later be updated by update-alternatives calls.
+# The update-alternatives.bbclass' postinst script runs firstly before other
+# postinst, but this part of code needs run firstly, so add this funtion.
+python populate_packages_updatealternatives_append() {
+    postinst = """
+test -n 2 > /dev/null || alias test='busybox test'
+if test "x$D" = "x"; then
+    # Remove busybox.nosuid if it's a symlink, because this situation indicates
+    # that we're installing or upgrading to a one-binary busybox.
+    if test -h ${base_bindir}/busybox.nosuid; then
+        rm -f ${base_bindir}/busybox.nosuid
+    fi
+    for suffix in "" ".nosuid" ".suid"; do
+        if test -e ${sysconfdir}/busybox.links$suffix; then
+            while read link; do
+                if test ! -e "$link"; then
+                    # we can use busybox here because even if we are using splitted busybox
+                    # we've made a symlink from /bin/busybox to /bin/busybox.nosuid.
+                    busybox rm -f $link
+                    busybox ln -s "${base_bindir}/busybox$suffix" $link
+                fi
+            done < ${sysconfdir}/busybox.links$suffix
+        fi
+    done
+fi
+if grep -q "^${base_bindir}/bash$" $D${sysconfdir}/busybox.links*; then
+    grep -q "^${base_bindir}/bash$" $D${sysconfdir}/shells || echo ${base_bindir}/bash >> $D${sysconfdir}/shells
+fi
+
+"""
+    d.prependVar('pkg_postinst_%s' % pkg, postinst)
 }
 
 pkg_prerm_${PN} () {
Signature · 1 line
2.7.4
#3 lore raw

PATCH v3 3/3 gtk-icon-cache.bbclass: Depends on gtk+3

In reply to Robert Yang

The gtk-update-icon-cache is provided by gtk+3, gdk-pixbuf-query-loaders is provided by gdk-pixbuf, and gtk+3 depends on gdk-pixbuf, so depends on gtk+3 can fix the problems.

---
 meta/classes/gtk-icon-cache.bbclass | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
meta/classes/gtk-icon-cache.bbclass +10 -4
index 66fe781..4e60fe6 100644
@@ -4,6 +4,11 @@ DEPENDS +=" ${@['hicolor-icon-theme', '']['${BPN}' == 'hicolor-icon-theme']} gtk
 
 PACKAGE_WRITE_DEPS += "gtk+3-native gdk-pixbuf-native"
 
+inherit distro_features_check
+ANY_OF_DISTRO_FEATURES = "${GTK3DISTROFEATURES}"
+
+DEPENDS += "gtk+3"
+
 gtk_icon_cache_postinst() {
 if [ "x$D" != "x" ]; then
 	$INTERCEPT_DIR/postinst_intercept update_icon_cache ${PKG} \
@@ -45,10 +50,11 @@ python populate_packages_append () {
         if not os.path.exists(icon_dir):
             continue
 
-        bb.note("adding hicolor-icon-theme dependency to %s" % pkg)
-        rdepends = ' ' + d.getVar('MLPREFIX', False) + "hicolor-icon-theme"
-        d.appendVar('RDEPENDS_%s' % pkg, rdepends)
-    
+        for dep in ('hicolor-icon-theme', 'gtk+3'):
+            bb.note("Adding %s dependency to %s" % (dep, pkg))
+            rdepends = ' ' + d.getVar('MLPREFIX', False) + dep
+            d.appendVar('RDEPENDS_%s' % pkg, rdepends)
+
         bb.note("adding gtk-icon-cache postinst and postrm scripts to %s" % pkg)
         
         postinst = d.getVar('pkg_postinst_%s' % pkg)
Signature · 1 line
2.7.4