From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6458972999552860160 X-Received: by 10.28.135.67 with SMTP id j64mr285300wmd.6.1503846845689; Sun, 27 Aug 2017 08:14:05 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 10.28.109.195 with SMTP id b64ls321889wmi.19.canary-gmail; Sun, 27 Aug 2017 08:14:05 -0700 (PDT) X-Received: by 10.223.186.144 with SMTP id p16mr174964wrg.27.1503846845428; Sun, 27 Aug 2017 08:14:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503846845; cv=none; d=google.com; s=arc-20160816; b=Q2S30UTndWHptyhaIZIEAFtfE0aQWIoX7A49D+M03sbnszJ5Q4PwIdlJxpK7AG/Sab reVmb3TZGcMq8dUgHv5bI3V8ERuIsftsJCbp8j6reuNp5lh9jmgRtUmzsd7ha7gbnUAI mzu+1tx/sioSd5M9zpdyaDvnZTFSjoeXnxFAWe3uLwCdcf02/Md0wxzMWAbDBZPfRZYI DwR3pgPTV7t/Q4hFkWNaEX7DGjG4o7AUCGbZaGosbrIODkaXfrTQnQpjPnHSrZ20MhfI CrRAhfOLBR01sjBSgi6L7g1kbsiEGZjuA8tngDweChmk1f06Yfp9fA8OKUNsl8hgeUAB eOMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=Y5TanTdwGIqc6zDnbdmVCwlIaXv30amPM5CG2leVhlc=; b=0YlQ69mn1AhgK7ZR0+G9h4S05lfH9Y7Xg+M6MNsx4x+2Wp7esjtyQtbgUEoPRfIcCQ d7EtZDbAOjEIUOvkixpm+sohMrP6HlohuWadHicyxg9QxDbZMgo4OFWdZQvmA8R0oKMj MlMJ92vFFFU4UqTyehncvCTN2m4DI2xtalfIEptDMNDWqwTZxb9gNtlrQVvQYwstl+g/ jZ8IgKkmWpvDJaiH65eptAv2lJOKgGv/MHRJRcv6rZ3XdTNjEBHyJCEljxgw1aTM+RCM MWZJIfKfBrAN0uj4y6EgYMYRAlkArGbdTXWcBpWdB4AQwU2LZ7ZO7DCZHU/umRdzqY1Y oKhQ== 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 k84si385651wmh.5.2017.08.27.08.14.05 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 27 Aug 2017 08:14:05 -0700 (PDT) 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 localhost.localdomain ([188.227.110.165]) (authenticated bits=0) by aqmola.ilbers.de (8.14.4/8.14.4/Debian-4+deb7u1) with ESMTP id v7RFDkej006455 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 27 Aug 2017 17:13:56 +0200 From: Alexander Smirnov To: isar-users@googlegroups.com Cc: Frank Lenormand , Alexander Smirnov Subject: [PATCH 5/6] classes/dpkg: Properly update packages in the cache Date: Sun, 27 Aug 2017 18:13:38 +0300 Message-Id: <20170827151339.12806-6-asmirnov@ilbers.de> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170827151339.12806-1-asmirnov@ilbers.de> References: <20170827151339.12806-1-asmirnov@ilbers.de> X-TUID: X+YotAPy2jhv From: Frank Lenormand Before installing to cache, existing packages with the same name and version have to be removed. Signed-off-by: Frank Lenormand Signed-off-by: Alexander Smirnov --- meta/classes/dpkg.bbclass | 46 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/meta/classes/dpkg.bbclass b/meta/classes/dpkg.bbclass index 118ba2f..72ae79f 100644 --- a/meta/classes/dpkg.bbclass +++ b/meta/classes/dpkg.bbclass @@ -84,12 +84,52 @@ do_install_to_cache() { > "${DIR_CACHE}/conf/distributions" fi + print_field_value() { + awk "\$1 == \"${1}:\" { print \$2; }" + } + + call_reprepro() { + reprepro --waitforlock 3 -b "${DIR_CACHE}" --dbdir "${DIR_DB}" \ + -C main "$@" + } + # Add binary and source packages to the deb cache # If the cache doesn't exist yet, it will be created using the # `distributions` file generated above. - ls -1 "${BUILDROOT}"/*.deb "${BUILDROOT}"/*.dsc | while read -r p; do - reprepro --waitforlock 3 -b "${DIR_CACHE}" --dbdir "${DIR_DB}" \ - -C main "include${p##*.}" "${DEBDISTRONAME}" "${p}" + ls -1 "${BUILDROOT}"/*.deb | while read -r p; do + name_package=$(dpkg -f "${p}" | print_field_value "Package") + version_package=$(dpkg -f "${p}" | print_field_value "Version") + + # Remove all packages with the same version that were added to the + # repository in previous builds + call_reprepro \ + -A "${DISTRO_ARCH}" \ + removefilter "${DEBDISTRONAME}" \ + "Package (== ${name_package}), \ + Version (== ${version_package})" + call_reprepro \ + -A "${DISTRO_ARCH}" \ + "include${p##*.}" \ + "${DEBDISTRONAME}" \ + "${p}" + done + + ls -1 "${BUILDROOT}"/*.dsc | while read -r p; do + name_package=$(cat "${p}" | print_field_value "Source") + version_package=$(cat "${p}" | print_field_value "Version") + + # Remove all source packages with the same version that were added to + # the repository in previous builds + call_reprepro \ + -A "source" \ + removefilter "${DEBDISTRONAME}" \ + "Package (== ${name_package}), \ + Version (== ${version_package})" + call_reprepro \ + -A "source" \ + "include${p##*.}" \ + "${DEBDISTRONAME}" \ + "${p}" done } -- 2.1.4