meta-isar: Add simple example for injecting prebuilt deb packages

Message ID 8cbb94d5-0020-75b4-e724-4d6fde994c01@siemens.com
State Superseded, archived
Headers show
Series meta-isar: Add simple example for injecting prebuilt deb packages | expand

Commit Message

Jan Kiszka Feb. 12, 2021, 6:36 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
"sources" and the procedure for creating the deb is also included.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---

This was only lightly tested because our CI still f...-up thanks to some
primitive content checker at the proxies.

 meta-isar/conf/local.conf.sample                |   2 +-
 .../recipes-app/prebuilt-deb/files/README.deb   |   3 +++
 .../files/some-deb-package/DEBIAN/control       |   7 +++++++
 .../some-deb-package/opt/some-package-file      |   1 +
 .../files/some-deb-package_1.0.0-0_all.deb      | Bin 0 -> 780 bytes
 .../recipes-app/prebuilt-deb/prebuilt-deb.bb    |  16 ++++++++++++++++
 6 files changed, 28 insertions(+), 1 deletion(-)
 create mode 100644 meta-isar/recipes-app/prebuilt-deb/files/README.deb
 create mode 100644 meta-isar/recipes-app/prebuilt-deb/files/some-deb-package/DEBIAN/control
 create mode 100644 meta-isar/recipes-app/prebuilt-deb/files/some-deb-package/opt/some-package-file
 create mode 100644 meta-isar/recipes-app/prebuilt-deb/files/some-deb-package_1.0.0-0_all.deb
 create mode 100644 meta-isar/recipes-app/prebuilt-deb/prebuilt-deb.bb

Comments

Henning Schild Feb. 12, 2021, 7:07 a.m. UTC | #1
Ok, seems we did not align correctly on who does it. We both did add
actual code, while i later found that an example in the user manual
might have been enough after all.

Am Fri, 12 Feb 2021 17:36:40 +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 "sources" and the procedure for creating the deb is also
> included.
> 
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
> 
> This was only lightly tested because our CI still f...-up thanks to
> some primitive content checker at the proxies.
> 
>  meta-isar/conf/local.conf.sample                |   2 +-
>  .../recipes-app/prebuilt-deb/files/README.deb   |   3 +++
>  .../files/some-deb-package/DEBIAN/control       |   7 +++++++
>  .../some-deb-package/opt/some-package-file      |   1 +
>  .../files/some-deb-package_1.0.0-0_all.deb      | Bin 0 -> 780 bytes
>  .../recipes-app/prebuilt-deb/prebuilt-deb.bb    |  16
> ++++++++++++++++ 6 files changed, 28 insertions(+), 1 deletion(-)
>  create mode 100644
> meta-isar/recipes-app/prebuilt-deb/files/README.deb create mode
> 100644
> meta-isar/recipes-app/prebuilt-deb/files/some-deb-package/DEBIAN/control
> create mode 100644
> meta-isar/recipes-app/prebuilt-deb/files/some-deb-package/opt/some-package-file
> create mode 100644
> meta-isar/recipes-app/prebuilt-deb/files/some-deb-package_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..2379f1ca 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
> some-deb-package" # # Enable cross-compilation support diff --git
> a/meta-isar/recipes-app/prebuilt-deb/files/README.deb
> b/meta-isar/recipes-app/prebuilt-deb/files/README.deb new file mode
> 100644 index 00000000..92f07113 --- /dev/null
> +++ b/meta-isar/recipes-app/prebuilt-deb/files/README.deb

I would say ".txt" or ".md" dot deb is pretty confusing

> @@ -0,0 +1,3 @@
> +Create test deb package:
> +
> +dpkg -b some-deb-package some-deb-package_1.0.0-0_all.deb

Maybe fold all the files into here, if we have that binary and keep it.

