All of lore.kernel.org
 help / color / mirror / Atom feed
* Running script after installation (postinst)
@ 2012-06-12 14:35 Patrick
  2012-06-12 14:47 ` Richard Purdie
  2012-06-12 14:49 ` Tomas Frydrych
  0 siblings, 2 replies; 9+ messages in thread
From: Patrick @ 2012-06-12 14:35 UTC (permalink / raw)
  To: poky

Dear all,

In one of our recipes we need to execute a small script after the 
installation of the package. Following yocto dev manual point 4.3.6 we 
have added a pkg_postinst function.

This doesn’t work properly as the script is executed at first start-up 
and not after installation. Below are an example of this recipe.

Do you have any idea why this script is started as first boot time and 
not after installation ?

Thanks in advance for any help !

Patrick


DESCRIPTION = "System modifications needed for System"
LICENSE = "MIT"
LIC_FILES_CHKSUM = 
"file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
PACKAGE_ARCH = "${MACHINE_ARCH}"
ALLOW_EMPTY = "1"

PR = "r5"

RDEPENDS = "\
     rpm \
     "

pkg_postinst_task-system-tweaks () {
   #!/bin/sh -e

   #Mount tmprecovery at startup
   mkdir -p /tmprecovery
   mkdir -p /data
   echo "/dev/mtdblock6        /tmprecovery        yaffs2      0 0" >> 
/etc/fstab
   echo "/dev/mtdblock7        /data               yaffs2   noauto  0 0" 
 >> /etc/fstab
}



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

* Re: Running script after installation (postinst)
  2012-06-12 14:35 Running script after installation (postinst) Patrick
@ 2012-06-12 14:47 ` Richard Purdie
  2012-06-13  7:18   ` Patrick
  2012-06-12 14:49 ` Tomas Frydrych
  1 sibling, 1 reply; 9+ messages in thread
From: Richard Purdie @ 2012-06-12 14:47 UTC (permalink / raw)
  To: Patrick; +Cc: poky

On Tue, 2012-06-12 at 16:35 +0200, Patrick wrote:
> Dear all,
> 
> In one of our recipes we need to execute a small script after the 
> installation of the package. Following yocto dev manual point 4.3.6 we 
> have added a pkg_postinst function.
> 
> This doesn’t work properly as the script is executed at first start-up 
> and not after installation. Below are an example of this recipe.
> 
> Do you have any idea why this script is started as first boot time and 
> not after installation ?
> 
> Thanks in advance for any help !

We try and run postinstalls "offline" at image creation time. If they
fail, they run at first boot.

You can tell which context you're in by the contents of the $D variable
(note, $D, not ${D}). For example, you could therefore do:


pkg_postinst_task-system-tweaks () {
   #!/bin/sh -e

   #Mount tmprecovery at startup
   mkdir -p $D/tmprecovery
   mkdir -p $D/data
   echo "/dev/mtdblock6        /tmprecovery        yaffs2      0 0" >> $D/etc/fstab
   echo "/dev/mtdblock7        /data               yaffs2   noauto  0 0" >> $D/etc/fstab

Cheers,

Richard



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

* Re: Running script after installation (postinst)
  2012-06-12 14:35 Running script after installation (postinst) Patrick
  2012-06-12 14:47 ` Richard Purdie
@ 2012-06-12 14:49 ` Tomas Frydrych
  1 sibling, 0 replies; 9+ messages in thread
From: Tomas Frydrych @ 2012-06-12 14:49 UTC (permalink / raw)
  To: poky

Hi,

On 12/06/12 15:35, Patrick wrote:
> In one of our recipes we need to execute a small script after the
> installation of the package. Following yocto dev manual point 4.3.6 we
> have added a pkg_postinst function.
> 
> This doesn’t work properly as the script is executed at first start-up
> and not after installation. Below are an example of this recipe.
> 
> Do you have any idea why this script is started as first boot time and
> not after installation ?

It will be run both times (often postinst scripts have to be run on the
actual HW). You can chose when your code takes effect by testing the $D
variable; when it is set, your script is being run during the rootfs
creation, when it is unset, it is being run on the first boot. There are
many examples of this in the Yocto recipes.

Your particular script will not work as is at rootfs time, since it is
trying to modify '/etc', which at that point is the host /etc directory.

Tomas


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

* Re: Running script after installation (postinst)
  2012-06-12 14:47 ` Richard Purdie
