diff mbox series

[isar-cip-core,RFC,1/2] copy and symlink dpkg db to ro-rootfs

Message ID 20240130115648.311177-2-felix.moessbauer@siemens.com (mailing list archive)
State Changes Requested
Headers show
Series Deploy swupdate images with empty var partition | expand

Commit Message

Felix Moessbauer Jan. 30, 2024, 11:56 a.m. UTC
The dpkg database is located on the var partition, but this partition is
not updated (and might not even be deployed). To still have information
about what is installed, we relocate the database to /usr/share and
create a symlink using tmpdirs.d.

Note, that this is only enabled on debian bookworm, as the proper
packaging of tmpdirs files is only supported from debhelper-compat 13
on.

Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
---
 classes/read-only-rootfs.bbclass              | 10 +++++++
 .../cip-read-only-rootfs_0.1.bb               | 26 +++++++++++++++++++
 .../files/cip-read-only-rootfs.tmpfiles       |  1 +
 .../cip-read-only-rootfs/files/control        | 11 ++++++++
 4 files changed, 48 insertions(+)
 create mode 100644 recipes-core/cip-read-only-rootfs/cip-read-only-rootfs_0.1.bb
 create mode 100644 recipes-core/cip-read-only-rootfs/files/cip-read-only-rootfs.tmpfiles
 create mode 100644 recipes-core/cip-read-only-rootfs/files/control

Comments

