Skip to contentSkip to conversation

update-alternatives broken badly (by me :()

PATCH New Martin Jansa 4 participants 20 messages Jan 8, 2010 – Jan 13, 2010

lore
Share & tools
lore
#0 lore raw

After this change
http://cgit.openembedded.net/cgit.cgi/openembedded/commit/?id=9b641bbfed07c075ae5cbe84082a85f1ba703447

most distributions use opkg-native as u-a provider for building their images, but I haven't noticed that

update-alternatives-cworth use alternatives from
/usr/lib/ipkg/alternatives

opkg use
/usr/lib/opkg/alternatives

So image prepared with opkg-native cannot ship with update-alternatives-cworth installed, but it does, because task-boot DEPENDS on "update-alternatives" which could be fixed with DISTRO_UPDATE_ALTERNATIVES and using DISTRO_UPDATE_ALTERNATIVES for PREFERRED_PROVIDER_virtual/update-alternatives PREFERRED_PROVIDER_virtual/update-alternatives-native
and here in task-boot.

But this won't fix already installed/built images :/.

How to fix this properly? I guess that right combination of RCONFLICTS and good postinst scipt can fix that.. but its quite difficult to test it and it can break things even more :/. Please advise..

Sort of nasty workaround now is
opkg remove update-alternatives-cworth
opkg reinstall busybox

Here is info I just sent to SHR mailing list

In last opkg upgrade there is bump to busybox package, which triggers old bug in our images :(.

There are 2 scripts providing update-alternatives in our images, one is part of opkg itself installed in /usr/bin/update-alternatives (it was added to opkg later)

and older update-alternatives-cworth installed in
/usr/sbin/update-alternatives and used by default

But with busybox upgrade all symlinks are updated with knowledge only from /usr/lib/ipkg/alternatives because of that -cworth which shouldn't be part of image! (I'll push -cworth blacklist to our shr.conf but its too late for those who upgraded busybox yesterday).

Hopefully working work-around (haven't tested because I'm at work)

opkg remove update-alternatives-cworth
opkg reinstall busybox

Please also check
diff -rq /usr/lib/opkg/alternatives /usr/lib/ipkg/alternatives if there is some major difference, if yes reinstall packages where the alternatives provided by them are different in those 2 dirs.

Signature · 3 lines
uin:136542059                jid:[email protected]
Jansa Martin                 sip:[email protected] 
JaMa                         
#1 lore raw

PATCH 1/1 task-boot: use DISTRO_UPDATE_ALTERNATIVES instead of update-alternatives directly

* make opkg RCONFLICTS with update-alternatives-cworth because both do the same but installs alternatives to different directory (/usr/lib/ipkg/alternatives and /usr/lib/opkg/alternatives)
* Images built after 2009-12-08 9b641bbfed07c075ae5cbe84082a85f1ba703447 probably use opkg-native, but also ship with u-a-cworth
* Upgrade path is quite difficult, because users should remove cworth (RCONFLICT in opkg) and merge alternatives to opkg/alternatives

---
 recipes/opkg/opkg.inc      |    4 +++-
 recipes/tasks/task-boot.bb |   10 ++++++++--
 2 files changed, 11 insertions(+), 3 deletions(-)
recipes/opkg/opkg.inc +3 -1
index 1716034..caf90e7 100644
@@ -4,10 +4,12 @@ SECTION = "base"
 LICENSE = "GPL"
 DEPENDS = "curl gpgme"
 PV = "0.1.6+svnr${SRCPV}"
-INC_PR = "r18"
+INC_PR = "r19"
 
 FILESPATHPKG =. "opkg:"
 
+RCONFLICTS_${PN} = "update-alternatives-cworth"
+
 SRC_URI = "svn://opkg.googlecode.com/svn;module=trunk;proto=http \
 	file://opkg_unarchive.patch;patch=1;maxrev=201 \
 	file://opkg-intercept-cleanup.patch;patch=1;maxrev=241 \
recipes/tasks/task-boot.bb +8 -2
index 04c5535..45d50ef 100644
@@ -1,5 +1,5 @@
 DESCRIPTION = "Basic task to get a device booting"
-PR = "r51"
+PR = "r52"
 
 inherit task
 
@@ -13,6 +13,12 @@ PACKAGE_ARCH = "${MACHINE_ARCH}"
 MACHINE_ESSENTIAL_EXTRA_RDEPENDS ?= ""
 MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS ?= ""
 
+# update-alternatives script installed in rootfs needs to be the same as
+# u-a script used for building image which is defined with
+# PREFERRED_PROVIDER_virtual/update-alternatives-native
+
+DISTRO_UPDATE_ALTERNATIVES ?= "${PREFERRED_PROVIDER_virtual/update-alternatives}"
+
 # Make sure we build the kernel
 DEPENDS = "virtual/kernel"
 
@@ -26,7 +32,7 @@ RDEPENDS_task-boot = "\
     ${@base_contains("MACHINE_FEATURES", "keyboard", "keymaps", "", d)} \
     modutils-initscripts \
     netbase \
-    update-alternatives \
+    ${DISTRO_UPDATE_ALTERNATIVES} \
     ${MACHINE_ESSENTIAL_EXTRA_RDEPENDS} \
     "
 
Signature · 1 line
1.6.6
#2 lore raw
In reply to Martin Jansa
Quoted 3 lines · On Friday 08 January 2010 14:23:44 Martin Jansa wrote:

After this change
http://cgit.openembedded.net/cgit.cgi/openembedded/commit/?id=9b641bbfed07c
075ae5cbe84082a85f1ba703447

thanks for highlighting this. Let me say something regarding the commit message. Your commit message is not saying anything regarding "Why", it is not indicating a post to the mailinglist, it is not saying what problem is fixed.

Could we all try to have answers to:
- What
- How
- Why

in our commit messages? And maybe ask someone for review before touching basic files(*)?

z.

*: This comes from the guy who added a circular dependency last week

#3 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 9 lines · Holger Hans Peter Freyther
Quoted 3 lines · On Friday 08 January 2010 14:23:44 Martin Jansa wrote:

After this change
http://cgit.openembedded.net/cgit.cgi/openembedded/commit/?id=9b641bbfed07c
075ae5cbe84082a85f1ba703447

thanks for highlighting this. Let me say something regarding the commit message. Your commit message is not saying anything regarding "Why", it is not indicating a post to the mailinglist, it is not saying what problem is fixed.

Quoted 6 lines

Could we all try to have answers to:
- What
- How
- Why

in our commit messages?

Hey, did you spy on the TSC meeting yesterday? I proposed the same thing :) -----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Darwin)

iD8DBQFLRzwQMkyGM64RGpERAq7cAJ9Ik62s427Q1wijR4fEvT4Y38TlhgCfXftU JQEBShfcyAiD0XVB7Qn8Y48=
=9oKn
-----END PGP SIGNATURE-----

#4 lore raw
In reply to Holger Hans Peter Freyther
Quoted 9 lines · Holger Hans Peter Freyther
Quoted 3 lines · On Friday 08 January 2010 14:23:44 Martin Jansa wrote:

After this change
http://cgit.openembedded.net/cgit.cgi/openembedded/commit/?id=9b641bbfed07c
075ae5cbe84082a85f1ba703447

thanks for highlighting this. Let me say something regarding the commit message. Your commit message is not saying anything regarding "Why", it is not indicating a post to the mailinglist, it is not saying what problem is fixed.

Quoted 7 lines

Could we all try to have answers to:
- What
- How
- Why

in our commit messages? And maybe ask someone for review before touching basic files(*)?

It was sent here about month before commit
http://www.mail-archive.com/[email protected]/msg01444.html

Also discussed here
http://www.mail-archive.com/[email protected]/msg01180.html

Then again as part of compatibility-providers
http://www.mail-archive.com/[email protected]/msg01891.html

And one other thread I cannot find now..

But sorry I haven't provide better overwiev and/or links to those threads in commit msg.

Signature · 3 lines
uin:136542059                jid:[email protected]
Jansa Martin                 sip:[email protected] 
JaMa                         
#5 lore raw
In reply to Martin Jansa

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Can't we just make them both read from the opkg dir?

regards,

Koen

Quoted 49 lines · Martin Jansa

After this change
http://cgit.openembedded.net/cgit.cgi/openembedded/commit/?id=9b641bbfed07c075ae5cbe84082a85f1ba703447

most distributions use opkg-native as u-a provider for building their images, but I haven't noticed that

update-alternatives-cworth use alternatives from
/usr/lib/ipkg/alternatives

opkg use
/usr/lib/opkg/alternatives

