From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6624179968991559680 X-Received: by 2002:a1c:8046:: with SMTP id b67mr426887wmd.22.1542891049251; Thu, 22 Nov 2018 04:50:49 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a1c:2d56:: with SMTP id t83ls2704759wmt.4.canary-gmail; Thu, 22 Nov 2018 04:50:48 -0800 (PST) X-Google-Smtp-Source: AJdET5dnwXE0sjjl/NJRb33apcbRg/m4JOOevqRQa6LWk0Qo/ulJEgKaIqIQAwcxgdvQ8avnUCwB X-Received: by 2002:a1c:9e47:: with SMTP id h68mr1866074wme.18.1542891048656; Thu, 22 Nov 2018 04:50:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542891048; cv=none; d=google.com; s=arc-20160816; b=AOrlj1lheCoFA7t6kVZcpssM9V3fvlVOHwms5JuhrQtEiugVqTV+tnn2f2DPyaeTbV hz43aR2s94UhGMYhYWkgwTEG5fED7VxvUIEJqwpDPVGpx6MkWvL0N7AeO4yv7e6ctG2l qcpZVDE3Q7L8SqfP65piPEzFfGufTAotbM01oFi5/JFNch0bufe63p5n4ZsSyJQxx31z pRIbVowgFHa6Ygoc2itDYfUTSnWxsEUnzDK+0gXGnPlXlwOl63AvbhOt918t5mXqJyZG JPs6xJPoGkStTdWx1RF+mb5c3EPSLr9kBmXP0O7iezL47O+TSCOlqonPc+Gd5/WObVEc ZSAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:content-language:in-reply-to:mime-version :user-agent:date:message-id:organization:from:references:to:subject; bh=akXaTkQpPOhkEAZtsBVk3cXmmyy6Yktv8JZEEPG1QKs=; b=EBPByPQF60JEbOsKQIU0Xo99yEYmNc0gQIJFKIu6k1zaAHp0XN8KbWP/iOhp+UGbD0 jrRuJ985NI9qZztFOXUoZm98mT22Gc7Gc7YKZ5tSqRXtdUzIIeS4ASl13iHQLjQoi70G YEe6LmHGFTuCzSh0jjsJVhQRAXmSavRFsIY2Jxjbc6C48wpk2QDBDIHFyc0S3C226is/ gWG+AsCIS/SZWRiOxR7GQjSf3L6KNEziqQq8YWEKbsAUPZqypdnvHstoI26782N9Ypco BM4Iak8wfxB9xNm+PvOgmiXJ9rleqmBzVBR9T32gHkTMRWnwSb8agJMrFBxlZw4XV4NH pQZQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: best guess record for domain of mosipov@ilbers.de designates 85.214.62.211 as permitted sender) smtp.mailfrom=mosipov@ilbers.de Return-Path: Received: from aqmola.ilbers.de (aqmola.ilbers.de. [85.214.62.211]) by gmr-mx.google.com with ESMTPS id k140si144376wmd.2.2018.11.22.04.50.48 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Nov 2018 04:50:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of mosipov@ilbers.de designates 85.214.62.211 as permitted sender) client-ip=85.214.62.211; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: best guess record for domain of mosipov@ilbers.de designates 85.214.62.211 as permitted sender) smtp.mailfrom=mosipov@ilbers.de Received: from [192.168.50.180] (nat-ppp-217.71.235.199-satnet-spb.ru [217.71.235.199] (may be forged)) (authenticated bits=0) by aqmola.ilbers.de (8.14.4/8.14.4/Debian-4+deb7u1) with ESMTP id wAMCojFV022979 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT); Thu, 22 Nov 2018 13:50:46 +0100 Subject: Re: [PATCH] meta/dpkg-raw: build raw packages like all others To: Henning Schild , isar-users References: <20181115200121.23035-1-henning.schild@siemens.com> From: "Maxim Yu. Osipov" Organization: ilbers GmbH Message-ID: <78dae9f4-adc4-ea53-c255-b427671d28c3@ilbers.de> Date: Thu, 22 Nov 2018 15:50:40 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <20181115200121.23035-1-henning.schild@siemens.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-TUID: F5gCY3Oj38sY On 11/15/18 11:01 PM, Henning Schild wrote: > 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. Applied to the 'next' (with the typo fixed). Thanks, Maxim. > 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 > } > -- Maxim Osipov ilbers GmbH Maria-Merian-Str. 8 85521 Ottobrunn Germany +49 (151) 6517 6917 mosipov@ilbers.de http://ilbers.de/ Commercial register Munich, HRB 214197 General Manager: Baurzhan Ismagulov