[v2,1/2] meta-isar: Add simple example for injecting prebuilt deb packages

Message ID fbcc6263adb0fa46a9ebb1d77b5213556d8cb31d.1613220380.git.jan.kiszka@siemens.com
State Superseded, archived
Headers show
Series Prebuilt debian package example | expand

Commit Message

Jan Kiszka Feb. 13, 2021, 2:46 a.m. UTC
From: Jan Kiszka <jan.kiszka@siemens.com>

While it's definitely nicer and more convenient to pull deb packages
from repos, this may not always be the case. This recipe demonstrates
how to implement such a pattern.

The example embeds the deb as local artifact which is clearly an
anti-pattern. That path was only chosen here because it's hard to find a
stable URL to a prebuilt arch-independent deb file in the wild. The
procedure for creating the deb is also included as README.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 meta-isar/conf/local.conf.sample              |   2 +-
 .../prebuilt-deb/files/README-create-deb.txt  |  14 ++++++++++++
 .../files/example-prebuilt_1.0.0-0_all.deb    | Bin 0 -> 776 bytes
 .../recipes-app/prebuilt-deb/prebuilt-deb.bb  |  20 ++++++++++++++++++
 4 files changed, 35 insertions(+), 1 deletion(-)
 create mode 100644 meta-isar/recipes-app/prebuilt-deb/files/README-create-deb.txt
 create mode 100644 meta-isar/recipes-app/prebuilt-deb/files/example-prebuilt_1.0.0-0_all.deb
 create mode 100644 meta-isar/recipes-app/prebuilt-deb/prebuilt-deb.bb

Comments

Henning Schild Feb. 14, 2021, 9:45 p.m. UTC | #1
Am Sat, 13 Feb 2021 13:46:20 +0100
schrieb Jan Kiszka <jan.kiszka@siemens.com>:

> From: Jan Kiszka <jan.kiszka@siemens.com>
> 
> While it's definitely nicer and more convenient to pull deb packages
> from repos, this may not always be the case. This recipe demonstrates
> how to implement such a pattern.
> 
> The example embeds the deb as local artifact which is clearly an
> anti-pattern. That path was only chosen here because it's hard to
> find a stable URL to a prebuilt arch-independent deb file in the
> wild. The procedure for creating the deb is also included as README.
> 
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
>  meta-isar/conf/local.conf.sample              |   2 +-
>  .../prebuilt-deb/files/README-create-deb.txt  |  14 ++++++++++++
>  .../files/example-prebuilt_1.0.0-0_all.deb    | Bin 0 -> 776 bytes
>  .../recipes-app/prebuilt-deb/prebuilt-deb.bb  |  20
> ++++++++++++++++++ 4 files changed, 35 insertions(+), 1 deletion(-)
>  create mode 100644
> meta-isar/recipes-app/prebuilt-deb/files/README-create-deb.txt create
> mode 100644
> meta-isar/recipes-app/prebuilt-deb/files/example-prebuilt_1.0.0-0_all.deb
> create mode 100644 meta-isar/recipes-app/prebuilt-deb/prebuilt-deb.bb
> 
> diff --git a/meta-isar/conf/local.conf.sample
> b/meta-isar/conf/local.conf.sample index 107496c1..cc0b5c66 100644
> --- a/meta-isar/conf/local.conf.sample
> +++ b/meta-isar/conf/local.conf.sample
> @@ -172,7 +172,7 @@ CONF_VERSION = "1"
>  
>  #
>  # The default list of extra packages to be installed.
> -IMAGE_INSTALL = "hello-isar example-raw
> example-module-${KERNEL_NAME} enable-fsck isar-exclude-docs samefile
> hello isar-disable-apt-cache cowsay" +IMAGE_INSTALL = "hello-isar
> example-raw example-module-${KERNEL_NAME} enable-fsck
> isar-exclude-docs samefile hello isar-disable-apt-cache cowsay
> example-prebuilt" # # Enable cross-compilation support diff --git
> a/meta-isar/recipes-app/prebuilt-deb/files/README-create-deb.txt
> b/meta-isar/recipes-app/prebuilt-deb/files/README-create-deb.txt new
> file mode 100644 index 00000000..e2dc35dc --- /dev/null
> +++ b/meta-isar/recipes-app/prebuilt-deb/files/README-create-deb.txt
> @@ -0,0 +1,14 @@
> +Create test deb package:
> +
> +mkdir -p example-prebuilt/DEBIAN example-prebuilt/opt
> +cat << EOF > example-prebuilt/DEBIAN/control
> +Section: misc
> +Priority: optional
> +Package: example-prebuilt
> +Version: 1.0.0
> +Maintainer: Who Knows <who.knows@example.com>
> +Description: Just a test package
> +Architecture: all
> +EOF
> +echo "Just some test content" >
> example-prebuilt/opt/some-package-file +dpkg -b example-prebuilt
> example-prebuilt_1.0.0-0_all.deb diff --git
> a/meta-isar/recipes-app/prebuilt-deb/files/example-prebuilt_1.0.0-0_all.deb
> b/meta-isar/recipes-app/prebuilt-deb/files/example-prebuilt_1.0.0-0_all.deb
> new file mode 100644 index
> 0000000000000000000000000000000000000000..3049dab62d8e8bb1857626e2a791e65a986c8f36
> GIT binary patch literal 776
> zcmY$iNi0gvu;WTeP0CEn(@o0EODw8XP*5;5Gc-0dH8e4^R8TMg@?oT*fq|KciGl(U
> zK|unSk)8opa(-S(QGSkINn(*+MHONF#>QrF{eR7?BBB@=Se{+m;>L1d0#iePBBK}s
> z1c=Be={!*X&&UzWAkMu<rj~K)0a-7*O3_1S)D|b&2(F!~Wt_XYcj`Wmwjwe2$w`7W
> zcNkvUUAXiyd%l*p<Pt8%i${;t8GgHeG&{q1@}?zb->yuspRjqxy_YRdYBVND7#5f2
> zojAB~Q`K$05-xTIohG9<PVDox7|dXp#Wbxa(D69WhI0WI3e~HHA8q(o_0@l#o&6@(
> zwlkYV_?K)u^IdHBj<EBw`SR9s+k6}UaSP9!bm#2jaM{)Sa+YpWi><u6{iPREb_CZ=
> zZa$kQO<C7YzD#cVVf3r*e*bQ-lcgMsWPcVEt~~tMRy%(d=gYi(rlC>ar1|Vp{`0?+
> zGmh5!vGP}B^_Qz+ljl!vuwN=~khxmP{$jH3WN!ur_pGvC@;BsPGcc|Jh7|+D;&bc5
> zHXcd;%>)WEmdL1-#F9jKL;ypXP+S_BSm20@?TpBAacGgFB`_`+)+5J-+Z>rA{{;?r  
> zDJES0U>A4Mbkg>BhKoyfKZ^bHDTkvjv;OI?g)B0Xc6n=U6YUqgTlLZCx22wE_MFR!  
> zml`a@^X-z-ZcRL~D)HNvt!|yXn<jpU*XaJUbxq;V#eX>ddOzB=Yw^ccs|9VlcYWwh
> z4s<OS%c<0RHl_M%-j^wDv${7sWn^i_v)|jwmVY%WF8FEJ5!1VO6oPkDY;ya}C8Bj|
> ma*R#G{p}eGV}ZePiLHOqg_-NZ85l1E{lvhK&Rz8yIm`gKeJ%$8
> 
> literal 0
> HcmV?d00001
> 
> diff --git a/meta-isar/recipes-app/prebuilt-deb/prebuilt-deb.bb
> b/meta-isar/recipes-app/prebuilt-deb/prebuilt-deb.bb new file mode
> 100644 index 00000000..2f1b699e
> --- /dev/null
> +++ b/meta-isar/recipes-app/prebuilt-deb/prebuilt-deb.bb

prebuilt-deb-1.0.0.bb

> @@ -0,0 +1,20 @@
> +# This software is a part of ISAR.
> +# Copyright (c) Siemens AG, 2021
> +#
> +# SPDX-License-Identifier: MIT
> +
> +inherit dpkg-base
> +
> +# NOTE: The deb packages should almost never be stored in the repo
> itself but +#       rather fetched from a binary-serving location.
> For this example, local +#       storage was just simpler to maintain
> across all archs and distros. +#
> +# 2nd NOTE: "unpack=false" is important, bitbake unpacks deb files
> otherwise +SRC_URI =
> "file://example-prebuilt_1.0.0-0_all.deb;unpack=false" +

file://${P}-0_all.deb

> +# Only needed if recipe name != package name, as in this case. Or
> multiple +# packages are provided by a single recipe.
> +PROVIDES += "example-prebuilt"
> +
> +do_dpkg_build() {
> +}
Jan Kiszka Feb. 14, 2021, 11:25 p.m. UTC | #2
On 15.02.21 08:45, Henning Schild wrote:
> Am Sat, 13 Feb 2021 13:46:20 +0100
> schrieb Jan Kiszka <jan.kiszka@siemens.com>:
> 
>> From: Jan Kiszka <jan.kiszka@siemens.com>
>>
>> While it's definitely nicer and more convenient to pull deb packages
>> from repos, this may not always be the case. This recipe demonstrates
>> how to implement such a pattern.
>>
>> The example embeds the deb as local artifact which is clearly an
>> anti-pattern. That path was only chosen here because it's hard to
>> find a stable URL to a prebuilt arch-independent deb file in the
>> wild. The procedure for creating the deb is also included as README.
>>
>> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
>> ---
>>  meta-isar/conf/local.conf.sample              |   2 +-
>>  .../prebuilt-deb/files/README-create-deb.txt  |  14 ++++++++++++
>>  .../files/example-prebuilt_1.0.0-0_all.deb    | Bin 0 -> 776 bytes
>>  .../recipes-app/prebuilt-deb/prebuilt-deb.bb  |  20
>> ++++++++++++++++++ 4 files changed, 35 insertions(+), 1 deletion(-)
>>  create mode 100644
>> meta-isar/recipes-app/prebuilt-deb/files/README-create-deb.txt create
>> mode 100644
>> meta-isar/recipes-app/prebuilt-deb/files/example-prebuilt_1.0.0-0_all.deb
>> create mode 100644 meta-isar/recipes-app/prebuilt-deb/prebuilt-deb.bb
>>
>> diff --git a/meta-isar/conf/local.conf.sample
>> b/meta-isar/conf/local.conf.sample index 107496c1..cc0b5c66 100644
>> --- a/meta-isar/conf/local.conf.sample
>> +++ b/meta-isar/conf/local.conf.sample
>> @@ -172,7 +172,7 @@ CONF_VERSION = "1"
>>  
>>  #
>>  # The default list of extra packages to be installed.
>> -IMAGE_INSTALL = "hello-isar example-raw
>> example-module-${KERNEL_NAME} enable-fsck isar-exclude-docs samefile
>> hello isar-disable-apt-cache cowsay" +IMAGE_INSTALL = "hello-isar
>> example-raw example-module-${KERNEL_NAME} enable-fsck
>> isar-exclude-docs samefile hello isar-disable-apt-cache cowsay
>> example-prebuilt" # # Enable cross-compilation support diff --git
>> a/meta-isar/recipes-app/prebuilt-deb/files/README-create-deb.txt
>> b/meta-isar/recipes-app/prebuilt-deb/files/README-create-deb.txt new
>> file mode 100644 index 00000000..e2dc35dc --- /dev/null
>> +++ b/meta-isar/recipes-app/prebuilt-deb/files/README-create-deb.txt
>> @@ -0,0 +1,14 @@
>> +Create test deb package:
>> +
>> +mkdir -p example-prebuilt/DEBIAN example-prebuilt/opt
>> +cat << EOF > example-prebuilt/DEBIAN/control
>> +Section: misc
>> +Priority: optional
>> +Package: example-prebuilt
>> +Version: 1.0.0
>> +Maintainer: Who Knows <who.knows@example.com>
>> +Description: Just a test package
>> +Architecture: all
>> +EOF
>> +echo "Just some test content" >
>> example-prebuilt/opt/some-package-file +dpkg -b example-prebuilt
>> example-prebuilt_1.0.0-0_all.deb diff --git
>> a/meta-isar/recipes-app/prebuilt-deb/files/example-prebuilt_1.0.0-0_all.deb
>> b/meta-isar/recipes-app/prebuilt-deb/files/example-prebuilt_1.0.0-0_all.deb
>> new file mode 100644 index
>> 0000000000000000000000000000000000000000..3049dab62d8e8bb1857626e2a791e65a986c8f36
>> GIT binary patch literal 776
>> zcmY$iNi0gvu;WTeP0CEn(@o0EODw8XP*5;5Gc-0dH8e4^R8TMg@?oT*fq|KciGl(U
>> zK|unSk)8opa(-S(QGSkINn(*+MHONF#>QrF{eR7?BBB@=Se{+m;>L1d0#iePBBK}s
>> z1c=Be={!*X&&UzWAkMu<rj~K)0a-7*O3_1S)D|b&2(F!~Wt_XYcj`Wmwjwe2$w`7W
>> zcNkvUUAXiyd%l*p<Pt8%i${;t8GgHeG&{q1@}?zb->yuspRjqxy_YRdYBVND7#5f2
>> zojAB~Q`K$05-xTIohG9<PVDox7|dXp#Wbxa(D69WhI0WI3e~HHA8q(o_0@l#o&6@(
>> zwlkYV_?K)u^IdHBj<EBw`SR9s+k6}UaSP9!bm#2jaM{)Sa+YpWi><u6{iPREb_CZ=
>> zZa$kQO<C7YzD#cVVf3r*e*bQ-lcgMsWPcVEt~~tMRy%(d=gYi(rlC>ar1|Vp{`0?+
>> zGmh5!vGP}B^_Qz+ljl!vuwN=~khxmP{$jH3WN!ur_pGvC@;BsPGcc|Jh7|+D;&bc5
>> zHXcd;%>)WEmdL1-#F9jKL;ypXP+S_BSm20@?TpBAacGgFB`_`+)+5J-+Z>rA{{;?r  
>> zDJES0U>A4Mbkg>BhKoyfKZ^bHDTkvjv;OI?g)B0Xc6n=U6YUqgTlLZCx22wE_MFR!  
>> zml`a@^X-z-ZcRL~D)HNvt!|yXn<jpU*XaJUbxq;V#eX>ddOzB=Yw^ccs|9VlcYWwh
>> z4s<OS%c<0RHl_M%-j^wDv${7sWn^i_v)|jwmVY%WF8FEJ5!1VO6oPkDY;ya}C8Bj|
>> ma*R#G{p}eGV}ZePiLHOqg_-NZ85l1E{lvhK&Rz8yIm`gKeJ%$8
>>
>> literal 0
>> HcmV?d00001
>>
>> diff --git a/meta-isar/recipes-app/prebuilt-deb/prebuilt-deb.bb
>> b/meta-isar/recipes-app/prebuilt-deb/prebuilt-deb.bb new file mode
>> 100644 index 00000000..2f1b699e
>> --- /dev/null
>> +++ b/meta-isar/recipes-app/prebuilt-deb/prebuilt-deb.bb
> 
> prebuilt-deb-1.0.0.bb
> 

Well, not consistently done in our examples. But I can change that.

>> @@ -0,0 +1,20 @@
>> +# This software is a part of ISAR.
>> +# Copyright (c) Siemens AG, 2021
>> +#
>> +# SPDX-License-Identifier: MIT
>> +
>> +inherit dpkg-base
>> +
>> +# NOTE: The deb packages should almost never be stored in the repo
>> itself but +#       rather fetched from a binary-serving location.
>> For this example, local +#       storage was just simpler to maintain
>> across all archs and distros. +#
>> +# 2nd NOTE: "unpack=false" is important, bitbake unpacks deb files
>> otherwise +SRC_URI =
>> "file://example-prebuilt_1.0.0-0_all.deb;unpack=false" +
> 
> file://${P}-0_all.deb
> 

Nope, these are intentionally decoupled. No magics here, that's only
confusing.

>> +# Only needed if recipe name != package name, as in this case. Or
>> multiple +# packages are provided by a single recipe.
>> +PROVIDES += "example-prebuilt"
>> +
>> +do_dpkg_build() {
>> +}
> 

Jan

Patch

diff --git a/meta-isar/conf/local.conf.sample b/meta-isar/conf/local.conf.sample
index 107496c1..cc0b5c66 100644
--- a/meta-isar/conf/local.conf.sample
+++ b/meta-isar/conf/local.conf.sample
@@ -172,7 +172,7 @@  CONF_VERSION = "1"
 
 #
 # The default list of extra packages to be installed.
-IMAGE_INSTALL = "hello-isar example-raw example-module-${KERNEL_NAME} enable-fsck isar-exclude-docs samefile hello isar-disable-apt-cache cowsay"
+IMAGE_INSTALL = "hello-isar example-raw example-module-${KERNEL_NAME} enable-fsck isar-exclude-docs samefile hello isar-disable-apt-cache cowsay example-prebuilt"
 
 #
 # Enable cross-compilation support
diff --git a/meta-isar/recipes-app/prebuilt-deb/files/README-create-deb.txt b/meta-isar/recipes-app/prebuilt-deb/files/README-create-deb.txt
new file mode 100644
index 00000000..e2dc35dc
--- /dev/null
+++ b/meta-isar/recipes-app/prebuilt-deb/files/README-create-deb.txt
@@ -0,0 +1,14 @@ 
+Create test deb package:
+
+mkdir -p example-prebuilt/DEBIAN example-prebuilt/opt
+cat << EOF > example-prebuilt/DEBIAN/control
+Section: misc
+Priority: optional
+Package: example-prebuilt
+Version: 1.0.0
+Maintainer: Who Knows <who.knows@example.com>
+Description: Just a test package
+Architecture: all
+EOF
+echo "Just some test content" > example-prebuilt/opt/some-package-file
+dpkg -b example-prebuilt example-prebuilt_1.0.0-0_all.deb
diff --git a/meta-isar/recipes-app/prebuilt-deb/files/example-prebuilt_1.0.0-0_all.deb b/meta-isar/recipes-app/prebuilt-deb/files/example-prebuilt_1.0.0-0_all.deb
new file mode 100644
index 0000000000000000000000000000000000000000..3049dab62d8e8bb1857626e2a791e65a986c8f36
GIT binary patch
literal 776
zcmY$iNi0gvu;WTeP0CEn(@o0EODw8XP*5;5Gc-0dH8e4^R8TMg@?oT*fq|KciGl(U
zK|unSk)8opa(-S(QGSkINn(*+MHONF#>QrF{eR7?BBB@=Se{+m;>L1d0#iePBBK}s
z1c=Be={!*X&&UzWAkMu<rj~K)0a-7*O3_1S)D|b&2(F!~Wt_XYcj`Wmwjwe2$w`7W
zcNkvUUAXiyd%l*p<Pt8%i${;t8GgHeG&{q1@}?zb->yuspRjqxy_YRdYBVND7#5f2
zojAB~Q`K$05-xTIohG9<PVDox7|dXp#Wbxa(D69WhI0WI3e~HHA8q(o_0@l#o&6@(
zwlkYV_?K)u^IdHBj<EBw`SR9s+k6}UaSP9!bm#2jaM{)Sa+YpWi><u6{iPREb_CZ=
zZa$kQO<C7YzD#cVVf3r*e*bQ-lcgMsWPcVEt~~tMRy%(d=gYi(rlC>ar1|Vp{`0?+
zGmh5!vGP}B^_Qz+ljl!vuwN=~khxmP{$jH3WN!ur_pGvC@;BsPGcc|Jh7|+D;&bc5
zHXcd;%>)WEmdL1-#F9jKL;ypXP+S_BSm20@?TpBAacGgFB`_`+)+5J-+Z>rA{{;?r
zDJES0U>A4Mbkg>BhKoyfKZ^bHDTkvjv;OI?g)B0Xc6n=U6YUqgTlLZCx22wE_MFR!
zml`a@^X-z-ZcRL~D)HNvt!|yXn<jpU*XaJUbxq;V#eX>ddOzB=Yw^ccs|9VlcYWwh
z4s<OS%c<0RHl_M%-j^wDv${7sWn^i_v)|jwmVY%WF8FEJ5!1VO6oPkDY;ya}C8Bj|
ma*R#G{p}eGV}ZePiLHOqg_-NZ85l1E{lvhK&Rz8yIm`gKeJ%$8

literal 0
HcmV?d00001

diff --git a/meta-isar/recipes-app/prebuilt-deb/prebuilt-deb.bb b/meta-isar/recipes-app/prebuilt-deb/prebuilt-deb.bb
new file mode 100644
index 00000000..2f1b699e
--- /dev/null
+++ b/meta-isar/recipes-app/prebuilt-deb/prebuilt-deb.bb
@@ -0,0 +1,20 @@ 
+# This software is a part of ISAR.
+# Copyright (c) Siemens AG, 2021
+#
+# SPDX-License-Identifier: MIT
+
+inherit dpkg-base
+
+# NOTE: The deb packages should almost never be stored in the repo itself but
+#       rather fetched from a binary-serving location. For this example, local
+#       storage was just simpler to maintain across all archs and distros.
+#
+# 2nd NOTE: "unpack=false" is important, bitbake unpacks deb files otherwise
+SRC_URI = "file://example-prebuilt_1.0.0-0_all.deb;unpack=false"
+
+# Only needed if recipe name != package name, as in this case. Or multiple
+# packages are provided by a single recipe.
+PROVIDES += "example-prebuilt"
+
+do_dpkg_build() {
+}