So image prepared with opkg-native cannot ship with update-alternatives-cworth installed, but it does, because task-boot DEPENDS on "update-alternatives" which could be fixed with DISTRO_UPDATE_ALTERNATIVES and using DISTRO_UPDATE_ALTERNATIVES for PREFERRED_PROVIDER_virtual/update-alternatives PREFERRED_PROVIDER_virtual/update-alternatives-native
and here in task-boot.

But this won't fix already installed/built images :/.

How to fix this properly? I guess that right combination of RCONFLICTS and good postinst scipt can fix that.. but its quite difficult to test it and it can break things even more :/. Please advise..

Sort of nasty workaround now is
opkg remove update-alternatives-cworth
opkg reinstall busybox

Here is info I just sent to SHR mailing list

In last opkg upgrade there is bump to busybox package, which triggers old bug in our images :(.

There are 2 scripts providing update-alternatives in our images, one is part of opkg itself installed in /usr/bin/update-alternatives (it was added to opkg later)

and older update-alternatives-cworth installed in
/usr/sbin/update-alternatives and used by default

But with busybox upgrade all symlinks are updated with knowledge only from /usr/lib/ipkg/alternatives because of that -cworth which shouldn't be part of image! (I'll push -cworth blacklist to our shr.conf but its too late for those who upgraded busybox yesterday).

Hopefully working work-around (haven't tested because I'm at work)

Quoted 8 lines

opkg remove update-alternatives-cworth
opkg reinstall busybox

Please also check
diff -rq /usr/lib/opkg/alternatives /usr/lib/ipkg/alternatives if there is some major difference, if yes reinstall packages where the alternatives provided by them are different in those 2 dirs.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Darwin)

iD8DBQFLRzuPMkyGM64RGpERAhO/AJ96HpNyFXugDyZQM72YbijPg61k2ACePp/e WiVNV4APMwMBJ/HCK3sof48=
=UpsU
-----END PGP SIGNATURE-----

#6 lore raw
Quoted 8 lines · Koen Kooi

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Can't we just make them both read from the opkg dir?

regards,

Koen

Yes this would be nice, but still we would need something for merging those 2. Because in older image there would be better state in ipkg dir if it wasnt upgraded much and in newer image in opkg dir.

Because here isn't newer == better :/. I would go with merging "longer" files to opkg dir. It doesn't work only for users who intentionaly removed some alternatives with highest priority after image creation.

But it will fail badly in this case:

root@om-gta02 ~ $ cat /usr/lib/ipkg/alternatives/init /sbin/init
../bin/busybox 50
/sbin/init.sysvinit 60

root@om-gta02 ~ $ cat /usr/lib/opkg/alternatives/init /sbin/init
../bin/busybox 50

If user have both busybox and sysvinit installed than longer version from cworth will be merged and sysvinit used - usually good thing. But if he removed sysvinit intentionally then after ie busybox upgrade init will be switched to nonexistent file /sbin/init.sysvinit and won't boot anymore :/.

I can send small patch with PR bump in -cworth,, patching it for opkg dir and "merger" in postinst.

Regards,

Signature · 3 lines
uin:136542059                jid:[email protected]
Jansa Martin                 sip:[email protected] 
JaMa                         
#7 lore raw

PATCH 1/1 update-alternatives-cworth: use /usr/lib/opkg/alternatives directory instead of /usr/lib/ipkg/alternatives

* It's usefull to make it compatible with u-a script in opkg package
* Old entries are merged to new directory in quite verbose postinst script
* If entry exists only in old its moved
* If entry exists in both the one with more lines is used
* The one with less lines is not used and warning is shown
* If they have the same number of lines diff is checked
* If they are the same, old one is ignored
* If they are different, old one is ignored and warning is shown

---
 .../update-alternatives-cworth.inc                 |   44 +++++++++++++++++++-
 .../use-opkg-dir-instead-of-ipkg.patch             |   11 +++++
 2 files changed, 53 insertions(+), 2 deletions(-)
 create mode 100644 recipes/update-alternatives/update-alternatives-cworth/use-opkg-dir-instead-of-ipkg.patch
recipes/update-alternatives/update-alternatives-cworth.inc +42 -2
index 2d8fd42..23d559b 100644
@@ -1,8 +1,48 @@
 LICENSE = "GPL"
 SECTION = "base"
 SRC_URI = "${HANDHELDS_CVS};module=familiar/dist/ipkg;tag=${@'V' + bb.data.getVar('PV',d,1).replace('.', '-')} \
-           file://update-alternatives.use.last.patch;patch=1"
+           file://update-alternatives.use.last.patch;patch=1 \
+           file://use-opkg-dir-instead-of-ipkg.patch;patch=1 "
 S = "${WORKDIR}/ipkg/C"
 PACKAGE_ARCH = "all"
 
