From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6753266854416875520 Date: Fri, 1 Nov 2019 00:08:35 -0700 (PDT) From: chombourger@gmail.com To: isar-users Message-Id: <783feb0f-41d0-46fa-95a3-aa9ce9b0a5f9@googlegroups.com> In-Reply-To: <20191029164424.14681-5-henning.schild@siemens.com> References: <20191029164424.14681-1-henning.schild@siemens.com> <20191029164424.14681-5-henning.schild@siemens.com> Subject: Re: [PATCH 4/5] doc: write something about "debianize" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_196_2071665381.1572592115892" X-Google-Token: EPOz7-0F3xLXnPSBHik0 X-Google-IP: 139.181.48.2 X-TUID: JIVrTB+pKkm+ ------=_Part_196_2071665381.1572592115892 Content-Type: multipart/alternative; boundary="----=_Part_197_428091438.1572592115892" ------=_Part_197_428091438.1572592115892 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On Tuesday, October 29, 2019 at 5:44:28 PM UTC+1, Henning Schild wrote: > > From: Henning Schild > > > Also add some comments to the implementation and extend the example > recipe with some pre- and post-processing. > > Signed-off-by: Henning Schild > > --- > doc/user_manual.md | 19 ++++++++++++++++++- > .../recipes-app/samefile/samefile_2.14.bb | 14 ++++++++++++++ > meta/classes/debianize.bbclass | 6 ++++++ > 3 files changed, 38 insertions(+), 1 deletion(-) > > diff --git a/doc/user_manual.md b/doc/user_manual.md > index 34f50df..7c23fcc 100644 > --- a/doc/user_manual.md > +++ b/doc/user_manual.md > @@ -583,7 +583,7 @@ Isar currently supports two ways of creating custom > packages. > > The `deb` packages are built using `dpkg-buildpackage`, so the sources > should contain the `debian` directory with necessary meta information. This > way is the default way of adding software that needs to be compiled from > source. The bbclass for this approach is called `dpkg`. > > -**NOTE:** If the sources do not contain a `debian` directory your recipe > can fetch, create, or ship that. > +**NOTE:** If the sources do not contain a `debian` directory your recipe > can fetch, create, or ship that. You might want to read the the next > section before returning here. > > This is also what you do if you want to rebuild/modify an upstream > package. > Isar does understand `SRC_URI` entries starting with "apt://". For an > example > @@ -624,6 +624,23 @@ This approach prevents duplication of the license > files in different packages. > > The last line in the example above adds recipe to the Isar work chain. > > +### Compilation of sources missing the debian/-directory > + > +The `debian` directory contains meta information on how to build a > package from source. This is roughly speaking "configure", "compile", > "install" all described in a Debian-specific way. > +Isar expects your sources to contain the `debian` folder and the above > steps need to be described in it, not in a task in a recipe. > + > +So once you have sources you always need to combine them with a `debian` > folder before Isar can build a package for you. > +You might be able to find a debianization for a component on the > internet, i.e. Ubuntu does package an open source component while Debian > does not. Your recipe could download the `debian` folder from Ubuntu and > the sources from the open source project. > + > +You can write it yourself, which can be pretty easy but requires a bit of > studying. > + > +Isar does actually contain a helper that aims to "debianize" sources for > your. If your package uses a build-system that Debian knows and follows the > well known "configure", "compile", "install" scheme that debianization > might just fit your needs without reading Debian manuals. > +If it does not fully fit your needs, it probably gives you a good > starting point for your manual tuning. > + > +The shell function `deb_debianize` creates a `debian` folder. But it will > not overwrite files that already are in WORKDIR. So you can either just > call it to fully generate the `debian` folder. Or you combine it with > pre-existing parts. > + > +Have a look at meta-isar/recipes-app/samefile/samefile_2.14.bb and > meta/classes/debianize.bbclass for an example and the implementation. > + > ### Packages without source > > If your customization is not about compiling from source there is a > second way of creating `deb` packages. That way can be used for cases like: > diff --git a/meta-isar/recipes-app/samefile/samefile_2.14.bb > b/meta-isar/recipes-app/samefile/samefile_2.14.bb > index a24d574..0ace85a 100644 > --- a/meta-isar/recipes-app/samefile/samefile_2.14.bb > +++ b/meta-isar/recipes-app/samefile/samefile_2.14.bb > @@ -12,5 +12,19 @@ SRC_URI[md5sum] = "0b438249f3549f18b49cbb49b0473f70" > > do_prepare_build[cleandirs] += "${S}/debian" > do_prepare_build() { > + # you could also create parts of your debianization before > + # pre-exisiting files will not be recreated > + # 42 is not actually valid ... this is just a stupid example > + echo 42 > "${WORKDIR}"/compat > + > + # this step creates everything dpkg-buildpackage needs, compat will > not be > + # overwritten > deb_debianize > + > do we want to "read compat <${S}/compat" before we overwrite it just to make sure it is still 42? and bbfatal if it isn't? in other words is this recipe more of a test or of an example? (either way is fine by me) > + # now if you are not happy you can post-process the result > + # now let us "repair" the compat > + echo 9 > "${S}/debian/compat" > + # compat happens to be used by this step, so do that again > + # see debianize.bbclass > + deb_create_control > } > diff --git a/meta/classes/debianize.bbclass > b/meta/classes/debianize.bbclass > index fb9c234..e1c79ab 100644 > --- a/meta/classes/debianize.bbclass > +++ b/meta/classes/debianize.bbclass > @@ -76,23 +76,29 @@ EOF > } > > deb_debianize() { > + # create the compat-file if there is no file with that name in > WORKDIR > if [ -f ${WORKDIR}/compat ]; then > install -v -m 644 ${WORKDIR}/compat ${S}/debian/compat > else > deb_create_compat > fi > + # create the control-file if there is no contro-file in WORKDIR > if [ -f ${WORKDIR}/control ]; then > install -v -m 644 ${WORKDIR}/control ${S}/debian/control > else > deb_create_control > fi > + # create rules if WORKDIR does not contain a rules-file > if [ -f ${WORKDIR}/rules ]; then > install -v -m 755 ${WORKDIR}/rules ${S}/debian/rules > else > deb_create_rules > fi > + # prepend a changelog-entry unless an existing changelog file > already > + # contains an entry with CHANGELOG_V > deb_add_changelog > > + # copy all hooks from WORKDIR into debian/, hooks are not > generated > for t in pre post > do > for a in inst rm > -- > 2.23.0 > > ------=_Part_197_428091438.1572592115892 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable


On Tuesday, October 29, 2019 at 5:44:28 PM UTC+1, = Henning Schild wrote:
From: Hen= ning Schild <hennin...@siemens.com>

Also add some comments to the implementation and extend the example
recipe with some pre- and post-processing.

Signed-off-by: Henning Schild <hennin...@siemens.com>
---
=C2=A0doc/user_manual.md =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 =C2=A0| 19 ++++++++++++++++++= -
=C2=A0.../recipes-app/samefile/samefile_2.14.bb =C2=A0 =C2=A0 | 14 ++++++++++++++
=C2=A0meta/classes/debianize.bbclass =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0| =C2=A06 ++++++
=C2=A03 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/doc/user_manual.md b/doc/user_manual.md
index 34f50df..7c23fcc 100644
--- a/doc/user_manual.md
+++ b/doc/user_manual.md
@@ -583,7 +583,7 @@ Isar currently supports two ways of creating custom= packages.
=C2=A0
=C2=A0The `deb` packages are built using `dpkg-buildpackage`, so the so= urces should contain the `debian` directory with necessary meta information= . This way is the default way of adding software that needs to be compiled = from source. The bbclass for this approach is called `dpkg`.
=C2=A0
-**NOTE:** If the sources do not contain a `debian` directory your reci= pe can fetch, create, or ship that.
+**NOTE:** If the sources do not contain a `debian` directory your reci= pe can fetch, create, or ship that. You might want to read the the next sec= tion before returning here.
=C2=A0
=C2=A0This is also what you do if you want to rebuild/modify an upstrea= m package.
=C2=A0Isar does understand `SRC_URI` entries starting with "apt://= ". For an example
@@ -624,6 +624,23 @@ This approach prevents duplication of the license = files in different packages.
=C2=A0
=C2=A0The last line in the example above adds recipe to the Isar work c= hain.
=C2=A0
+### Compilation of sources missing the debian/-directory
+
+The `debian` directory contains meta information on how to build a pac= kage from source. This is roughly speaking "configure", "com= pile", "install" all described in a Debian-specific way.
+Isar expects your sources to contain the `debian` folder and the above= steps need to be described in it, not in a task in a recipe.
+
+So once you have sources you always need to combine them with a `debia= n` folder before Isar can build a package for you.
+You might be able to find a debianization for a component on the inter= net, i.e. Ubuntu does package an open source component while Debian does no= t. Your recipe could download the `debian` folder from Ubuntu and the sourc= es from the open source project.
+
+You can write it yourself, which can be pretty easy but requires a bit= of studying. <https://www.debian.org/doc/debian-policy/index.htm= l>
+
+Isar does actually contain a helper that aims to "debianize"= sources for your. If your package uses a build-system that Debian knows an= d follows the well known "configure", "compile", "= install" scheme that debianization might just fit your needs without r= eading Debian manuals.
+If it does not fully fit your needs, it probably gives you a good star= ting point for your manual tuning.
+
+The shell function `deb_debianize` creates a `debian` folder. But it w= ill not overwrite files that already are in WORKDIR. So you can either just= call it to fully generate the `debian` folder. Or you combine it with pre-= existing parts.
+
+Have a look at meta-isar/recipes-app/samefile/samefile_2.14.bb and meta/classes/de= bianize.bbclass for an example and the implementation.
+
=C2=A0### Packages without source
=C2=A0
=C2=A0If your customization is not about compiling from source there is= a second way of creating `deb` packages. That way can be used for cases li= ke:
diff --git a/meta-isar/recipes-app/samefile/samefile_2.14.bb b/meta-isar/recipes-= app/samefile/sam= efile_2.14.bb
index a24d574..0ace85a 100644
--- a/meta-isar/recipes-app/samefile/samefile_2.14.bb
+++ b/meta-isar/recipes-app/samefile/samefile_2.14.bb
@@ -12,5 +12,19 @@ SRC_URI[md5sum] =3D "0b438249f3549f18b49cb= b49b0473f70"
=C2=A0
=C2=A0do_prepare_build[cleandirs] +=3D "${S}/debian"
=C2=A0do_prepare_build() {
+ =C2=A0 =C2=A0# you could also create parts of your debianization befo= re
+ =C2=A0 =C2=A0# pre-exisiting files will not be recreated
+ =C2=A0 =C2=A0# 42 is not actually valid ... this is just a stupid exa= mple
+ =C2=A0 =C2=A0echo 42 > "${WORKDIR}"/compat
+
+ =C2=A0 =C2=A0# this step creates everything dpkg-buildpackage needs, = compat will not be
+ =C2=A0 =C2=A0# overwritten
=C2=A0 =C2=A0 =C2=A0deb_debianize
+

do we want to "read compat <${= S}/compat" before we overwrite it just to make sure it is still 42? an= d bbfatal if it isn't?
in other words is this recipe more of = a test or of an example?
(either way is fine by me)
=C2= =A0
+ =C2=A0 =C2=A0# now = if you are not happy you can post-process the result
+ =C2=A0 =C2=A0# now let us "repair" the compat
+ =C2=A0 =C2=A0echo 9 > "${S}/debian/compat"
+ =C2=A0 =C2=A0# compat happens to be used by this step, so do that aga= in
+ =C2=A0 =C2=A0# see debianize.bbclass
+ =C2=A0 =C2=A0deb_create_control
=C2=A0}
diff --git a/meta/classes/debianize.bbclass b/meta/classes/debiani= ze.bbclass
index fb9c234..e1c79ab 100644
--- a/meta/classes/debianize.bbclass
+++ b/meta/classes/debianize.bbclass
@@ -76,23 +76,29 @@ EOF
=C2=A0}
=C2=A0
=C2=A0deb_debianize() {
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0# create the compat-fi= le if there is no file with that name in WORKDIR
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if [ -f ${WORKDIR= }/compat ]; then
=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=C2=A0=C2=A0=C2=A0=C2=A0install -v -m 644 ${WORKDIR}/compat ${S}/d= ebian/compat
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0else
=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=C2=A0=C2=A0=C2=A0=C2=A0deb_create_compat
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0fi
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0# create the control-f= ile if there is no contro-file in WORKDIR
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if [ -f ${WORKDIR= }/control ]; then
=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=C2=A0=C2=A0=C2=A0=C2=A0install -v -m 644 ${WORKDIR}/control ${S}/= debian/control
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0else
=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=C2=A0=C2=A0=C2=A0=C2=A0deb_create_control
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0fi
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0# create rules if WORK= DIR does not contain a rules-file
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0if [ -f ${WORKDIR= }/rules ]; then
=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=C2=A0=C2=A0=C2=A0=C2=A0install -v -m 755 ${WORKDIR}/rules ${S}/de= bian/rules
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0else
=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=C2=A0=C2=A0=C2=A0=C2=A0deb_create_rules
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0fi
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0# prepend a changelog-= entry unless an existing changelog file already
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0# contains an entry wi= th CHANGELOG_V
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0deb_add_changelog
=C2=A0
+=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0# copy all hooks from = WORKDIR into debian/, hooks are not generated
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0for t in pre post
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0do
=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=C2=A0=C2=A0=C2=A0=C2=A0for a in inst rm
--=20
2.23.0

------=_Part_197_428091438.1572592115892-- ------=_Part_196_2071665381.1572592115892--