Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH] dpkg, opkg, rpm-postinst: fix overwriting the run-postinstall script
@ 2013-04-11  6:42 Laurentiu Palcu
  2013-04-11  7:06 ` ChenQi
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Laurentiu Palcu @ 2013-04-11  6:42 UTC (permalink / raw)
  To: openembedded-core

If multiple package managers are installed in the image, they will
overwrite each other's run-postinsts script, resulting in postinstalls
not beeing run at all at first boot.

What this patch does:
 * checks whether opkg/dpks/rpm is actually used to install
   the packages and, only after, creates the run-postinsts script;
 * brings dpkg recipe in sync with opkg: moves the script creation from
   do_install to postinstall;
 * move creation of run-postinsts script (rpm-postinsts recipe) to the
   postinstall scriptlet in order to better control the creation of the
   script according to the package manager used;

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@intel.com>
---
 meta/recipes-devtools/dpkg/dpkg.inc        |   23 ++++++++++++++---------
 meta/recipes-devtools/opkg/opkg.inc        |    3 ++-
 meta/recipes-devtools/rpm/rpm-postinsts.bb |   19 ++++++++++++-------
 3 files changed, 28 insertions(+), 17 deletions(-)

diff --git a/meta/recipes-devtools/dpkg/dpkg.inc b/meta/recipes-devtools/dpkg/dpkg.inc
index 6bb1e16..f7f7b01 100644
--- a/meta/recipes-devtools/dpkg/dpkg.inc
+++ b/meta/recipes-devtools/dpkg/dpkg.inc
@@ -39,15 +39,6 @@ POSTLOG ?= "/var/log/postinstall.log"
 REDIRECT_CMD = "${@base_contains('IMAGE_FEATURES', 'debug-tweaks', '>${POSTLOG} 2>&1', '', d)}"
 
 DPKG_INIT_POSITION ?= "98"
-do_install_prepend () {
-	install -d ${D}/${sysconfdir}/rcS.d
-	# this happens at S98 where our good 'ole packages script used to run
-	echo "#!/bin/sh
-dpkg --configure -a ${REDIRECT_CMD}
-rm -f ${sysconfdir}/rcS.d/S${DPKG_INIT_POSITION}run-postinsts
-" > ${D}/${sysconfdir}/rcS.d/S${DPKG_INIT_POSITION}run-postinsts
-	chmod 0755 ${D}/${sysconfdir}/rcS.d/S${DPKG_INIT_POSITION}run-postinsts
-}
 
 do_install_append () {
 	if [ "${PN}" = "dpkg-native" ]; then
@@ -67,6 +58,20 @@ do_install_append_class-native () {
 	done
 }
 
+pkg_postinst_${PN} () {
+#!/bin/sh
+if [ "x$D" != "x" ] && [ "deb" = "${IMAGE_PKGTYPE}" ]; then
+	install -d ${D}/${sysconfdir}/rcS.d
+
+	# this happens at S98 where our good 'ole packages script used to run
+	echo "#!/bin/sh
+dpkg --configure -a ${REDIRECT_CMD}
+rm -f ${sysconfdir}/rcS.d/S${DPKG_INIT_POSITION}run-postinsts
+" > ${D}/${sysconfdir}/rcS.d/S${DPKG_INIT_POSITION}run-postinsts
+	chmod 0755 ${D}/${sysconfdir}/rcS.d/S${DPKG_INIT_POSITION}run-postinsts
+fi
+}
+
 PROV = "virtual/update-alternatives"
 PROV_class-native = ""
 
diff --git a/meta/recipes-devtools/opkg/opkg.inc b/meta/recipes-devtools/opkg/opkg.inc
index f9c1202..d400dcd 100644
--- a/meta/recipes-devtools/opkg/opkg.inc
+++ b/meta/recipes-devtools/opkg/opkg.inc
@@ -62,8 +62,9 @@ REDIRECT_CMD = "${@base_contains('IMAGE_FEATURES', 'debug-tweaks', '>${POSTLOG}
 
 pkg_postinst_${PN} () {
 #!/bin/sh
-if [ "x$D" != "x" ]; then
+if [ "x$D" != "x" ] && [ "ipk" = "${IMAGE_PKGTYPE}" ]; then
 	install -d $D${sysconfdir}/rcS.d
+
 	# this happens at S98 where our good 'ole packages script used to run
 	echo "#!/bin/sh
 opkg-cl configure ${REDIRECT_CMD}
diff --git a/meta/recipes-devtools/rpm/rpm-postinsts.bb b/meta/recipes-devtools/rpm/rpm-postinsts.bb
index fb05ad6..281cb14 100644
--- a/meta/recipes-devtools/rpm/rpm-postinsts.bb
+++ b/meta/recipes-devtools/rpm/rpm-postinsts.bb
@@ -27,15 +27,17 @@ do_compile() {
 }
 
 do_install() {
-	install -d ${D}/${sysconfdir}/rcS.d
-	# Stop $i getting expanded below...
-	i=\$i
-	cat > ${D}${sysconfdir}/rcS.d/S${POSTINSTALL_INITPOSITION}run-postinsts << EOF
-#!/bin/sh
+	:
+}
 
+pkg_postinst_${PN} () {
+if [ "x$D" != "x" ] && [ "rpm" = "${IMAGE_PKGTYPE}" ]; then
+	install -d $D/${sysconfdir}/rcS.d
+	cat > $D${sysconfdir}/rcS.d/S${POSTINSTALL_INITPOSITION}run-postinsts << "EOF"
+#!/bin/sh
 . /etc/default/rcS
 
-[ -d /etc/rpm-postinsts ] && for i in \`ls /etc/rpm-postinsts/ \`; do
+[ -d /etc/rpm-postinsts ] && for i in `ls /etc/rpm-postinsts/`; do
 	i=/etc/rpm-postinsts/$i
 	echo "Running postinst $i..."
 	if [ -f $i ] && $i ${REDIRECT_CMD}; then
@@ -46,5 +48,8 @@ do_install() {
 done
 rm -f ${sysconfdir}/rcS.d/S${POSTINSTALL_INITPOSITION}run-postinsts 2>/dev/null
 EOF
-	chmod 0755 ${D}${sysconfdir}/rcS.d/S${POSTINSTALL_INITPOSITION}run-postinsts
+	chmod 0755 $D${sysconfdir}/rcS.d/S${POSTINSTALL_INITPOSITION}run-postinsts
+fi
 }
+
+ALLOW_EMPTY_${PN} = "1"
-- 
1.7.9.5




^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] dpkg, opkg, rpm-postinst: fix overwriting the run-postinstall script
  2013-04-11  6:42 [PATCH] dpkg, opkg, rpm-postinst: fix overwriting the run-postinstall script Laurentiu Palcu
@ 2013-04-11  7:06 ` ChenQi
  2013-04-11  7:33 ` Richard Purdie
  2013-04-11 11:09 ` [PATCH v2] " Laurentiu Palcu
  2 siblings, 0 replies; 6+ messages in thread