-INC_PR = "r3"
+INC_PR = "r4"
+
+# Moves all entries from /usr/lib/ipkg/alternatives to /usr/lib/opkg/alternatives
+# If it exists in both it use file with more lines
+
+pkg_postinst() {
+        alternatives_dir_old="${prefix}/lib/ipkg/alternatives"
+        alternatives_dir_new="${prefix}/lib/opkg/alternatives"
+        if [ -e "${alternatives_dir_old}" ] ; then
+                echo "Old alternatives directory ${alternatives_dir_old} exists, moving entries to new one ${alternatives_dir_new}"
+                echo "Creating backup copy of both ${alternatives_dir_old}-backup and ${alternatives_dir_new}-backup"
+                cp -ra "${alternatives_dir_old}" "${alternatives_dir_old}-backup"
+                cp -ra "${alternatives_dir_new}" "${alternatives_dir_new}-backup"
+
+                cd ${alternatives_dir_old}
+                for alt_file in * ; do
+                        if [ ! -e "${alternatives_dir_new}/${alt_file}" ] ; then
+                                echo "Moving old '${alternatives_dir_old}/${alt_file}' to '${alternatives_dir_new}/${alt_file}'";
+                                mv -f "${alternatives_dir_old}/${alt_file}" "${alternatives_dir_new}/${alt_file}"
+                        else
+                                OLD_LINES=`wc -l ${alternatives_dir_old}/${alt_file} | cut -d/ -f 1`;
+                                NEW_LINES=`wc -l ${alternatives_dir_new}/${alt_file} | cut -d/ -f 1`;
+                                if [ $OLD_LINES -gt $NEW_LINES ] ; then
+                                        echo "Replacing '${alternatives_dir_new}/${alt_file}' with '${alternatives_dir_old}/${alt_file}'";
+                                        mv -f "${alternatives_dir_old}/${alt_file}" "${alternatives_dir_new}/${alt_file}"
+                                elif [ $OLD_LINES -eq $NEW_LINES ] ; then
+                                        if diff -q "${alternatives_dir_new}/${alt_file}" "${alternatives_dir_old}/${alt_file}" >/dev/null ; then
+                                                echo "'{alternatives_dir_new}/${alt_file}' is the same"
+                                        else
+                                                echo "WARN: You have to update manually if needed. Please check: diff '${alternatives_dir_old}-backup/${alt_file}' '${alternatives_dir_new}-backup/${alt_file}'"
+                                        fi
+                                else
+                                        echo "WARN: '${alternatives_dir_old}/${alt_file}' is shorter than new one, ignoring, but please check and update manually if needed"
+                                fi
+                        fi
+                done
+		rm -rf ${alternatives_dir_old}
+		echo "Merge finished, old directory '${alternatives_dir_old}' is removed"
+        fi
+}
recipes/update-alternatives/update-alternatives-cworth/use-opkg-dir-instead-of-ipkg.patch new file +11 -0
new file mode 100644
index 0000000..4355556
@@ -0,0 +1,11 @@
+--- C.orig/update-alternatives	2010-01-08 15:40:20.000000000 +0100
++++ C/update-alternatives	2010-01-08 15:40:47.000000000 +0100
+@@ -21,7 +21,7 @@
+ set -e
+ 
+ # admin dir
+-ad="$IPKG_OFFLINE_ROOT/usr/lib/ipkg/alternatives"
++ad="$IPKG_OFFLINE_ROOT/usr/lib/opkg/alternatives"
+ 
+ usage() {
+ 	echo "update-alternatives: $*
Signature · 1 line
1.6.6
#8 lore raw
In reply to Martin Jansa
Quoted 3 lines · Martin Jansa

I can send small patch with PR bump in -cworth,, patching it for opkg dir and "merger" in postinst.

Sent in other thread.. sorry not sure why "In-Reply-To:
<[email protected]>" and then "In-Reply-To:
<20100108143501.GD2156@jama>"  didn't work :/.

Tested on angstrom here. Log from merge attached.

Please review it soon, because "busybox: Add new version 1.15" (d48c5b17a2b1b6f086faf16f85019a4454c5436d) triggered this bug quite badly.

Tricky part is how to apply this
First I would push this patch for merge on all devices and then fix for task-boot and RCONFLICTS to opkg.

Maybe RCONFLICTS is not needed anymore (as they will be compatible), but for new images would be nice to have task-boot fix.

Cheers,

Quoted 3 lines

uin:136542059                jid:[email protected] Jansa Martin                 sip:[email protected] JaMa

Old alternatives directory /usr/lib/ipkg/alternatives exists, moving entries to new one /usr/lib/opkg/alternatives
Creating backup copy of both /usr/lib/ipkg/alternatives-backup and /usr/lib/opkg/alternatives-backup
Moving old '/usr/lib/ipkg/alternatives/[' to '/usr/lib/opkg/alternatives/['
Moving old '/usr/lib/ipkg/alternatives/[[' to '/usr/lib/opkg/alternatives/[['
Moving old '/usr/lib/ipkg/alternatives/addgroup' to '/usr/lib/opkg/alternatives/addgroup'
Moving old '/usr/lib/ipkg/alternatives/adduser' to '/usr/lib/opkg/alternatives/adduser'
Moving old '/usr/lib/ipkg/alternatives/ar' to '/usr/lib/opkg/alternatives/ar'
Moving old '/usr/lib/ipkg/alternatives/ash' to '/usr/lib/opkg/alternatives/ash'
Moving old '/usr/lib/ipkg/alternatives/awk' to '/usr/lib/opkg/alternatives/awk'
Moving old '/usr/lib/ipkg/alternatives/basename' to '/usr/lib/opkg/alternatives/basename'
Moving old '/usr/lib/ipkg/alternatives/bin-lsmod' to '/usr/lib/opkg/alternatives/bin-lsmod'
Moving old '/usr/lib/ipkg/alternatives/blkid' to '/usr/lib/opkg/alternatives/blkid'
Moving old '/usr/lib/ipkg/alternatives/bunzip2' to '/usr/lib/opkg/alternatives/bunzip2'
Moving old '/usr/lib/ipkg/alternatives/bzcat' to '/usr/lib/opkg/alternatives/bzcat'
Moving old '/usr/lib/ipkg/alternatives/cat' to '/usr/lib/opkg/alternatives/cat'
Moving old '/usr/lib/ipkg/alternatives/chattr' to '/usr/lib/opkg/alternatives/chattr'
Moving old '/usr/lib/ipkg/alternatives/chgrp' to '/usr/lib/opkg/alternatives/chgrp'
Moving old '/usr/lib/ipkg/alternatives/chmod' to '/usr/lib/opkg/alternatives/chmod'
Moving old '/usr/lib/ipkg/alternatives/chown' to '/usr/lib/opkg/alternatives/chown'
Moving old '/usr/lib/ipkg/alternatives/chpasswd' to '/usr/lib/opkg/alternatives/chpasswd'
Moving old '/usr/lib/ipkg/alternatives/chroot' to '/usr/lib/opkg/alternatives/chroot'
Moving old '/usr/lib/ipkg/alternatives/chvt' to '/usr/lib/opkg/alternatives/chvt'
Moving old '/usr/lib/ipkg/alternatives/clear' to '/usr/lib/opkg/alternatives/clear'
Moving old '/usr/lib/ipkg/alternatives/cmp' to '/usr/lib/opkg/alternatives/cmp'
Moving old '/usr/lib/ipkg/alternatives/cp' to '/usr/lib/opkg/alternatives/cp'
Moving old '/usr/lib/ipkg/alternatives/cpio' to '/usr/lib/opkg/alternatives/cpio'
Moving old '/usr/lib/ipkg/alternatives/cryptpw' to '/usr/lib/opkg/alternatives/cryptpw'
Moving old '/usr/lib/ipkg/alternatives/cut' to '/usr/lib/opkg/alternatives/cut'
Moving old '/usr/lib/ipkg/alternatives/date' to '/usr/lib/opkg/alternatives/date'
Moving old '/usr/lib/ipkg/alternatives/dc' to '/usr/lib/opkg/alternatives/dc'
Moving old '/usr/lib/ipkg/alternatives/dd' to '/usr/lib/opkg/alternatives/dd'
Moving old '/usr/lib/ipkg/alternatives/deallocvt' to '/usr/lib/opkg/alternatives/deallocvt'
Moving old '/usr/lib/ipkg/alternatives/delgroup' to '/usr/lib/opkg/alternatives/delgroup'
Moving old '/usr/lib/ipkg/alternatives/deluser' to '/usr/lib/opkg/alternatives/deluser'
Moving old '/usr/lib/ipkg/alternatives/depmod' to '/usr/lib/opkg/alternatives/depmod'
Moving old '/usr/lib/ipkg/alternatives/df' to '/usr/lib/opkg/alternatives/df'
Moving old '/usr/lib/ipkg/alternatives/dhcprelay' to '/usr/lib/opkg/alternatives/dhcprelay'
Moving old '/usr/lib/ipkg/alternatives/diff' to '/usr/lib/opkg/alternatives/diff'
Moving old '/usr/lib/ipkg/alternatives/dirname' to '/usr/lib/opkg/alternatives/dirname'
Moving old '/usr/lib/ipkg/alternatives/dmesg' to '/usr/lib/opkg/alternatives/dmesg'
Moving old '/usr/lib/ipkg/alternatives/du' to '/usr/lib/opkg/alternatives/du'
Moving old '/usr/lib/ipkg/alternatives/dumpkmap' to '/usr/lib/opkg/alternatives/dumpkmap'
Moving old '/usr/lib/ipkg/alternatives/dumpleases' to '/usr/lib/opkg/alternatives/dumpleases'
Moving old '/usr/lib/ipkg/alternatives/e2fsck' to '/usr/lib/opkg/alternatives/e2fsck'
Moving old '/usr/lib/ipkg/alternatives/echo' to '/usr/lib/opkg/alternatives/echo'
WARN: You have to update manually if needed. Please check: diff '/usr/lib/ipkg/alternatives-backup/egrep' '/usr/lib/opkg/alternatives-backup/egrep' Moving old '/usr/lib/ipkg/alternatives/env' to '/usr/lib/opkg/alternatives/env'
Moving old '/usr/lib/ipkg/alternatives/expr' to '/usr/lib/opkg/alternatives/expr'
Moving old '/usr/lib/ipkg/alternatives/false' to '/usr/lib/opkg/alternatives/false'
Moving old '/usr/lib/ipkg/alternatives/fbset' to '/usr/lib/opkg/alternatives/fbset'
Moving old '/usr/lib/ipkg/alternatives/fbsplash' to '/usr/lib/opkg/alternatives/fbsplash'
Moving old '/usr/lib/ipkg/alternatives/fdisk' to '/usr/lib/opkg/alternatives/fdisk'
WARN: You have to update manually if needed. Please check: diff '/usr/lib/ipkg/alternatives-backup/fgrep' '/usr/lib/opkg/alternatives-backup/fgrep' Moving old '/usr/lib/ipkg/alternatives/find' to '/usr/lib/opkg/alternatives/find'
Moving old '/usr/lib/ipkg/alternatives/free' to '/usr/lib/opkg/alternatives/free'
Moving old '/usr/lib/ipkg/alternatives/freeramdisk' to '/usr/lib/opkg/alternatives/freeramdisk'
Moving old '/usr/lib/ipkg/alternatives/fsck' to '/usr/lib/opkg/alternatives/fsck'
Moving old '/usr/lib/ipkg/alternatives/fsck.ext2' to '/usr/lib/opkg/alternatives/fsck.ext2'
Moving old '/usr/lib/ipkg/alternatives/fsck.ext3' to '/usr/lib/opkg/alternatives/fsck.ext3'
Moving old '/usr/lib/ipkg/alternatives/fsck.ext4' to '/usr/lib/opkg/alternatives/fsck.ext4'
Moving old '/usr/lib/ipkg/alternatives/fsck.ext4dev' to '/usr/lib/opkg/alternatives/fsck.ext4dev'
Moving old '/usr/lib/ipkg/alternatives/fsck.minix' to '/usr/lib/opkg/alternatives/fsck.minix'
Moving old '/usr/lib/ipkg/alternatives/fuser' to '/usr/lib/opkg/alternatives/fuser'
Moving old '/usr/lib/ipkg/alternatives/getopt' to '/usr/lib/opkg/alternatives/getopt'
Moving old '/usr/lib/ipkg/alternatives/getty' to '/usr/lib/opkg/alternatives/getty'
Moving old '/usr/lib/ipkg/alternatives/gpe-logout.sh' to '/usr/lib/opkg/alternatives/gpe-logout.sh'
Moving old '/usr/lib/ipkg/alternatives/gpe-pixmaps' to '/usr/lib/opkg/alternatives/gpe-pixmaps'
WARN: You have to update manually if needed. Please check: diff '/usr/lib/ipkg/alternatives-backup/grep' '/usr/lib/opkg/alternatives-backup/grep' Moving old '/usr/lib/ipkg/alternatives/gunzip' to '/usr/lib/opkg/alternatives/gunzip'
Moving old '/usr/lib/ipkg/alternatives/gzip' to '/usr/lib/opkg/alternatives/gzip'
Moving old '/usr/lib/ipkg/alternatives/halt' to '/usr/lib/opkg/alternatives/halt'
Moving old '/usr/lib/ipkg/alternatives/hdparm' to '/usr/lib/opkg/alternatives/hdparm'
Moving old '/usr/lib/ipkg/alternatives/head' to '/usr/lib/opkg/alternatives/head'
Moving old '/usr/lib/ipkg/alternatives/hexdump' to '/usr/lib/opkg/alternatives/hexdump'
Moving old '/usr/lib/ipkg/alternatives/hostname' to '/usr/lib/opkg/alternatives/hostname'
Moving old '/usr/lib/ipkg/alternatives/httpd' to '/usr/lib/opkg/alternatives/httpd'
Moving old '/usr/lib/ipkg/alternatives/hwclock' to '/usr/lib/opkg/alternatives/hwclock'
Moving old '/usr/lib/ipkg/alternatives/id' to '/usr/lib/opkg/alternatives/id'
Moving old '/usr/lib/ipkg/alternatives/ifconfig' to '/usr/lib/opkg/alternatives/ifconfig'
Moving old '/usr/lib/ipkg/alternatives/ifdown' to '/usr/lib/opkg/alternatives/ifdown'
Moving old '/usr/lib/ipkg/alternatives/ifup' to '/usr/lib/opkg/alternatives/ifup'
Moving old '/usr/lib/ipkg/alternatives/init' to '/usr/lib/opkg/alternatives/init'
Moving old '/usr/lib/ipkg/alternatives/insmod' to '/usr/lib/opkg/alternatives/insmod'
Moving old '/usr/lib/ipkg/alternatives/ip' to '/usr/lib/opkg/alternatives/ip'
Moving old '/usr/lib/ipkg/alternatives/keylaunchrc' to '/usr/lib/opkg/alternatives/keylaunchrc'
Moving old '/usr/lib/ipkg/alternatives/kill' to '/usr/lib/opkg/alternatives/kill'
Moving old '/usr/lib/ipkg/alternatives/killall' to '/usr/lib/opkg/alternatives/killall'
Moving old '/usr/lib/ipkg/alternatives/klogd' to '/usr/lib/opkg/alternatives/klogd'
Moving old '/usr/lib/ipkg/alternatives/last' to '/usr/lib/opkg/alternatives/last'
Moving old '/usr/lib/ipkg/alternatives/less' to '/usr/lib/opkg/alternatives/less'
Moving old '/usr/lib/ipkg/alternatives/linuxrc' to '/usr/lib/opkg/alternatives/linuxrc'
Moving old '/usr/lib/ipkg/alternatives/ln' to '/usr/lib/opkg/alternatives/ln'
Moving old '/usr/lib/ipkg/alternatives/loadfont' to '/usr/lib/opkg/alternatives/loadfont'
Moving old '/usr/lib/ipkg/alternatives/loadkmap' to '/usr/lib/opkg/alternatives/loadkmap'
Moving old '/usr/lib/ipkg/alternatives/logger' to '/usr/lib/opkg/alternatives/logger'
Moving old '/usr/lib/ipkg/alternatives/login' to '/usr/lib/opkg/alternatives/login'
Moving old '/usr/lib/ipkg/alternatives/logname' to '/usr/lib/opkg/alternatives/logname'
Moving old '/usr/lib/ipkg/alternatives/logread' to '/usr/lib/opkg/alternatives/logread'
Moving old '/usr/lib/ipkg/alternatives/losetup' to '/usr/lib/opkg/alternatives/losetup'
Moving old '/usr/lib/ipkg/alternatives/ls' to '/usr/lib/opkg/alternatives/ls'
Moving old '/usr/lib/ipkg/alternatives/lsmod' to '/usr/lib/opkg/alternatives/lsmod'
Moving old '/usr/lib/ipkg/alternatives/makedevs' to '/usr/lib/opkg/alternatives/makedevs'
Moving old '/usr/lib/ipkg/alternatives/md5sum' to '/usr/lib/opkg/alternatives/md5sum'
Moving old '/usr/lib/ipkg/alternatives/mdev' to '/usr/lib/opkg/alternatives/mdev'
Moving old '/usr/lib/ipkg/alternatives/mesg' to '/usr/lib/opkg/alternatives/mesg'
Moving old '/usr/lib/ipkg/alternatives/microcom' to '/usr/lib/opkg/alternatives/microcom'
Moving old '/usr/lib/ipkg/alternatives/mkdir' to '/usr/lib/opkg/alternatives/mkdir'
Moving old '/usr/lib/ipkg/alternatives/mke2fs' to '/usr/lib/opkg/alternatives/mke2fs'
Moving old '/usr/lib/ipkg/alternatives/mkfifo' to '/usr/lib/opkg/alternatives/mkfifo'
Moving old '/usr/lib/ipkg/alternatives/mkfs.ext2' to '/usr/lib/opkg/alternatives/mkfs.ext2'
Moving old '/usr/lib/ipkg/alternatives/mkfs.ext3' to '/usr/lib/opkg/alternatives/mkfs.ext3'
Moving old '/usr/lib/ipkg/alternatives/mkfs.ext4' to '/usr/lib/opkg/alternatives/mkfs.ext4'
Moving old '/usr/lib/ipkg/alternatives/mkfs.ext4dev' to '/usr/lib/opkg/alternatives/mkfs.ext4dev'
Moving old '/usr/lib/ipkg/alternatives/mkfs.minix' to '/usr/lib/opkg/alternatives/mkfs.minix'
Moving old '/usr/lib/ipkg/alternatives/mknod' to '/usr/lib/opkg/alternatives/mknod'
Moving old '/usr/lib/ipkg/alternatives/mkswap' to '/usr/lib/opkg/alternatives/mkswap'
Moving old '/usr/lib/ipkg/alternatives/mktemp' to '/usr/lib/opkg/alternatives/mktemp'
Moving old '/usr/lib/ipkg/alternatives/modinfo' to '/usr/lib/opkg/alternatives/modinfo'
Moving old '/usr/lib/ipkg/alternatives/modprobe' to '/usr/lib/opkg/alternatives/modprobe'
Moving old '/usr/lib/ipkg/alternatives/more' to '/usr/lib/opkg/alternatives/more'
Moving old '/usr/lib/ipkg/alternatives/mount' to '/usr/lib/opkg/alternatives/mount'
Moving old '/usr/lib/ipkg/alternatives/mv' to '/usr/lib/opkg/alternatives/mv'
Moving old '/usr/lib/ipkg/alternatives/nc' to '/usr/lib/opkg/alternatives/nc'
Moving old '/usr/lib/ipkg/alternatives/netstat' to '/usr/lib/opkg/alternatives/netstat'
Moving old '/usr/lib/ipkg/alternatives/nice' to '/usr/lib/opkg/alternatives/nice'
Moving old '/usr/lib/ipkg/alternatives/nohup' to '/usr/lib/opkg/alternatives/nohup'
Moving old '/usr/lib/ipkg/alternatives/nslookup' to '/usr/lib/opkg/alternatives/nslookup'
Moving old '/usr/lib/ipkg/alternatives/od' to '/usr/lib/opkg/alternatives/od'
Moving old '/usr/lib/ipkg/alternatives/openvt' to '/usr/lib/opkg/alternatives/openvt'
Moving old '/usr/lib/ipkg/alternatives/opkg' to '/usr/lib/opkg/alternatives/opkg'
Moving old '/usr/lib/ipkg/alternatives/passwd' to '/usr/lib/opkg/alternatives/passwd'
Moving old '/usr/lib/ipkg/alternatives/patch' to '/usr/lib/opkg/alternatives/patch'
Moving old '/usr/lib/ipkg/alternatives/pidof' to '/usr/lib/opkg/alternatives/pidof'
Moving old '/usr/lib/ipkg/alternatives/ping' to '/usr/lib/opkg/alternatives/ping'
Moving old '/usr/lib/ipkg/alternatives/ping6' to '/usr/lib/opkg/alternatives/ping6'
Moving old '/usr/lib/ipkg/alternatives/pivot_root' to '/usr/lib/opkg/alternatives/pivot_root'
Moving old '/usr/lib/ipkg/alternatives/pkill' to '/usr/lib/opkg/alternatives/pkill'
Moving old '/usr/lib/ipkg/alternatives/poweroff' to '/usr/lib/opkg/alternatives/poweroff'
Moving old '/usr/lib/ipkg/alternatives/printf' to '/usr/lib/opkg/alternatives/printf'
Moving old '/usr/lib/ipkg/alternatives/ps' to '/usr/lib/opkg/alternatives/ps'
Moving old '/usr/lib/ipkg/alternatives/psplash' to '/usr/lib/opkg/alternatives/psplash'
Moving old '/usr/lib/ipkg/alternatives/pwd' to '/usr/lib/opkg/alternatives/pwd'
Moving old '/usr/lib/ipkg/alternatives/rdate' to '/usr/lib/opkg/alternatives/rdate'
Moving old '/usr/lib/ipkg/alternatives/rdev' to '/usr/lib/opkg/alternatives/rdev'
Moving old '/usr/lib/ipkg/alternatives/readahead' to '/usr/lib/opkg/alternatives/readahead'
Moving old '/usr/lib/ipkg/alternatives/readlink' to '/usr/lib/opkg/alternatives/readlink'
Moving old '/usr/lib/ipkg/alternatives/readprofile' to '/usr/lib/opkg/alternatives/readprofile'
Moving old '/usr/lib/ipkg/alternatives/realpath' to '/usr/lib/opkg/alternatives/realpath'
Moving old '/usr/lib/ipkg/alternatives/reboot' to '/usr/lib/opkg/alternatives/reboot'
Moving old '/usr/lib/ipkg/alternatives/renice' to '/usr/lib/opkg/alternatives/renice'
Moving old '/usr/lib/ipkg/alternatives/reset' to '/usr/lib/opkg/alternatives/reset'
Moving old '/usr/lib/ipkg/alternatives/rm' to '/usr/lib/opkg/alternatives/rm'
Moving old '/usr/lib/ipkg/alternatives/rmdir' to '/usr/lib/opkg/alternatives/rmdir'
Moving old '/usr/lib/ipkg/alternatives/rmmod' to '/usr/lib/opkg/alternatives/rmmod'
Moving old '/usr/lib/ipkg/alternatives/route' to '/usr/lib/opkg/alternatives/route'
Moving old '/usr/lib/ipkg/alternatives/rtcwake' to '/usr/lib/opkg/alternatives/rtcwake'
Moving old '/usr/lib/ipkg/alternatives/run-parts' to '/usr/lib/opkg/alternatives/run-parts'
Moving old '/usr/lib/ipkg/alternatives/scp' to '/usr/lib/opkg/alternatives/scp'
Moving old '/usr/lib/ipkg/alternatives/sed' to '/usr/lib/opkg/alternatives/sed'
Moving old '/usr/lib/ipkg/alternatives/seq' to '/usr/lib/opkg/alternatives/seq'
Moving old '/usr/lib/ipkg/alternatives/setconsole' to '/usr/lib/opkg/alternatives/setconsole'
Moving old '/usr/lib/ipkg/alternatives/setfont' to '/usr/lib/opkg/alternatives/setfont'
Moving old '/usr/lib/ipkg/alternatives/sh' to '/usr/lib/opkg/alternatives/sh'
Moving old '/usr/lib/ipkg/alternatives/showkey' to '/usr/lib/opkg/alternatives/showkey'
Moving old '/usr/lib/ipkg/alternatives/shutdown' to '/usr/lib/opkg/alternatives/shutdown'
Moving old '/usr/lib/ipkg/alternatives/sleep' to '/usr/lib/opkg/alternatives/sleep'
Moving old '/usr/lib/ipkg/alternatives/sort' to '/usr/lib/opkg/alternatives/sort'
Moving old '/usr/lib/ipkg/alternatives/ssh' to '/usr/lib/opkg/alternatives/ssh'
Moving old '/usr/lib/ipkg/alternatives/start-stop-daemon' to '/usr/lib/opkg/alternatives/start-stop-daemon'
Moving old '/usr/lib/ipkg/alternatives/stat' to '/usr/lib/opkg/alternatives/stat'
Moving old '/usr/lib/ipkg/alternatives/strings' to '/usr/lib/opkg/alternatives/strings'
Moving old '/usr/lib/ipkg/alternatives/stty' to '/usr/lib/opkg/alternatives/stty'
Moving old '/usr/lib/ipkg/alternatives/su' to '/usr/lib/opkg/alternatives/su'
Moving old '/usr/lib/ipkg/alternatives/sulogin' to '/usr/lib/opkg/alternatives/sulogin'
Moving old '/usr/lib/ipkg/alternatives/swapoff' to '/usr/lib/opkg/alternatives/swapoff'
Moving old '/usr/lib/ipkg/alternatives/swapon' to '/usr/lib/opkg/alternatives/swapon'
Moving old '/usr/lib/ipkg/alternatives/switch_root' to '/usr/lib/opkg/alternatives/switch_root'
Moving old '/usr/lib/ipkg/alternatives/sync' to '/usr/lib/opkg/alternatives/sync'
Moving old '/usr/lib/ipkg/alternatives/sysctl' to '/usr/lib/opkg/alternatives/sysctl'
Moving old '/usr/lib/ipkg/alternatives/syslogd' to '/usr/lib/opkg/alternatives/syslogd'
Moving old '/usr/lib/ipkg/alternatives/tail' to '/usr/lib/opkg/alternatives/tail'
Moving old '/usr/lib/ipkg/alternatives/tar' to '/usr/lib/opkg/alternatives/tar'
Moving old '/usr/lib/ipkg/alternatives/tee' to '/usr/lib/opkg/alternatives/tee'
Moving old '/usr/lib/ipkg/alternatives/telnet' to '/usr/lib/opkg/alternatives/telnet'
Moving old '/usr/lib/ipkg/alternatives/telnetd' to '/usr/lib/opkg/alternatives/telnetd'
Moving old '/usr/lib/ipkg/alternatives/test' to '/usr/lib/opkg/alternatives/test'
Moving old '/usr/lib/ipkg/alternatives/tftp' to '/usr/lib/opkg/alternatives/tftp'
Moving old '/usr/lib/ipkg/alternatives/time' to '/usr/lib/opkg/alternatives/time'
Moving old '/usr/lib/ipkg/alternatives/top' to '/usr/lib/opkg/alternatives/top'
Moving old '/usr/lib/ipkg/alternatives/touch' to '/usr/lib/opkg/alternatives/touch'
Moving old '/usr/lib/ipkg/alternatives/tr' to '/usr/lib/opkg/alternatives/tr'
Moving old '/usr/lib/ipkg/alternatives/traceroute' to '/usr/lib/opkg/alternatives/traceroute'
Moving old '/usr/lib/ipkg/alternatives/true' to '/usr/lib/opkg/alternatives/true'
Moving old '/usr/lib/ipkg/alternatives/tty' to '/usr/lib/opkg/alternatives/tty'
Moving old '/usr/lib/ipkg/alternatives/udhcpc' to '/usr/lib/opkg/alternatives/udhcpc'
Moving old '/usr/lib/ipkg/alternatives/udhcpd' to '/usr/lib/opkg/alternatives/udhcpd'
Moving old '/usr/lib/ipkg/alternatives/umount' to '/usr/lib/opkg/alternatives/umount'
Moving old '/usr/lib/ipkg/alternatives/uname' to '/usr/lib/opkg/alternatives/uname'
Moving old '/usr/lib/ipkg/alternatives/uniq' to '/usr/lib/opkg/alternatives/uniq'
Moving old '/usr/lib/ipkg/alternatives/unzip' to '/usr/lib/opkg/alternatives/unzip'
Moving old '/usr/lib/ipkg/alternatives/uptime' to '/usr/lib/opkg/alternatives/uptime'
Moving old '/usr/lib/ipkg/alternatives/usleep' to '/usr/lib/opkg/alternatives/usleep'
Moving old '/usr/lib/ipkg/alternatives/vi' to '/usr/lib/opkg/alternatives/vi'
Moving old '/usr/lib/ipkg/alternatives/vlock' to '/usr/lib/opkg/alternatives/vlock'
Moving old '/usr/lib/ipkg/alternatives/wall' to '/usr/lib/opkg/alternatives/wall'
Moving old '/usr/lib/ipkg/alternatives/watch' to '/usr/lib/opkg/alternatives/watch'
Moving old '/usr/lib/ipkg/alternatives/wc' to '/usr/lib/opkg/alternatives/wc'
Moving old '/usr/lib/ipkg/alternatives/wget' to '/usr/lib/opkg/alternatives/wget'
Moving old '/usr/lib/ipkg/alternatives/which' to '/usr/lib/opkg/alternatives/which'
Moving old '/usr/lib/ipkg/alternatives/who' to '/usr/lib/opkg/alternatives/who'
Moving old '/usr/lib/ipkg/alternatives/whoami' to '/usr/lib/opkg/alternatives/whoami'
Moving old '/usr/lib/ipkg/alternatives/x-terminal-emulator' to '/usr/lib/opkg/alternatives/x-terminal-emulator'
Replacing '/usr/lib/opkg/alternatives/x-window-manager' with '/usr/lib/ipkg/alternatives/x-window-manager'
Moving old '/usr/lib/ipkg/alternatives/xargs' to '/usr/lib/opkg/alternatives/xargs'
Moving old '/usr/lib/ipkg/alternatives/yes' to '/usr/lib/opkg/alternatives/yes'
Moving old '/usr/lib/ipkg/alternatives/zImage' to '/usr/lib/opkg/alternatives/zImage'
Moving old '/usr/lib/ipkg/alternatives/zcat' to '/usr/lib/opkg/alternatives/zcat'
Merge finished, old directory '/usr/lib/ipkg/alternatives' is removed

#9 lore raw

PATCH 1/1 update-alternatives-cworth: use /usr/lib/opkg/alternatives directory instead of /usr/lib/ipkg/alternatives

In reply to Koen Kooi

* It's usefull to make it compatible with u-a script in opkg package
* Old entries are merged to new directory in quite verbose postinst script
* If entry exists only in old its moved
* If entry exists in both the one with more lines is used
* The one with less lines is not used and warning is shown
* If they have the same number of lines diff is checked
* If they are the same, old one is ignored
* If they are different, old one is ignored and warning is shown

---
 .../update-alternatives-cworth.inc                 |   44 +++++++++++++++++++-
 .../use-opkg-dir-instead-of-ipkg.patch             |   11 +++++
 2 files changed, 53 insertions(+), 2 deletions(-)
 create mode 100644 recipes/update-alternatives/update-alternatives-cworth/use-opkg-dir-instead-of-ipkg.patch
recipes/update-alternatives/update-alternatives-cworth.inc +42 -2
index 2d8fd42..23d559b 100644
@@ -1,8 +1,48 @@
 LICENSE = "GPL"
 SECTION = "base"
 SRC_URI = "${HANDHELDS_CVS};module=familiar/dist/ipkg;tag=${@'V' + bb.data.getVar('PV',d,1).replace('.', '-')} \
-           file://update-alternatives.use.last.patch;patch=1"
+           file://update-alternatives.use.last.patch;patch=1 \
+           file://use-opkg-dir-instead-of-ipkg.patch;patch=1 "
 S = "${WORKDIR}/ipkg/C"
 PACKAGE_ARCH = "all"
 
-INC_PR = "r3"
+INC_PR = "r4"
+
+# Moves all entries from /usr/lib/ipkg/alternatives to /usr/lib/opkg/alternatives
+# If it exists in both it use file with more lines
+
+pkg_postinst() {
+        alternatives_dir_old="${prefix}/lib/ipkg/alternatives"
+        alternatives_dir_new="${prefix}/lib/opkg/alternatives"
+        if [ -e "${alternatives_dir_old}" ] ; then
+                echo "Old alternatives directory ${alternatives_dir_old} exists, moving entries to new one ${alternatives_dir_new}"
+                echo "Creating backup copy of both ${alternatives_dir_old}-backup and ${alternatives_dir_new}-backup"
+                cp -ra "${alternatives_dir_old}" "${alternatives_dir_old}-backup"
+                cp -ra "${alternatives_dir_new}" "${alternatives_dir_new}-backup"
+
+                cd ${alternatives_dir_old}
+                for alt_file in * ; do
+                        if [ ! -e "${alternatives_dir_new}/${alt_file}" ] ; then
+                                echo "Moving old '${alternatives_dir_old}/${alt_file}' to '${alternatives_dir_new}/${alt_file}'";
+                                mv -f "${alternatives_dir_old}/${alt_file}" "${alternatives_dir_new}/${alt_file}"
+                        else
+                                OLD_LINES=`wc -l ${alternatives_dir_old}/${alt_file} | cut -d/ -f 1`;
+                                NEW_LINES=`wc -l ${alternatives_dir_new}/${alt_file} | cut -d/ -f 1`;
+                                if [ $OLD_LINES -gt $NEW_LINES ] ; then
+                                        echo "Replacing '${alternatives_dir_new}/${alt_file}' with '${alternatives_dir_old}/${alt_file}'";
+                                        mv -f "${alternatives_dir_old}/${alt_file}" "${alternatives_dir_new}/${alt_file}"
+                                elif [ $OLD_LINES -eq $NEW_LINES ] ; then
+                                        if diff -q "${alternatives_dir_new}/${alt_file}" "${alternatives_dir_old}/${alt_file}" >/dev/null ; then
+                                                echo "'{alternatives_dir_new}/${alt_file}' is the same"
+                                        else
+                                                echo "WARN: You have to update manually if needed. Please check: diff '${alternatives_dir_old}-backup/${alt_file}' '${alternatives_dir_new}-backup/${alt_file}'"
+                                        fi
+                                else
+                                        echo "WARN: '${alternatives_dir_old}/${alt_file}' is shorter than new one, ignoring, but please check and update manually if needed"
+                                fi
+                        fi
+                done
+		rm -rf ${alternatives_dir_old}
+		echo "Merge finished, old directory '${alternatives_dir_old}' is removed"
+        fi
+}
recipes/update-alternatives/update-alternatives-cworth/use-opkg-dir-instead-of-ipkg.patch new file +11 -0
new file mode 100644
index 0000000..4355556
@@ -0,0 +1,11 @@
+--- C.orig/update-alternatives	2010-01-08 15:40:20.000000000 +0100
++++ C/update-alternatives	2010-01-08 15:40:47.000000000 +0100
+@@ -21,7 +21,7 @@
+ set -e
+ 
+ # admin dir
+-ad="$IPKG_OFFLINE_ROOT/usr/lib/ipkg/alternatives"
++ad="$IPKG_OFFLINE_ROOT/usr/lib/opkg/alternatives"
+ 
+ usage() {
+ 	echo "update-alternatives: $*
Signature · 1 line
1.6.6
#10 lore raw

Re: [PATCH] update-alternatives-cworth: use /usr/lib/opkg/alternatives directory instead of /usr/lib/ipkg/alternatives

There is missing $, fixed locally

Quoted 3 lines

+                                                echo "'{alternatives_dir_new}/${alt_file}' is the same"

+                                                echo "$'{alternatives_dir_new}/${alt_file}' is the same"

But I have another successful test on image built before 2009-12-09 so with most alternatives in ipkg/alternatives from -cworth-native

http://pastebin.com/m4bc4f1d8

#11 lore raw

Re: [PATCH] update-alternatives-cworth: use /usr/lib/opkg/alternatives directory instead of /usr/lib/ipkg/alternatives

I've already pushed it to shr/merge branch with temporary D_P = -1 in new busybox. Please review if its good enough for oe.dev.

BTW: same postinst should be added to opkg, to fix the issue also on systems where u-a-cworth was removed already, or used only for building image. And if its part of opkg postinst we can remove -cworth.

Does opkg upgrade itself before upgrading other stuff? As we need to force "alternatives merge" with opkg or u-a-cworth bump, before ie busybox upgrade.

Cheers,

#12 lore raw
In reply to Martin Jansa

Hi,

Still no review/ACK :(.

I'll try to explain it better to show how bad it can be and even make review easier.

We have target where sysvinit as init is crucial for successful boot (ie SHR on freerunner) and u-a-cworth is installed on image, because task-boot RDEPENDs on update-alternatives.

Let's start with image built after 2009-12-08.
u-a-opkg is used for in do_rootfs, but u-a-cworth is installed in image too and is used by default.

T1) after flashing
ipkg/alternatives/init opkg/alternatives/init

    doesnt-exist                  /sbin/init
                                  /sbin/init.sysvinit 60
                                 ../bin/busybox 50

=>sysvinit is used, everything is fine

good scenario:
T2a) sysvinit is upgraded first
ipkg/alternatives/init opkg/alternatives/init
/sbin/init /sbin/init
/sbin/init.sysvinit 60 /sbin/init.sysvinit 60
../bin/busybox 50
=>sysvinit is used, everything is fine
- newer file works but is incomplete

T3a) busybox is upgraded
ipkg/alternatives/init opkg/alternatives/init

    /sbin/init                    /sbin/init
    /sbin/init.sysvinit 60        /sbin/init.sysvinit 60
    ../bin/busybox 50             ../bin/busybox 50

