From: Henning Schild <henning.schild@siemens.com>
To: isar-users <isar-users@googlegroups.com>
Subject: Re: [PATCH] meta/dpkg-raw: build raw packages like all others
Date: Mon, 19 Nov 2018 10:42:33 +0100 [thread overview]
Message-ID: <20181119104233.2177b9b8@md1za8fc.ad001.siemens.net> (raw)
In-Reply-To: <20181115200121.23035-1-henning.schild@siemens.com>
Am Thu, 15 Nov 2018 21:01:21 +0100
schrieb Henning Schild <henning.schild@siemens.com>:
> Instead of just packaging a bunch of files, debian/-ize them and send
> them through the whole build chain. That was inspired by the chown and
> "sudo rm" changes that we recently had to make.
> This way is much cleaner than what we did before, and we get all
> debian quality assurance on top. But the original idea is to bring
> random files into the rootfs, where we might not be able to fulfill
> the quality. So there is a way for a recipe to bring its own rules
> and disable debhelpers it does not like.
>
> The code is intentionally split into many functions, because in fact
> you can use that to debian/-ize random sources as well. But i do not
> suggest to try that with this version.
>
> Signed-off-by: Henning Schild <henning.schild@siemens.com>
> ---
> RECIPE-API-CHANGELOG.md | 11 +-
> doc/user_manual.md | 2 +-
> ...{example-raw_0.2.bb => example-raw_0.3.bb} | 12 +-
> meta-isar/recipes-app/example-raw/files/rules | 8 ++
> meta/classes/dpkg-raw.bbclass | 106
> +++++++++++++----- 5 files changed, 99 insertions(+), 40 deletions(-)
> rename meta-isar/recipes-app/example-raw/{example-raw_0.2.bb =>
> example-raw_0.3.bb} (73%) create mode 100644
> meta-isar/recipes-app/example-raw/files/rules
>
> diff --git a/RECIPE-API-CHANGELOG.md b/RECIPE-API-CHANGELOG.md
> index 7eb5e09..af12994 100644
> --- a/RECIPE-API-CHANGELOG.md
> +++ b/RECIPE-API-CHANGELOG.md
> @@ -6,10 +6,15 @@ Baseline: Release v0.5
> Upcoming changes (v0.7)
> -----------------------
>
> -### dpkg-raw recipes chown all files to "root:root"
> +### dpkg-raw recipes build method changed
>
> -if your recipes rely on any other ownership, you will have to change
> file -ownership in the postinst script
> +These packages are now built using the whole dpkg-buildpackage
> workflow, and +not just packaged as before.
> +
> + - all files will be owned by root:root before it might have been
> 1000:1000
> + use postinst to change that (see example-raw)
> + - a lot of debhelpers will help .. or complain
> + fix the issues or override the helpers (see example-raw)
>
> ### location of image artifacts
>
> diff --git a/doc/user_manual.md b/doc/user_manual.md
> index 5c46d5a..a3dd93e 100644
> --- a/doc/user_manual.md
> +++ b/doc/user_manual.md
> @@ -603,7 +603,7 @@ For the variables please have a look at the
> previous example, the following new
> - `DEBIAN_DEPENDS` - Debian packages that the package depends on
>
> Have a look at the `example-raw` recipe to get an idea how the
> `dpkg-raw` class can be used to customize your image. -Note that all
> files you install will be owned by "root:root". If you want to change
> that, call chown in the postinst script. +Not that the package will
typo Not -> Note
Henning
> be build using the whole debian package workflow, so your package
> will be checked by many debhelper scripts. If those helpers point out
> quality issues it might be a good idea to fix them. But `example-raw`
> also shows how rules can still be violated. ## Isar Cross-compilation
> diff --git a/meta-isar/recipes-app/example-raw/example-raw_0.2.bb
> b/meta-isar/recipes-app/example-raw/example-raw_0.3.bb similarity
> index 73% rename from
> meta-isar/recipes-app/example-raw/example-raw_0.2.bb rename to
> meta-isar/recipes-app/example-raw/example-raw_0.3.bb index
> 9200e0d..d9f3a2e 100644 ---
> a/meta-isar/recipes-app/example-raw/example-raw_0.2.bb +++
> b/meta-isar/recipes-app/example-raw/example-raw_0.3.bb @@ -8,7 +8,8
> @@ MAINTAINER = "Your name here <you@domain.com>" DEBIAN_DEPENDS =
> "apt (>= 0.4.2), passwd" SRC_URI = "file://README \
> - file://postinst"
> + file://postinst \
> + file://rules"
>
> inherit dpkg-raw
>
> @@ -17,16 +18,17 @@ do_install() {
> echo "#!/bin/sh" > ${WORKDIR}/${PN}
> echo "echo Hello ISAR! ${PN}_${PV}" >> ${WORKDIR}/${PN}
>
> + # here we violate dh_usrlocal, see files/rules
> bbnote "Putting ${PN} into package"
> install -v -d ${D}/usr/local/bin/
> install -v -m 755 ${WORKDIR}/${PN} ${D}/usr/local/bin/${PN}
>
> bbnote "Now copy ${FILESDIR}/README into package"
> - install -v -d ${D}/usr/local/doc/
> - install -v -m 644 ${WORKDIR}/README
> ${D}/usr/local/doc/README-${P}
> + install -v -d ${D}/usr/doc/
> + install -v -m 644 ${WORKDIR}/README ${D}/usr/doc/README-${P}
>
> bbnote "Now for a fake config file"
> echo "# empty config file" > ${WORKDIR}/${PN}.conf
> - install -v -d ${D}/usr/local/etc/
> - install -v -m 644 ${WORKDIR}/${PN}.conf
> ${D}/usr/local/etc/${PN}.conf
> + install -v -d ${D}/etc/
> + install -v -m 644 ${WORKDIR}/${PN}.conf ${D}/etc/${PN}.conf
> }
> diff --git a/meta-isar/recipes-app/example-raw/files/rules
> b/meta-isar/recipes-app/example-raw/files/rules new file mode 100644
> index 0000000..a116737
> --- /dev/null
> +++ b/meta-isar/recipes-app/example-raw/files/rules
> @@ -0,0 +1,8 @@
> +#!/usr/bin/make -f
> +%:
> + dh \$@
> +
> +# we do violate debian quality rules here, but on purpose to demo how
> +# to deal with it
> +override_dh_usrlocal:
> + true
> diff --git a/meta/classes/dpkg-raw.bbclass
> b/meta/classes/dpkg-raw.bbclass index d662422..8d11433 100644
> --- a/meta/classes/dpkg-raw.bbclass
> +++ b/meta/classes/dpkg-raw.bbclass
> @@ -1,59 +1,103 @@
> # This software is a part of ISAR.
> -# Copyright (C) 2017 Siemens AG
> +# Copyright (C) 2017-2018 Siemens AG
>
> -inherit dpkg-base
> +inherit dpkg
>
> DEBIAN_DEPENDS ?= ""
> -MAINTAINER ?= "FIXME Unknown maintainer"
> +MAINTAINER ?= "Unknown maintainer <unknown@example.com>"
>
> -D = "${WORKDIR}/image/"
> +D = "${S}"
>
> # Populate folder that will be picked up as package
> do_install() {
> bbnote "Put your files for this package in ${D}"
> }
>
> +do_install[cleandirs] = "${D}"
> do_install[stamp-extra-info] = "${DISTRO}-${DISTRO_ARCH}"
> addtask install after do_unpack before do_prepare_build
>
> -deb_package_prepare() {
> - sudo rm -rf ${D}/DEBIAN
> - mkdir -p ${D}/DEBIAN
> - cat<<-__EOF__ > ${D}/DEBIAN/control
> - Package: ${PN}
> - Architecture: ${DISTRO_ARCH}
> - Section: misc
> - Priority: optional
> - Maintainer: ${MAINTAINER}
> - Version: ${PV}+isar
> - Description: ${DESCRIPTION}
> - __EOF__
> - [ "${DEBIAN_DEPENDS}" != "" ] && echo "Depends:
> ${DEBIAN_DEPENDS}" >> \
> - ${D}/DEBIAN/control
> +deb_add_changelog() {
> + date=$( LANG=C date -R )
> + cat <<EOF > ${D}/debian/changelog
> +${PN} (${PV}) UNRELEASED; urgency=low
> +
> + * generated by Isar
> +
> + -- ${MAINTAINER} ${date}
> +EOF
> + if [ -f ${WORKDIR}/changelog ]; then
> + echo >> ${D}/debian/changelog
> + cat ${WORKDIR}/changelog >> ${D}/debian/changelog
> + fi
> +}
> +
> +deb_create_compat() {
> + echo 9 > ${D}/debian/compat
> +}
> +
> +deb_create_control() {
> + compat=$( cat ${D}/debian/compat )
> + cat << EOF > ${D}/debian/control
> +Source: ${PN}
> +Section: misc
> +Priority: optional
> +Standards-Version: 3.9.6
> +Maintainer: ${MAINTAINER}
> +Build-Depends: debhelper (>= ${compat})
> +
> +Package: ${PN}
> +Architecture: any
> +Depends: ${DEBIAN_DEPENDS}
> +Description: ${DESCRIPTION}
> +EOF
> +}
> +
> +deb_create_rules() {
> + cat << EOF > ${S}/debian/rules
> +#!/usr/bin/make -f
> +%:
> + dh \$@
> +
> +EOF
> + chmod +x ${S}/debian/rules
> +}
> +
> +deb_debianize() {
> + if [ -f ${WORKDIR}/compat ]; then
> + install -v -m 644 ${WORKDIR}/compat
> ${D}/debian/compat
> + else
> + deb_create_compat
> + fi
> + if [ -f ${WORKDIR}/control ]; then
> + install -v -m 644 ${WORKDIR}/control
> ${D}/debian/control
> + else
> + deb_create_control
> + fi
> + if [ -f ${WORKDIR}/rules ]; then
> + install -v -m 755 ${WORKDIR}/rules ${D}/debian/rules
> + else
> + deb_create_rules
> + fi
> + deb_add_changelog
> +
> for t in pre post
> do
> for a in inst rm
> do
> if [ -f ${WORKDIR}/${t}${a} ]; then
> install -v -m 755
> ${WORKDIR}/${t}${a} \
> - ${D}/DEBIAN/${t}${a}
> + ${D}/debian/${t}${a}
> fi
> done
> done
> }
>
> -deb_package_conffiles() {
> - CONFFILES=${D}/DEBIAN/conffiles
> - find ${D} -type f -path '${D}/etc/*' | sed -e 's|^${D}|/|'
> >> $CONFFILES
> - test -s $CONFFILES || rm $CONFFILES
> -}
> -
> +do_prepare_build[cleandirs] += "${D}/debian"
> do_prepare_build() {
> - deb_package_prepare
> - deb_package_conffiles
> -}
> + cd ${D}
> + find . ! -type d | sed 's:^./::' > ${WORKDIR}/${PN}.install
> + mv ${WORKDIR}/${PN}.install ${D}/debian/
>
> -dpkg_runbuild() {
> - sudo chown -R root:root ${D}
> - sudo chroot ${BUILDCHROOT_DIR} dpkg-deb --build ${PP}/image
> ${PP}
> + deb_debianize
> }
next prev parent reply other threads:[~2018-11-19 9:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-15 20:01 Henning Schild
2018-11-15 20:03 ` Henning Schild
2018-11-19 9:42 ` Henning Schild [this message]
2018-11-22 9:19 ` [PATCH v2] " Henning Schild
2018-11-22 12:50 ` [PATCH] " Maxim Yu. Osipov
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=20181119104233.2177b9b8@md1za8fc.ad001.siemens.net \
--to=henning.schild@siemens.com \
--cc=isar-users@googlegroups.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