From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6517147827419742208 X-Received: by 10.28.192.26 with SMTP id q26mr179345wmf.29.1518533073473; Tue, 13 Feb 2018 06:44:33 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 10.28.231.15 with SMTP id e15ls1611314wmh.8.gmail; Tue, 13 Feb 2018 06:44:32 -0800 (PST) X-Google-Smtp-Source: AH8x224xIt2F5s6IugsVaZ0xtG2dqayF2DUbS4nYb01SenvTU2ted8Z4mXr2zS9v6GdpvBiU7dko X-Received: by 10.28.156.21 with SMTP id f21mr187322wme.10.1518533072955; Tue, 13 Feb 2018 06:44:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518533072; cv=none; d=google.com; s=arc-20160816; b=SC/wdw3dDEDfxWnrGIyNs7TeWBAgBDZsryEVEvFNifGCn83iJrs1y/4l+m3SAZj2Vx Hwdiq6J/whuEw+ngxy8N3aQNLVHjtWutXQePNcxbarLPAmmGBslM4bOr11N3zF9BV1oF gNtHtKZQ6LWYKR/6BiWTlpB7yMtONtwuhK2XxVUTebr9Bvk9DQLsn7mRG5meb+hmZSXf AtLiSXyiXtRNaUdX985cSeHTQRRTV+bXgCrSWeZpejtRsjV4r5GXMQOOx1JrxoKHirnJ taiw79WKMvnA1/tcSfEuwny9hlMFxfV09ZPc5Oo2PNBIF9+ksSi6IpGbrzyB8sGFavw8 UTfg== 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:from:references:to:subject :arc-authentication-results; bh=S8aoyU+9tpEAVoX1OlOisN9lQBvBZQVD6xDz1NhvLog=; b=fEE5A+bBmd8AuFwXR7QxMxgt9FveBADe/n1SPUgkyn5ZR6aLe0IRY4wj2Hh4tF8xle dxOFuCnXU1lsIifmYH1aZDUjKTQtKII9LrJ8LeyYyOKh7ge0HuAXR02+YVM33WcovqoV 8pcOuO0usJG3mu46fPPzgFbJZRm3faq9SKQOzckxB2jsE8anPmRdmMsrz4dYdDkV3EoL Zefq4jHk8je95f+zKga7A5Kov/IUpwIc3LDBtoDypP5f/QSQbRxFOtnu7aeoTdOchzLv X6YxdAIEZ9qWQsnnJDKZVmshhSuHnOi3RUHNv0BkMin9S9sHWyq7ws4XINyWrAlJH8Vp LAfg== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: best guess record for domain of asmirnov@ilbers.de designates 85.214.62.211 as permitted sender) smtp.mailfrom=asmirnov@ilbers.de Return-Path: Received: from aqmola.ilbers.de (aqmola.ilbers.de. [85.214.62.211]) by gmr-mx.google.com with ESMTPS id f8si407374wmc.2.2018.02.13.06.44.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Feb 2018 06:44:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of asmirnov@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 asmirnov@ilbers.de designates 85.214.62.211 as permitted sender) smtp.mailfrom=asmirnov@ilbers.de Received: from [10.0.2.15] ([188.227.110.165]) (authenticated bits=0) by aqmola.ilbers.de (8.14.4/8.14.4/Debian-4+deb7u1) with ESMTP id w1DEiTS8006345 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT); Tue, 13 Feb 2018 15:44:31 +0100 Subject: Re: [PATCH 2/9] images: new class wic-img for wic intregration To: Henning Schild , isar-users@googlegroups.com References: <122454433490bad5b449b9a984c4578da525a03a.1517390790.git.henning.schild@siemens.com> From: Alexander Smirnov Message-ID: <9342ef1b-ea13-06cf-3f31-8e86eac2cf76@ilbers.de> Date: Tue, 13 Feb 2018 17:44:24 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <122454433490bad5b449b9a984c4578da525a03a.1517390790.git.henning.schild@siemens.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-TUID: 8ZqPBkTq9BVy On 01/31/2018 12:41 PM, Henning Schild wrote: > This patch integrates wic into the bitbake workflow, wic will be used > for the imaging step, no need to call it manually. > > The target of this patch is to work with an unmodified wic, that is why > it contains a few wic-specifics, mostly taken from OE. > > There is one major difference to OE, we assume that wic is run as root. > And we smuggle in a wrapper that patches calls to an fsck that does not > behave like the one on OE. > > Issues: > - wic was never integrated > - you always had to build an ext4-img to create a wic image later > - there was never a way to control the size of wic disks/partition, > only directly in the wks > > Impact: > The patch solves the Issues without changing the default behaviour of > Isar. > > Signed-off-by: Henning Schild > --- > meta/classes/wic-img.bbclass | 64 ++++++++++++++++++++++++++++++++++++++++++++ > scripts/wic_fakeroot | 37 +++++++++++++++++++++++++ > 2 files changed, 101 insertions(+) > create mode 100644 meta/classes/wic-img.bbclass > create mode 100755 scripts/wic_fakeroot > > diff --git a/meta/classes/wic-img.bbclass b/meta/classes/wic-img.bbclass > new file mode 100644 > index 0000000..e8d2678 > --- /dev/null > +++ b/meta/classes/wic-img.bbclass > @@ -0,0 +1,64 @@ > +# This software is a part of ISAR. > +# Copyright (C) 2018 Siemens AG > +# > +# this class is heavily inspired by OEs ./meta/classes/image_types_wic.bbclass > +# > + > +WKS_FILE ?= "sdimage-efi" > + > +# TODO here we leak buildenv into the image > +# this needs to come from buildchroot > +# and the isar efi plugin has the same problem > +# syslinux in debian has different folder structure, need to for those plugins > +STAGING_DATADIR ?= "/usr/share/" > +STAGING_LIBDIR ?= "/usr/lib/" > +STAGING_DIR ?= "${TMPDIR}" > +IMAGE_BASENAME ?= "multiconfig:${MACHINE}-${DISTRO}:${PN}" > +FAKEROOTCMD ?= "wic_fakeroot" > +RECIPE_SYSROOT_NATIVE ?= "/" > + > +do_wic_image[stamp-extra-info] = "${DISTRO}-${MACHINE}" > + > +WIC_CREATE_EXTRA_ARGS ?= "" > + > +WICVARS ?= "\ > + BBLAYERS IMGDEPLOYDIR DEPLOY_DIR_IMAGE FAKEROOTCMD IMAGE_BASENAME IMAGE_BOOT_FILES \ > + IMAGE_LINK_NAME IMAGE_ROOTFS INITRAMFS_FSTYPES INITRD INITRD_LIVE ISODIR RECIPE_SYSROOT_NATIVE \ > + ROOTFS_SIZE STAGING_DATADIR STAGING_DIR STAGING_LIBDIR TARGET_SYS TRANSLATED_TARGET_ARCH" > + > +# Isar specific vars used in our plugins > +WICVARS += "KERNEL_IMAGE INITRD_IMAGE DISTRO_ARCH" > + > +python do_rootfs_wicenv () { > + wicvars = d.getVar('WICVARS', True) > + if not wicvars: > + return > + > + stdir = d.getVar('STAGING_DIR', True) > + outdir = os.path.join(stdir, d.getVar('MACHINE', True), 'imgdata') > + bb.utils.mkdirhier(outdir) > + basename = d.getVar('IMAGE_BASENAME', True) > + with open(os.path.join(outdir, basename) + '.env', 'w') as envf: > + for var in wicvars.split(): > + value = d.getVar(var, True) > + if value: > + envf.write('%s="%s"\n' % (var, value.strip())) > + > + # this part is stolen from OE ./meta/recipes-core/meta/wic-tools.bb > + with open(os.path.join(outdir, "wic-tools.env"), 'w') as envf: > + for var in ('RECIPE_SYSROOT_NATIVE', 'STAGING_DATADIR', 'STAGING_LIBDIR'): > + envf.write('%s="%s"\n' % (var, d.getVar(var, True).strip())) > + > +} > + > +addtask do_rootfs_wicenv after do_copy_boot_files before do_wic_image > +do_rootfs_wicenv[vardeps] += "${WICVARS}" > +do_rootfs_wicenv[prefuncs] = 'set_image_size' > + > +do_wic_image() { > + export BUILDDIR="${BUILDDIR}" > + > + sudo -E PATH="$PATH:/builder/isar/bitbake/bin:/builder/isar/scripts" /builder/isar/scripts/wic create ${WKS_FILE} --vars "${STAGING_DIR}/${MACHINE}/imgdata/" -o ${DEPLOY_DIR_IMAGE} -e ${IMAGE_BASENAME} ${WIC_CREATE_EXTRA_ARGS} > +} How this hardcoded path intended to work? Alex > + > +addtask wic_image before do_build after do_copy_boot_files > diff --git a/scripts/wic_fakeroot b/scripts/wic_fakeroot > new file mode 100755 > index 0000000..9e01c38 > --- /dev/null > +++ b/scripts/wic_fakeroot > @@ -0,0 +1,37 @@ > +#!/usr/bin/env python3 > +# > +# wic needs a FAKEROOT cmd to run, the default is pseudo. In Isar we do/can not > +# use pseudo. And we call wic as root to begin with, so this script could be a > +# dummy doing nothing. It is almost a dummy ... > +# > +# If the fsck hack ever becomes obsolete, FAKEROOTCMD ?= "true;" can be used > +# > +# This software is a part of Isar. > +# Copyright (C) 2018 Siemens AG > +# > +import os > +import sys > +import shutil > +import subprocess > + > +args = sys.argv > +args.pop(0) > +cmd = args[0] > + > +# expect to be running as root > +# we could loosen that and execv(sudo, args) but even some early > +# "du"s fail, which do not use the fakeroot-wrapper > +# i.e. in wics partition.py the "du -ks" fails on > +# var/cache/apt/archives/partial > +# rootfs/root ... > +assert 'root' == os.environ["USER"] > + > +# e2fsck <= 1.43.5 returns 1 on non-errors (stretch and before affected) > +# treat 1 as safe ... the filesystem was successfully repaired and is OK > +if cmd.startswith('fsck.'): > + ret = subprocess.call(args) > + if ret == 0 or ret == 1: > + sys.exit(0) > + sys.exit(ret) > + > +os.execv(shutil.which(cmd), args) >