=>sysvinit is used, everything is fine
- newer file works and is the same as opkg

bad scenario
T2b) busybox is upgrade first
ipkg/alternatives/init opkg/alternatives/init
/sbin/init /sbin/init
../bin/busybox 50 /sbin/init.sysvinit 60
../bin/busybox 50
=>busybox is used, device won't boot anymore
- newer file is from cworth but is worse

T3b) sysvinit is upgraded
ipkg/alternatives/init opkg/alternatives/init
/sbin/init /sbin/init
/sbin/init.sysvinit 60 /sbin/init.sysvinit 60
../bin/busybox 50 ../bin/busybox 50

=>sysvinit is used again, everything is fine
- newer file works and is the same again

If we merge ipkg/alternatives and opkg/alternatives before T2b) there will be no problem.

If we merge it after T2b) and then force busybox upgrade then we will fix broken image too (as busybox is using probably the most u-a links and has lowest priority). So busybox PR bump is good idea AFTER merging u-a alternatives.

Worst scenario (where merger fails):
Tfsck) After T3a) or T3b) user intentionally remove sysvint package
(ie because he can boot even with busybox)
ipkg/alternatives/init opkg/alternatives/init
/sbin/init /sbin/init
../bin/busybox 50 /sbin/init.sysvinit 60
../bin/busybox 50
=>busybox is used, user is happy

