From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6721684426774806528 Date: Mon, 5 Aug 2019 07:37:30 -0700 (PDT) From: vijai kumar To: isar-users Message-Id: In-Reply-To: <20190805140742.11479-1-Quirin.Gylstorff@siemens.com> References: <20190805140742.11479-1-Quirin.Gylstorff@siemens.com> Subject: Re: [PATCH] meta/classes: generate bill of material from image MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_1557_577688922.1565015850888" X-Google-Token: EKr-oOoF5ks_fuHX3qY0 X-Google-IP: 139.181.36.34 X-TUID: q4l56yeYCAI7 ------=_Part_1557_577688922.1565015850888 Content-Type: multipart/alternative; boundary="----=_Part_1558_1796949727.1565015850888" ------=_Part_1558_1796949727.1565015850888 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Ok. I have been looking for something like this for some time now :) On Monday, August 5, 2019 at 7:38:31 PM UTC+5:30, Q. Gylstorff wrote: > From: Quirin Gylstorff > > > To create products it is necessary to have a list > of used packages for clearance and to security monitoring. > To get a simple list of packages use dpkg-query and generate > a list with the following pattern: > > source name| source version | binary package name | binary version > > To use it add following line to the local.conf: > ISAR_DO_PACKAGE_LIST ?= "1" > > Signed-off-by: Quirin Gylstorff > > --- > meta-isar/conf/local.conf.sample | 4 ++++ > .../classes/image-package-list-extension.bbclass | 16 ++++++++++++++++ > meta/classes/image.bbclass | 1 + > 3 files changed, 21 insertions(+) > create mode 100644 meta/classes/image-package-list-extension.bbclass > > diff --git a/meta-isar/conf/local.conf.sample > b/meta-isar/conf/local.conf.sample > index 5b3a0a1..d188051 100644 > --- a/meta-isar/conf/local.conf.sample > +++ b/meta-isar/conf/local.conf.sample > @@ -170,6 +170,10 @@ IMAGE_INSTALL = "hello-isar example-raw > example-module-${KERNEL_NAME} enable-fsc > # NOTE: this works on build host >= stretch for armhf, arm64 and amd64 > targets for now. > ISAR_CROSS_COMPILE ?= "0" > > +# > +# Generate package list > +ISAR_DO_PACKAGE_LIST ?= "1" > + > # > # Uncomment this to enable use of cached base repository > #ISAR_USE_CACHED_BASE_REPO ?= "1" > diff --git a/meta/classes/image-package-list-extension.bbclass > b/meta/classes/image-package-list-extension.bbclass > new file mode 100644 > index 0000000..558922e > --- /dev/null > +++ b/meta/classes/image-package-list-extension.bbclass > @@ -0,0 +1,16 @@ > +# This software is a part of ISAR. > +# Copyright (C) Siemens AG, 2019 > +# > +# SPDX-License-Identifier: MIT > + > +ISAR_DO_PACKAGE_LIST ??= "0" > +image_package_list[dirs] = "${DEPLOY_DIR_IMAGE}" > +image_package_list() { > + if [ > "${@repr(bb.utils.to_boolean(d.getVar('ISAR_DO_PACKAGE_LIST')))}" = 'True' > ]; then > + dpkg-query --admindir=${IMAGE_ROOTFS}/var/lib/dpkg/ \ > + -f > '${source:Package}|${source:Version}|${binary:Package}|${Version}\n' -W > \ > + ${DEPLOY_DIR_IMAGE}/${IMAGE_FULLNAME}.packages.lst > May be we could format and sort this a bit. dpkg-query --admindir=${IMAGE_ROOTFS}/var/lib/dpkg/ \ -f '${source:Package}|${source:Version}|${binary:Package}|${Version}\n' -W | column -t | sort You could add column headers as well. + fi > +} > +ROOTFS_POSTPROCESS_COMMAND =+ "image_package_list" > + > diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass > index ec6bd39..85bab64 100644 > --- a/meta/classes/image.bbclass > +++ b/meta/classes/image.bbclass > @@ -68,6 +68,7 @@ inherit image-tools-extension > inherit image-postproc-extension > inherit image-locales-extension > inherit image-account-extension > +inherit image-package-list-extension > > # Extra space for rootfs in MB > ROOTFS_EXTRA ?= "64" > -- > 2.20.1 > Thanks, Vijai Kumar K ------=_Part_1558_1796949727.1565015850888 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
Ok. I have been looking for something like this for s= ome time now :)


