All of lore.kernel.org
 help / color / mirror / Atom feed
* pkg_postinst_ontarget not executed
@ 2020-05-08  9:32 Damien LEFEVRE
  2020-05-08 15:15 ` [yocto] " Alexander Kanavin
  0 siblings, 1 reply; 5+ messages in thread
From: Damien LEFEVRE @ 2020-05-08  9:32 UTC (permalink / raw)
  To: yocto

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

Hi,

I have a device with rootfs mounted readonly and with an overlay on top of
it to do the factory reset.

There's A/B partitioning. So there is a duplicate set of partitions.

There's an OTA engine to deploy atomics images.

I have the following usecase:
1. I flash a minimal image
2. I write the device type into a file (mutiple variant but same HW setup)
to a persistent data partition.
3. I deploy the common product image via OTA engine. The whole rootfs is
deployed atomically
4. I copy the current overlay partition content to the next overlay
partition
5. Reboot
6. System boots to the next slot to the common product image

Currently, the common product image is the minimal image with the addition
of this test-deployment package:

DISCRIPTION = "Test product specific deployment"
LICENSE = "CLOSED"
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"

SRC_URI = " \
    file://config.type1 \
    file://config.type2 \
    file://config.type3 \
"

do_configure[noexec] = "1"
do_compile[noexec] = "1"

do_install() {
    install -d ${D}/opt/test
    install -m 0644 ${WORKDIR}/config.type1 ${D}/opt/test
    install -m 0644 ${WORKDIR}/config.type2 ${D}/opt/test
    install -m 0644 ${WORKDIR}/config.type3 ${D}/opt/test
}

pkg_postinst_ontarget_${PN}() {
    systemid=$(cat /persistent/systemid)
    cd /opt/test
    mv config.$systemid config
    rm config.*
}

FILES_${PN} += " \
    /opt/test/* \
"


The /opt/test folder is now present but it still contains config.type1,
config.type2 and config.type3.

If can find the postinst script in
/var/lib/opkg/info/test-deployment.postinst and execute it.

Since test-deployment is a new package, I would have expected
pkg_postinst_ontarget to be executed

How is the first boot detected on a poky image? Is there a way to detect if
.postinst scripts haven't been executed?

Thanks,
-Damien

[-- Attachment #2: Type: text/html, Size: 2155 bytes --]

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

* Re: [yocto] pkg_postinst_ontarget not executed
  2020-05-08  9:32 pkg_postinst_ontarget not executed Damien LEFEVRE
@ 2020-05-08 15:15 ` Alexander Kanavin
  2020-05-13  7:32   ` Damien LEFEVRE
  0 siblings, 1 reply; 5+ messages in thread
From: Alexander Kanavin @ 2020-05-08 15:15 UTC (permalink / raw)
  To: Damien LEFEVRE; +Cc: yocto

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

On Fri, 8 May 2020 at 11:32, Damien LEFEVRE <lefevre.da@gmail.com> wrote:

>
> If can find the postinst script in
> /var/lib/opkg/info/test-deployment.postinst and execute it.
>
> Since test-deployment is a new package, I would have expected
> pkg_postinst_ontarget to be executed
>
> How is the first boot detected on a poky image? Is there a way to detect
> if .postinst scripts haven't been executed?
>

The scripts to be executed  are written into /etc/rpm|deb|ipk-postinsts/
and executed by
meta/recipes-devtools/run-postinsts/run-postinsts/run-postinsts script
(which is started on first boot as a service).
Then they get deleted.

Alex

[-- Attachment #2: Type: text/html, Size: 1026 bytes --]

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

* Re: [yocto] pkg_postinst_ontarget not executed
  2020-05-08 15:15 ` [yocto] " Alexander Kanavin
@ 2020-05-13  7:32   ` Damien LEFEVRE
  2020-05-13  9:03     ` Alexander Kanavin
  0 siblings, 1 reply; 5+ messages in thread
From: Damien LEFEVRE @ 2020-05-13  7:32 UTC (permalink / raw)
  To: Alexander Kanavin; +Cc: yocto

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

Thanks Alex,

When I do a factory reset, the system detects as a first boot and the
script is executed.

> cat /var/log/postinstall.log
Configuring test-deployment.

One thing which puzzles me: the /etc/ipk-postinsts directory do not exist.
Not in the image recipe folder, not in the image file which I mount to
check the content before flashing and of course it's deleted at the end of
run-postinsts