then we run merge script (longer alternative file wins =>sysvinit is used again, but without actuall /sbin/init.sysvinit file in fs.. boot fails, user is sad. I think there is no way to distinguish between T2b where newer shorter file is wrong and Tfsck where newer shorter file is the right one (without checking opkg history..)

With images built before 2009-12-08 it should be simple opkg/alternatives should be empty, all files from ipkg/alternatives are just moved there..

Why would I like to add the same merge script to opkg?
1) someone maybe already removed -cworth from image with first sign of issues (but still too late) and -cworth postinst is still needed

2) task-boot will be fixed (RDEPEND on same u-a as virtual/update-alternatives-native) and user won't get -cworth update.

3) If I get new -cworth and busybox in one opkg upgrade batch, then I'm not sure which postinst will be executed first (we need -cworth first), but opkg maybe run own postinst before configuring other packages (ie portage does that completely even with restart of upgrade process)

Updated -cworth is already used in SHR (from shr/merge branch).

My shell foo is maybe not strong enough to check that everything is available in all environments and no bashisms were used..)

Thanks and please comment (I'll resend whole patch serie as soon as someone confirms that's good path to go).

Regards,

Signature · 3 lines
uin:136542059                jid:[email protected]
Jansa Martin                 sip:[email protected] 
JaMa                         
#13 lore raw

