From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6624179968991559680 X-Received: by 2002:a1c:994b:: with SMTP id b72-v6mr431061wme.12.1542312225833; Thu, 15 Nov 2018 12:03:45 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:adf:db48:: with SMTP id f8ls1478097wrj.1.gmail; Thu, 15 Nov 2018 12:03:45 -0800 (PST) X-Google-Smtp-Source: AFSGD/UH0X7+h7gKT6hBKbxMUb1dcIVZgruqx2bWRf7l5Petiom1PXRFPKv5uvGYcyoL/zRQQVMt X-Received: by 2002:adf:9d83:: with SMTP id p3-v6mr471922wre.31.1542312225398; Thu, 15 Nov 2018 12:03:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542312225; cv=none; d=google.com; s=arc-20160816; b=X38zhZGw50fDoK2/1LSyNYz42mCVo6WUuLtkuNN+dMQ7dVdDi6uVwzezpjJDws/nla Q0x2IoOFtwH+WMkXiyd0Evs7Ocs6hIBgGEFrdpPvu4DV5Z5DiEAyrnkLpDLdnuXvCvZZ +NwAPvUDGJ+0ILphiNJOJw5T7UjGVWLV5bMlyQDe52fV7KJLsBTNLjLw5crIxvM0Uw07 oDOo5AZXA93f4+9i9vlFr1kYR4SkOdB+RJRXMu9VniubxvyW4xbt1FAThlD9hncPBn1D KZ8YnPNIMzMedecIXNyRelczq0RAQ8tsYbEtrzYWFPAv0E6YD+FSmaqR8JxF1jGmGYwz /UBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:to:from:date; bh=GVoLta8JaFNHQuwGW0cilw0GrLPtAcDia5Z2FBFNFmc=; b=SaF2ihQANVMnwurCYyn8s7bshqGDjdsEtjfdlHBbr2T5iv7Fio1xiwu7mEAh852Iv/ sXOWLbI9X3K4gaujPuZfQ2x1A/887bIzAa+yUIA1yw5R4xXaA34eTHNIuXJc6gov/kvV zBZUOX8YfqeSTL/RMZduTA3hRyHnYOYeM9wKdXd7gMJ912zbPbMsDmH0Ov8ZrpkwG0x3 XgkHkm5eGZajf3x9ApSrVfpC9fcchnW8vH9O09L87ITecKNx54Qxh71iYRfPOnY3leUw eIIo3WcJu+ZAvipbqDhEyvETwPqVxiWWb7TsnVXFFAKBH+tsRIrYgvEQBmPPDtmMUil2 enPA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of henning.schild@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=henning.schild@siemens.com Return-Path: Received: from david.siemens.de (david.siemens.de. [192.35.17.14]) by gmr-mx.google.com with ESMTPS id n9-v6si864790wmh.2.2018.11.15.12.03.45 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Nov 2018 12:03:45 -0800 (PST) Received-SPF: pass (google.com: domain of henning.schild@siemens.com designates 192.35.17.14 as permitted sender) client-ip=192.35.17.14; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of henning.schild@siemens.com designates 192.35.17.14 as permitted sender) smtp.mailfrom=henning.schild@siemens.com Received: from mail1.sbs.de (mail1.sbs.de [192.129.41.35]) by david.siemens.de (8.15.2/8.15.2) with ESMTPS id wAFK3ihv012961 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 15 Nov 2018 21:03:45 +0100 Received: from md1za8fc.ad001.siemens.net ([139.25.0.37]) by mail1.sbs.de (8.15.2/8.15.2) with ESMTP id wAFK3iNY025781 for ; Thu, 15 Nov 2018 21:03:44 +0100 Date: Thu, 15 Nov 2018 21:03:44 +0100 From: Henning Schild To: isar-users Subject: Re: [PATCH] meta/dpkg-raw: build raw packages like all others Message-ID: <20181115210344.68681248@md1za8fc.ad001.siemens.net> In-Reply-To: <20181115200121.23035-1-henning.schild@siemens.com> References: <20181115200121.23035-1-henning.schild@siemens.com> X-Mailer: Claws Mail 3.15.0-dirty (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-TUID: 3RXQJTbQTjWN If discussions on this are fast, it could be used instead of "[PATCH v2] meta/dpkg-raw: do_install into a fresh directory every time" Otherwise the former one should probably be merged and i will rebase on that. Btw here we just use [cleandirs] for the problem, because we do not need to be root anymore. Henning Am Thu, 15 Nov 2018 21:01:21 +0100 schrieb Henning Schild : > 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 > --- > 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 > 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 " 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 " > > -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 < ${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 > }