On Monday, Augu= st 5, 2019 at 7:38:31 PM UTC+5:30, Q. Gylstorff wrote:
From: Quirin Gylstorff <quirin....@siemens.com<= /a>>

To create products it is necessary to have a list
of used packages for clearance and to security monitoring.
To get a simple list of packages use dpkg-query and generate
a list with the following pattern:

source name| source version | binary package name | binary version

To use it add following line to the local.conf:
ISAR_DO_PACKAGE_LIST ?=3D "1"

Signed-off-by: Quirin Gylstorff <
quirin....@siemens.com>
---
=C2=A0meta-isar/conf/local.conf.sample =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 | =C2=A04 ++++
=C2=A0.../classes/image-package-list-extension.bbclass | 16 ++++++= ++++++++++
=C2=A0meta/classes/image.bbclass =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | =C2=A01 +
=C2=A03 files changed, 21 insertions(+)
=C2=A0create mode 100644 meta/classes/image-package-list-extension= .bbclass

diff --git a/meta-isar/conf/local.conf.sample b/meta-isar/conf/loc= al.conf.sample
index 5b3a0a1..d188051 100644
--- a/meta-isar/conf/local.conf.sample
+++ b/meta-isar/conf/local.conf.sample
@@ -170,6 +170,10 @@ IMAGE_INSTALL =3D "hello-isar example-raw exa= mple-module-${KERNEL_NAME} enable-fsc
=C2=A0# NOTE: this works on build host >=3D stretch for armhf, arm64= and amd64 targets for now.
=C2=A0ISAR_CROSS_COMPILE ?=3D "0"
=C2=A0
+#
+# Generate package list=20
+ISAR_DO_PACKAGE_LIST ?=3D "1"
+
=C2=A0#
=C2=A0# Uncomment this to enable use of cached base repository
=C2=A0#ISAR_USE_CACHED_BASE_REPO ?=3D "1"
diff --git a/meta/classes/image-package-list-extension.bbclass b/m= eta/classes/image-package-list-extension.bbclass
new file mode 100644
index 0000000..558922e
--- /dev/null
+++ b/meta/classes/image-package-list-extension.bbclass
@@ -0,0 +1,16 @@
+# This software is a part of ISAR.
+# Copyright (C) Siemens AG, 2019
+#
+# SPDX-License-Identifier: MIT
+
+ISAR_DO_PACKAGE_LIST ??=3D "0"
+image_package_list[dirs] =3D "${DEPLOY_DIR_IMAGE}"
+image_package_list() {
+ =C2=A0 =C2=A0if [ "${@repr(bb.utils.to_boolean(d.getVar(= 9;ISAR_DO_PACKAGE_LIST')))}" =3D 'True' ]; then
+ =C2=A0 =C2=A0 =C2=A0dpkg-query --admindir=3D${IMAGE_ROOTFS}/var/= lib/dpkg/ \
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0-f '${source:Package}|${source:= Version}|${binary:Package}|${Version}\n' -W > \
+ =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0${DEPLOY_DIR_IMAGE}/${IMAGE_FU= LLNAME}.packages.lst

May be we could format and sort this a= bit.

dpkg-query --admindir=3D${IMAGE_ROOTFS}/var/= lib/dpkg/ \
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0 -f '${source:Package}|${source:Version}|${b= inary:Package}|${Version}\n' -W | column -t | sort

=
You could add column headers as well.

+ =C2=A0 =C2=A0fi
+}
+ROOTFS_POSTPROCESS_COMMAND =3D+ "image_package_list"
+
diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass
index ec6bd39..85bab64 100644
--- a/meta/classes/image.bbclass
+++ b/meta/classes/image.bbclass
@@ -68,6 +68,7 @@ inherit image-tools-extension
=C2=A0inherit image-postproc-extension
=C2=A0inherit image-locales-extension
=C2=A0inherit image-account-extension
+inherit image-package-list-extension
=C2=A0
=C2=A0# Extra space for rootfs in MB
=C2=A0ROOTFS_EXTRA ?=3D "64"
--=20
2.20.1

Thanks,
Vijai Kumar K
------=_Part_1558_1796949727.1565015850888-- ------=_Part_1557_577688922.1565015850888--