PATCH 1/3 opkg, update-alternatives-cworth: use /usr/lib/opkg/alternatives directory instead of /usr/lib/ipkg/alternatives

* It's usefull to make it compatible with u-a script in opkg package
* Old entries are merged to new directory in quite verbose postinst script
* If entry exists only in old its moved
* If entry exists in both the one with more lines is used
* The one with less lines is not used and warning is shown
* If they have the same number of lines diff is checked
* If they are the same, old one is ignored
* If they are different, old one is ignored and warning is shown

---
 recipes/opkg/opkg.inc                              |    2 +-
 recipes/opkg/opkg_svn.bb                           |    2 +
 recipes/opkg/update-alternatives-merge.inc         |   41 ++++++++++++++++++++
 .../update-alternatives-cworth.inc                 |    7 ++-
 .../use-opkg-dir-instead-of-ipkg.patch             |   11 +++++
 5 files changed, 60 insertions(+), 3 deletions(-)
 create mode 100644 recipes/opkg/update-alternatives-merge.inc
 create mode 100644 recipes/update-alternatives/update-alternatives-cworth/use-opkg-dir-instead-of-ipkg.patch
recipes/opkg/opkg.inc +1 -1
index 1716034..b317de4 100644
@@ -4,7 +4,7 @@ SECTION = "base"
 LICENSE = "GPL"
 DEPENDS = "curl gpgme"
 PV = "0.1.6+svnr${SRCPV}"