Jan Kiszka Feb. 12, 2024, 6:16 p.m. UTC | #1
On 30.01.24 12:56, Felix Moessbauer wrote:
> The dpkg database is located on the var partition, but this partition is
> not updated (and might not even be deployed). To still have information
> about what is installed, we relocate the database to /usr/share and
> create a symlink using tmpdirs.d.
> 
> Note, that this is only enabled on debian bookworm, as the proper
> packaging of tmpdirs files is only supported from debhelper-compat 13
> on.
> 
> Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
> ---
>  classes/read-only-rootfs.bbclass              | 10 +++++++
>  .../cip-read-only-rootfs_0.1.bb               | 26 +++++++++++++++++++
>  .../files/cip-read-only-rootfs.tmpfiles       |  1 +
>  .../cip-read-only-rootfs/files/control        | 11 ++++++++
>  4 files changed, 48 insertions(+)
>  create mode 100644 recipes-core/cip-read-only-rootfs/cip-read-only-rootfs_0.1.bb
>  create mode 100644 recipes-core/cip-read-only-rootfs/files/cip-read-only-rootfs.tmpfiles
>  create mode 100644 recipes-core/cip-read-only-rootfs/files/control
> 
> diff --git a/classes/read-only-rootfs.bbclass b/classes/read-only-rootfs.bbclass
> index 6f91f66..14ed85d 100644
> --- a/classes/read-only-rootfs.bbclass
> +++ b/classes/read-only-rootfs.bbclass
> @@ -17,6 +17,16 @@ do_image_wic[depends] += "${INITRAMFS_RECIPE}:do_build"
>  IMAGE_INSTALL += "home-fs"
>  IMAGE_INSTALL += "tmp-fs"
>  
> +# For pre bookworm images, empty /var is not usable
> +IMAGE_INSTALL:append:bookworm = " cip-read-only-rootfs"
> +
> +ROOTFS_POSTPROCESS_COMMAND:append:bookworm =" cip_copy_dpkg_state"
> +cip_copy_dpkg_state() {
> +    IMMUTABLE_VAR_LIB="${ROOTFSDIR}/usr/share/cip/var/lib"

Hmm, should we really add "cip" to the path here? I would suggest to
have a more generic name like "immutable-data" or so, avoiding that this
recipe is renaming while branded downstream or has to be renamed if we
ever hand this over to Isar upstream. Maybe the package name should be
aligned as well then.

Jan

> +    sudo mkdir -p "$IMMUTABLE_VAR_LIB"
> +    sudo cp -a ${ROOTFSDIR}/var/lib/dpkg "$IMMUTABLE_VAR_LIB/"
> +}
> +
>  image_configure_fstab() {
>      sudo tee '${IMAGE_ROOTFS}/etc/fstab' << EOF
>  # Begin /etc/fstab
> diff --git a/recipes-core/cip-read-only-rootfs/cip-read-only-rootfs_0.1.bb b/recipes-core/cip-read-only-rootfs/cip-read-only-rootfs_0.1.bb
> new file mode 100644
> index 0000000..76453ab
> --- /dev/null
> +++ b/recipes-core/cip-read-only-rootfs/cip-read-only-rootfs_0.1.bb
> @@ -0,0 +1,26 @@
> +#
> +# CIP Core, generic profile
> +#
> +# Copyright (c) Siemens AG, 2024
> +#
> +# Authors:
> +#  Felix Moessbauer <felix.moessbauer@siemens.com>
> +#
> +# SPDX-License-Identifier: MIT
> +
> +# Note: This requires debhelper-compat 13, which limits it to bookworm
> +
> +inherit dpkg
> +
> +SRC_URI = " \
> +    file://${BPN}.tmpfiles \
> +    file://control"
> +
> +do_prepare_build[cleandirs] += "${S}/debian"
> +do_prepare_build() {
> +    deb_debianize
> +    rm -f ${S}/debian/compat
> +    cp ${WORKDIR}/control \
> +       ${WORKDIR}/${BPN}.tmpfiles \
> +       ${S}/debian/

dpkg-raw wouldn't have simplified this? I think even compat is not
customizable.

> +}
> diff --git a/recipes-core/cip-read-only-rootfs/files/cip-read-only-rootfs.tmpfiles b/recipes-core/cip-read-only-rootfs/files/cip-read-only-rootfs.tmpfiles
> new file mode 100644
> index 0000000..16a91bd
> --- /dev/null
> +++ b/recipes-core/cip-read-only-rootfs/files/cip-read-only-rootfs.tmpfiles
> @@ -0,0 +1 @@
> +L /var/lib/dpkg - - - - /usr/share/cip/var/lib/dpkg

This file is supposed to grow in downstream integration when more data
should be handled like dpkg, right?

> diff --git a/recipes-core/cip-read-only-rootfs/files/control b/recipes-core/cip-read-only-rootfs/files/control
> new file mode 100644
> index 0000000..55eec25
> --- /dev/null
> +++ b/recipes-core/cip-read-only-rootfs/files/control
> @@ -0,0 +1,11 @@
> +Source: cip-read-only-rootfs
> +Section: misc
> +Priority: optional
> +Standards-Version: 4.6.1
> +Maintainer: Felix Moessbauer <felix.moessbauer@siemens.com>
> +Build-Depends: debhelper-compat (= 13)
> +
> +Package: cip-read-only-rootfs
> +Architecture: all
> +Depends: ${misc:Depends}
> +Description: Config to link volatile data to immutable copies

In general, the idea looks good to me.

Jan
Felix Moessbauer Feb. 13, 2024, 10:24 a.m. UTC | #2
On Mon, 2024-02-12 at 19:16 +0100, Jan Kiszka wrote:
> On 30.01.24 12:56, Felix Moessbauer wrote:
> > The dpkg database is located on the var partition, but this
> > partition is
> > not updated (and might not even be deployed). To still have
> > information
> > about what is installed, we relocate the database to /usr/share and
> > create a symlink using tmpdirs.d.
> > 
> > Note, that this is only enabled on debian bookworm, as the proper
> > packaging of tmpdirs files is only supported from debhelper-compat
> > 13
> > on.
> > 
> > Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
> > ---
> >  classes/read-only-rootfs.bbclass              | 10 +++++++
> >  .../cip-read-only-rootfs_0.1.bb               | 26
> > +++++++++++++++++++
> >  .../files/cip-read-only-rootfs.tmpfiles       |  1 +
> >  .../cip-read-only-rootfs/files/control        | 11 ++++++++
> >  4 files changed, 48 insertions(+)
> >  create mode 100644 recipes-core/cip-read-only-rootfs/cip-read-
> > only-rootfs_0.1.bb
> >  create mode 100644 recipes-core/cip-read-only-rootfs/files/cip-
> > read-only-rootfs.tmpfiles
> >  create mode 100644 recipes-core/cip-read-only-rootfs/files/control
> > 
> > diff --git a/classes/read-only-rootfs.bbclass b/classes/read-only-
> > rootfs.bbclass
> > index 6f91f66..14ed85d 100644
> > --- a/classes/read-only-rootfs.bbclass
> > +++ b/classes/read-only-rootfs.bbclass
> > @@ -17,6 +17,16 @@ do_image_wic[depends] +=
> > "${INITRAMFS_RECIPE}:do_build"
> >  IMAGE_INSTALL += "home-fs"
> >  IMAGE_INSTALL += "tmp-fs"
> >  
> > +# For pre bookworm images, empty /var is not usable
> > +IMAGE_INSTALL:append:bookworm = " cip-read-only-rootfs"
> > +
> > +ROOTFS_POSTPROCESS_COMMAND:append:bookworm =" cip_copy_dpkg_state"
> > +cip_copy_dpkg_state() {
> > +    IMMUTABLE_VAR_LIB="${ROOTFSDIR}/usr/share/cip/var/lib"
> 
> Hmm, should we really add "cip" to the path here? I would suggest to
> have a more generic name like "immutable-data" or so, avoiding that
> this
> recipe is renaming while branded downstream or has to be renamed if
> we
> ever hand this over to Isar upstream. Maybe the package name should
> be
> aligned as well then.

Yes, we can use a different name here, but in general downstream users
should place their immutable data in dedicated packages. How about
immutable-dpkg ?

> 
> Jan
> 
> > +    sudo mkdir -p "$IMMUTABLE_VAR_LIB"
> > +    sudo cp -a ${ROOTFSDIR}/var/lib/dpkg "$IMMUTABLE_VAR_LIB/"
> > +}
> > +
> >  image_configure_fstab() {
> >      sudo tee '${IMAGE_ROOTFS}/etc/fstab' << EOF
> >  # Begin /etc/fstab
> > diff --git a/recipes-core/cip-read-only-rootfs/cip-read-only-
> > rootfs_0.1.bb b/recipes-core/cip-read-only-rootfs/cip-read-only-
> > rootfs_0.1.bb
> > new file mode 100644
> > index 0000000..76453ab
> > --- /dev/null
> > +++ b/recipes-core/cip-read-only-rootfs/cip-read-only-rootfs_0.1.bb
> > @@ -0,0 +1,26 @@
> > +#
> > +# CIP Core, generic profile
> > +#
> > +# Copyright (c) Siemens AG, 2024
> > +#
> > +# Authors:
> > +#  Felix Moessbauer <felix.moessbauer@siemens.com>
> > +#
> > +# SPDX-License-Identifier: MIT
> > +
> > +# Note: This requires debhelper-compat 13, which limits it to
> > bookworm
> > +
> > +inherit dpkg
> > +
> > +SRC_URI = " \
> > +    file://${BPN}.tmpfiles \
> > +    file://control"
> > +
> > +do_prepare_build[cleandirs] += "${S}/debian"
> > +do_prepare_build() {
> > +    deb_debianize
> > +    rm -f ${S}/debian/compat
> > +    cp ${WORKDIR}/control \
> > +       ${WORKDIR}/${BPN}.tmpfiles \
> > +       ${S}/debian/
> 
> dpkg-raw wouldn't have simplified this? I think even compat is not
> customizable.

DPKG raw in general is only useful for a trivial copy of files into the
rootfs. Here, we need the debhelper logic to process the tmpfiles.d.
Also, we need to update the compat mode so that these debhelpers become
active. I don't see any value in mixing this with dpkg-raw, as most
parts would need to be written manually anyways.

Felix

> 
> > +}
> > diff --git a/recipes-core/cip-read-only-rootfs/files/cip-read-only-
> > rootfs.tmpfiles b/recipes-core/cip-read-only-rootfs/files/cip-read-
> > only-rootfs.tmpfiles
> > new file mode 100644
> > index 0000000..16a91bd
> > --- /dev/null
> > +++ b/recipes-core/cip-read-only-rootfs/files/cip-read-only-
> > rootfs.tmpfiles
> > @@ -0,0 +1 @@
> > +L /var/lib/dpkg - - - - /usr/share/cip/var/lib/dpkg
> 
> This file is supposed to grow in downstream integration when more
> data
> should be handled like dpkg, right?
> 
> > diff --git a/recipes-core/cip-read-only-rootfs/files/control
> > b/recipes-core/cip-read-only-rootfs/files/control
> > new file mode 100644
> > index 0000000..55eec25
> > --- /dev/null
> > +++ b/recipes-core/cip-read-only-rootfs/files/control
> > @@ -0,0 +1,11 @@
> > +Source: cip-read-only-rootfs
> > +Section: misc
> > +Priority: optional
> > +Standards-Version: 4.6.1
> > +Maintainer: Felix Moessbauer <felix.moessbauer@siemens.com>
> > +Build-Depends: debhelper-compat (= 13)
> > +
> > +Package: cip-read-only-rootfs
> > +Architecture: all
> > +Depends: ${misc:Depends}
> > +Description: Config to link volatile data to immutable copies
> 
> In general, the idea looks good to me.
> 
> Jan
>
Jan Kiszka Feb. 13, 2024, 10:33 a.m. UTC | #3
On 13.02.24 11:24, Moessbauer, Felix (T CED OES-DE) wrote:
> On Mon, 2024-02-12 at 19:16 +0100, Jan Kiszka wrote:
>> On 30.01.24 12:56, Felix Moessbauer wrote:
>>> The dpkg database is located on the var partition, but this
>>> partition is
>>> not updated (and might not even be deployed). To still have
>>> information
>>> about what is installed, we relocate the database to /usr/share and
>>> create a symlink using tmpdirs.d.
>>>
>>> Note, that this is only enabled on debian bookworm, as the proper
>>> packaging of tmpdirs files is only supported from debhelper-compat
>>> 13
>>> on.
>>>
>>> Signed-off-by: Felix Moessbauer <felix.moessbauer@siemens.com>
>>> ---
>>>  classes/read-only-rootfs.bbclass              | 10 +++++++
>>>  .../cip-read-only-rootfs_0.1.bb               | 26
>>> +++++++++++++++++++
>>>  .../files/cip-read-only-rootfs.tmpfiles       |  1 +
>>>  .../cip-read-only-rootfs/files/control        | 11 ++++++++
>>>  4 files changed, 48 insertions(+)
>>>  create mode 100644 recipes-core/cip-read-only-rootfs/cip-read-
>>> only-rootfs_0.1.bb
>>>  create mode 100644 recipes-core/cip-read-only-rootfs/files/cip-
>>> read-only-rootfs.tmpfiles
>>>  create mode 100644 recipes-core/cip-read-only-rootfs/files/control
>>>
>>> diff --git a/classes/read-only-rootfs.bbclass b/classes/read-only-
>>> rootfs.bbclass
>>> index 6f91f66..14ed85d 100644
>>> --- a/classes/read-only-rootfs.bbclass
>>> +++ b/classes/read-only-rootfs.bbclass
>>> @@ -17,6 +17,16 @@ do_image_wic[depends] +=
>>> "${INITRAMFS_RECIPE}:do_build"
>>>  IMAGE_INSTALL += "home-fs"
>>>  IMAGE_INSTALL += "tmp-fs"
>>>  
>>> +# For pre bookworm images, empty /var is not usable
>>> +IMAGE_INSTALL:append:bookworm = " cip-read-only-rootfs"
>>> +
>>> +ROOTFS_POSTPROCESS_COMMAND:append:bookworm =" cip_copy_dpkg_state"
>>> +cip_copy_dpkg_state() {
>>> +    IMMUTABLE_VAR_LIB="${ROOTFSDIR}/usr/share/cip/var/lib"
>>
>> Hmm, should we really add "cip" to the path here? I would suggest to
>> have a more generic name like "immutable-data" or so, avoiding that
>> this
>> recipe is renaming while branded downstream or has to be renamed if
>> we
>> ever hand this over to Isar upstream. Maybe the package name should
>> be
>> aligned as well then.
> 
> Yes, we can use a different name here, but in general downstream users
> should place their immutable data in dedicated packages. How about
> immutable-dpkg ?
> 
>>
>> Jan
>>
>>> +    sudo mkdir -p "$IMMUTABLE_VAR_LIB"
>>> +    sudo cp -a ${ROOTFSDIR}/var/lib/dpkg "$IMMUTABLE_VAR_LIB/"
>>> +}
>>> +
>>>  image_configure_fstab() {
>>>      sudo tee '${IMAGE_ROOTFS}/etc/fstab' << EOF
>>>  # Begin /etc/fstab
>>> diff --git a/recipes-core/cip-read-only-rootfs/cip-read-only-
>>> rootfs_0.1.bb b/recipes-core/cip-read-only-rootfs/cip-read-only-
>>> rootfs_0.1.bb
>>> new file mode 100644
>>> index 0000000..76453ab
>>> --- /dev/null
>>> +++ b/recipes-core/cip-read-only-rootfs/cip-read-only-rootfs_0.1.bb
>>> @@ -0,0 +1,26 @@
>>> +#
>>> +# CIP Core, generic profile
>>> +#
>>> +# Copyright (c) Siemens AG, 2024
>>> +#
>>> +# Authors:
>>> +#  Felix Moessbauer <felix.moessbauer@siemens.com>
>>> +#
>>> +# SPDX-License-Identifier: MIT
>>> +
>>> +# Note: This requires debhelper-compat 13, which limits it to
>>> bookworm
>>> +
>>> +inherit dpkg
>>> +
>>> +SRC_URI = " \
>>> +    file://${BPN}.tmpfiles \
>>> +    file://control"
>>> +
>>> +do_prepare_build[cleandirs] += "${S}/debian"
>>> +do_prepare_build() {
>>> +    deb_debianize
>>> +    rm -f ${S}/debian/compat
>>> +    cp ${WORKDIR}/control \
>>> +       ${WORKDIR}/${BPN}.tmpfiles \
>>> +       ${S}/debian/
>>
>> dpkg-raw wouldn't have simplified this? I think even compat is not
>> customizable.
> 
> DPKG raw in general is only useful for a trivial copy of files into the
> rootfs. Here, we need the debhelper logic to process the tmpfiles.d.
> Also, we need to update the compat mode so that these debhelpers become
> active. I don't see any value in mixing this with dpkg-raw, as most
> parts would need to be written manually anyways.
> 

With [1] (granted, not yet upstream), this would simply be

inherit dpkg-raw

DPKG_ARCH = "all"

SRC_URI = "file://${BPN}.tmpfiles"

do_install() {
	cp ${WORKDIR}/${BPN}.tmpfiles ${S}/debian/
}


The whole control file would become obsolete.

Jan

[1]
https://groups.google.com/d/msgid/isar-users/20240201101236.3555681-1-Quirin.Gylstorff%40siemens.com
Felix Moessbauer Feb. 19, 2024, 11:19 a.m. UTC | #4
On Tue, 2024-02-13 at 11:33 +0100, Jan Kiszka wrote:
> > > >  image_configure_fstab() {
> > > >      sudo tee '${IMAGE_ROOTFS}/etc/fstab' << EOF
> > > >  # Begin /etc/fstab
> > > > diff --git a/recipes-core/cip-read-only-rootfs/cip-read-only-
> > > > rootfs_0.1.bb b/recipes-core/cip-read-only-rootfs/cip-read-
> > > > only-
> > > > rootfs_0.1.bb
> > > > new file mode 100644
> > > > index 0000000..76453ab
> > > > --- /dev/null
> > > > +++ b/recipes-core/cip-read-only-rootfs/cip-read-only-
> > > > rootfs_0.1.bb
> > > > @@ -0,0 +1,26 @@
> > > > +#
> > > > +# CIP Core, generic profile
> > > > +#
> > > > +# Copyright (c) Siemens AG, 2024
> > > > +#
> > > > +# Authors:
> > > > +#  Felix Moessbauer <felix.moessbauer@siemens.com>
> > > > +#
> > > > +# SPDX-License-Identifier: MIT
> > > > +
> > > > +# Note: This requires debhelper-compat 13, which limits it to
> > > > bookworm
> > > > +
> > > > +inherit dpkg
> > > > +
> > > > +SRC_URI = " \
> > > > +    file://${BPN}.tmpfiles \
> > > > +    file://control"
> > > > +
> > > > +do_prepare_build[cleandirs] += "${S}/debian"
> > > > +do_prepare_build() {
> > > > +    deb_debianize
> > > > +    rm -f ${S}/debian/compat
> > > > +    cp ${WORKDIR}/control \
> > > > +       ${WORKDIR}/${BPN}.tmpfiles \
> > > > +       ${S}/debian/
> > > 
> > > dpkg-raw wouldn't have simplified this? I think even compat is
> > > not
> > > customizable.
> > 
> > DPKG raw in general is only useful for a trivial copy of files into
> > the
> > rootfs. Here, we need the debhelper logic to process the
> > tmpfiles.d.
> > Also, we need to update the compat mode so that these debhelpers
> > become
> > active. I don't see any value in mixing this with dpkg-raw, as most
> > parts would need to be written manually anyways.
> > 
> 
> With [1] (granted, not yet upstream), this would simply be

This is already merged into ISAR-next (as f1b8679), but as we only
reference ISAR-master in CIP, we need to wait for that to get
integrated there as well. I can prepare everything, but still we need
to wait for the ISAR update.

Putting the ISAR list in CC.

Felix


> 
> inherit dpkg-raw
> 
> DPKG_ARCH = "all"
> 
> SRC_URI = "file://${BPN}.tmpfiles"
> 
> do_install() {
>         cp ${WORKDIR}/${BPN}.tmpfiles ${S}/debian/
> }
> 
> 
> The whole control file would become obsolete.
> 
> Jan
> 
> [1]
> https://groups.google.com/d/msgid/isar-users/20240201101236.3555681-1-Quirin.Gylstorff%40siemens.com
>
Jan Kiszka Feb. 19, 2024, 11:35 a.m. UTC | #5
On 19.02.24 12:19, Moessbauer, Felix (T CED OES-DE) wrote:
> On Tue, 2024-02-13 at 11:33 +0100, Jan Kiszka wrote:
>>>>>  image_configure_fstab() {
>>>>>      sudo tee '${IMAGE_ROOTFS}/etc/fstab' << EOF
>>>>>  # Begin /etc/fstab
>>>>> diff --git a/recipes-core/cip-read-only-rootfs/cip-read-only-
>>>>> rootfs_0.1.bb b/recipes-core/cip-read-only-rootfs/cip-read-
>>>>> only-
>>>>> rootfs_0.1.bb
>>>>> new file mode 100644
>>>>> index 0000000..76453ab
>>>>> --- /dev/null
>>>>> +++ b/recipes-core/cip-read-only-rootfs/cip-read-only-
>>>>> rootfs_0.1.bb
>>>>> @@ -0,0 +1,26 @@
>>>>> +#
>>>>> +# CIP Core, generic profile
>>>>> +#
>>>>> +# Copyright (c) Siemens AG, 2024
>>>>> +#
>>>>> +# Authors:
>>>>> +#  Felix Moessbauer <felix.moessbauer@siemens.com>
>>>>> +#
>>>>> +# SPDX-License-Identifier: MIT
>>>>> +
>>>>> +# Note: This requires debhelper-compat 13, which limits it to
>>>>> bookworm
>>>>> +
>>>>> +inherit dpkg
>>>>> +
>>>>> +SRC_URI = " \
>>>>> +    file://${BPN}.tmpfiles \
>>>>> +    file://control"
>>>>> +
>>>>> +do_prepare_build[cleandirs] += "${S}/debian"
>>>>> +do_prepare_build() {
>>>>> +    deb_debianize
>>>>> +    rm -f ${S}/debian/compat
>>>>> +    cp ${WORKDIR}/control \
>>>>> +       ${WORKDIR}/${BPN}.tmpfiles \
>>>>> +       ${S}/debian/
>>>>
>>>> dpkg-raw wouldn't have simplified this? I think even compat is
>>>> not
>>>> customizable.
>>>
>>> DPKG raw in general is only useful for a trivial copy of files into
>>> the
>>> rootfs. Here, we need the debhelper logic to process the
>>> tmpfiles.d.
>>> Also, we need to update the compat mode so that these debhelpers
>>> become
>>> active. I don't see any value in mixing this with dpkg-raw, as most
>>> parts would need to be written manually anyways.
>>>
>>
>> With [1] (granted, not yet upstream), this would simply be
> 
> This is already merged into ISAR-next (as f1b8679), but as we only
> reference ISAR-master in CIP, we need to wait for that to get
> integrated there as well. I can prepare everything, but still we need
> to wait for the ISAR update.

We don't have a master-only rule in isar-cip-core /wrt isar because isar
is not rebasing next (unlike many other projects).

Jan

> 
> Putting the ISAR list in CC.
> 
> Felix
> 
> 
>>
>> inherit dpkg-raw
>>
>> DPKG_ARCH = "all"
>>
>> SRC_URI = "file://${BPN}.tmpfiles"
>>
>> do_install() {
>>         cp ${WORKDIR}/${BPN}.tmpfiles ${S}/debian/
>> }
>>
>>
>> The whole control file would become obsolete.
>>
>> Jan
>>
>> [1]
>> https://groups.google.com/d/msgid/isar-users/20240201101236.3555681-1-Quirin.Gylstorff%40siemens.com
>>
>
diff mbox series

Patch

diff --git a/classes/read-only-rootfs.bbclass b/classes/read-only-rootfs.bbclass
index 6f91f66..14ed85d 100644
--- a/classes/read-only-rootfs.bbclass
+++ b/classes/read-only-rootfs.bbclass
@@ -17,6 +17,16 @@  do_image_wic[depends] += "${INITRAMFS_RECIPE}:do_build"
 IMAGE_INSTALL += "home-fs"
 IMAGE_INSTALL += "tmp-fs"
 
+# For pre bookworm images, empty /var is not usable
+IMAGE_INSTALL:append:bookworm = " cip-read-only-rootfs"
+
+ROOTFS_POSTPROCESS_COMMAND:append:bookworm =" cip_copy_dpkg_state"
+cip_copy_dpkg_state() {
+    IMMUTABLE_VAR_LIB="${ROOTFSDIR}/usr/share/cip/var/lib"
+    sudo mkdir -p "$IMMUTABLE_VAR_LIB"
+    sudo cp -a ${ROOTFSDIR}/var/lib/dpkg "$IMMUTABLE_VAR_LIB/"
+}
+
 image_configure_fstab() {
     sudo tee '${IMAGE_ROOTFS}/etc/fstab' << EOF
 # Begin /etc/fstab
diff --git a/recipes-core/cip-read-only-rootfs/cip-read-only-rootfs_0.1.bb b/recipes-core/cip-read-only-rootfs/cip-read-only-rootfs_0.1.bb
new file mode 100644
index 0000000..76453ab
--- /dev/null
+++ b/recipes-core/cip-read-only-rootfs/cip-read-only-rootfs_0.1.bb
@@ -0,0 +1,26 @@ 
+#
+# CIP Core, generic profile
+#
+# Copyright (c) Siemens AG, 2024
+#
+# Authors:
+#  Felix Moessbauer <felix.moessbauer@siemens.com>
+#
+# SPDX-License-Identifier: MIT
+
+# Note: This requires debhelper-compat 13, which limits it to bookworm
+
+inherit dpkg
+
+SRC_URI = " \
+    file://${BPN}.tmpfiles \
+    file://control"
+
+do_prepare_build[cleandirs] += "${S}/debian"
+do_prepare_build() {
+    deb_debianize
+    rm -f ${S}/debian/compat
+    cp ${WORKDIR}/control \
+       ${WORKDIR}/${BPN}.tmpfiles \
+       ${S}/debian/
+}
diff --git a/recipes-core/cip-read-only-rootfs/files/cip-read-only-rootfs.tmpfiles b/recipes-core/cip-read-only-rootfs/files/cip-read-only-rootfs.tmpfiles
new file mode 100644
index 0000000..16a91bd
--- /dev/null
+++ b/recipes-core/cip-read-only-rootfs/files/cip-read-only-rootfs.tmpfiles
@@ -0,0 +1 @@ 
+L /var/lib/dpkg - - - - /usr/share/cip/var/lib/dpkg
diff --git a/recipes-core/cip-read-only-rootfs/files/control b/recipes-core/cip-read-only-rootfs/files/control
new file mode 100644
index 0000000..55eec25
--- /dev/null
+++ b/recipes-core/cip-read-only-rootfs/files/control
@@ -0,0 +1,11 @@ 
+Source: cip-read-only-rootfs
+Section: misc
+Priority: optional
+Standards-Version: 4.6.1
+Maintainer: Felix Moessbauer <felix.moessbauer@siemens.com>
+Build-Depends: debhelper-compat (= 13)
+
+Package: cip-read-only-rootfs
+Architecture: all
+Depends: ${misc:Depends}
+Description: Config to link volatile data to immutable copies