From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6607733288662466560 X-Received: by 2002:a5d:4f88:: with SMTP id d8-v6mr1093974wru.29.1538487584610; Tue, 02 Oct 2018 06:39:44 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a7b:c1d6:: with SMTP id a22-v6ls309479wmj.1.canary-gmail; Tue, 02 Oct 2018 06:39:44 -0700 (PDT) X-Google-Smtp-Source: ACcGV62i0M2VheBtufcJ4lyDqEGDs6CLFxnMZo55WN94VIGBHKYT+t8tkroZEQiaxWzh0buXcQhT X-Received: by 2002:a1c:7a10:: with SMTP id v16-v6mr272766wmc.11.1538487584152; Tue, 02 Oct 2018 06:39:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538487584; cv=none; d=google.com; s=arc-20160816; b=Zk0ObfrYNB93tAXGWyY4dbEHq6nIkd/fphq6fXt5H035uThXRZL7UzTkpKwn1S86kM tc0VIjiRrWqs1clVY1NyacvyTYhCfQEQ7ooB+KlVQsw4BqDZBdupxuFgwJ+ZAPEUNoSu 573F/IhskrKtUYYYGT4V1yxC7/MqwQIKUqiOUw8cZ0YfnD/BGfTTQzzwxgqb/pxp6zw3 XozO0wiG0SULIZ4Fu6fiduaGwvME8v9AWMnGtJTxfbKX4jIG7Mivc4IAzhrLA5W8BXP1 Q4Hz8Cc8SEUavg5YyajLAEcSWFwC0Z9jPX3pWIEuHnAB+3LPgfwqkFvglOI2U/PNp1Q2 MfQA== 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; bh=GDB4YJqYkoq+MIEnq+S0VN9yV71tbuJYrEQdqAAyTW4=; b=eEWWC9JG39yARtQJkANfm4FuxRufVYFnnfz0vn3C67TfKKv1BA28X8cZFh1jQeoAAl I3tVGwd+nW5/hM0ke//Gkf6ItnjtKiqUnQbuhgXRcTU3CExUId2CROrdJXRJAeMZZ7Xd WKuTAoRncOrO6SJtNsVJUoBcbB6lEIhc+G8bDrmHLOFP6VLR8Tjq3N+nA+k/myiFrtFO IoAKYDDBfq0vPsL15VUbZ6jpcwU+l4VqgRQ1ECFMIdvbB0LYK37W3fEvEgafNWcDTNwN OseTef7yn9BYQdGRSmp/WWb1qlMaHPN5VGXtFeK7XSvuJ/NhUQwkWsVW7gMJsJ68iyso Qamw== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of claudius.heine.ext@siemens.com designates 194.138.37.40 as permitted sender) smtp.mailfrom=claudius.heine.ext@siemens.com Return-Path: Received: from gecko.sbs.de (gecko.sbs.de. [194.138.37.40]) by gmr-mx.google.com with ESMTPS id 191-v6si49338wmv.0.2018.10.02.06.39.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Oct 2018 06:39:44 -0700 (PDT) Received-SPF: pass (google.com: domain of claudius.heine.ext@siemens.com designates 194.138.37.40 as permitted sender) client-ip=194.138.37.40; Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of claudius.heine.ext@siemens.com designates 194.138.37.40 as permitted sender) smtp.mailfrom=claudius.heine.ext@siemens.com Received: from mail2.sbs.de (mail2.sbs.de [192.129.41.66]) by gecko.sbs.de (8.15.2/8.15.2) with ESMTPS id w92Ddh8B004732 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 2 Oct 2018 15:39:43 +0200 Received: from [139.25.69.181] (linux-ses-ext02.ppmd.siemens.net [139.25.69.181]) by mail2.sbs.de (8.15.2/8.15.2) with ESMTP id w92DdgV3004429; Tue, 2 Oct 2018 15:39:42 +0200 Subject: Re: [PATCH 1/9] base-apt: Add helper class To: "Maxim Yu. Osipov" , isar-users@googlegroups.com References: <20181002121907.18476-1-mosipov@ilbers.de> <20181002121907.18476-2-mosipov@ilbers.de> From: Claudius Heine Message-ID: <57177149-44b1-0876-7c5c-49d687b42267@siemens.com> Date: Tue, 2 Oct 2018 15:39:42 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: <20181002121907.18476-2-mosipov@ilbers.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-TUID: w5fZFQ7YycAS Hi Maxim, On 10/2/18 2:18 PM, Maxim Yu. Osipov wrote: > From: Alexander Smirnov > > base-apt intended to store original upstream debs to re-use them > later offline. This class helps to populate base-apt with the packages > used during build. > > Signed-off-by: Alexander Smirnov > --- > meta/classes/base-apt-helper.bbclass | 53 ++++++++++++++++++++++++++++++++++++ > 1 file changed, 53 insertions(+) > create mode 100644 meta/classes/base-apt-helper.bbclass > > diff --git a/meta/classes/base-apt-helper.bbclass b/meta/classes/base-apt-helper.bbclass > new file mode 100644 > index 0000000..5e3fe36 > --- /dev/null > +++ b/meta/classes/base-apt-helper.bbclass > @@ -0,0 +1,53 @@ > +# This software is a part of ISAR. > +# Copyright (C) 2018 ilbers GmbH > + > +DISTRO_NAME ?= "${@ d.getVar('DISTRO', True).split('-')[0]}" > +DISTRO_SUITE ?= "${@ d.getVar('DISTRO', True).split('-')[1]}" > + > +populate_base_apt() { > + search_dir=$1 > + > + for package in $(find $search_dir -name '*.deb'); do find ... | while read package; do or while read package; do ...; done <<< $(find ...) is better performance wise since the loop is iterated as results come in. > + # NOTE: due to packages stored by reprepro are not modified, we can > + # use search by filename to check if package is already in repo. In > + # addition, m5sums could be compared to ensure, that package is the > + # same and should not be overwritten. This method is easier and more > + # robust than querying reprepro by name. > + > + # Check if this package is taken from Isar-apt, if so - ingore it. > + isar_package=$(find ${DEPLOY_DIR_APT}/${DISTRO} -name $package) Don't you need a `${package##*/}` here to remove the leading path? > + if [ -n "$isar_package" ]; then > + # Check if MD5 sums are iendtical. This helps to avoid the case identical > + # when packages is overriden from another repo. overridden > + md1=$(md5sum $package) > + md2=$(md5sum $isar_package) md5sum produces output with like this: $ md5sum conf/local.conf c543793c1df3b1f45a5555d92b6f3ee2 conf/local.conf So you need to remove that before comparing. The same issues are in the following code as well. Cheers, Claudius > + if [ "$md1" = "$md2" ]; then > + continue > + fi > + fi > + > + # Check if this package is already in base-apt > + isar_package=$(find ${BASE_APT_DIR}/${DISTRO_NAME} -name $package) > + if [ -n "$isar_package" ]; then > + md1=$(md5sum $package) > + md2=$(md5sum $isar_package) > + if [ "$md1" = "$md2" ]; then > + continue > + fi > + > + # md5sum differs, so remove the package from base-apt > + name=$(basename $package | cut -d '_' -f 1) > + reprepro -b ${BASE_APT_DIR}/${DISTRO_NAME} \ > + --dbdir ${BASE_APT_DB}/${DISTRO_NAME} \ > + -C main -A ${DISTRO_ARCH} \ > + remove ${DISTRO_SUITE} \ > + $name > + fi > + > + reprepro -b ${BASE_APT_DIR}/${DISTRO_NAME} \ > + --dbdir ${BASE_APT_DB}/${DISTRO_NAME} \ > + -C main \ > + includedeb ${DISTRO_SUITE} \ > + $package > + done > +} > -- 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