From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6473366578589073408 X-Received: by 10.223.133.244 with SMTP id 49mr2519000wru.22.1507203839459; Thu, 05 Oct 2017 04:43:59 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 10.223.142.79 with SMTP id n73ls258873wrb.3.gmail; Thu, 05 Oct 2017 04:43:59 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDABn6SeB43cRQAdE1OE277SSKRU1/wZSyEmpyjpwXPMoO+k4M2tjqnhz3CSVoi9yA2IO9r X-Received: by 10.28.0.7 with SMTP id 7mr2819088wma.26.1507203839126; Thu, 05 Oct 2017 04:43:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507203839; cv=none; d=google.com; s=arc-20160816; b=qQaercD5csi1Mwp6icnYKwPNJg3eNeCM/BMgAjAX7qSk2T/q0ZxhDOUSDCGoEunw/1 M8uTtQpkjHxzAQ4oSK7OqqSgy+v8U+A2dRx52wUDP6N/rSgzsqimxP5S7ATaZbnt+DBT oA9bCkyLuUaiSSX4oVsCxvXf/XnNAfbo2WmzzJz4SiqDLbdNtEXLMtqVDjCaN3Wqg6pe 0mN1poE+OrTjiGX44AWCjBv5uy3IeAP1qNMyZE9/ALhuCs0py/E7fYKzmOzuysan1iJC 4zYyxEfbBlYZEhLEj6499l2XKzu4JgMt8XucSmo94/D1hKGMx6AnNnLt+CpZjkQSfeI3 Z/XA== 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=GZOyojYjxeSPrwef9T4SWjJBR/4OLNiMhl2Ld2N3HoU=; b=lN+nJ3E2Z+CLKHh+Eyhp+CKe2XnHCFWyfreMC70fU9Kjzh4yPwfksRxL8BsiDQp5dg AixWnscwYsXYoWhhCb8Sxz5J3/KvkjLohwbgTgQcjNXJ00KZHo07YDu4OLUljgvP1yMu V2HyMZ4dP++oBCVzRi+a2ih2eIdCHEcCMZrAYHtq72svyOFSi9HVqAbN/PVoh6wKKK8v J9VR8m8iNciUsonQBxPxhBPYiLiIrdNKPL12TKcEEY3avh66wi9Ar07cm3Pustg5oT5N ypy9vrAcgp5/IuvN16A7QAcMmpS3IIJZSRadLZAq7IDrsJOLySZXSmHBhjYGGUuB+V5Q EgBA== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 192.35.17.2 is neither permitted nor denied by best guess record for domain of claudius.heine.ext@siemens.com) smtp.mailfrom=claudius.heine.ext@siemens.com Return-Path: Received: from thoth.sbs.de (thoth.sbs.de. [192.35.17.2]) by gmr-mx.google.com with ESMTPS id d82si1776443wmd.1.2017.10.05.04.43.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Oct 2017 04:43:59 -0700 (PDT) Received-SPF: neutral (google.com: 192.35.17.2 is neither permitted nor denied by best guess record for domain of claudius.heine.ext@siemens.com) client-ip=192.35.17.2; Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 192.35.17.2 is neither permitted nor denied by best guess record for domain of claudius.heine.ext@siemens.com) smtp.mailfrom=claudius.heine.ext@siemens.com Received: from mail2.sbs.de (mail2.sbs.de [192.129.41.66]) by thoth.sbs.de (8.15.2/8.15.2) with ESMTPS id v95Bhw0w023976 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 5 Oct 2017 13:43:58 +0200 Received: from [139.25.68.223] (linux-ses-ext02.ppmd.siemens.net [139.25.68.223]) by mail2.sbs.de (8.15.2/8.15.2) with ESMTP id v95BhwnT019369; Thu, 5 Oct 2017 13:43:58 +0200 Subject: Re: [PATCH 2/4] apt: Generate Isar reprepro database To: Alexander Smirnov , isar-users@googlegroups.com References: <20171005100807.3369-1-asmirnov@ilbers.de> <20171005100807.3369-3-asmirnov@ilbers.de> From: Claudius Heine Message-ID: <479038a2-247e-2bb0-b30c-c738f1da306c@siemens.com> Date: Thu, 5 Oct 2017 13:43:58 +0200 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: <20171005100807.3369-3-asmirnov@ilbers.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-TUID: NsSABQd7IoXS Hi, On 10/05/2017 12:08 PM, Alexander Smirnov wrote: > Generate reprepro database for Isar apt repository. > > Signed-off-by: Alexander Smirnov > --- > meta-isar/conf/layer.conf | 3 +++ > meta-isar/conf/local.conf.sample | 4 ++++ > meta/classes/image.bbclass | 34 ++++++++++++++++++++++++++++++++++ > 3 files changed, 41 insertions(+) > > diff --git a/meta-isar/conf/layer.conf b/meta-isar/conf/layer.conf > index 0950a34..cd42f06 100644 > --- a/meta-isar/conf/layer.conf > +++ b/meta-isar/conf/layer.conf > @@ -22,3 +22,6 @@ DEBDISTRONAME = "isar" > > # Path to the Isar apt repository > DEPLOY_DIR_APT ?= "${DEPLOY_DIR}/apt" > + > +# Path to the Isar databases used by `reprepro` > +DEPLOY_DIR_DB ?= "${DEPLOY_DIR}/db" The same comment in the previous patch applies here. > diff --git a/meta-isar/conf/local.conf.sample b/meta-isar/conf/local.conf.sample > index a456b1b..660958f 100644 > --- a/meta-isar/conf/local.conf.sample > +++ b/meta-isar/conf/local.conf.sample > @@ -158,3 +158,7 @@ IMAGE_INSTALL = "hello example-raw" > # > # Default parallel jobs for bitbake: > BB_NUMBER_THREADS = "4" > + > +# > +# Number of attempts to try to get reprepro lock for access to apt cache > +REPREPRO_LOCK_ATTEMPTS = "16" > diff --git a/meta/classes/image.bbclass b/meta/classes/image.bbclass > index 57705a7..47f53a3 100644 > --- a/meta/classes/image.bbclass > +++ b/meta/classes/image.bbclass > @@ -10,6 +10,31 @@ IMAGE_ROOTFS = "${WORKDIR}/rootfs" > > inherit ${IMAGE_TYPE} > > +call_reprepro() { > + for i in $(seq 1 ${REPREPRO_LOCK_ATTEMPTS}); do > + # According to `sh` manual page, shell exit statuses fall between > + # 0-255. The EEXIST error code is (-17), so casting to usigned 8-bit > + # integer results value (239). > + eexist=$(python -c 'import errno; print(256-errno.EEXIST)') You can just use the python interpreter that is already running like this: def _eexist(): import errno return 265-errno.EEXIST ... eexist="${@_eexist()}" > + retval="0" > + reprepro $* || retval="$?" > + > + # If reprepro has failed to get database lock, it returns EEXIST code. > + # In this case we continue trying to get lock until max amount of > + # attempts is reached. > + if [ $retval -eq $eexist ]; then > + bbwarn "Failed to get reprepro lock, trying again..." > + sleep 5 > + else > + break > + fi > + done > + > + if [ $retval -ne 0 ]; then > + bbfatal "reprepro failed" > + fi > +} > + > CACHE_CONF_DIR = "${DEPLOY_DIR_APT}/${DISTRO}/conf" > do_cache_config[dirs] = "${CACHE_CONF_DIR}" > do_cache_config[stamp-extra-info] = "${DISTRO}" > @@ -21,6 +46,15 @@ do_cache_config() { > sed -e "s#{DISTRO_NAME}#"${DEBDISTRONAME}"#g" \ > ${FILESDIR}/distributions.in > ${CACHE_CONF_DIR}/distributions > fi > + > + path_cache="${DEPLOY_DIR_APT}/${DISTRO}" > + path_databases="${DEPLOY_DIR_DB}/${DISTRO}" > + > + if [ ! -d "${path_databases}" ]; then > + call_reprepro -b ${path_cache} \ > + --dbdir ${path_databases} \ > + export ${DEBDISTRONAME} > + fi > } > > addtask cache_config before do_fetch > Claudius -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-54 Fax: (+49)-8142-66989-80 Email: ch@denx.de