From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6624179968991559680 X-Received: by 2002:a7b:c0cd:: with SMTP id s13mr1665042wmh.15.1542878384679; Thu, 22 Nov 2018 01:19:44 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a1c:dc04:: with SMTP id t4ls2621853wmg.12.gmail; Thu, 22 Nov 2018 01:19:44 -0800 (PST) X-Google-Smtp-Source: AFSGD/Uwz0t0ZN9yZaK8HQ/StewMeF9+EgiWIq5cVoHPUyUj67vypGtAffd4lgNDPWk89lroN7dd X-Received: by 2002:a1c:a548:: with SMTP id o69mr1633286wme.4.1542878384160; Thu, 22 Nov 2018 01:19:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542878384; cv=none; d=google.com; s=arc-20160816; b=aX0FV0xErt4+MvYChHI8GHGyMMeFJvoWlDQDipe6pTNcllir2cCx6GYw5iapRUkt/h inSbedPCJ0EQ5A5ORI26D1xq//ANMp2OaHfHL39lRtDCs0o/Zrem1seDL4FE+A1VrEsD vJKSb5jre7liPBBeVBCk2geRSxps4frEYWQwvn2Mx+gSoO/NcZmP/4F8jxPPF2UXtiH3 0jwfDN6x+bk46V4RdeOQSPNURSouVpJavwJ6lSxvATaJUFHPWkjV1WB9RNhZikng0OvI gqU3eZrsW/U4BNvih+MRvnJ0YAZQseQTkPpXuyigXJz4tSY2gPB/SDAmo2/U4ObyuTy5 6czA== 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:date:subject:cc:to:from; bh=QG4+vC9gT9MiXSKT02jgg3/ibO+BVAVR1bluihyPS58=; b=c4dP3VhsDhktYYopFpKIiqOBPAfcbq/LCsTAujsL7k1ad519/sDC0MQfVd5QJW1U2k nxLYkrkN1Vli+KBgAeRZsJT4vlwwTlW+wGZgvkAqpKxPXEZTJ4hoVAPHzX9csg+wilCK ajxXzTABA0eA7e4Psiu8FfWabx/GMBES4976swdJC7zxbfrEyFaZNDs37N8VDs9bQoaQ 6NxYkF25IMDDl+nwCRb7+XBIJ47BcdnXcHFNJwbfIk2C3M/ZwewVNVorNBFjeTTtoHi4 ATsqy0wME3d4dWIP3z/+Y1wMbL03hpoN35AinnMswDWh14AWjnhLtcKZTtBJ+fcKjRSQ XLjQ== 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 b12-v6si93370wme.1.2018.11.22.01.19.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Nov 2018 01:19:44 -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 wAM9JhFL027189 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Thu, 22 Nov 2018 10:19:43 +0100 Received: from md1za8fc.ad001.siemens.net ([139.25.69.187]) by mail1.sbs.de (8.15.2/8.15.2) with ESMTP id wAM9JhYV017815; Thu, 22 Nov 2018 10:19:43 +0100 From: Henning Schild To: isar-users@googlegroups.com Cc: Henning Schild Subject: [PATCH v2] meta/dpkg-raw: build raw packages like all others Date: Thu, 22 Nov 2018 10:19:42 +0100 Message-Id: <20181122091942.20956-1-henning.schild@siemens.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181115200121.23035-1-henning.schild@siemens.com> References: <20181115200121.23035-1-henning.schild@siemens.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TUID: UChXR0iTctLZ 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 --- Changes in v2: - fixed typo 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..e124ed9 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. +Note 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 } -- 2.19.1