public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: Claudius Heine <claudius.heine.ext@siemens.com>
To: "[ext] Jan Kiszka" <jan.kiszka@siemens.com>,
	"[ext] Henning Schild" <henning.schild@siemens.com>,
	isar-users@googlegroups.com
Subject: Re: [PATCH 16/16] recipes-app/hello-bin: add example on how to use dpkg-bin
Date: Wed, 2 Aug 2017 08:55:20 +0200	[thread overview]
Message-ID: <9eb7bf64-33fc-a313-024e-6c691ace364a@siemens.com> (raw)
In-Reply-To: <dc205079-9a14-0ea5-50d5-b28d281f252c@siemens.com>

On 08/02/2017 08:33 AM, [ext] Jan Kiszka wrote:
> On 2017-08-01 12:17, [ext] Henning Schild wrote:
>> Signed-off-by: Henning Schild <henning.schild@siemens.com>
>> ---
>>   meta-isar/recipes-app/hello-bin/files/README     |  1 +
>>   meta-isar/recipes-app/hello-bin/files/postinst   | 14 +++++++++++++
>>   meta-isar/recipes-app/hello-bin/hello-bin_0.1.bb | 26 ++++++++++++++++++++++++
>>   3 files changed, 41 insertions(+)
>>   create mode 100644 meta-isar/recipes-app/hello-bin/files/README
>>   create mode 100644 meta-isar/recipes-app/hello-bin/files/postinst
>>   create mode 100644 meta-isar/recipes-app/hello-bin/hello-bin_0.1.bb
>>
>> diff --git a/meta-isar/recipes-app/hello-bin/files/README b/meta-isar/recipes-app/hello-bin/files/README
>> new file mode 100644
>> index 0000000..6e2ce0f
>> --- /dev/null
>> +++ b/meta-isar/recipes-app/hello-bin/files/README
>> @@ -0,0 +1 @@
>> +This is an example file that we get from FILESDIR in recipe.
>> diff --git a/meta-isar/recipes-app/hello-bin/files/postinst b/meta-isar/recipes-app/hello-bin/files/postinst
>> new file mode 100644
>> index 0000000..2a9eab6
>> --- /dev/null
>> +++ b/meta-isar/recipes-app/hello-bin/files/postinst
>> @@ -0,0 +1,14 @@
>> +#!/bin/sh
>> +
>> +set -e
>> +
>> +if ! getent group hello >/dev/null; then
>> +	addgroup --quiet --system hello
>> +fi
>> +
>> +if ! getent passwd hello >/dev/null; then
>> +	adduser --system --ingroup hello --home /var/lib/hello hello \
>> +		--gecos "My hello user"
>> +fi
>> +
>> +chown -R hello:hello /var/lib/hello
> 
> Nice.
> 
>> diff --git a/meta-isar/recipes-app/hello-bin/hello-bin_0.1.bb b/meta-isar/recipes-app/hello-bin/hello-bin_0.1.bb
>> new file mode 100644
>> index 0000000..5ff12d3
>> --- /dev/null
>> +++ b/meta-isar/recipes-app/hello-bin/hello-bin_0.1.bb
>> @@ -0,0 +1,26 @@
>> +# Sample application using dpkg-bin, which turns a folder (${D}) of
>> +# files into a .deb
>> +#
>> +# This software is a part of ISAR.
>> +
>> +DESCRIPTION = "Sample bin application for ISAR"
>> +DEBIAN_MAINTAINER = "Your name here <you@domain.com>"
>> +
>> +inherit dpkg-bin
>> +
> 
> In contrast to OE/Yocto, we don't need to specify the files we want to
> install later on here via SRC_URI? I'm not sure right now that we do not
> lose some features when skipping this local fetching steps.

The fetch step is still there, but it doesn't do anything because 
SRC_URI is empty.

> 
>> +	install -v -d ${D}/usr/local/bin/
>> +	install -v -m 755 ${WORKDIR}/${PN} ${D}/usr/local/bin/${PN}
>> +
>> +	bbnote "Now copy ${FILESDIR}/README to overlay"
> 
> In OE, FILESDIR is deprecated and has been removed already. Probably not
> a good idea to introduce it here. FILESPATH is now the standard.

The README should be put into the SRC_URI and then fetched via the 
do_fetch step from the FILESDIR/FILESPATH into the WORKDIR.

> However:
> 
> "Usage of FILESPATH is discouraged, since it can make recipes harder
> to bbappend. Instead FILESEXTRAPATHS should be used to extend the path."
> 
>> +	install -v -d ${D}/usr/local/doc/
>> +	install -v -m 644 ${FILESDIR}/README ${D}/usr/local/doc/README-${P}
>> +
>> +	bbnote "Now for a debian hook, see dpkg-deb"
>> +	install -v -m 755 ${FILESDIR}/postinst ${D}/DEBIAN/postinst
> 
> Maybe this could be automated - to avoid boilerplate logic - by defining
> some DEBIAN_POSTINST var. dpkg-bin could evaluate that var and install
> everything mentioned in it without requiring the user to do this here
> manually.

Here is another idea, simpler but then you can put the additional steps 
easily into the recipe. Provide a variable to 
"${D}/DEBIAN/[postinst,...]" so you can simply do something like this:

cat >${DEBIAN_POSTINST_FILE} <<EOF
#!/bin/sh

set -e

if ! getent group hello >/dev/null; then
     addgroup --quiet --system hello
fi

if ! getent passwd hello >/dev/null; then
     adduser --system --ingroup hello --home /var/lib/hello hello \
             --gecos "My hello user"
fi

chown -R hello:hello /var/lib/hello
EOF

