From patchwork Fri Sep 18 08:04:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quirin Gylstorff X-Patchwork-Id: 11784221 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AA19C6CA for ; Fri, 18 Sep 2020 08:04:42 +0000 (UTC) Received: from web01.groups.io (web01.groups.io [66.175.222.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DCDFA21481 for ; Fri, 18 Sep 2020 08:04:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=lists.cip-project.org header.i=@lists.cip-project.org header.b="q84JQ48O" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DCDFA21481 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=siemens.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=bounce+64572+5462+4520428+8129116@lists.cip-project.org X-Received: by 127.0.0.2 with SMTP id XlKDYY4521763xMh6y4xKtec; Fri, 18 Sep 2020 01:04:41 -0700 X-Received: from david.siemens.de (david.siemens.de [192.35.17.14]) by mx.groups.io with SMTP id smtpd.web11.8073.1600416279521592592 for ; Fri, 18 Sep 2020 01:04:40 -0700 X-Received: from mail2.sbs.de (mail2.sbs.de [192.129.41.66]) by david.siemens.de (8.15.2/8.15.2) with ESMTPS id 08I84aEq014038 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 18 Sep 2020 10:04:37 +0200 X-Received: from md2dvrtc.fritz.box ([167.87.34.10]) by mail2.sbs.de (8.15.2/8.15.2) with ESMTP id 08I84aku006193; Fri, 18 Sep 2020 10:04:36 +0200 From: "Quirin Gylstorff" To: cip-dev@lists.cip-project.org, Jan.Kiszka@siemens.com Cc: Quirin Gylstorff Subject: [cip-dev] [isar-cip-core][PATCH] classes/image_uuid: Generate new uuid if a new package is added Date: Fri, 18 Sep 2020 10:04:35 +0200 Message-Id: <20200918080435.24136-1-Quirin.Gylstorff@siemens.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: cip-dev@lists.cip-project.org List-Id: Mailing-List: list cip-dev@lists.cip-project.org; contact cip-dev+owner@lists.cip-project.org Delivered-To: mailing list cip-dev@lists.cip-project.org Reply-To: cip-dev@lists.cip-project.org X-Gm-Message-State: rL7cq45VmKPCIbwwzUacJOFtx4520428AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.cip-project.org; q=dns/txt; s=20140610; t=1600416281; bh=osTO/GPv7XfOcN5w4ZKpFfJwdJ64Rq5eSiLyS4hCrRU=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=q84JQ48OJoh2vSi4y6UOlprvctJaBQ/p6KWXxOyb64azRcZgttdsqRiY4npfZI9flBF fnggpOoXwmk7aqvEuaP2qBB00aEwawXcvx7PPGgO4rGsWxgn0tiozlczlg2Aihx6hIoKk uHMasnHX22Ivw5DRUXFMsCnvS08hdjR7g0s= From: Quirin Gylstorff BB_BASEHASH only includes the task itself and its metadata. Dependencies are not taken into account when this hash is generated which means updating a package will not generate a new UUID. BB_TASKHASH takes the changes into account. Signed-off-by: Quirin Gylstorff --- classes/image_uuid.bbclass | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/classes/image_uuid.bbclass b/classes/image_uuid.bbclass index d5337b8..873abc5 100644 --- a/classes/image_uuid.bbclass +++ b/classes/image_uuid.bbclass @@ -9,23 +9,23 @@ # SPDX-License-Identifier: MIT # -def generate_image_uuid(d): - import uuid +IMAGE_UUID ?= "random" - base_hash = d.getVar("BB_BASEHASH_task-do_rootfs_install", True) - if base_hash is None: - return None - return str(uuid.UUID(base_hash[:32], version=4)) - -IMAGE_UUID ?= "${@generate_image_uuid(d)}" +IMAGE_UUID_NAMESPACE = "6090f47e-b068-475c-b125-7be7c24cdd4e" do_generate_image_uuid[vardeps] += "IMAGE_UUID" do_generate_image_uuid[depends] = "buildchroot-target:do_build" +IMAGER_INSTALL += "uuid-runtime" do_generate_image_uuid() { + image_do_mounts + if [ "${IMAGE_UUID}" != "random" ]; then + IMAGE_UUID_FINAL="${IMAGE_UUID}" + else + IMAGE_UUID_FINAL="$(sudo -E chroot ${BUILDCHROOT_DIR} uuidgen -s -n "${IMAGE_UUID_NAMESPACE}" -N "${BB_TASKHASH}")" + fi sudo sed -i '/^IMAGE_UUID=.*/d' '${IMAGE_ROOTFS}/etc/os-release' - echo "IMAGE_UUID=\"${IMAGE_UUID}\"" | \ + echo "IMAGE_UUID=\"${IMAGE_UUID_FINAL}\"" | \ sudo tee -a '${IMAGE_ROOTFS}/etc/os-release' - image_do_mounts # update initramfs to add uuid sudo chroot '${IMAGE_ROOTFS}' update-initramfs -u