> diff --git
> a/meta-isar/recipes-app/prebuilt-deb/files/some-deb-package/DEBIAN/control
> b/meta-isar/recipes-app/prebuilt-deb/files/some-deb-package/DEBIAN/control
> new file mode 100644 index 00000000..cb2c39fe --- /dev/null
> +++
> b/meta-isar/recipes-app/prebuilt-deb/files/some-deb-package/DEBIAN/control
> @@ -0,0 +1,7 @@ +Section: misc
> +Priority: optional
> +Package: some-deb-package
> +Version: 1.0.0
> +Maintainer: Who Knows <who.knows@example.com>
> +Description: Just a test package
> +Architecture: all
> diff --git
> a/meta-isar/recipes-app/prebuilt-deb/files/some-deb-package/opt/some-package-file
> b/meta-isar/recipes-app/prebuilt-deb/files/some-deb-package/opt/some-package-file
> new file mode 100644 index 00000000..6f6625ec --- /dev/null
> +++
> b/meta-isar/recipes-app/prebuilt-deb/files/some-deb-package/opt/some-package-file
> @@ -0,0 +1 @@ +Just some test content
> diff --git
> a/meta-isar/recipes-app/prebuilt-deb/files/some-deb-package_1.0.0-0_all.deb
> b/meta-isar/recipes-app/prebuilt-deb/files/some-deb-package_1.0.0-0_all.deb
> new file mode 100644 index
> 0000000000000000000000000000000000000000..a4a760736634405807edac4d877f4cef7b86413f
> GIT binary patch literal 780
> zcmY$iNi0gvu;WTeP0CEn(@o0EODw8XP*5;5Gc-0dF|#x=Qcy4e@?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(Fzf^fgQ<<LI8cr@vJuYq#jl
> zx+f?ra#=crzhZ7v#ryvMx*KjK$A-*3CCL?48u*_7_SMSI-+S3iH{HwXtGe%c?dVtE
> z>Hdo^eb!7g*4_Uhkoo>Dfx{)fa#I@9-$vDa|C%<T`ml~>?%WNxEKYBq8M0x@T;GN3  
> zI?@#u1k0RQ{xIgJP2ba+drHq!A5B!8^4IhFEc1<b`*>a&mY)*cXB4e+;9!rB<HFs%
> zp0N|Y6dmsE<`A`0Qa(4K;!4DK<vD^!qAEKyG7jvGo4=4taC>^d8t3wv2D4l$0%sm#
> ztTCu-;Onbhv43WF`L6qSE^4(iZ;Lxz<!ZN>rGkN>N2h+Lb5Z?K2F5kOuwr0Xd~RLX
> z#v|#!nLt6t5*d|}Sds{j2w*4^ic2F?U?hV<0vBpr>|#WYi<y^p_W|RAVH0v(xXqC{
> z@?YR^mtw-@4|Z`EO($)Cr*_cl@+9w?S5~%*U9K9;@!!KJsnw7ycW>ePi!-NYJj=B&
> zywCTBf9Z|PpUZ#koBN3WsqU%r(r*h-T#i=B$rsOFDzCCiVP|}*?cp~QEuJc`dJ#2;
> z-KIh2%4xORWiqEYCL8#RNUZj|R<z~Sk7w_$td05UAvf1r_HFX3ezCOKJ72WRzUgXv
> vUv?tv7}w87VeYFs!@f+{Rt5#l@6;9#QQo!E42;)+{$gObGHd&8<ZuH3TDvj1
> 
> literal 0
> HcmV?d00001

A binary? It is small and you provided sources ... acceptable.

One reason to not build a random package within isar was that i did not
want it misunderstood as a valid way of building a package.

So i like the binary and suggest to move the sources into the README.
To give that README content but not give people files to do stupid
stuff.

And if it is a ```shell copy paste section ...

> 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..2ead6024
> --- /dev/null
> +++ b/meta-isar/recipes-app/prebuilt-deb/prebuilt-deb.bb
> @@ -0,0 +1,16 @@
> +# 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. +SRC_URI =
> "file://some-deb-package_1.0.0-0_all.deb;unpack=false" +
> +PROVIDES += "some-deb-package"
> +
> +do_dpkg_build() {
> +}

This is much more readable than mine and more to the point, without the
second package and the hacks to rename and pull it.

And my hacks are really bad examples ... overriding the checksumming
function, pulling packages out of isar-apt, task reordering ... it is
even fragile and hard to maintain.

Maybe take the verbosity of my patches and put it into your patch where
applicable. Which also means i only have to review and not code ;)

Henning

Patch

diff --git a/meta-isar/conf/local.conf.sample b/meta-isar/conf/local.conf.sample
index 107496c1..2379f1ca 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 some-deb-package"
 
 #
 # Enable cross-compilation support
diff --git a/meta-isar/recipes-app/prebuilt-deb/files/README.deb b/meta-isar/recipes-app/prebuilt-deb/files/README.deb
new file mode 100644
index 00000000..92f07113
--- /dev/null
+++ b/meta-isar/recipes-app/prebuilt-deb/files/README.deb
@@ -0,0 +1,3 @@ 
+Create test deb package:
+
+dpkg -b some-deb-package some-deb-package_1.0.0-0_all.deb
diff --git a/meta-isar/recipes-app/prebuilt-deb/files/some-deb-package/DEBIAN/control b/meta-isar/recipes-app/prebuilt-deb/files/some-deb-package/DEBIAN/control
new file mode 100644
index 00000000..cb2c39fe
--- /dev/null
+++ b/meta-isar/recipes-app/prebuilt-deb/files/some-deb-package/DEBIAN/control
@@ -0,0 +1,7 @@ 
+Section: misc
+Priority: optional
+Package: some-deb-package
+Version: 1.0.0
+Maintainer: Who Knows <who.knows@example.com>
+Description: Just a test package
+Architecture: all
diff --git a/meta-isar/recipes-app/prebuilt-deb/files/some-deb-package/opt/some-package-file b/meta-isar/recipes-app/prebuilt-deb/files/some-deb-package/opt/some-package-file
new file mode 100644
index 00000000..6f6625ec
--- /dev/null
+++ b/meta-isar/recipes-app/prebuilt-deb/files/some-deb-package/opt/some-package-file
@@ -0,0 +1 @@ 
+Just some test content
diff --git a/meta-isar/recipes-app/prebuilt-deb/files/some-deb-package_1.0.0-0_all.deb b/meta-isar/recipes-app/prebuilt-deb/files/some-deb-package_1.0.0-0_all.deb
new file mode 100644
index 0000000000000000000000000000000000000000..a4a760736634405807edac4d877f4cef7b86413f
GIT binary patch
literal 780
zcmY$iNi0gvu;WTeP0CEn(@o0EODw8XP*5;5Gc-0dF|#x=Qcy4e@?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(Fzf^fgQ<<LI8cr@vJuYq#jl
zx+f?ra#=crzhZ7v#ryvMx*KjK$A-*3CCL?48u*_7_SMSI-+S3iH{HwXtGe%c?dVtE
z>Hdo^eb!7g*4_Uhkoo>Dfx{)fa#I@9-$vDa|C%<T`ml~>?%WNxEKYBq8M0x@T;GN3
zI?@#u1k0RQ{xIgJP2ba+drHq!A5B!8^4IhFEc1<b`*>a&mY)*cXB4e+;9!rB<HFs%
zp0N|Y6dmsE<`A`0Qa(4K;!4DK<vD^!qAEKyG7jvGo4=4taC>^d8t3wv2D4l$0%sm#
ztTCu-;Onbhv43WF`L6qSE^4(iZ;Lxz<!ZN>rGkN>N2h+Lb5Z?K2F5kOuwr0Xd~RLX
z#v|#!nLt6t5*d|}Sds{j2w*4^ic2F?U?hV<0vBpr>|#WYi<y^p_W|RAVH0v(xXqC{
z@?YR^mtw-@4|Z`EO($)Cr*_cl@+9w?S5~%*U9K9;@!!KJsnw7ycW>ePi!-NYJj=B&
zywCTBf9Z|PpUZ#koBN3WsqU%r(r*h-T#i=B$rsOFDzCCiVP|}*?cp~QEuJc`dJ#2;
z-KIh2%4xORWiqEYCL8#RNUZj|R<z~Sk7w_$td05UAvf1r_HFX3ezCOKJ72WRzUgXv
vUv?tv7}w87VeYFs!@f+{Rt5#l@6;9#QQo!E42;)+{$gObGHd&8<ZuH3TDvj1

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..2ead6024
--- /dev/null
+++ b/meta-isar/recipes-app/prebuilt-deb/prebuilt-deb.bb
@@ -0,0 +1,16 @@ 
+# 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.
+SRC_URI = "file://some-deb-package_1.0.0-0_all.deb;unpack=false"
+
+PROVIDES += "some-deb-package"
+
+do_dpkg_build() {
+}