-INC_PR = "r18"
+INC_PR = "r20"
 
 FILESPATHPKG =. "opkg:"
 
recipes/opkg/opkg_svn.bb +2 -0
index 44c0baf..4945260 100644
@@ -25,3 +25,5 @@ pkg_postinst_${PN} () {
 pkg_postrm_${PN} () {
   update-alternatives --remove opkg ${bindir}/opkg-cl
 }
+
+require update-alternatives-merge.inc
recipes/opkg/update-alternatives-merge.inc new file +41 -0

41 lines not on this page · raw message

recipes/update-alternatives/update-alternatives-cworth.inc +5 -2
index 2d8fd42..16d779e 100644
@@ -1,8 +1,11 @@
 LICENSE = "GPL"
 SECTION = "base"
 SRC_URI = "${HANDHELDS_CVS};module=familiar/dist/ipkg;tag=${@'V' + bb.data.getVar('PV',d,1).replace('.', '-')} \
-           file://update-alternatives.use.last.patch;patch=1"
+           file://update-alternatives.use.last.patch;patch=1 \
+           file://use-opkg-dir-instead-of-ipkg.patch;patch=1 "
 S = "${WORKDIR}/ipkg/C"
 PACKAGE_ARCH = "all"
 
-INC_PR = "r3"
+INC_PR = "r4"
+
+require ../opkg/update-alternatives-merge.inc
recipes/update-alternatives/update-alternatives-cworth/use-opkg-dir-instead-of-ipkg.patch new file +11 -0
new file mode 100644
index 0000000..4355556
@@ -0,0 +1,11 @@
+--- C.orig/update-alternatives	2010-01-08 15:40:20.000000000 +0100
++++ C/update-alternatives	2010-01-08 15:40:47.000000000 +0100
+@@ -21,7 +21,7 @@
+ set -e
+ 
+ # admin dir
+-ad="$IPKG_OFFLINE_ROOT/usr/lib/ipkg/alternatives"
++ad="$IPKG_OFFLINE_ROOT/usr/lib/opkg/alternatives"
+ 
+ usage() {
+ 	echo "update-alternatives: $*
Signature · 1 line
1.6.6
#14 lore raw

PATCH 2/3 task-boot: use DISTRO_UPDATE_ALTERNATIVES instead of update-alternatives directly

* Images built after 2009-12-08 9b641bbfed07c075ae5cbe84082a85f1ba703447 probably use opkg-native, but also ship with u-a-cworth

---
 recipes/tasks/task-boot.bb |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)
recipes/tasks/task-boot.bb +8 -2
index 04c5535..45d50ef 100644
@@ -1,5 +1,5 @@
 DESCRIPTION = "Basic task to get a device booting"
-PR = "r51"
+PR = "r52"
 
 inherit task
 
@@ -13,6 +13,12 @@ PACKAGE_ARCH = "${MACHINE_ARCH}"
 MACHINE_ESSENTIAL_EXTRA_RDEPENDS ?= ""
 MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS ?= ""
 
+# update-alternatives script installed in rootfs needs to be the same as
+# u-a script used for building image which is defined with
+# PREFERRED_PROVIDER_virtual/update-alternatives-native
+
+DISTRO_UPDATE_ALTERNATIVES ?= "${PREFERRED_PROVIDER_virtual/update-alternatives}"
+
 # Make sure we build the kernel
 DEPENDS = "virtual/kernel"
 
@@ -26,7 +32,7 @@ RDEPENDS_task-boot = "\
     ${@base_contains("MACHINE_FEATURES", "keyboard", "keymaps", "", d)} \
     modutils-initscripts \
     netbase \
-    update-alternatives \
+    ${DISTRO_UPDATE_ALTERNATIVES} \
     ${MACHINE_ESSENTIAL_EXTRA_RDEPENDS} \
     "
 
Signature · 1 line
1.6.6
#15 lore raw

PATCH 3/3 busybox: bump INC_PR to force postinst script run on targets after u-a fixup

---
 recipes/busybox/busybox.inc |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
recipes/busybox/busybox.inc +1 -1
index 753b402..519fcd6 100644
@@ -11,7 +11,7 @@ LICENSE = "GPL"
 SECTION = "base"
 PRIORITY = "required"
 
-INC_PR = "r23"
+INC_PR = "r24"
 
 SRC_URI = "\
   http://www.busybox.net/downloads/busybox-${PV}.tar.gz \
Signature · 1 line
1.6.6
#16 lore raw

Re: [PATCH 1/3] opkg, update-alternatives-cworth: use /usr/lib/opkg/alternatives directory instead of /usr/lib/ipkg/alternatives

In reply to Martin Jansa

Am Mittwoch, den 13.01.2010, 01:17 +0100 schrieb Martin Jansa:

Quoted 4 lines

* It's usefull to make it compatible with u-a script in opkg package
* Old entries are merged to new directory in quite verbose postinst script
* If entry exists only in old its moved

it’s

[…]

recipes/opkg/opkg.inc SECTION = "base" · line 7

Quoted 10 lines
recipes/opkg/opkg.inc +1 -1
index 1716034..b317de4 100644
@@ -4,7 +4,7 @@ SECTION = "base"
 LICENSE = "GPL"
 DEPENDS = "curl gpgme"
 PV = "0.1.6+svnr${SRCPV}"
-INC_PR = "r18"
+INC_PR = "r20"

I know it would not be a problem, but should not that only be increased by one [1]?

[…]

Thanks,

Paul

[1] http://docs.openembedded.org/usermanual/html/recipes_versioning.html

#17 lore raw

Re: [PATCH 1/3] opkg, update-alternatives-cworth: use /usr/lib/opkg/alternatives directory instead of /usr/lib/ipkg/alternatives

Quoted 7 lines · Paul Menzel

Am Mittwoch, den 13.01.2010, 01:17 +0100 schrieb Martin Jansa:

Quoted 4 lines

* It's usefull to make it compatible with u-a script in opkg package
* Old entries are merged to new directory in quite verbose postinst script
* If entry exists only in old its moved

it’s

Thanks, will fix that.

Quoted 16 lines

[…]

recipes/opkg/opkg.inc SECTION = "base" · line 7

Quoted 10 lines
recipes/opkg/opkg.inc +1 -1
index 1716034..b317de4 100644
@@ -4,7 +4,7 @@ SECTION = "base"
 LICENSE = "GPL"
 DEPENDS = "curl gpgme"
 PV = "0.1.6+svnr${SRCPV}"
-INC_PR = "r18"
+INC_PR = "r20"

I know it would not be a problem, but should not that only be increased by one [1]?

OK, will fix that one too, sorry for that.. I had one bump in between because adding RCONFLICTS_${PN} = "update-alternatives-cworth", but I dropped this patch later, because it's not such a problem with both u-a using same dir. And would confuse end-user a bit more with next upgrade.

Quoted 16 lines

[…]

Thanks,

Paul

[1] http://docs.openembedded.org/usermanual/html/recipes_versioning.html

_______________________________________________
Openembedded-devel mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-devel

Signature · 3 lines
uin:136542059                jid:[email protected]
Jansa Martin                 sip:[email protected] 
JaMa                         
#18 lore raw
In reply to Martin Jansa

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 3 lines · Martin Jansa

Hi,

Still no review/ACK :(.

They seem to look decent enough, but I lack the time to test them, so feel free to apply them

regards,

Koen

Quoted 94 lines

I'll try to explain it better to show how bad it can be and even make review easier.

We have target where sysvinit as init is crucial for successful boot (ie SHR on freerunner) and u-a-cworth is installed on image, because task-boot RDEPENDs on update-alternatives.

Let's start with image built after 2009-12-08.
u-a-opkg is used for in do_rootfs, but u-a-cworth is installed in image too and is used by default.

T1) after flashing
ipkg/alternatives/init opkg/alternatives/init

    doesnt-exist                  /sbin/init
                                  /sbin/init.sysvinit 60
                                 ../bin/busybox 50

=>sysvinit is used, everything is fine

good scenario:
T2a) sysvinit is upgraded first
ipkg/alternatives/init opkg/alternatives/init
/sbin/init /sbin/init
/sbin/init.sysvinit 60 /sbin/init.sysvinit 60
../bin/busybox 50
=>sysvinit is used, everything is fine
- newer file works but is incomplete

