From patchwork Tue Oct 12 15:24:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 14109 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 210A9C323E for ; Tue, 12 Oct 2021 15:24:31 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DFD6468F53; Tue, 12 Oct 2021 17:24:29 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="ICg2pXwm"; dkim-atps=neutral Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 412FD68F4C for ; Tue, 12 Oct 2021 17:24:28 +0200 (CEST) Received: by mail-wr1-x433.google.com with SMTP id t2so68095151wrb.8 for ; Tue, 12 Oct 2021 08:24:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OvMhSQhG+5/bk6lR+tOIZyQf2Gts38eW8TySEnyx7kM=; b=ICg2pXwm7tgC1Vt1lFUiagKyXA+ap7z4Al2dz6gjjJH/8hrjQnERTmejhGeDhmlft5 rglBCxc2lSb1Vzko6NHgg4tNfiFI81OsBhuVCFcFLnMLJeZHdtHO3EqQwPGReBKknvSB vIIreI52/nNWfFNuFmeQluNlmTpt94dtI9X1zK97madc9s2tKZfKpC15gtysWLKha9mF Uwrwt9ausVD1tWii3cxfLfjYFkQgg0A8ssXEUWm8nCU+skJL+0oWv4yVNkLmf+2WHpyo 2tJvJ5/hu7KmrFUcV0SjHHFdhYVQV3mDKsqNloimhseyRbmYmJR70pxb/4vNA0xxZIYH kdCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OvMhSQhG+5/bk6lR+tOIZyQf2Gts38eW8TySEnyx7kM=; b=eoCX93YKUiS/jtC3Dsjp88YAZ5bfwe4zo13R9Db1XTosFb6f4NQD7K5ogHp0Pqe5E8 1wBj+HnKAtX3kJ59EILB22xxCUUAgkNCaQTjZEKFCXWOemqOo7gEs81YQm9vDxKigL1T rZcwPHkNKQDQ8sZZjo8b1hPgU6MSOj9dqpkANLOnkl5uEg5+l8yuDU8anPvO/dPlppCd KmJt0WsOYF+I3/oCjcXAHHs7GwXXpzrmJGVZl0eZmIVNnpC0IgjfIGuBz3vONJ/SPDJV fXXdaMsWmDAvp0ukntv6n3nnK75n3DNdN1KgjkvYqRU7iczJ0xbEm0abR3TJ92ThGdaf CxDw== X-Gm-Message-State: AOAM530F7Kve82232ULUS+vl6QVG+uibolYDhugDdZRAuLa6NN6n3kew AKt/XrfdKsel0V4lCtUfrWRwQyrm3IoyUA== X-Google-Smtp-Source: ABdhPJxt8lueEJw6S2FI5B54f9WtvOHanNi92x8bvRsv8HHJ+Kw96/JEu9gJoiDDEOAlYYQs0Ay7Nw== X-Received: by 2002:adf:d1cb:: with SMTP id b11mr33346850wrd.418.1634052267654; Tue, 12 Oct 2021 08:24:27 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:26ae:314c:5c3f:f0df]) by smtp.gmail.com with ESMTPSA id s14sm10683449wro.76.2021.10.12.08.24.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Oct 2021 08:24:26 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Tue, 12 Oct 2021 16:24:09 +0100 Message-Id: <20211012152410.978077-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211012152410.978077-1-naush@raspberrypi.com> References: <20211012152410.978077-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [RFC 1/2] utils: Add an option to override SHA string in gen-version.sh X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add an optional second command line argument to the gen-version.sh shell script that would be used as the SHA value in the version string. An override is needed if distributions make libcamera builds outside of the upstream git tree. In these cases, the user can then use the correct SHA value of the upstream tree instead of the local downstream build tree. Signed-off-by: Naushir Patuck --- utils/gen-version.sh | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/utils/gen-version.sh b/utils/gen-version.sh index b09ad495f86a..ba5185fa264c 100755 --- a/utils/gen-version.sh +++ b/utils/gen-version.sh @@ -2,15 +2,26 @@ # SPDX-License-Identifier: GPL-2.0-or-later # Generate a version string using git describe +# +# An optional sha string can be passed as the second command line argument +# if the caller wishes to override the SHA value picked up by git. This may be +# useful when distribution packages are build outside of the upstream repo. build_dir="$1" +sha_override="$2" -# Bail out if the directory isn't under git control -src_dir=$(git rev-parse --git-dir 2>&1) || exit 1 -src_dir=$(readlink -f "$src_dir/..") - -# Get a short description from the tree. -version=$(git describe --abbrev=8 --match "v[0-9]*" 2>/dev/null) +if [ -n "$sha_override" ] +then + # Use the sha provided on the command line. + version="v0.0.0-g$sha_override" +else + # Bail out if the directory isn't under git control + src_dir=$(git rev-parse --git-dir 2>&1) || exit 1 + src_dir=$(readlink -f "$src_dir/..") + + # Get a short description from the tree. + version=$(git describe --abbrev=8 --match "v[0-9]*" 2>/dev/null) +fi if [ -z "$version" ] then @@ -26,7 +37,7 @@ if [ -z "$build_dir" ] || (echo "$build_dir" | grep -q "$src_dir") then git update-index --refresh > /dev/null 2>&1 fi -git diff-index --quiet HEAD || version="$version-dirty ($(date --iso-8601=seconds))" +[ -n "$sha_override" ] || git diff-index --quiet HEAD || version="$version-dirty ($(date --iso-8601=seconds))" # Replace first '-' with a '+' to denote build metadata, strip the 'g' in from # of the git SHA1 and remove the initial 'v'.