[oe-commits] Martin Jansa : opkg, update-alternatives-cworth: use /usr/lib/opkg/ alternatives directory instead of /usr/lib/ipkg/alternatives

git version control git at git.openembedded.org
Thu Jan 14 09:45:08 UTC 2010


Module: openembedded.git
Branch: shr/testing2009
Commit: 4d7a482f9b7bcd3a86d67fed8f0988297bd17d47
URL:    http://gitweb.openembedded.net/?p=openembedded.git&a=commit;h=4d7a482f9b7bcd3a86d67fed8f0988297bd17d47

Author: Martin Jansa <Martin.Jansa at gmail.com>
Date:   Fri Jan  8 16:14:46 2010 +0100

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 it's 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

Signed-off-by: Martin Jansa <Martin.Jansa at gmail.com>

---

 recipes/opkg/opkg.inc                              |    2 +-
 recipes/opkg/opkg_svn.bb                           |    2 +
 recipes/opkg/update-alternatives-merge.inc         |   41 ++++++++++++++++++++
 .../update-alternatives-cworth.inc                 |   39 -------------------
 .../update-alternatives-cworth_0.99.154.bb         |    2 +
 5 files changed, 46 insertions(+), 40 deletions(-)

diff --git a/recipes/opkg/opkg.inc b/recipes/opkg/opkg.inc
index 1716034..20f415e 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 = "r19"
 
 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..a07275d
--- /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_${PN}_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 217b787..2d8ebb4 100644
--- a/recipes/update-alternatives/update-alternatives-cworth.inc
+++ b/recipes/update-alternatives/update-alternatives-cworth.inc
@@ -7,42 +7,3 @@ S = "${WORKDIR}/ipkg/C"
 PACKAGE_ARCH = "all"
 
 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
-}
diff --git a/recipes/update-alternatives/update-alternatives-cworth_0.99.154.bb b/recipes/update-alternatives/update-alternatives-cworth_0.99.154.bb
index b95d6d5..111d8c6 100644
--- a/recipes/update-alternatives/update-alternatives-cworth_0.99.154.bb
+++ b/recipes/update-alternatives/update-alternatives-cworth_0.99.154.bb
@@ -11,3 +11,5 @@ do_install () {
 
     install -m 0755 update-alternatives ${D}${sbindir}/update-alternatives
 }
+
+require ../opkg/update-alternatives-merge.inc





More information about the Openembedded-commits mailing list