T3a) busybox is upgraded
ipkg/alternatives/init opkg/alternatives/init

    /sbin/init                    /sbin/init
    /sbin/init.sysvinit 60        /sbin/init.sysvinit 60
    ../bin/busybox 50             ../bin/busybox 50

=>sysvinit is used, everything is fine
- newer file works and is the same as opkg

bad scenario
T2b) busybox is upgrade first
ipkg/alternatives/init opkg/alternatives/init
/sbin/init /sbin/init
../bin/busybox 50 /sbin/init.sysvinit 60
../bin/busybox 50
=>busybox is used, device won't boot anymore
- newer file is from cworth but is worse

T3b) sysvinit is upgraded
ipkg/alternatives/init opkg/alternatives/init
/sbin/init /sbin/init
/sbin/init.sysvinit 60 /sbin/init.sysvinit 60
../bin/busybox 50 ../bin/busybox 50

=>sysvinit is used again, everything is fine
- newer file works and is the same again

If we merge ipkg/alternatives and opkg/alternatives before T2b) there will be no problem.

If we merge it after T2b) and then force busybox upgrade then we will fix broken image too (as busybox is using probably the most u-a links and has lowest priority). So busybox PR bump is good idea AFTER merging u-a alternatives.

Worst scenario (where merger fails):
Tfsck) After T3a) or T3b) user intentionally remove sysvint package
(ie because he can boot even with busybox)
ipkg/alternatives/init opkg/alternatives/init
/sbin/init /sbin/init
../bin/busybox 50 /sbin/init.sysvinit 60
../bin/busybox 50
=>busybox is used, user is happy

then we run merge script (longer alternative file wins =>sysvinit is used again, but without actuall /sbin/init.sysvinit file in fs.. boot fails, user is sad. I think there is no way to distinguish between T2b where newer shorter file is wrong and Tfsck where newer shorter file is the right one (without checking opkg history..)

With images built before 2009-12-08 it should be simple opkg/alternatives should be empty, all files from ipkg/alternatives are just moved there..

Why would I like to add the same merge script to opkg?
1) someone maybe already removed -cworth from image with first sign of issues (but still too late) and -cworth postinst is still needed

2) task-boot will be fixed (RDEPEND on same u-a as virtual/update-alternatives-native) and user won't get -cworth update.

3) If I get new -cworth and busybox in one opkg upgrade batch, then I'm not sure which postinst will be executed first (we need -cworth first), but opkg maybe run own postinst before configuring other packages (ie portage does that completely even with restart of upgrade process)

Updated -cworth is already used in SHR (from shr/merge branch).

Quoted 8 lines

My shell foo is maybe not strong enough to check that everything is available in all environments and no bashisms were used..)

Thanks and please comment (I'll resend whole patch serie as soon as someone confirms that's good path to go).

Regards,

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Darwin)

iD8DBQFLTYRRMkyGM64RGpERAqECAKCx2TxGSWTxSt0JlFP2APfRu7sEIwCeM/bc CKNj3N9TmFmaWj0LGCAlrJc=
=vegr
-----END PGP SIGNATURE-----

#19 lore raw
Quoted 6 lines · Koen Kooi

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 2 lines · Martin Jansa

Hi,

Quoted 8 lines
Quoted 1 line

Still no review/ACK :(.

They seem to look decent enough, but I lack the time to test them, so feel free to apply them

regards,

Koen

Thanks, pushed.

and small warning..

buildhost with u-a-cworth staged from times before 2009-12-08 should be also "fixed", because after P_P_virtual/update-alternatives-native change is not -cworth-native upgrade with opkg patch pulled to build and new image is still using old u-a-cworth and store alternatives in /usr/lib/ipkg/. u-a-cworth-native should be removed or at least upgraded.

shr@opmbuild:~/shr-unstable$ find tmp/staging/ -name update-alternatives
tmp/staging/x86_64-linux/usr/sbin/update-alternatives
tmp/staging/x86_64-linux/usr/bin/update-alternatives
shr@opmbuild:~/shr-unstable$ bitbake -c clean -b openembedded/recipes/update-alternatives/update-alternatives-cworth-native_0.99.154.bb
...
shr@opmbuild:~/shr-unstable$ find tmp/staging/ -name update-alternatives
tmp/staging/x86_64-linux/usr/bin/update-alternatives
Signature · 3 lines
uin:136542059                jid:[email protected]
Jansa Martin                 sip:[email protected] 
JaMa