All of lore.kernel.org
 help / color / mirror / Atom feed
From: Martin Jansa <martin.jansa@gmail.com>
To: openembedded-devel@lists.openembedded.org
Subject: [PATCH 1/3] opkg, update-alternatives-cworth: use /usr/lib/opkg/alternatives directory instead of /usr/lib/ipkg/alternatives
Date: Wed, 13 Jan 2010 01:17:18 +0100	[thread overview]
Message-ID: <1263341840-19186-1-git-send-email-Martin.Jansa@gmail.com> (raw)
In-Reply-To: <20100112222121.GD10781@jama>

* 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

diff --git a/recipes/opkg/opkg.inc b/recipes/opkg/opkg.inc
index 1716034..b317de4 100644
--- a/recipes/opkg/opkg.inc
+++ b/recipes/opkg/opkg.inc
@@ -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:"
 
diff --git a/recipes/opkg/opkg_svn.bb b/recipes/opkg/opkg_svn.bb
index 44c0baf..4945260 100644
--- a/recipes/opkg/opkg_svn.bb
+++ b/recipes/opkg/opkg_svn.bb
@@ -25,3 +25,5 @@ pkg_postinst_${PN} () {
 pkg_postrm_${PN} () {
   update-alternatives --remove opkg ${bindir}/opkg-cl
 }
+
+require update-alternatives-merge.inc
diff --git a/recipes/opkg/update-alternatives-merge.inc b/recipes/opkg/update-alternatives-merge.inc
new file mode 100644
index 0000000..69d949b
--- /dev/null
+++ b/recipes/opkg/update-alternatives-merge.inc
@@ -0,0 +1,41 @@
+# 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_append () {
+        alternatives_dir_old="${prefix}/lib/ipkg/alternatives"
+        alternatives_dir_new="${prefix}/lib/opkg/alternatives"
+        if [ -e "${alternatives_dir_old}" ] ; then
+        	if [ ! -e "${alternatives_dir_new}" ] ; then
+			mkdir -p "${alternatives_dir_new}";
+		fi
+                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
+}
diff --git a/recipes/update-alternatives/update-alternatives-cworth.inc b/recipes/update-alternatives/update-alternatives-cworth.inc
index 2d8fd42..16d779e 100644
--- a/recipes/update-alternatives/update-alternatives-cworth.inc
+++ b/recipes/update-alternatives/update-alternatives-cworth.inc
@@ -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
diff --git a/recipes/update-alternatives/update-alternatives-cworth/use-opkg-dir-instead-of-ipkg.patch b/recipes/update-alternatives/update-alternatives-cworth/use-opkg-dir-instead-of-ipkg.patch
new file mode 100644
index 0000000..4355556
--- /dev/null
+++ b/recipes/update-alternatives/update-alternatives-cworth/use-opkg-dir-instead-of-ipkg.patch
@@ -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: $*
-- 
1.6.6




  reply	other threads:[~2010-01-13  0:21 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-08 13:23 update-alternatives broken badly (by me :() Martin Jansa
2010-01-08 13:53 ` [PATCH] task-boot: use DISTRO_UPDATE_ALTERNATIVES instead of update-alternatives directly Martin Jansa
2010-01-08 14:02 ` update-alternatives broken badly (by me :() Holger Hans Peter Freyther
2010-01-08 14:07   ` Koen Kooi
2010-01-08 14:24   ` Martin Jansa
2010-01-08 14:05 ` Koen Kooi
2010-01-08 14:35   ` Martin Jansa
2010-01-08 15:47     ` [PATCH] update-alternatives-cworth: use /usr/lib/opkg/alternatives directory instead of /usr/lib/ipkg/alternatives Martin Jansa
2010-01-08 15:55     ` update-alternatives broken badly (by me :() Martin Jansa
2010-01-08 15:42   ` [PATCH] update-alternatives-cworth: use /usr/lib/opkg/alternatives directory instead of /usr/lib/ipkg/alternatives Martin Jansa
2010-01-08 18:32     ` Martin Jansa
2010-01-09 18:04       ` Martin Jansa
2010-01-12 22:21 ` update-alternatives broken badly (by me :() Martin Jansa
2010-01-13  0:17   ` Martin Jansa [this message]
2010-01-13  0:17     ` [PATCH 2/3] task-boot: use DISTRO_UPDATE_ALTERNATIVES instead of update-alternatives directly Martin Jansa
2010-01-13  0:17       ` [PATCH 3/3] busybox: bump INC_PR to force postinst script run on targets after u-a fixup Martin Jansa
2010-01-13  9:18     ` [PATCH 1/3] opkg, update-alternatives-cworth: use /usr/lib/opkg/alternatives directory instead of /usr/lib/ipkg/alternatives Paul Menzel
2010-01-13  9:28       ` Martin Jansa
2010-01-13  8:29   ` update-alternatives broken badly (by me :() Koen Kooi
2010-01-13 14:44     ` Martin Jansa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1263341840-19186-1-git-send-email-Martin.Jansa@gmail.com \
    --to=martin.jansa@gmail.com \
    --cc=openembedded-devel@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.