@ 2012-06-13  7:18   ` Patrick
  2012-06-13  8:08     ` Richard Purdie
  0 siblings, 1 reply; 9+ messages in thread
From: Patrick @ 2012-06-13  7:18 UTC (permalink / raw)
  To: Richard Purdie; +Cc: poky

On 06/12/2012 04:47 PM, Richard Purdie wrote:
> On Tue, 2012-06-12 at 16:35 +0200, Patrick wrote:
>> Dear all,
>>
>> In one of our recipes we need to execute a small script after the
>> installation of the package. Following yocto dev manual point 4.3.6 we
>> have added a pkg_postinst function.
>>
>> This doesn’t work properly as the script is executed at first start-up
>> and not after installation. Below are an example of this recipe.
>>
>> Do you have any idea why this script is started as first boot time and
>> not after installation ?
>>
>> Thanks in advance for any help !
>
> We try and run postinstalls "offline" at image creation time. If they
> fail, they run at first boot.
>
> You can tell which context you're in by the contents of the $D variable
> (note, $D, not ${D}). For example, you could therefore do:
>
>
> pkg_postinst_task-system-tweaks () {
>     #!/bin/sh -e
>
>     #Mount tmprecovery at startup
>     mkdir -p $D/tmprecovery
>     mkdir -p $D/data
>     echo "/dev/mtdblock6        /tmprecovery        yaffs2      0 0">>  $D/etc/fstab
>     echo "/dev/mtdblock7        /data               yaffs2   noauto  0 0">>  $D/etc/fstab
>
> Cheers,
>
> Richard
>

Thanks for your answer

The problems when using $D is that the script is executed against the 
files of the package not against the whole rootfs. For example in the 
dummy recipes above we change the file $D/etc/fstab that is not in the 
package of the recipes.

We have also tried to add (R)DEPENDS to the package that contains fstab 
with no change.

Any idea why ?

Patrick


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

* Re: Running script after installation (postinst)
  2012-06-13  7:18   ` Patrick
@ 2012-06-13  8:08     ` Richard Purdie
       [not found]       ` <4FD8A5F5.4080001@yahoo.fr>
  0 siblings, 1 reply; 9+ messages in thread
From: Richard Purdie @ 2012-06-13  8:08 UTC (permalink / raw)
  To: Patrick; +Cc: poky

On Wed, 2012-06-13 at 09:18 +0200, Patrick wrote:
> On 06/12/2012 04:47 PM, Richard Purdie wrote:
> > On Tue, 2012-06-12 at 16:35 +0200, Patrick wrote:
> >> Dear all,
> >>
> >> In one of our recipes we need to execute a small script after the
> >> installation of the package. Following yocto dev manual point 4.3.6 we
> >> have added a pkg_postinst function.
> >>
> >> This doesn’t work properly as the script is executed at first start-up
> >> and not after installation. Below are an example of this recipe.
> >>
> >> Do you have any idea why this script is started as first boot time and
> >> not after installation ?
> >>
> >> Thanks in advance for any help !
> >
> > We try and run postinstalls "offline" at image creation time. If they
> > fail, they run at first boot.
> >
> > You can tell which context you're in by the contents of the $D variable
> > (note, $D, not ${D}). For example, you could therefore do:
> >
> >
> > pkg_postinst_task-system-tweaks () {
> >     #!/bin/sh -e
> >
> >     #Mount tmprecovery at startup
> >     mkdir -p $D/tmprecovery
> >     mkdir -p $D/data
> >     echo "/dev/mtdblock6        /tmprecovery        yaffs2      0 0">>  $D/etc/fstab
> >     echo "/dev/mtdblock7        /data               yaffs2   noauto  0 0">>  $D/etc/fstab
> >

> The problems when using $D is that the script is executed against the 
> files of the package not against the whole rootfs. For example in the 
> dummy recipes above we change the file $D/etc/fstab that is not in the 
> package of the recipes.

If you reference $D as part of a postinst script, it will run against
the files of the rootfs, not just the package. There are some problems
ensuring dependencies are present when this happens though, some
backends like rpm don't like ensuring that dependencies are present.

> We have also tried to add (R)DEPENDS to the package that contains fstab 
> with no change.
> 
> Any idea why ?

You would need to add the dependency in and then it sounds like you're
probably using rpm and it doesn't want to honour the dependency for some
reason. You could add a rootfs post process command to add in what you
need which would guarantee all the files are present first...

Cheers,

Richard



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

* Re: Running script after installation (postinst)
       [not found]       ` <4FD8A5F5.4080001@yahoo.fr>
@ 2012-06-13 15:22         ` Patrick
  2012-06-14 13:30           ` Patrick
  0 siblings, 1 reply; 9+ messages in thread
From: Patrick @ 2012-06-13 15:22 UTC (permalink / raw)
  To: Richard Purdie; +Cc: poky

On 06/13/2012 04:38 PM, Patrick wrote:
> On 06/13/2012 10:08 AM, Richard Purdie wrote:
>> On Wed, 2012-06-13 at 09:18 +0200, Patrick wrote:
>>> On 06/12/2012 04:47 PM, Richard Purdie wrote:
>>>> On Tue, 2012-06-12 at 16:35 +0200, Patrick wrote:
>>>>> Dear all,
>>>>>
>>>>> In one of our recipes we need to execute a small script after the
>>>>> installation of the package. Following yocto dev manual point 4.3.6 we
>>>>> have added a pkg_postinst function.
>>>>>
>>>>> This doesn’t work properly as the script is executed at first start-up
>>>>> and not after installation. Below are an example of this recipe.
>>>>>
>>>>> Do you have any idea why this script is started as first boot time and
>>>>> not after installation ?
>>>>>
>>>>> Thanks in advance for any help !
>>>>
>>>> We try and run postinstalls "offline" at image creation time. If they
>>>> fail, they run at first boot.
>>>>
>>>> You can tell which context you're in by the contents of the $D variable
>>>> (note, $D, not ${D}). For example, you could therefore do:
>>>>
>>>>
>>>> pkg_postinst_task-system-tweaks () {
>>>> #!/bin/sh -e
>>>>
>>>> #Mount tmprecovery at startup
>>>> mkdir -p $D/tmprecovery
>>>> mkdir -p $D/data
>>>> echo "/dev/mtdblock6 /tmprecovery yaffs2 0 0">> $D/etc/fstab
>>>> echo "/dev/mtdblock7 /data yaffs2 noauto 0 0">> $D/etc/fstab
>>>>
>>
>>> The problems when using $D is that the script is executed against the
>>> files of the package not against the whole rootfs. For example in the
>>> dummy recipes above we change the file $D/etc/fstab that is not in the
>>> package of the recipes.
>>
>> If you reference $D as part of a postinst script, it will run against
>> the files of the rootfs, not just the package. There are some problems
>> ensuring dependencies are present when this happens though, some
>> backends like rpm don't like ensuring that dependencies are present.
>>
>>> We have also tried to add (R)DEPENDS to the package that contains fstab
>>> with no change.
>>>
>>> Any idea why ?
>>
>> You would need to add the dependency in and then it sounds like you're
>> probably using rpm and it doesn't want to honour the dependency for some
>> reason. You could add a rootfs post process command to add in what you
>> need which would guarantee all the files are present first...
>
> That's a good idea ! What would be the correct function name ? Something
> like do_rootfs_append() ?
> In this case do we have to prefix all the path with ${IMAGE_ROOTFS} ?
>
> Patrick

I reply myself:
as suggested above, using do_rootfs_append() and ${IMAGE_ROOTFS} it 
works nicely !

Thanks to all for your help

Patrick


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

* Re: Running script after installation (postinst)
  2012-06-13 15:22         ` Patrick
@ 2012-06-14 13:30           ` Patrick
  2012-06-14 14:24             ` Patrick
  2012-06-14 14:40             ` Richard Purdie
  0 siblings, 2 replies; 9+ messages in thread
From: Patrick @ 2012-06-14 13:30 UTC (permalink / raw)
  To: Richard Purdie; +Cc: poky

On 06/13/2012 05:22 PM, Patrick wrote:
> On 06/13/2012 04:38 PM, Patrick wrote:
>> On 06/13/2012 10:08 AM, Richard Purdie wrote:
>>> On Wed, 2012-06-13 at 09:18 +0200, Patrick wrote:
>>>> On 06/12/2012 04:47 PM, Richard Purdie wrote:
>>>>> On Tue, 2012-06-12 at 16:35 +0200, Patrick wrote:
>>>>>> Dear all,
>>>>>>
>>>>>> In one of our recipes we need to execute a small script after the
>>>>>> installation of the package. Following yocto dev manual point
>>>>>> 4.3.6 we
>>>>>> have added a pkg_postinst function.
>>>>>>
>>>>>> This doesn’t work properly as the script is executed at first
>>>>>> start-up
>>>>>> and not after installation. Below are an example of this recipe.
>>>>>>
>>>>>> Do you have any idea why this script is started as first boot time
>>>>>> and
>>>>>> not after installation ?
>>>>>>
>>>>>> Thanks in advance for any help !
>>>>>
>>>>> We try and run postinstalls "offline" at image creation time. If they
>>>>> fail, they run at first boot.
>>>>>
>>>>> You can tell which context you're in by the contents of the $D
>>>>> variable
>>>>> (note, $D, not ${D}). For example, you could therefore do:
>>>>>
>>>>>
>>>>> pkg_postinst_task-system-tweaks () {
>>>>> #!/bin/sh -e
>>>>>
>>>>> #Mount tmprecovery at startup
>>>>> mkdir -p $D/tmprecovery
>>>>> mkdir -p $D/data
>>>>> echo "/dev/mtdblock6 /tmprecovery yaffs2 0 0">> $D/etc/fstab
>>>>> echo "/dev/mtdblock7 /data yaffs2 noauto 0 0">> $D/etc/fstab
>>>>>
>>>
>>>> The problems when using $D is that the script is executed against the
>>>> files of the package not against the whole rootfs. For example in the
>>>> dummy recipes above we change the file $D/etc/fstab that is not in the
>>>> package of the recipes.
>>>
>>> If you reference $D as part of a postinst script, it will run against
>>> the files of the rootfs, not just the package. There are some problems
>>> ensuring dependencies are present when this happens though, some
>>> backends like rpm don't like ensuring that dependencies are present.
>>>
>>>> We have also tried to add (R)DEPENDS to the package that contains fstab
>>>> with no change.
>>>>
>>>> Any idea why ?
>>>
>>> You would need to add the dependency in and then it sounds like you're
>>> probably using rpm and it doesn't want to honour the dependency for some
>>> reason. You could add a rootfs post process command to add in what you
>>> need which would guarantee all the files are present first...
>>
>> That's a good idea ! What would be the correct function name ? Something
>> like do_rootfs_append() ?
>> In this case do we have to prefix all the path with ${IMAGE_ROOTFS} ?
>>
>> Patrick
>
> I reply myself:
> as suggested above, using do_rootfs_append() and ${IMAGE_ROOTFS} it
> works nicely !
>

Argh, in fact it doesn't work. The script is executed against right 
files but *after* packaging everything into a single image...
The script should be executed just before packaging of the image.

Any idea how to do that ?



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

* Re: Running script after installation (postinst)
  2012-06-14 13:30           ` Patrick
@ 2012-06-14 14:24             ` Patrick
  2012-06-14 14:40             ` Richard Purdie
  1 sibling, 0 replies; 9+ messages in thread
From: Patrick @ 2012-06-14 14:24 UTC (permalink / raw)
  To: poky

On 06/14/2012 03:30 PM, Patrick wrote:
> On 06/13/2012 05:22 PM, Patrick wrote:
>> On 06/13/2012 04:38 PM, Patrick wrote:
>>> On 06/13/2012 10:08 AM, Richard Purdie wrote:
>>>> On Wed, 2012-06-13 at 09:18 +0200, Patrick wrote:
>>>>> On 06/12/2012 04:47 PM, Richard Purdie wrote:
>>>>>> On Tue, 2012-06-12 at 16:35 +0200, Patrick wrote:
>>>>>>> Dear all,
>>>>>>>
>>>>>>> In one of our recipes we need to execute a small script after the
>>>>>>> installation of the package. Following yocto dev manual point
>>>>>>> 4.3.6 we
>>>>>>> have added a pkg_postinst function.
>>>>>>>
>>>>>>> This doesn’t work properly as the script is executed at first
>>>>>>> start-up
>>>>>>> and not after installation. Below are an example of this recipe.
>>>>>>>
>>>>>>> Do you have any idea why this script is started as first boot time
>>>>>>> and
>>>>>>> not after installation ?
>>>>>>>
>>>>>>> Thanks in advance for any help !
>>>>>>
>>>>>> We try and run postinstalls "offline" at image creation time. If they
>>>>>> fail, they run at first boot.
>>>>>>
>>>>>> You can tell which context you're in by the contents of the $D
>>>>>> variable
>>>>>> (note, $D, not ${D}). For example, you could therefore do:
>>>>>>
>>>>>>
>>>>>> pkg_postinst_task-system-tweaks () {
>>>>>> #!/bin/sh -e
>>>>>>
>>>>>> #Mount tmprecovery at startup
>>>>>> mkdir -p $D/tmprecovery
>>>>>> mkdir -p $D/data
>>>>>> echo "/dev/mtdblock6 /tmprecovery yaffs2 0 0">> $D/etc/fstab
>>>>>> echo "/dev/mtdblock7 /data yaffs2 noauto 0 0">> $D/etc/fstab
>>>>>>
>>>>
>>>>> The problems when using $D is that the script is executed against the
>>>>> files of the package not against the whole rootfs. For example in the
>>>>> dummy recipes above we change the file $D/etc/fstab that is not in the
>>>>> package of the recipes.
>>>>
>>>> If you reference $D as part of a postinst script, it will run against
>>>> the files of the rootfs, not just the package. There are some problems
>>>> ensuring dependencies are present when this happens though, some
>>>> backends like rpm don't like ensuring that dependencies are present.
>>>>
>>>>> We have also tried to add (R)DEPENDS to the package that contains
>>>>> fstab
>>>>> with no change.
>>>>>
>>>>> Any idea why ?
>>>>
>>>> You would need to add the dependency in and then it sounds like you're
>>>> probably using rpm and it doesn't want to honour the dependency for
>>>> some
>>>> reason. You could add a rootfs post process command to add in what you
>>>> need which would guarantee all the files are present first...
>>>
>>> That's a good idea ! What would be the correct function name ? Something
>>> like do_rootfs_append() ?
>>> In this case do we have to prefix all the path with ${IMAGE_ROOTFS} ?
>>>
>>> Patrick
>>
>> I reply myself:
>> as suggested above, using do_rootfs_append() and ${IMAGE_ROOTFS} it
>> works nicely !
>>
>
> Argh, in fact it doesn't work. The script is executed against right
> files but *after* packaging everything into a single image...
> The script should be executed just before packaging of the image.
>
> Any idea how to do that ?
>
I reply myself, it works with rootfs_rpm_do_rootfs_append instead of 
using do_rootfs_append but I don't know if it's the best way to do.
If you know more recommended way to do feel free to comment here !

Patrick



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

* Re: Running script after installation (postinst)
  2012-06-14 13:30           ` Patrick
  2012-06-14 14:24             ` Patrick
@ 2012-06-14 14:40             ` Richard Purdie
  1 sibling, 0 replies; 9+ messages in thread
From: Richard Purdie @ 2012-06-14 14:40 UTC (permalink / raw)
  To: Patrick; +Cc: poky

On Thu, 2012-06-14 at 15:30 +0200, Patrick wrote:
> On 06/13/2012 05:22 PM, Patrick wrote:
> > On 06/13/2012 04:38 PM, Patrick wrote:
> >> On 06/13/2012 10:08 AM, Richard Purdie wrote:
> >>> You would need to add the dependency in and then it sounds like you're
> >>> probably using rpm and it doesn't want to honour the dependency for some
> >>> reason. You could add a rootfs post process command to add in what you
> >>> need which would guarantee all the files are present first...
> >>
> >> That's a good idea ! What would be the correct function name ? Something
> >> like do_rootfs_append() ?
> >> In this case do we have to prefix all the path with ${IMAGE_ROOTFS} ?
> >>
> >> Patrick
> >
> > I reply myself:
> > as suggested above, using do_rootfs_append() and ${IMAGE_ROOTFS} it
> > works nicely !
> >
> 
> Argh, in fact it doesn't work. The script is executed against right 
> files but *after* packaging everything into a single image...
> The script should be executed just before packaging of the image.
> 
> Any idea how to do that ?

ROOTFS_POSTPROCESS_COMMAND is probably what you're looking for.

Cheers,

Richard





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

end of thread, other threads:[~2012-06-14 14:40 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-12 14:35 Running script after installation (postinst) Patrick
2012-06-12 14:47 ` Richard Purdie
2012-06-13  7:18   ` Patrick
2012-06-13  8:08     ` Richard Purdie
     [not found]       ` <4FD8A5F5.4080001@yahoo.fr>
2012-06-13 15:22         ` Patrick
2012-06-14 13:30           ` Patrick
2012-06-14 14:24             ` Patrick
2012-06-14 14:40             ` Richard Purdie
2012-06-12 14:49 ` Tomas Frydrych

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.