rootfs.py:
    def _save_postinsts_common(self, dst_postinst_dir, src_postinst_dir):
        if bb.utils.contains("IMAGE_FEATURES", "package-management",
                         True, False, self.d):
            return
        num = 0
        for p in self._get_delayed_postinsts():
            bb.utils.mkdirhier(dst_postinst_dir)

            if os.path.exists(os.path.join(src_postinst_dir, p +
".postinst")):
                shutil.copy(os.path.join(src_postinst_dir, p + ".postinst"),
                            os.path.join(dst_postinst_dir, "%03d-%s" %
(num, p)))

            num += 1


package-management is in my image features so I understand nothing get
written.

So who temporarily creates that /etc/ipk-postinsts?

Thanks,
-Damien

On Fri, May 8, 2020 at 6:15 PM Alexander Kanavin <alex.kanavin@gmail.com>
wrote:

> On Fri, 8 May 2020 at 11:32, Damien LEFEVRE <lefevre.da@gmail.com> wrote:
>
>>
>> If can find the postinst script in
>> /var/lib/opkg/info/test-deployment.postinst and execute it.
>>
>> Since test-deployment is a new package, I would have expected
>> pkg_postinst_ontarget to be executed
>>
>> How is the first boot detected on a poky image? Is there a way to detect
>> if .postinst scripts haven't been executed?
>>
>
> The scripts to be executed  are written into /etc/rpm|deb|ipk-postinsts/
> and executed by
> meta/recipes-devtools/run-postinsts/run-postinsts/run-postinsts script
> (which is started on first boot as a service).
> Then they get deleted.
>
> Alex
>

