From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6624179968991559680 X-Received: by 2002:adf:81c7:: with SMTP id 65-v6mr3659698wra.16.1542620555681; Mon, 19 Nov 2018 01:42:35 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:adf:a391:: with SMTP id l17-v6ls10975372wrb.4.gmail; Mon, 19 Nov 2018 01:42:35 -0800 (PST) X-Google-Smtp-Source: AFSGD/XM9FZIGrsDGNnMfQ24stMojOX0l4CGt4DuHre0urM2+6dKh+VQYvSA49UQBaR4cDMzRklT X-Received: by 2002:adf:8245:: with SMTP id 63mr3690824wrb.25.1542620555267; Mon, 19 Nov 2018 01:42:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542620555; cv=none; d=google.com; s=arc-20160816; b=GJKyJ/vdWCTstDony2JEXqh6glhLFnIA6AAkYMARsF1ilNU9leYSBf0tKfoxN23qW1 Fsslu1ViB04bTYGQjRcPFH6tz1ZXTsQQOHCBC3qUqVLYY/nFpAnz599Lb/tqMP3th/oW 8GyjQQEavi9g7OmvDH9UHqDZLauxA+q6+2tY+bgsE8GMvBoVa8deR+ZBdEKO0+p/gbc0 z0z2NtQXqxa5JaRjuBfWNTJqubI2VGVrEY2eidkFomTYFMkAskkOv4JTRcCJu5oI2vrt n3pEIat8a4wgb08i/SFyy/sKGtPND1pBro4RIgADx7U3B4d7Yxy+2H2mFbyGm8tBJEAI ly0g== 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=tL+1hZR3OwN/icyVItM56vA+3mYEnnVlidrxAJVHJAY=; b=BVCqqwRE0c5rrz+IdZzd7zGCBKBSUyPwShN3s3gxQsZL/5LWJzhXWw8dGfLFh7zw/D bD4CIrj9Lx8e6b3yhV19uXTwvDA+HKnUEiMfhGDkWt9XVHvOVvgIknBIniv85XYpkdYy 9eZ3Q4GmZfAVnoDy4i+NIgsOaWdRKdI7OsiGvhWu8cV3r4yKqiDxKbSYkQS6yrBqLty0 qoQNyCF2CeeMNJbbRdViez9z53Ct7w62OxfGuk2fqx6Khi4kpSIk8lmDc/nAsptopvre 4+frVBuySdLtNCbhkng3A1F/z3t9Ia0PWWVKJxOARDA9XCdqoq/HeucGUzhXePf6dSeT gJeg== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of henning.schild@siemens.com designates 194.138.37.39 as permitted sender) smtp.mailfrom=henning.schild@siemens.com Return-Path: Received: from lizzard.sbs.de (lizzard.sbs.de. [194.138.37.39]) by gmr-mx.google.com with ESMTPS id v6-v6si1253342wrn.0.2018.11.19.01.42.35 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Nov 2018 01:42:35 -0800 (PST) Received-SPF: pass (google.com: domain of henning.schild@siemens.com designates 194.138.37.39 as permitted sender) client-ip=194.138.37.39; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of henning.schild@siemens.com designates 194.138.37.39 as permitted sender) smtp.mailfrom=henning.schild@siemens.com Received: from mail1.sbs.de (mail1.sbs.de [192.129.41.35]) by lizzard.sbs.de (8.15.2/8.15.2) with ESMTPS id wAJ9gYVW008037 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 19 Nov 2018 10:42:35 +0100 Received: from md1za8fc.ad001.siemens.net ([139.25.68.180]) by mail1.sbs.de (8.15.2/8.15.2) with ESMTP id wAJ9gYR2025697 for ; Mon, 19 Nov 2018 10:42:34 +0100 Date: Mon, 19 Nov 2018 10:42:33 +0100 From: Henning Schild To: isar-users Subject: Re: [PATCH] meta/dpkg-raw: build raw packages like all others Message-ID: <20181119104233.2177b9b8@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: TC0DRBxLfze3 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 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 " 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 > }