in the do_install step. This way you would have every step to setup the 
package and rootfs neatly in a single file and if this becomes to long, 
just add a file to the SRC_URI, fetch it to the workdir and copy/install 
it to this path in the do_install step.

Cheers,
Claudius

  reply	other threads:[~2017-08-02  6:55 UTC|newest]

Thread overview: 64+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-01 10:17 [PATCH 00/16] fixes and introducing dpdk-bin support Henning Schild
2017-08-01 10:17 ` [PATCH 01/16] meta: ext4-img: copy and keep attributes, always copy with sudo Henning Schild
2017-08-02  7:48   ` Alexander Smirnov
2017-08-02 11:18     ` Henning Schild
2017-10-19 18:04   ` Henning Schild
2017-10-19 19:41     ` Alexander Smirnov
2017-08-01 10:17 ` [PATCH 02/16] meta: classes: use base.bbclass from bitbake Henning Schild
     [not found]   ` <CAJmB2rBjBqHxPKTna-XUtgmW9i-ooQwbACyFgQTQahTqUAxHcg@mail.gmail.com>
2017-08-02  8:21     ` Alexander Smirnov
2017-08-01 10:17 ` [PATCH 03/16] meta: isar-base: remove unused function Henning Schild
     [not found]   ` <CAJmB2rBwssbfjgqL2wAsOFfGUK7DbBY31tF_QhR09Ot0rmRVjQ@mail.gmail.com>
2017-08-02  8:20     ` Alexander Smirnov
2017-08-01 10:17 ` [PATCH 04/16] remove redundant variable THISDIR Henning Schild
2017-08-02  8:25   ` Alexander Smirnov
2017-08-02 11:20     ` Henning Schild
2017-08-01 10:17 ` [PATCH 05/16] meta: conf: use bitbake.conf from bitbake and apply local changes Henning Schild
2017-08-02  8:34   ` Alexander Smirnov
2017-08-02 11:22     ` Henning Schild
2017-08-01 10:17 ` [PATCH 06/16] meta: conf: clean up local bitbake config Henning Schild
2017-08-02  8:35   ` Alexander Smirnov
2017-08-02 11:23     ` Henning Schild
2017-08-01 10:17 ` [PATCH 07/16] classes: use WORKDIR and get rid of BUILDROOT Henning Schild
2017-08-02  9:24   ` Alexander Smirnov
2017-08-02 11:30     ` Henning Schild
2017-08-03 11:24     ` Henning Schild
2017-08-01 10:17 ` [PATCH 08/16] classes: move fetch and unpack into isar-base Henning Schild
2017-08-02  9:47   ` Alexander Smirnov
2017-08-02 11:33     ` Henning Schild
2017-08-01 10:17 ` [PATCH 09/16] meta: dpdk use [dirs] directive instead of mkdir Henning Schild
2017-08-01 10:17 ` [PATCH 10/16] meta: dpkg: reorder and rename do_install to install in addtask Henning Schild
2017-08-01 10:17 ` [PATCH 11/16] meta: classes: make do_build always the end of the task-chain Henning Schild
2017-08-02  9:54   ` Alexander Smirnov
2017-08-02 12:05     ` Henning Schild
2017-08-01 10:17 ` [PATCH 12/16] meta: dpkg rename install to install_package Henning Schild
2017-08-02  9:59   ` Alexander Smirnov
2017-08-01 10:17 ` [PATCH 13/16] meta: classes: move install_package to isar-base Henning Schild
2017-08-01 11:48   ` Claudius Heine
2017-08-01 14:00   ` Claudius Heine
2017-08-01 15:01     ` Henning Schild
2017-08-01 10:17 ` [PATCH 14/16] meta: classes: rename dpkg to dpkg-src Henning Schild
2017-08-02 10:02   ` Alexander Smirnov
2017-08-03 15:37     ` Henning Schild
2017-08-03 15:45       ` Jan Kiszka
2017-08-01 10:17 ` [PATCH 15/16] meta: add dpkg-bin class Henning Schild
2017-08-01 14:25   ` Claudius Heine
2017-08-01 15:10     ` Claudius Heine
2017-08-02 10:11       ` Alexander Smirnov
2017-08-02 10:25         ` Henning Schild
2017-08-02 12:31         ` Henning Schild
2017-08-02 12:50           ` Jan Kiszka
2017-08-02 13:40       ` Henning Schild
2017-08-02 15:03         ` Claudius Heine
2017-08-03  7:57           ` Henning Schild
2017-08-03 10:39             ` Claudius Heine
2017-08-03 14:17               ` Henning Schild
2017-08-02 11:11   ` Claudius Heine
2017-08-02 11:17     ` Claudius Heine
2017-08-02 11:26       ` Claudius Heine
2017-08-01 10:17 ` [PATCH 16/16] recipes-app/hello-bin: add example on how to use dpkg-bin Henning Schild
2017-08-02  6:33   ` Jan Kiszka
2017-08-02  6:55     ` Claudius Heine [this message]
2017-08-03 18:48     ` Henning Schild
2017-08-01 10:23 ` [PATCH 00/16] fixes and introducing dpdk-bin support Henning Schild
2017-08-01 11:24 ` Claudius Heine
2017-08-11  9:15 ` Alexander Smirnov
2017-08-11 10:35   ` Henning Schild

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9eb7bf64-33fc-a313-024e-6c691ace364a@siemens.com \
    --to=claudius.heine.ext@siemens.com \
    --cc=henning.schild@siemens.com \
    --cc=isar-users@googlegroups.com \
    --cc=jan.kiszka@siemens.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox