From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6519007876157014016 X-Received: by 10.107.68.9 with SMTP id r9mr664066ioa.89.1518101834322; Thu, 08 Feb 2018 06:57:14 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 10.36.29.16 with SMTP id 16ls1308286itj.4.gmail; Thu, 08 Feb 2018 06:57:13 -0800 (PST) X-Google-Smtp-Source: AH8x2263Tta1bVnWDRBwUmNkgO6AgzFMBo+si3Vpvt3DiTBQ0JM1q7G0PBfTsvDanY6xhboHaI9P X-Received: by 10.36.225.7 with SMTP id n7mr987871ith.55.1518101833751; Thu, 08 Feb 2018 06:57:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518101833; cv=none; d=google.com; s=arc-20160816; b=uD4yxylN0Nhixqg9jDVNUQFpFLfiAHFFkyQBhJclonUNIo7qfV5W6pvGYDdTG9BCT/ M+qETgpRsbplU7Dyt0cKAZ1HvgV8y6xQR3WetIRNoh4356vMsM5nUuUZIoFlYMh6HmTV om740HwxTNT+nw1kCjeXAn6W2cm8y62JNE2ealNBr//zk+GMa3IVQhcdpTaL8gUNhw5X iomFlpfcinSczV5oJ4vEMWpW+TGwit63GGDFsu9qnDeAJC+ZPV8uswKks5HhaZMLnSgp grfI5zmVdJWZlKRPkrW1S4wF7IfPCCNVLL9UnuYqE1N9ewgPZ7ayH8ziYPt+NBpH+8CL OcNw== 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:cc:to:subject :arc-authentication-results; bh=Sd8uECdbBSVXe+gjR0eE3rihNJAoCcnRFk/CKTsvWLU=; b=p+wAef51asoGk2xSyw3akgHYXDqNQBtx5HyY4gRW+LizCK2x+V/cjZgR2D2/38Wpxc l4C1xATzsoaCyp14u4EROlmsJG1HHBx7l2cLDPpT6QQlfCwnRsGMFA0eZ233iH5/dnKK Ao72FYukrShE7ULhBMHeuAQkA8FUchFWWBdWVnccDc1K1OB1fVGcav5bXNDAcjDOnzSZ MuVLPpWdxaZj4tVgAUTYLB5OIV55doYa+a/wkpR1Oqr60KKkRXhRGPFcD5RBsNvoWfXy Kl6L2hIIVKpYJcAs8oBdy55/jmIWgcxNgPL4K+qcGzBmDvZeyFPHdXfBpvE1DKtwCP2Z bpMw== 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 d10si15000ith.0.2018.02.08.06.57.12 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 08 Feb 2018 06:57:13 -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 w18Ev8iJ001181 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT); Thu, 8 Feb 2018 15:57:10 +0100 Subject: Re: [PATCH 3/5 v4] buildchroot: Enable isar-apt To: Henning Schild Cc: isar-users@googlegroups.com References: <20180205095931.23903-1-asmirnov@ilbers.de> <20180206135725.28502-1-asmirnov@ilbers.de> <20180208153721.35d2bcc1@mmd1pvb1c.ad001.siemens.net> From: Alexander Smirnov Message-ID: Date: Thu, 8 Feb 2018 17:57:03 +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: <20180208153721.35d2bcc1@mmd1pvb1c.ad001.siemens.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-TUID: 15wXmrLrUEL9 On 02/08/2018 05:37 PM, Henning Schild wrote: > Am Tue, 6 Feb 2018 16:57:25 +0300 > schrieb Alexander Smirnov : > >> 8<-- >> >> Branch to test: asmirnov/devel >> >> 8<-- >> >> This patch provides access to isar-apt from buildchroot. It does the >> following: >> - mount isar-apt during buildchroot building. >> - umount isar-apt using bitbake events. >> >> Also it needs to keep Isar build tree clean from any mounts despite >> on whether build succeed of failed. bitbake provides various events >> that could trigger custom python hooks. In this patch BuildCompleted >> event is used, which happened when bitbake finished its execution >> despite on the result. >> >> Signed-off-by: Alexander Smirnov >> --- >> meta/classes/dpkg-base.bbclass | 2 +- >> meta/classes/isar-events.bbclass | 20 >> ++++++++++++++++ meta/conf/isar-bitbake.conf >> | 3 +++ meta/recipes-devtools/buildchroot/buildchroot.bb | 28 >> +++++++++++++++++++++- .../buildchroot/files/multistrap.conf.in >> | 8 ++++++- 5 files changed, 58 insertions(+), 3 deletions(-) >> create mode 100644 meta/classes/isar-events.bbclass >> >> diff --git a/meta/classes/dpkg-base.bbclass >> b/meta/classes/dpkg-base.bbclass index 026028f..5d5a924 100644 >> --- a/meta/classes/dpkg-base.bbclass >> +++ b/meta/classes/dpkg-base.bbclass >> @@ -2,7 +2,7 @@ >> # Copyright (C) 2017 Siemens AG >> >> # Add dependency from buildchroot creation >> -do_build[depends] = "buildchroot:do_build" >> +do_build[depends] = "buildchroot:do_setup_mounts" >> >> # Each package should have its own unique build folder, so use >> # recipe name as identifier >> diff --git a/meta/classes/isar-events.bbclass >> b/meta/classes/isar-events.bbclass new file mode 100644 >> index 0000000..55fc106 >> --- /dev/null >> +++ b/meta/classes/isar-events.bbclass >> @@ -0,0 +1,20 @@ >> +# Isar event handlers. >> +# >> +# This software is a part of ISAR. >> +# Copyright (C) 2015-2017 ilbers GmbH >> + >> +addhandler isar_handler >> + >> +python isar_handler () { >> + import subprocess >> + >> + devnull = open(os.devnull, 'w') >> + >> + if isinstance(e, bb.event.BuildCompleted): >> + bchroot = d.getVar('BUILDCHROOT_DIR', True) >> + >> + # Clean up buildchroot >> + subprocess.call('/usr/bin/sudo /bin/umount ' + bchroot + >> '/isar-apt || /bin/true', stdout=devnull, stderr=devnull, shell=True) > > I would suggest to drop the hardcoded paths where possible. Imagine i > had my sudo sitting in /usr/local/bin/ or similar. And sudo internally > will take care of its own PATH so the /bin/ for umount is also not > required. > Another use-case could be a wrapper around the actual sudo where people > try to handle the sudo-problem of Isar by having a wrapper that uses a > whitelist of allowed commands. > This issue resolved in patch: [PATCH] isar: Clean mount point on bitbake exit Alex > Henning > >> + >> + devnull.close() >> +} >> diff --git a/meta/conf/isar-bitbake.conf b/meta/conf/isar-bitbake.conf >> index b853c88..36cca29 100644 >> --- a/meta/conf/isar-bitbake.conf >> +++ b/meta/conf/isar-bitbake.conf >> @@ -27,6 +27,9 @@ BUILDCHROOT_DIR = >> "${TMPDIR}/work/${DISTRO}-${DISTRO_ARCH}/buildchroot/rootfs" # Setup >> our default hash policy BB_SIGNATURE_HANDLER ?= "noop" >> >> +# Add event handlers for bitbake >> +INHERIT += "isar-events" >> + >> include conf/local.conf >> include conf/multiconfig/${BB_CURRENT_MC}.conf >> include conf/machine/${MACHINE}.conf >> diff --git a/meta/recipes-devtools/buildchroot/buildchroot.bb >> b/meta/recipes-devtools/buildchroot/buildchroot.bb index >> 51f9d5d..304c67e 100644 --- >> a/meta/recipes-devtools/buildchroot/buildchroot.bb +++ >> b/meta/recipes-devtools/buildchroot/buildchroot.bb @@ -32,7 +32,9 @@ >> BUILDCHROOT_PREINSTALL ?= "gcc \ WORKDIR = >> "${TMPDIR}/work/${DISTRO}-${DISTRO_ARCH}/${PN}" >> do_build[stamp-extra-info] = "${DISTRO}-${DISTRO_ARCH}" >> -do_build[dirs] = "${WORKDIR}/hooks_multistrap" >> +do_build[dirs] = "${WORKDIR}/hooks_multistrap \ >> + ${BUILDCHROOT_DIR}/isar-apt" >> +do_build[depends] = "isar-apt:do_cache_config" >> >> do_build() { >> E="${@ bb.utils.export_proxies(d)}" >> @@ -67,6 +69,8 @@ do_build() { >> } >> trap '_do_build_cleanup' EXIT >> >> + do_setup_mounts >> + >> # Create root filesystem >> sudo -E multistrap -a ${DISTRO_ARCH} -d "${BUILDCHROOT_DIR}" -f >> "${WORKDIR}/multistrap.conf" >> @@ -76,4 +80,26 @@ do_build() { >> # Configure root filesystem >> sudo chroot ${BUILDCHROOT_DIR} /configscript.sh >> _do_build_cleanup >> + >> + do_cleanup_mounts >> +} >> + >> +# Invalidate stamp for do_setup_mounts before each build start. >> +# This will guarantee that this function will be executed once >> +# per build. >> +python __anonymous() { >> + stamp = d.getVar("STAMP") + ".do_setup_mounts." + >> d.getVarFlag("do_setup_mounts", 'stamp-extra-info') >> + os.remove(stamp) if os.path.exists(stamp) else None >> +} >> + >> +do_setup_mounts[stamp-extra-info] = "${DISTRO}-${DISTRO_ARCH}" >> + >> +do_setup_mounts() { >> + sudo mount --bind ${DEPLOY_DIR_APT}/${DISTRO} >> ${BUILDCHROOT_DIR}/isar-apt +} >> + >> +addtask setup_mounts after do_build >> + >> +do_cleanup_mounts() { >> + sudo umount ${BUILDCHROOT_DIR}/isar-apt 2>/dev/null || true >> } >> diff --git >> a/meta/recipes-devtools/buildchroot/files/multistrap.conf.in >> b/meta/recipes-devtools/buildchroot/files/multistrap.conf.in index >> a0b28e3..480a4b8 100644 --- >> a/meta/recipes-devtools/buildchroot/files/multistrap.conf.in +++ >> b/meta/recipes-devtools/buildchroot/files/multistrap.conf.in @@ -6,7 >> +6,7 @@ noauth=true unpack=true ignorenativearch=true >> bootstrap=##DISTRO_MULTICONF_BOOTSTRAP## >> -aptsources=##DISTRO_MULTICONF_APTSOURCES## >> +aptsources=isar-apt ##DISTRO_MULTICONF_APTSOURCES## >> configscript=##CONFIG_SCRIPT## >> setupscript=##SETUP_SCRIPT## >> hookdir=##DIR_HOOKS## >> @@ -29,3 +29,9 @@ source=##DISTRO_APT_SOURCE_SEC## >> suite=##DISTRO_SUITE##/updates >> components=##DISTRO_COMPONENTS## >> omitdebsrc=true >> + >> +[isar-apt] >> +source=file:///isar-apt >> +suite=isar >> +components=main >> +omitdebsrc=true > -- With best regards, Alexander Smirnov ilbers GmbH Baierbrunner Str. 28c D-81379 Munich +49 (89) 122 67 24-0 http://ilbers.de/ Commercial register Munich, HRB 214197 General manager: Baurzhan Ismagulov