From: ChenQi @ 2013-04-11  7:06 UTC (permalink / raw)
  To: openembedded-core

On 04/11/2013 02:42 PM, Laurentiu Palcu wrote:
> If multiple package managers are installed in the image, they will
> overwrite each other's run-postinsts script, resulting in postinstalls
> not beeing run at all at first boot.
>
> What this patch does:
>   * checks whether opkg/dpks/rpm is actually used to install
>     the packages and, only after, creates the run-postinsts script;
>   * brings dpkg recipe in sync with opkg: moves the script creation from
>     do_install to postinstall;
>   * move creation of run-postinsts script (rpm-postinsts recipe) to the
>     postinstall scriptlet in order to better control the creation of the
>     script according to the package manager used;
>
> Signed-off-by: Laurentiu Palcu <laurentiu.palcu@intel.com>
> ---
>   meta/recipes-devtools/dpkg/dpkg.inc        |   23 ++++++++++++++---------
>   meta/recipes-devtools/opkg/opkg.inc        |    3 ++-
>   meta/recipes-devtools/rpm/rpm-postinsts.bb |   19 ++++++++++++-------
>   3 files changed, 28 insertions(+), 17 deletions(-)
>
> diff --git a/meta/recipes-devtools/dpkg/dpkg.inc b/meta/recipes-devtools/dpkg/dpkg.inc
> index 6bb1e16..f7f7b01 100644
> --- a/meta/recipes-devtools/dpkg/dpkg.inc
> +++ b/meta/recipes-devtools/dpkg/dpkg.inc
> @@ -39,15 +39,6 @@ POSTLOG ?= "/var/log/postinstall.log"
>   REDIRECT_CMD = "${@base_contains('IMAGE_FEATURES', 'debug-tweaks', '>${POSTLOG} 2>&1', '', d)}"
>   
>   DPKG_INIT_POSITION ?= "98"
> -do_install_prepend () {
> -	install -d ${D}/${sysconfdir}/rcS.d
> -	# this happens at S98 where our good 'ole packages script used to run
> -	echo "#!/bin/sh
> -dpkg --configure -a ${REDIRECT_CMD}
> -rm -f ${sysconfdir}/rcS.d/S${DPKG_INIT_POSITION}run-postinsts
> -" > ${D}/${sysconfdir}/rcS.d/S${DPKG_INIT_POSITION}run-postinsts
> -	chmod 0755 ${D}/${sysconfdir}/rcS.d/S${DPKG_INIT_POSITION}run-postinsts
> -}
>   
>   do_install_append () {
>   	if [ "${PN}" = "dpkg-native" ]; then
> @@ -67,6 +58,20 @@ do_install_append_class-native () {
>   	done
>   }
>   
> +pkg_postinst_${PN} () {
> +#!/bin/sh
> +if [ "x$D" != "x" ] && [ "deb" = "${IMAGE_PKGTYPE}" ]; then
> +	install -d ${D}/${sysconfdir}/rcS.d
> +
> +	# this happens at S98 where our good 'ole packages script used to run
> +	echo "#!/bin/sh
> +dpkg --configure -a ${REDIRECT_CMD}
> +rm -f ${sysconfdir}/rcS.d/S${DPKG_INIT_POSITION}run-postinsts
> +" > ${D}/${sysconfdir}/rcS.d/S${DPKG_INIT_POSITION}run-postinsts
> +	chmod 0755 ${D}/${sysconfdir}/rcS.d/S${DPKG_INIT_POSITION}run-postinsts
> +fi
> +}
> +
>   PROV = "virtual/update-alternatives"
>   PROV_class-native = ""
>   
> diff --git a/meta/recipes-devtools/opkg/opkg.inc b/meta/recipes-devtools/opkg/opkg.inc
> index f9c1202..d400dcd 100644
> --- a/meta/recipes-devtools/opkg/opkg.inc
> +++ b/meta/recipes-devtools/opkg/opkg.inc
> @@ -62,8 +62,9 @@ REDIRECT_CMD = "${@base_contains('IMAGE_FEATURES', 'debug-tweaks', '>${POSTLOG}
>   
>   pkg_postinst_${PN} () {
>   #!/bin/sh
> -if [ "x$D" != "x" ]; then
> +if [ "x$D" != "x" ] && [ "ipk" = "${IMAGE_PKGTYPE}" ]; then
>   	install -d $D${sysconfdir}/rcS.d
> +
>   	# this happens at S98 where our good 'ole packages script used to run
>   	echo "#!/bin/sh
>   opkg-cl configure ${REDIRECT_CMD}
> diff --git a/meta/recipes-devtools/rpm/rpm-postinsts.bb b/meta/recipes-devtools/rpm/rpm-postinsts.bb
> index fb05ad6..281cb14 100644
> --- a/meta/recipes-devtools/rpm/rpm-postinsts.bb
> +++ b/meta/recipes-devtools/rpm/rpm-postinsts.bb
> @@ -27,15 +27,17 @@ do_compile() {
>   }
>   
>   do_install() {
> -	install -d ${D}/${sysconfdir}/rcS.d
> -	# Stop $i getting expanded below...
> -	i=\$i
> -	cat > ${D}${sysconfdir}/rcS.d/S${POSTINSTALL_INITPOSITION}run-postinsts << EOF
> -#!/bin/sh
> +	:
> +}
>   
> +pkg_postinst_${PN} () {
> +if [ "x$D" != "x" ] && [ "rpm" = "${IMAGE_PKGTYPE}" ]; then
> +	install -d $D/${sysconfdir}/rcS.d
> +	cat > $D${sysconfdir}/rcS.d/S${POSTINSTALL_INITPOSITION}run-postinsts << "EOF"
> +#!/bin/sh
>   . /etc/default/rcS
>   
> -[ -d /etc/rpm-postinsts ] && for i in \`ls /etc/rpm-postinsts/ \`; do
> +[ -d /etc/rpm-postinsts ] && for i in `ls /etc/rpm-postinsts/`; do
>   	i=/etc/rpm-postinsts/$i
>   	echo "Running postinst $i..."
>   	if [ -f $i ] && $i ${REDIRECT_CMD}; then
> @@ -46,5 +48,8 @@ do_install() {
>   done
>   rm -f ${sysconfdir}/rcS.d/S${POSTINSTALL_INITPOSITION}run-postinsts 2>/dev/null
>   EOF
> -	chmod 0755 ${D}${sysconfdir}/rcS.d/S${POSTINSTALL_INITPOSITION}run-postinsts
> +	chmod 0755 $D${sysconfdir}/rcS.d/S${POSTINSTALL_INITPOSITION}run-postinsts
> +fi
>   }
> +
> +ALLOW_EMPTY_${PN} = "1"

bug#4231 (https://bugzilla.yoctoproject.org/show_bug.cgi?id=4231)?



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] dpkg, opkg, rpm-postinst: fix overwriting the run-postinstall script
  2013-04-11  6:42 [PATCH] dpkg, opkg, rpm-postinst: fix overwriting the run-postinstall script Laurentiu Palcu
  2013-04-11  7:06 ` ChenQi
@ 2013-04-11  7:33 ` Richard Purdie
  2013-04-11  8:44   ` Laurentiu Palcu
  2013-04-11 11:09 ` [PATCH v2] " Laurentiu Palcu
  2 siblings, 1 reply; 6+ messages in thread
From: Richard Purdie @ 2013-04-11  7:33 UTC (permalink / raw)
  To: Laurentiu Palcu; +Cc: openembedded-core

On Thu, 2013-04-11 at 09:42 +0300, Laurentiu Palcu wrote:
> If multiple package managers are installed in the image, they will
> overwrite each other's run-postinsts script, resulting in postinstalls
> not beeing run at all at first boot.
> 
> What this patch does:
>  * checks whether opkg/dpks/rpm is actually used to install
>    the packages and, only after, creates the run-postinsts script;
>  * brings dpkg recipe in sync with opkg: moves the script creation from
>    do_install to postinstall;
>  * move creation of run-postinsts script (rpm-postinsts recipe) to the
>    postinstall scriptlet in order to better control the creation of the
>    script according to the package manager used;
> 
> Signed-off-by: Laurentiu Palcu <laurentiu.palcu@intel.com>
> ---
>  meta/recipes-devtools/dpkg/dpkg.inc        |   23 ++++++++++++++---------
>  meta/recipes-devtools/opkg/opkg.inc        |    3 ++-
>  meta/recipes-devtools/rpm/rpm-postinsts.bb |   19 ++++++++++++-------
>  3 files changed, 28 insertions(+), 17 deletions(-)
> 
> diff --git a/meta/recipes-devtools/dpkg/dpkg.inc b/meta/recipes-devtools/dpkg/dpkg.inc
> index 6bb1e16..f7f7b01 100644
> --- a/meta/recipes-devtools/dpkg/dpkg.inc
> +++ b/meta/recipes-devtools/dpkg/dpkg.inc
> @@ -39,15 +39,6 @@ POSTLOG ?= "/var/log/postinstall.log"
>  REDIRECT_CMD = "${@base_contains('IMAGE_FEATURES', 'debug-tweaks', '>${POSTLOG} 2>&1', '', d)}"
>  
>  DPKG_INIT_POSITION ?= "98"
> -do_install_prepend () {
> -	install -d ${D}/${sysconfdir}/rcS.d
> -	# this happens at S98 where our good 'ole packages script used to run
> -	echo "#!/bin/sh
> -dpkg --configure -a ${REDIRECT_CMD}
> -rm -f ${sysconfdir}/rcS.d/S${DPKG_INIT_POSITION}run-postinsts
> -" > ${D}/${sysconfdir}/rcS.d/S${DPKG_INIT_POSITION}run-postinsts
> -	chmod 0755 ${D}/${sysconfdir}/rcS.d/S${DPKG_INIT_POSITION}run-postinsts
> -}
>  
>  do_install_append () {
>  	if [ "${PN}" = "dpkg-native" ]; then
> @@ -67,6 +58,20 @@ do_install_append_class-native () {
>  	done
>  }
>  
> +pkg_postinst_${PN} () {
> +#!/bin/sh
> +if [ "x$D" != "x" ] && [ "deb" = "${IMAGE_PKGTYPE}" ]; then

This is the right direction but this check will mean that rpm/dpkg/opkg
rebuilt each time IMAGE_PKGTYPE changes. Rather than hardcode this in,
can we test on something else which would be in the final runtime image
e.g. /var/lib/dpkg/status, the opkg status file and find some rpm
runtime file too?

Cheers,

Richard


> +	install -d ${D}/${sysconfdir}/rcS.d
> +
> +	# this happens at S98 where our good 'ole packages script used to run
> +	echo "#!/bin/sh
> +dpkg --configure -a ${REDIRECT_CMD}
> +rm -f ${sysconfdir}/rcS.d/S${DPKG_INIT_POSITION}run-postinsts
> +" > ${D}/${sysconfdir}/rcS.d/S${DPKG_INIT_POSITION}run-postinsts
> +	chmod 0755 ${D}/${sysconfdir}/rcS.d/S${DPKG_INIT_POSITION}run-postinsts
> +fi
> +}
> +
>  PROV = "virtual/update-alternatives"
>  PROV_class-native = ""
>  
> diff --git a/meta/recipes-devtools/opkg/opkg.inc b/meta/recipes-devtools/opkg/opkg.inc
> index f9c1202..d400dcd 100644
> --- a/meta/recipes-devtools/opkg/opkg.inc
> +++ b/meta/recipes-devtools/opkg/opkg.inc
> @@ -62,8 +62,9 @@ REDIRECT_CMD = "${@base_contains('IMAGE_FEATURES', 'debug-tweaks', '>${POSTLOG}
>  
>  pkg_postinst_${PN} () {
>  #!/bin/sh
> -if [ "x$D" != "x" ]; then
> +if [ "x$D" != "x" ] && [ "ipk" = "${IMAGE_PKGTYPE}" ]; then
>  	install -d $D${sysconfdir}/rcS.d
> +
>  	# this happens at S98 where our good 'ole packages script used to run
>  	echo "#!/bin/sh
>  opkg-cl configure ${REDIRECT_CMD}
> diff --git a/meta/recipes-devtools/rpm/rpm-postinsts.bb b/meta/recipes-devtools/rpm/rpm-postinsts.bb
> index fb05ad6..281cb14 100644
> --- a/meta/recipes-devtools/rpm/rpm-postinsts.bb
> +++ b/meta/recipes-devtools/rpm/rpm-postinsts.bb
> @@ -27,15 +27,17 @@ do_compile() {
>  }
>  
>  do_install() {
> -	install -d ${D}/${sysconfdir}/rcS.d
> -	# Stop $i getting expanded below...
> -	i=\$i
> -	cat > ${D}${sysconfdir}/rcS.d/S${POSTINSTALL_INITPOSITION}run-postinsts << EOF
> -#!/bin/sh
> +	:
> +}
>  
> +pkg_postinst_${PN} () {
> +if [ "x$D" != "x" ] && [ "rpm" = "${IMAGE_PKGTYPE}" ]; then
> +	install -d $D/${sysconfdir}/rcS.d
> +	cat > $D${sysconfdir}/rcS.d/S${POSTINSTALL_INITPOSITION}run-postinsts << "EOF"
> +#!/bin/sh
>  . /etc/default/rcS
>  
> -[ -d /etc/rpm-postinsts ] && for i in \`ls /etc/rpm-postinsts/ \`; do
> +[ -d /etc/rpm-postinsts ] && for i in `ls /etc/rpm-postinsts/`; do
>  	i=/etc/rpm-postinsts/$i
>  	echo "Running postinst $i..."
>  	if [ -f $i ] && $i ${REDIRECT_CMD}; then
> @@ -46,5 +48,8 @@ do_install() {
>  done
>  rm -f ${sysconfdir}/rcS.d/S${POSTINSTALL_INITPOSITION}run-postinsts 2>/dev/null
>  EOF
> -	chmod 0755 ${D}${sysconfdir}/rcS.d/S${POSTINSTALL_INITPOSITION}run-postinsts
> +	chmod 0755 $D${sysconfdir}/rcS.d/S${POSTINSTALL_INITPOSITION}run-postinsts
> +fi
>  }
> +
> +ALLOW_EMPTY_${PN} = "1"





^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] dpkg, opkg, rpm-postinst: fix overwriting the run-postinstall script
  2013-04-11  7:33 ` Richard Purdie
@ 2013-04-11  8:44   ` Laurentiu Palcu
  0 siblings, 0 replies; 6+ messages in thread
From: Laurentiu Palcu @ 2013-04-11  8:44 UTC (permalink / raw)
  To: Richard Purdie; +Cc: openembedded-core



On 04/11/2013 10:33 AM, Richard Purdie wrote:
> On Thu, 2013-04-11 at 09:42 +0300, Laurentiu Palcu wrote:
>> If multiple package managers are installed in the image, they will
>> overwrite each other's run-postinsts script, resulting in postinstalls
>> not beeing run at all at first boot.
>>
>> What this patch does:
>>  * checks whether opkg/dpks/rpm is actually used to install
>>    the packages and, only after, creates the run-postinsts script;
>>  * brings dpkg recipe in sync with opkg: moves the script creation from
>>    do_install to postinstall;
>>  * move creation of run-postinsts script (rpm-postinsts recipe) to the
>>    postinstall scriptlet in order to better control the creation of the
>>    script according to the package manager used;
>>
>> Signed-off-by: Laurentiu Palcu <laurentiu.palcu@intel.com>
>> ---
>>  meta/recipes-devtools/dpkg/dpkg.inc        |   23 ++++++++++++++---------
>>  meta/recipes-devtools/opkg/opkg.inc        |    3 ++-
>>  meta/recipes-devtools/rpm/rpm-postinsts.bb |   19 ++++++++++++-------
>>  3 files changed, 28 insertions(+), 17 deletions(-)
>>
>> diff --git a/meta/recipes-devtools/dpkg/dpkg.inc b/meta/recipes-devtools/dpkg/dpkg.inc
>> index 6bb1e16..f7f7b01 100644
>> --- a/meta/recipes-devtools/dpkg/dpkg.inc
>> +++ b/meta/recipes-devtools/dpkg/dpkg.inc
>> @@ -39,15 +39,6 @@ POSTLOG ?= "/var/log/postinstall.log"
>>  REDIRECT_CMD = "${@base_contains('IMAGE_FEATURES', 'debug-tweaks', '>${POSTLOG} 2>&1', '', d)}"
>>  
>>  DPKG_INIT_POSITION ?= "98"
>> -do_install_prepend () {
>> -	install -d ${D}/${sysconfdir}/rcS.d
>> -	# this happens at S98 where our good 'ole packages script used to run
>> -	echo "#!/bin/sh
>> -dpkg --configure -a ${REDIRECT_CMD}
>> -rm -f ${sysconfdir}/rcS.d/S${DPKG_INIT_POSITION}run-postinsts
>> -" > ${D}/${sysconfdir}/rcS.d/S${DPKG_INIT_POSITION}run-postinsts
>> -	chmod 0755 ${D}/${sysconfdir}/rcS.d/S${DPKG_INIT_POSITION}run-postinsts
>> -}
>>  
>>  do_install_append () {
>>  	if [ "${PN}" = "dpkg-native" ]; then
>> @@ -67,6 +58,20 @@ do_install_append_class-native () {
>>  	done
>>  }
>>  
>> +pkg_postinst_${PN} () {
>> +#!/bin/sh
>> +if [ "x$D" != "x" ] && [ "deb" = "${IMAGE_PKGTYPE}" ]; then
> 
> This is the right direction but this check will mean that rpm/dpkg/opkg
> rebuilt each time IMAGE_PKGTYPE changes. Rather than hardcode this in,
> can we test on something else which would be in the final runtime image
> e.g. /var/lib/dpkg/status, the opkg status file and find some rpm
> runtime file too?
Hmm, my original solution was to check for the existence of status file
but for some reason, it doesn't work for deb (maybe the status file is
not created by the time dpkg package is installed, but I'm not sure)...
Also, this seemed like a consistent solution for all package managers.
I'll try to see what other options I can find.

Thanks,
Laurentiu

> 
> Cheers,
> 
> Richard
> 
> 
>> +	install -d ${D}/${sysconfdir}/rcS.d
>> +
>> +	# this happens at S98 where our good 'ole packages script used to run
>> +	echo "#!/bin/sh
>> +dpkg --configure -a ${REDIRECT_CMD}
>> +rm -f ${sysconfdir}/rcS.d/S${DPKG_INIT_POSITION}run-postinsts
>> +" > ${D}/${sysconfdir}/rcS.d/S${DPKG_INIT_POSITION}run-postinsts
>> +	chmod 0755 ${D}/${sysconfdir}/rcS.d/S${DPKG_INIT_POSITION}run-postinsts
>> +fi
>> +}
>> +
>>  PROV = "virtual/update-alternatives"
>>  PROV_class-native = ""
>>  
>> diff --git a/meta/recipes-devtools/opkg/opkg.inc b/meta/recipes-devtools/opkg/opkg.inc
>> index f9c1202..d400dcd 100644
>> --- a/meta/recipes-devtools/opkg/opkg.inc
>> +++ b/meta/recipes-devtools/opkg/opkg.inc
>> @@ -62,8 +62,9 @@ REDIRECT_CMD = "${@base_contains('IMAGE_FEATURES', 'debug-tweaks', '>${POSTLOG}
>>  
>>  pkg_postinst_${PN} () {
>>  #!/bin/sh
>> -if [ "x$D" != "x" ]; then
>> +if [ "x$D" != "x" ] && [ "ipk" = "${IMAGE_PKGTYPE}" ]; then
>>  	install -d $D${sysconfdir}/rcS.d
>> +
>>  	# this happens at S98 where our good 'ole packages script used to run
>>  	echo "#!/bin/sh
>>  opkg-cl configure ${REDIRECT_CMD}
>> diff --git a/meta/recipes-devtools/rpm/rpm-postinsts.bb b/meta/recipes-devtools/rpm/rpm-postinsts.bb
>> index fb05ad6..281cb14 100644
>> --- a/meta/recipes-devtools/rpm/rpm-postinsts.bb
>> +++ b/meta/recipes-devtools/rpm/rpm-postinsts.bb
>> @@ -27,15 +27,17 @@ do_compile() {
>>  }
>>  
>>  do_install() {
>> -	install -d ${D}/${sysconfdir}/rcS.d
>> -	# Stop $i getting expanded below...
>> -	i=\$i
>> -	cat > ${D}${sysconfdir}/rcS.d/S${POSTINSTALL_INITPOSITION}run-postinsts << EOF
>> -#!/bin/sh
>> +	:
>> +}
>>  
>> +pkg_postinst_${PN} () {
>> +if [ "x$D" != "x" ] && [ "rpm" = "${IMAGE_PKGTYPE}" ]; then
>> +	install -d $D/${sysconfdir}/rcS.d
>> +	cat > $D${sysconfdir}/rcS.d/S${POSTINSTALL_INITPOSITION}run-postinsts << "EOF"
>> +#!/bin/sh
>>  . /etc/default/rcS
>>  
>> -[ -d /etc/rpm-postinsts ] && for i in \`ls /etc/rpm-postinsts/ \`; do
>> +[ -d /etc/rpm-postinsts ] && for i in `ls /etc/rpm-postinsts/`; do
>>  	i=/etc/rpm-postinsts/$i
>>  	echo "Running postinst $i..."
>>  	if [ -f $i ] && $i ${REDIRECT_CMD}; then
>> @@ -46,5 +48,8 @@ do_install() {
>>  done
>>  rm -f ${sysconfdir}/rcS.d/S${POSTINSTALL_INITPOSITION}run-postinsts 2>/dev/null
>>  EOF
>> -	chmod 0755 ${D}${sysconfdir}/rcS.d/S${POSTINSTALL_INITPOSITION}run-postinsts
>> +	chmod 0755 $D${sysconfdir}/rcS.d/S${POSTINSTALL_INITPOSITION}run-postinsts
>> +fi
>>  }
>> +
>> +ALLOW_EMPTY_${PN} = "1"
> 
> 



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2] dpkg, opkg, rpm-postinst: fix overwriting the run-postinstall script
  2013-04-11  6:42 [PATCH] dpkg, opkg, rpm-postinst: fix overwriting the run-postinstall script Laurentiu Palcu
  2013-04-11  7:06 ` ChenQi
  2013-04-11  7:33 ` Richard Purdie
@ 2013-04-11 11:09 ` Laurentiu Palcu
  2013-04-11 12:35   ` Martin Jansa
  2 siblings, 1 reply; 6+ messages in thread
From: Laurentiu Palcu @ 2013-04-11 11:09 UTC (permalink / raw)
  To: openembedded-core

If multiple package managers are installed in the image, they will
overwrite each other's run-postinsts script, resulting in postinstalls
not beeing run at all at first boot.

What this patch does:
 * checks whether opkg/dpks/rpm is actually used to install
   the packages and, only after, creates the run-postinsts script;
 * brings dpkg recipe in sync with opkg: moves the script creation from
   do_install to postinstall;
 * move creation of run-postinsts script (rpm-postinsts recipe) to the
   postinstall scriptlet in order to better control the creation of the
   script according to the package manager used;

[YOCTO #4231]
[YOCTO #4179]

Signed-off-by: Laurentiu Palcu <laurentiu.palcu@intel.com>
---
Changes in v2:
 * addressed Richard's comment and, instead of using ${IMAGE_PKGTYPE}, check for the
   existence of 'status' file for opkg/dpkg and 'Packages' file, for rpm;

I did tests with all backends as default package managers and another one installed
with CORE_IMAGE_EXTRA_INSTALL. I saw no issues. The default's PM run-postinsts script
is not overwritten.

Thanks,
Laurentiu

 meta/recipes-devtools/dpkg/dpkg.inc        |   23 ++++++++++++++---------
 meta/recipes-devtools/opkg/opkg.inc        |    3 ++-
 meta/recipes-devtools/rpm/rpm-postinsts.bb |   19 ++++++++++++-------
 3 files changed, 28 insertions(+), 17 deletions(-)

diff --git a/meta/recipes-devtools/dpkg/dpkg.inc b/meta/recipes-devtools/dpkg/dpkg.inc
index 6bb1e16..5554920 100644
--- a/meta/recipes-devtools/dpkg/dpkg.inc
+++ b/meta/recipes-devtools/dpkg/dpkg.inc
@@ -39,15 +39,6 @@ POSTLOG ?= "/var/log/postinstall.log"
 REDIRECT_CMD = "${@base_contains('IMAGE_FEATURES', 'debug-tweaks', '>${POSTLOG} 2>&1', '', d)}"
 
 DPKG_INIT_POSITION ?= "98"
-do_install_prepend () {
-	install -d ${D}/${sysconfdir}/rcS.d
-	# this happens at S98 where our good 'ole packages script used to run
-	echo "#!/bin/sh
-dpkg --configure -a ${REDIRECT_CMD}
-rm -f ${sysconfdir}/rcS.d/S${DPKG_INIT_POSITION}run-postinsts
-" > ${D}/${sysconfdir}/rcS.d/S${DPKG_INIT_POSITION}run-postinsts
-	chmod 0755 ${D}/${sysconfdir}/rcS.d/S${DPKG_INIT_POSITION}run-postinsts
-}
 
 do_install_append () {
 	if [ "${PN}" = "dpkg-native" ]; then
@@ -67,6 +58,20 @@ do_install_append_class-native () {
 	done
 }
 
+pkg_postinst_${PN} () {
+#!/bin/sh
+if [ "x$D" != "x" ] && [ -f $D/var/lib/dpkg/status ]; then
+	install -d ${D}/${sysconfdir}/rcS.d
+
+	# this happens at S98 where our good 'ole packages script used to run
+	echo "#!/bin/sh
+dpkg --configure -a ${REDIRECT_CMD}
+rm -f ${sysconfdir}/rcS.d/S${DPKG_INIT_POSITION}run-postinsts
+" > ${D}/${sysconfdir}/rcS.d/S${DPKG_INIT_POSITION}run-postinsts
+	chmod 0755 ${D}/${sysconfdir}/rcS.d/S${DPKG_INIT_POSITION}run-postinsts
+fi
+}
+
 PROV = "virtual/update-alternatives"
 PROV_class-native = ""
 
diff --git a/meta/recipes-devtools/opkg/opkg.inc b/meta/recipes-devtools/opkg/opkg.inc
index f9c1202..ff26b04 100644
--- a/meta/recipes-devtools/opkg/opkg.inc
+++ b/meta/recipes-devtools/opkg/opkg.inc
@@ -62,8 +62,9 @@ REDIRECT_CMD = "${@base_contains('IMAGE_FEATURES', 'debug-tweaks', '>${POSTLOG}
 
 pkg_postinst_${PN} () {
 #!/bin/sh
-if [ "x$D" != "x" ]; then
+if [ "x$D" != "x" ] && [ -f $D/var/lib/opkg/status ]; then
 	install -d $D${sysconfdir}/rcS.d
+
 	# this happens at S98 where our good 'ole packages script used to run
 	echo "#!/bin/sh
 opkg-cl configure ${REDIRECT_CMD}
diff --git a/meta/recipes-devtools/rpm/rpm-postinsts.bb b/meta/recipes-devtools/rpm/rpm-postinsts.bb
index fb05ad6..b551c8d 100644
--- a/meta/recipes-devtools/rpm/rpm-postinsts.bb
+++ b/meta/recipes-devtools/rpm/rpm-postinsts.bb
@@ -27,15 +27,17 @@ do_compile() {
 }
 
 do_install() {
-	install -d ${D}/${sysconfdir}/rcS.d
-	# Stop $i getting expanded below...
-	i=\$i
-	cat > ${D}${sysconfdir}/rcS.d/S${POSTINSTALL_INITPOSITION}run-postinsts << EOF
-#!/bin/sh
+	:
+}
 
+pkg_postinst_${PN} () {
+if [ "x$D" != "x" ] && [ -f $D/var/lib/rpm/Packages ]; then
+	install -d $D/${sysconfdir}/rcS.d
+	cat > $D${sysconfdir}/rcS.d/S${POSTINSTALL_INITPOSITION}run-postinsts << "EOF"
+#!/bin/sh
 . /etc/default/rcS
 
-[ -d /etc/rpm-postinsts ] && for i in \`ls /etc/rpm-postinsts/ \`; do
+[ -d /etc/rpm-postinsts ] && for i in `ls /etc/rpm-postinsts/`; do
 	i=/etc/rpm-postinsts/$i
 	echo "Running postinst $i..."
 	if [ -f $i ] && $i ${REDIRECT_CMD}; then
@@ -46,5 +48,8 @@ do_install() {
 done
 rm -f ${sysconfdir}/rcS.d/S${POSTINSTALL_INITPOSITION}run-postinsts 2>/dev/null
 EOF
-	chmod 0755 ${D}${sysconfdir}/rcS.d/S${POSTINSTALL_INITPOSITION}run-postinsts
+	chmod 0755 $D${sysconfdir}/rcS.d/S${POSTINSTALL_INITPOSITION}run-postinsts
+fi
 }
+
+ALLOW_EMPTY_${PN} = "1"
-- 
1.7.9.5




^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] dpkg, opkg, rpm-postinst: fix overwriting the run-postinstall script
  2013-04-11 11:09 ` [PATCH v2] " Laurentiu Palcu
@ 2013-04-11 12:35   ` Martin Jansa
  0 siblings, 0 replies; 6+ messages in thread
From: Martin Jansa @ 2013-04-11 12:35 UTC (permalink / raw)
  To: Laurentiu Palcu; +Cc: openembedded-core

[-- Attachment #1: Type: text/plain, Size: 5553 bytes --]

On Thu, Apr 11, 2013 at 02:09:25PM +0300, Laurentiu Palcu wrote:
> If multiple package managers are installed in the image, they will
> overwrite each other's run-postinsts script, resulting in postinstalls
> not beeing run at all at first boot.
> 
> What this patch does:
>  * checks whether opkg/dpks/rpm is actually used to install
>    the packages and, only after, creates the run-postinsts script;
>  * brings dpkg recipe in sync with opkg: moves the script creation from
>    do_install to postinstall;
>  * move creation of run-postinsts script (rpm-postinsts recipe) to the
>    postinstall scriptlet in order to better control the creation of the
>    script according to the package manager used;
> 
> [YOCTO #4231]
> [YOCTO #4179]
> 
> Signed-off-by: Laurentiu Palcu <laurentiu.palcu@intel.com>
> ---
> Changes in v2:
>  * addressed Richard's comment and, instead of using ${IMAGE_PKGTYPE}, check for the
>    existence of 'status' file for opkg/dpkg and 'Packages' file, for rpm;
> 
> I did tests with all backends as default package managers and another one installed
> with CORE_IMAGE_EXTRA_INSTALL. I saw no issues. The default's PM run-postinsts script
> is not overwritten.
> 
> Thanks,
> Laurentiu
> 
>  meta/recipes-devtools/dpkg/dpkg.inc        |   23 ++++++++++++++---------
>  meta/recipes-devtools/opkg/opkg.inc        |    3 ++-
>  meta/recipes-devtools/rpm/rpm-postinsts.bb |   19 ++++++++++++-------
>  3 files changed, 28 insertions(+), 17 deletions(-)
> 
> diff --git a/meta/recipes-devtools/dpkg/dpkg.inc b/meta/recipes-devtools/dpkg/dpkg.inc
> index 6bb1e16..5554920 100644
> --- a/meta/recipes-devtools/dpkg/dpkg.inc
> +++ b/meta/recipes-devtools/dpkg/dpkg.inc
> @@ -39,15 +39,6 @@ POSTLOG ?= "/var/log/postinstall.log"
>  REDIRECT_CMD = "${@base_contains('IMAGE_FEATURES', 'debug-tweaks', '>${POSTLOG} 2>&1', '', d)}"
>  
>  DPKG_INIT_POSITION ?= "98"
> -do_install_prepend () {
> -	install -d ${D}/${sysconfdir}/rcS.d
> -	# this happens at S98 where our good 'ole packages script used to run
> -	echo "#!/bin/sh
> -dpkg --configure -a ${REDIRECT_CMD}
> -rm -f ${sysconfdir}/rcS.d/S${DPKG_INIT_POSITION}run-postinsts
> -" > ${D}/${sysconfdir}/rcS.d/S${DPKG_INIT_POSITION}run-postinsts
> -	chmod 0755 ${D}/${sysconfdir}/rcS.d/S${DPKG_INIT_POSITION}run-postinsts
> -}
>  
>  do_install_append () {
>  	if [ "${PN}" = "dpkg-native" ]; then
> @@ -67,6 +58,20 @@ do_install_append_class-native () {
>  	done
>  }
>  
> +pkg_postinst_${PN} () {
> +#!/bin/sh
> +if [ "x$D" != "x" ] && [ -f $D/var/lib/dpkg/status ]; then
> +	install -d ${D}/${sysconfdir}/rcS.d
> +
> +	# this happens at S98 where our good 'ole packages script used to run
> +	echo "#!/bin/sh
> +dpkg --configure -a ${REDIRECT_CMD}
> +rm -f ${sysconfdir}/rcS.d/S${DPKG_INIT_POSITION}run-postinsts
> +" > ${D}/${sysconfdir}/rcS.d/S${DPKG_INIT_POSITION}run-postinsts
> +	chmod 0755 ${D}/${sysconfdir}/rcS.d/S${DPKG_INIT_POSITION}run-postinsts
> +fi
> +}
> +
>  PROV = "virtual/update-alternatives"
>  PROV_class-native = ""
>  
> diff --git a/meta/recipes-devtools/opkg/opkg.inc b/meta/recipes-devtools/opkg/opkg.inc
> index f9c1202..ff26b04 100644
> --- a/meta/recipes-devtools/opkg/opkg.inc
> +++ b/meta/recipes-devtools/opkg/opkg.inc
> @@ -62,8 +62,9 @@ REDIRECT_CMD = "${@base_contains('IMAGE_FEATURES', 'debug-tweaks', '>${POSTLOG}
>  
>  pkg_postinst_${PN} () {
>  #!/bin/sh
> -if [ "x$D" != "x" ]; then
> +if [ "x$D" != "x" ] && [ -f $D/var/lib/opkg/status ]; then

Don't hardcode '/var/lib/opkg' we have variable for that.
http://git.openembedded.org/openembedded-core/commit/?id=cf0aa9c4fdae8855803e96b1922d54a2431795d3

>  	install -d $D${sysconfdir}/rcS.d
> +
>  	# this happens at S98 where our good 'ole packages script used to run
>  	echo "#!/bin/sh
>  opkg-cl configure ${REDIRECT_CMD}
> diff --git a/meta/recipes-devtools/rpm/rpm-postinsts.bb b/meta/recipes-devtools/rpm/rpm-postinsts.bb
> index fb05ad6..b551c8d 100644
> --- a/meta/recipes-devtools/rpm/rpm-postinsts.bb
> +++ b/meta/recipes-devtools/rpm/rpm-postinsts.bb
> @@ -27,15 +27,17 @@ do_compile() {
>  }
>  
>  do_install() {
> -	install -d ${D}/${sysconfdir}/rcS.d
> -	# Stop $i getting expanded below...
> -	i=\$i
> -	cat > ${D}${sysconfdir}/rcS.d/S${POSTINSTALL_INITPOSITION}run-postinsts << EOF
> -#!/bin/sh
> +	:
> +}
>  
> +pkg_postinst_${PN} () {
> +if [ "x$D" != "x" ] && [ -f $D/var/lib/rpm/Packages ]; then
> +	install -d $D/${sysconfdir}/rcS.d
> +	cat > $D${sysconfdir}/rcS.d/S${POSTINSTALL_INITPOSITION}run-postinsts << "EOF"
> +#!/bin/sh
>  . /etc/default/rcS
>  
> -[ -d /etc/rpm-postinsts ] && for i in \`ls /etc/rpm-postinsts/ \`; do
> +[ -d /etc/rpm-postinsts ] && for i in `ls /etc/rpm-postinsts/`; do
>  	i=/etc/rpm-postinsts/$i
>  	echo "Running postinst $i..."
>  	if [ -f $i ] && $i ${REDIRECT_CMD}; then
> @@ -46,5 +48,8 @@ do_install() {
>  done
>  rm -f ${sysconfdir}/rcS.d/S${POSTINSTALL_INITPOSITION}run-postinsts 2>/dev/null
>  EOF
> -	chmod 0755 ${D}${sysconfdir}/rcS.d/S${POSTINSTALL_INITPOSITION}run-postinsts
> +	chmod 0755 $D${sysconfdir}/rcS.d/S${POSTINSTALL_INITPOSITION}run-postinsts
> +fi
>  }
> +
> +ALLOW_EMPTY_${PN} = "1"
> -- 
> 1.7.9.5
> 
> 
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core

-- 
Martin 'JaMa' Jansa     jabber: Martin.Jansa@gmail.com

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 205 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-04-11 12:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-11  6:42 [PATCH] dpkg, opkg, rpm-postinst: fix overwriting the run-postinstall script Laurentiu Palcu
2013-04-11  7:06 ` ChenQi
2013-04-11  7:33 ` Richard Purdie
2013-04-11  8:44   ` Laurentiu Palcu
2013-04-11 11:09 ` [PATCH v2] " Laurentiu Palcu
2013-04-11 12:35   ` Martin Jansa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox