From patchwork Thu Oct 14 11:59:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 14524 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by patchwork.libcamera.org (Postfix) with ESMTPS id 5B072BDB1C for ; Wed, 10 Nov 2021 14:00:55 +0000 (UTC) Received: from pendragon.ideasonboard.com (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 019DED8B for ; Wed, 10 Nov 2021 15:00:54 +0100 (CET) Authentication-Results: perceval.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="Y8alH7cY"; dkim-atps=neutral Delivered-To: kbingham@ideasonboard.com Received: from perceval.ideasonboard.com by perceval.ideasonboard.com with LMTP id 8D8lMr8baGF/RgAA4E0KoQ (envelope-from ) for ; Thu, 14 Oct 2021 13:59:59 +0200 Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by perceval.ideasonboard.com (Postfix) with ESMTPS id B8F1A268; Thu, 14 Oct 2021 13:59:59 +0200 (CEST) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 80C0568F52; Thu, 14 Oct 2021 13:59:59 +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="Y8alH7cY"; dkim-atps=neutral Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id D0D5A68F4E for ; Thu, 14 Oct 2021 13:59:55 +0200 (CEST) Received: by mail-wr1-x436.google.com with SMTP id t2so18656584wrb.8 for ; Thu, 14 Oct 2021 04:59:55 -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=mIcULU9fg47HvyfwA792JL/cDKHnNvB7uUSYd7Kqdns=; b=Y8alH7cYx82IDwTB5ZpF+pmV73VbQ1l+ky10jqjVztY4VdexwiteoCd+lKPB5yF3vr NLLRt0Sp7hwul3dsPgFpNFlYs7FlB8+ik7sulvq6kdoUsunCjjYF2sJGmgXt5CaJTF1K UQe428JIq3e6XxUFW+XY3lPEY5KBTVbyYGBOMc+TLKlAUOkOXsr9/tY91QI0jjiaW2Jr C/CPjnoC4CKAIGreAyId1wdstZajAJWmWpm3kDewgpoJ/Wy2gd+j6UPDDzQyHaZTbMV1 aCHvw6rveqJc8DMIgdNkPmFiHcdpAEhasJRF5/Ly8KQh/Ib5On7cQ+utBS/O7MJK67oT fkEA== 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=mIcULU9fg47HvyfwA792JL/cDKHnNvB7uUSYd7Kqdns=; b=4OShba5ulT4BoS/JmReaQUXumcoYngmmyQtw7WRQj2Psi2p2BO+4utgHl2LroDUD6k 0bQ0jT7ZeuYErP7UHoLdcpH6OOv+ILhQmsMmbfR55PKiwS03lw6QRgfoh0KesnCnFDk/ Bf0jko1G1W6vxtnFk+54yIgFnbablOwHzZfV3NfxV9xlf2WxefBryedNyLNi6gRhPLGF suGmKUr5sqfO9C9NZ5BDj2POo8Wms4WLcpxlO8iedXWZC8HkDtcRs+I5iF4V+mPhm2MZ gMhpFAqzpHWzn4lrPeoVz8oPVsOtM67Yf4B/EEWCkcKCbEh5WfQurj+p9a25BgbZXC7R fr+g== X-Gm-Message-State: AOAM530YakBtM9Q95td5/209aNu+Ycs1frWY/5uak1Wdo6y+UeNky9rZ dGFmL6UOKc6o8Wrt7826imxNI+Gawq+Iipa1 X-Google-Smtp-Source: =?utf-8?q?ABdhPJz5pXAZ9vMZLDIBj4JTe2YcrU3BFux2zHMtH?= =?utf-8?q?87gFiGapz3is9fd50JPcfIYCOGGC103dd7b9A=3D=3D?= X-Received: by 2002:a1c:9dd1:: with SMTP id g200mr18783443wme.42.1634212795301; Thu, 14 Oct 2021 04:59:55 -0700 (PDT) Received: from naush-laptop.pitowers.org ([2a00:1098:3142:14:26af:fb8f:5d03:5eab]) by smtp.gmail.com with ESMTPSA id y191sm8658324wmc.36.2021.10.14.04.59.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Oct 2021 04:59:54 -0700 (PDT) From: Naushir Patuck To: libcamera-devel@lists.libcamera.org Date: Thu, 14 Oct 2021 12:59:51 +0100 Message-Id: <20211014115951.2996808-3-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211014115951.2996808-1-naush@raspberrypi.com> References: <20211014115951.2996808-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 2/2] build: Preserve upstream git versioning using meson dist 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" X-TUID: HifRsnB1d4Fl Resent-From: Kieran Bingham Resent-To: parsemail@patchwork.libcamera.org When distributions build and package libcamera libraries, they may not necessarily run the build in the upstream source tree. In these cases, the git SHA1 versioning information will be lost. This change addresses that problem by requiring package managers to run 'meson dist' to create a tarball of the source files and build from there. On runing 'meson dist', the utils/run-dist.sh script will create a .tarball-version file in the release tarball with the version string generated from the existing utils/gen-version.sh script. The utils/gen-version.sh script has been updated to check for the presence of this .tarball-version file and read the version string from it instead of creating one. Signed-off-by: Naushir Patuck --- meson.build | 3 +++ utils/gen-version.sh | 9 +++++++++ utils/run-dist.sh | 11 +++++++++++ 3 files changed, 23 insertions(+) create mode 100644 utils/run-dist.sh diff --git a/meson.build b/meson.build index 556a3f7c42f8..bd19bd836579 100644 --- a/meson.build +++ b/meson.build @@ -25,6 +25,9 @@ endif libcamera_version = libcamera_git_version.split('+')[0] +# This script gererates the .tarball-version file on a 'meson dist' command. +meson.add_dist_script('utils/run-dist.sh') + # Configure the build environment. cc = meson.get_compiler('c') cxx = meson.get_compiler('cpp') diff --git a/utils/gen-version.sh b/utils/gen-version.sh index da191691a7c5..8759e722ffe1 100755 --- a/utils/gen-version.sh +++ b/utils/gen-version.sh @@ -6,6 +6,15 @@ build_dir="$1" src_dir="$2" +# If .tarball-version exists, output the version string from the file and exit. +# This file is auto-generated on a 'meson dist' command from the run-dist.sh +# script. +if [ -f "$src_dir"/.tarball-version ] +then + cat "$src_dir"/.tarball-version + exit 0 +fi + # Bail out if the directory isn't under git control git rev-parse --git-dir > /dev/null 2>&1 || exit 1 diff --git a/utils/run-dist.sh b/utils/run-dist.sh new file mode 100644 index 000000000000..e89c3733b56c --- /dev/null +++ b/utils/run-dist.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +# SPDX-License-Identifier: GPL-2.0-or-later +# +# On a meson dist run, generate the version string and store it in a file. +# This will later be picked up by the utils/gen-version.sh script and used +# instead of re-generating it. This way, if we are not building in the upstream +# git source tree, the upstream version information will be preserved. + +cd "$MESON_SOURCE_ROOT" || return +./utils/gen-version.sh > "$MESON_DIST_ROOT"/.tarball-version