[-- Attachment #2: Type: text/html, Size: 2950 bytes --]

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

* Re: [yocto] pkg_postinst_ontarget not executed
  2020-05-13  7:32   ` Damien LEFEVRE
@ 2020-05-13  9:03     ` Alexander Kanavin
  2020-05-13  9:39       ` Damien LEFEVRE
  0 siblings, 1 reply; 5+ messages in thread
From: Alexander Kanavin @ 2020-05-13  9:03 UTC (permalink / raw)
  To: Damien LEFEVRE; +Cc: yocto

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

Reading recipes-devtools/run-postinsts/run-postinsts/run-postinsts
and_save_postinsts_common (in rootfs.py) once more, it seems
/etc/ipk-postinsts is only used if there is no package manager on the
target.

If there is, then 'opkg configure' is run directly, and so postinsts come
from some internal database. There is some additional magic in rootfs.py to
mark packages with first-boot postinsts as unpacked, so they'll get picked
up by opkg.

Alex

On Wed, 13 May 2020 at 09:33, Damien LEFEVRE <lefevre.da@gmail.com> wrote:

> Thanks Alex,
>
> When I do a factory reset, the system detects as a first boot and the
> script is executed.
>
> > cat /var/log/postinstall.log
> Configuring test-deployment.
>
> One thing which puzzles me: the /etc/ipk-postinsts directory do not exist.
> Not in the image recipe folder, not in the image file which I mount to
> check the content before flashing and of course it's deleted at the end of
> run-postinsts
>
> rootfs.py:
>     def _save_postinsts_common(self, dst_postinst_dir, src_postinst_dir):
>         if bb.utils.contains("IMAGE_FEATURES", "package-management",
>                          True, False, self.d):
>             return
>         num = 0
>         for p in self._get_delayed_postinsts():
>             bb.utils.mkdirhier(dst_postinst_dir)
>
>             if os.path.exists(os.path.join(src_postinst_dir, p +
> ".postinst")):
>                 shutil.copy(os.path.join(src_postinst_dir, p +
> ".postinst"),
>                             os.path.join(dst_postinst_dir, "%03d-%s" %
> (num, p)))
>
>             num += 1
>
>
> package-management is in my image features so I understand nothing get
> written.
>
> So who temporarily creates that /etc/ipk-postinsts?
>
> Thanks,
> -Damien
>
> On Fri, May 8, 2020 at 6:15 PM Alexander Kanavin <alex.kanavin@gmail.com>
> wrote:
>
>> On Fri, 8 May 2020 at 11:32, Damien LEFEVRE <lefevre.da@gmail.com> wrote:
>>
>>>
>>> If can find the postinst script in
>>> /var/lib/opkg/info/test-deployment.postinst and execute it.
>>>
>>> Since test-deployment is a new package, I would have expected
>>> pkg_postinst_ontarget to be executed
>>>
>>> How is the first boot detected on a poky image? Is there a way to detect
>>> if .postinst scripts haven't been executed?
>>>
>>
>> The scripts to be executed  are written into /etc/rpm|deb|ipk-postinsts/
>> and executed by
>> meta/recipes-devtools/run-postinsts/run-postinsts/run-postinsts script
>> (which is started on first boot as a service).
>> Then they get deleted.
>>
>> Alex
>>
>

[-- Attachment #2: Type: text/html, Size: 3852 bytes --]

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

* Re: [yocto] pkg_postinst_ontarget not executed
  2020-05-13  9:03     ` Alexander Kanavin
@ 2020-05-13  9:39       ` Damien LEFEVRE
  0 siblings, 0 replies; 5+ messages in thread
From: Damien LEFEVRE @ 2020-05-13  9:39 UTC (permalink / raw)
  To: Alexander Kanavin; +Cc: yocto

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

OK I found.

Yes "opkg configure" will call /var/lib/opkg/info/*.postinst for packages
marked as "unpacked" in /var/lib/opkg/status ex:

Package: test-deployment-lic
Version: 1.0-r0
Status: install ok unpacked
Architecture: aarch64
Installed-Time: 1589349316
Auto-Installed: yes

After update
Package: test-deployment-lic
Version: 1.0-r0
Status: install ok unpacked
Architecture: aarch64
Installed-Time: 1589349316
Auto-Installed: yes

Should be easy to merge.

Thanks!
-Damien

On Wed, May 13, 2020 at 12:04 PM Alexander Kanavin <alex.kanavin@gmail.com>
wrote:

> Reading recipes-devtools/run-postinsts/run-postinsts/run-postinsts
> and_save_postinsts_common (in rootfs.py) once more, it seems
> /etc/ipk-postinsts is only used if there is no package manager on the
> target.
>
> If there is, then 'opkg configure' is run directly, and so postinsts come
> from some internal database. There is some additional magic in rootfs.py to
> mark packages with first-boot postinsts as unpacked, so they'll get picked
> up by opkg.
>
> Alex
>
> On Wed, 13 May 2020 at 09:33, Damien LEFEVRE <lefevre.da@gmail.com> wrote:
>
>> Thanks Alex,
>>
>> When I do a factory reset, the system detects as a first boot and the
>> script is executed.
>>
>> > cat /var/log/postinstall.log
>> Configuring test-deployment.
>>
>> One thing which puzzles me: the /etc/ipk-postinsts directory do not
>> exist. Not in the image recipe folder, not in the image file which I mount
>> to check the content before flashing and of course it's deleted at the end
>> of run-postinsts
>>
>> rootfs.py:
>>     def _save_postinsts_common(self, dst_postinst_dir, src_postinst_dir):
>>         if bb.utils.contains("IMAGE_FEATURES", "package-management",
>>                          True, False, self.d):
>>             return
>>         num = 0
>>         for p in self._get_delayed_postinsts():
>>             bb.utils.mkdirhier(dst_postinst_dir)
>>
>>             if os.path.exists(os.path.join(src_postinst_dir, p +
>> ".postinst")):
>>                 shutil.copy(os.path.join(src_postinst_dir, p +
>> ".postinst"),
>>                             os.path.join(dst_postinst_dir, "%03d-%s" %
>> (num, p)))
>>
>>             num += 1
>>
>>
>> package-management is in my image features so I understand nothing get
>> written.
>>
>> So who temporarily creates that /etc/ipk-postinsts?
>>
>> Thanks,
>> -Damien
>>
>> On Fri, May 8, 2020 at 6:15 PM Alexander Kanavin <alex.kanavin@gmail.com>
>> wrote:
>>
>>> On Fri, 8 May 2020 at 11:32, Damien LEFEVRE <lefevre.da@gmail.com>
>>> wrote:
>>>
>>>>
>>>> If can find the postinst script in
>>>> /var/lib/opkg/info/test-deployment.postinst and execute it.
>>>>
>>>> Since test-deployment is a new package, I would have expected
>>>> pkg_postinst_ontarget to be executed
>>>>
>>>> How is the first boot detected on a poky image? Is there a way to
>>>> detect if .postinst scripts haven't been executed?
>>>>
>>>
>>> The scripts to be executed  are written into /etc/rpm|deb|ipk-postinsts/
>>> and executed by
>>> meta/recipes-devtools/run-postinsts/run-postinsts/run-postinsts script
>>> (which is started on first boot as a service).
>>> Then they get deleted.
>>>
>>> Alex
>>>
>>

[-- Attachment #2: Type: text/html, Size: 4921 bytes --]

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

end of thread, other threads:[~2020-05-13  9:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-08  9:32 pkg_postinst_ontarget not executed Damien LEFEVRE
2020-05-08 15:15 ` [yocto] " Alexander Kanavin
2020-05-13  7:32   ` Damien LEFEVRE
2020-05-13  9:03     ` Alexander Kanavin
2020-05-13  9:39       ` Damien LEFEVRE

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.