Skip to contentSkip to conversation

opkg: update-alternatives fails for "[" and "[[" in busybox

PATCH In review Liu Jian 2 participants 2 messages Oct 22, 2014

lore
Share & tools
lore

Liu Jian

author
#0 lore raw

PATCH v2 1/1 opkg: update-alternatives fails for "[" and "[[" in busybox

Building a small filesystem with busybox gives the following error lines:
(see log.do_rootfs under bitbake_build/tmp/work/)
sed: -e expression #1, char 41: unterminated address regex
sed: -e expression #1, char 42: unterminated address regex This is caused by the script bitbake_build/tmp/sysroots/x86_64-linux/usr/bin/update-alternatives. "[" can not be used directly in sed expression.

---
...andle-leftbracket-for-update-alternatives.patch | 23
++++++++++++++++++++++
meta/recipes-devtools/opkg/opkg_0.2.2.bb | 1 +

2 files changed, 24 insertions(+)

create mode 100644 meta/recipes-devtools/opkg/opkg/handle-leftbracket-for-update-alternatives.patch

diff --git a/meta/recipes-devtools/opkg/opkg/handle-leftbracket-for-update-alternatives.patch b/meta/recipes-devtools/opkg/opkg/handle-leftbracket-for-update-alternatives.patch new file mode 100644
index 0000000..7c9eac7
--- /dev/null
+++
b/meta/recipes-devtools/opkg/opkg/handle-leftbracket-for-update-alternatives.patch @@ -0,0 +1,23 @@
+diff -Nur trunk.orig/utils/update-alternatives.in trunk/utils/update-alternatives.in
+--- trunk.orig/utils/update-alternatives.in 2013-08-16 04:22:29.000000000 +0800
++++ trunk/utils/update-alternatives.in 2014-09-19 10:55:22.238159317 +0800 +@@ -68,6 +68,10 @@
+ sed -e 's/\//\\\//g'
+ }
+
++protect_special_character() {
++ sed -e 's/\[/\\\[/g'
++}
++
+ remove_alt() {
+ [ $# -lt 2 ] && return 1
+ local name="$1"
+@@ -75,7 +79,7 @@
+
+ [ ! -f $ad/$name ] && return 0
+

+- path=`echo $path | protect_slashes`
++ path=`echo $path | protect_slashes | protect_special_character`

+ sed -ne "/^$path\>.*/!p" $ad/$name > $ad/$name.new
+ mv $ad/$name.new $ad/$name
+ }

(quoted diff) +0 -0

b/meta/recipes-devtools/opkg/opkg_0.2.2.bb
index 867ff7a..9d09194 100644

meta/recipes-devtools/opkg/opkg_0.2.2.bb +0 -0
@@ -5,6 +5,7 @@ SRC_URI =

"http://downloads.yoctoproject.org/releases/${BPN}/${BPN}-${PV}.tar.gz file://add-exclude.patch \
file://opkg-configure.service \
file://libopkg-opkg_remove.c-avoid-remove-pkg-repeatly-with.patch \
+ file://handle-leftbracket-for-update-alternatives.patch \
"

S = "${WORKDIR}/${BPN}-${PV}"

Signature · 6 lines
1.8.5.2.233.g932f7e4

-- 
Jian Liu
Email: [email protected]
Office Phone: 86-10-84778539
#1 lore raw
Quoted 64 lines · Liu Jian

Building a small filesystem with busybox gives the following error lines:
(see log.do_rootfs under bitbake_build/tmp/work/)
sed: -e expression #1, char 41: unterminated address regex
sed: -e expression #1, char 42: unterminated address regex This is caused by the script bitbake_build/tmp/sysroots/x86_64-linux/usr/bin/update-alternatives. "[" can not be used directly in sed expression.

---
...andle-leftbracket-for-update-alternatives.patch | 23
++++++++++++++++++++++
meta/recipes-devtools/opkg/opkg_0.2.2.bb | 1 +

2 files changed, 24 insertions(+)

create mode 100644 meta/recipes-devtools/opkg/opkg/handle-leftbracket-for-update-alternatives.patch

diff --git a/meta/recipes-devtools/opkg/opkg/handle-leftbracket-for-update-alternatives.patch b/meta/recipes-devtools/opkg/opkg/handle-leftbracket-for-update-alternatives.patch new file mode 100644
index 0000000..7c9eac7
--- /dev/null
+++
b/meta/recipes-devtools/opkg/opkg/handle-leftbracket-for-update-alternatives.patch

(quoted diff) +1 -0
@@ -0,0 +1,23 @@
+diff -Nur trunk.orig/utils/update-alternatives.in

trunk/utils/update-alternatives.in
+--- trunk.orig/utils/update-alternatives.in 2013-08-16 04:22:29.000000000 +0800
++++ trunk/utils/update-alternatives.in 2014-09-19 10:55:22.238159317 +0800 +@@ -68,6 +68,10 @@
+ sed -e 's/\//\\\//g'
+ }

(quoted diff) +17 -0
+
++protect_special_character() {
++ sed -e 's/\[/\\\[/g'
++}
++
+ remove_alt() {
+ [ $# -lt 2 ] && return 1
+ local name="$1"
+@@ -75,7 +79,7 @@
+
+ [ ! -f $ad/$name ] && return 0
+
+- path=`echo $path | protect_slashes`
++ path=`echo $path | protect_slashes | protect_special_character`
+ sed -ne "/^$path\>.*/!p" $ad/$name > $ad/$name.new
+ mv $ad/$name.new $ad/$name
+ }
meta/recipes-devtools/opkg/opkg_0.2.2.bb +0 -0
index 867ff7a..9d09194 100644
@@ -5,6 +5,7 @@ SRC_URI =

"http://downloads.yoctoproject.org/releases/${BPN}/${BPN}-${PV}.tar.gz file://add-exclude.patch \
file://opkg-configure.service \
file://libopkg-opkg_remove.c-avoid-remove-pkg-repeatly-with.patch \
+ file://handle-leftbracket-for-update-alternatives.patch \
"

Quoted 9 lines

S = "${WORKDIR}/${BPN}-${PV}"
--
1.8.5.2.233.g932f7e4

--
Jian Liu
Email: [email protected]
Office Phone: 86-10-84778539

update-alternatives is now provided by the opkg-utils recipe, not opkg. opkg-utils is part of the Yocto Project so we maintain upstream as well. Could you take a look at the contribution guidelines for opkg-utils (http://git.yoctoproject.org/cgit/cgit.cgi/opkg-utils/tree/CONTRIBUTING)
and submit the patch against that? We can then just bump the SRCREV which is used within OpenEmbedded, rather than maintaining an isolated patch.

This should hopefully be fairly straightforward to do, the patch you have should apply cleanly to update-alternatives (there is no 'update-alternatives.in' anymore) and then just commit and send to the appropriate email addresses. If there's any issues let me know.

When opkg v0.3.0 is released, it will no longer contain the update-alternatives script so hopefully that will make things less confusing.

Thanks,

Signature · 4 lines
Paul Barker

Email: [email protected]
http://www.paulbarker.me.uk