From patchwork Mon Oct 10 17:32:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 17573 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 F3327C327C for ; Mon, 10 Oct 2022 17:33:26 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C097F62D71; Mon, 10 Oct 2022 19:33:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1665423204; bh=dTdEWFs0yMn6lG3OUtZ1giJTgAPQdjuqfMUW/V8ueCY=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=xXFkHNJca0CQZJc0vymlnZp7Nux9xGYnzVaTCz7fPLdr+87keSgZoWBl4duvW8ucJ BTz5pFsEhw/pDeOik0cGXHmQBGiPG6hk/rQ5pd/lPXn6OtDIgNB0t1munP3oOjs3JK wjktf9PxWnKX6g7uJ3yXDARQ3ortk2oO+3XbOwqiXY8MIP026JLMw0yF+6sA1RxGFS 7ULEa82nDkBkbwHSV28hoGUThKoG4olGw7HSNjkXAlkTsBzdzN8mjy05Hz8vfm/e8i NcuQO0gwyGcAwoMnh+6U6rNlU8JzZvQJsK6gVO371Klo14n54WmOirtM/6v8UhBkzX Bsswh0T1K6VpQ== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 82F4C62272 for ; Mon, 10 Oct 2022 19:33:23 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="g7df18BQ"; dkim-atps=neutral Received: from Monstersaurus.ksquared.org.uk.beta.tailscale.net (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C34B3E3A; Mon, 10 Oct 2022 19:33:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1665423203; bh=dTdEWFs0yMn6lG3OUtZ1giJTgAPQdjuqfMUW/V8ueCY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g7df18BQnExT3BZ0uoGIVbs5ZC+Ws44MtZIpD7JRb+GpMOOZ5/TIP92UGQ09XkgMA sKVhAsnp/izJ2+L4UShnfuApgPh06iTRkKKZFSSuCjL2BvlMF+u4npQl5MuYH9Rf7V lZq9ki90+ikFtrj/APtLGE7WllWb9vfAFFQ34lNg= To: libcamera devel Date: Mon, 10 Oct 2022 18:32:10 +0100 Message-Id: <20221010173214.3547133-2-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221010173214.3547133-1-kieran.bingham@ideasonboard.com> References: <20221010173214.3547133-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 1/5] meson: Fix typo 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: , X-Patchwork-Original-From: Kieran Bingham via libcamera-devel From: Kieran Bingham Reply-To: Kieran Bingham Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The comment for supporting the custom script on 'make dist' contains a typo. Fix it. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart Reviewed-by: Jacopo Mondi Reviewed-by: Eric Curtin --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 72919102ad55..2c6173b4f97e 100644 --- a/meson.build +++ b/meson.build @@ -26,7 +26,7 @@ endif libcamera_version = libcamera_git_version.split('+')[0] -# This script gererates the .tarball-version file on a 'meson dist' command. +# This script generates the .tarball-version file on a 'meson dist' command. meson.add_dist_script('utils/run-dist.sh') # Configure the build environment. From patchwork Mon Oct 10 17:32:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 17574 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 A53BFC3285 for ; Mon, 10 Oct 2022 17:33:27 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 1A4B562D78; Mon, 10 Oct 2022 19:33:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1665423205; bh=pitq57k3xQLLB3p0hzEY5XESU1yZjwMqr/stW6Su0iI=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=zYKVc62nNOdULaVOZOY/O7lilTDyF9Rn65w/xZFX8PzLqMVMiTSsbV0qU1dYL7QL1 pjQAm9dHCNnfF9NZARQggF57REQVTP5nDGyjaLXNwCvNWfaUbiJcQbyAKy84NThGot vxb92ioM0ohQhOplNG2HuRybzvX+/HgIlQZzZF7YQuSp2zkB3nwfAt7uTTgRQQLqTz 5joc/KKJvpYeAy/4u1PwBhBoEnJEO1QJvFQaczYxn6aM4OA+xXm+xV2FjPacJ6w0Eh U3GRuUUo9GJLCTTpHtBNVpmB1g4aTDBmdY8+MXq4BoLZlG0vMnxdRlc29CupsQH86u j5rThsfhlr9/g== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C201F62D6B for ; Mon, 10 Oct 2022 19:33:23 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Dk/3nu9H"; dkim-atps=neutral Received: from Monstersaurus.ksquared.org.uk.beta.tailscale.net (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2C78EBB0; Mon, 10 Oct 2022 19:33:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1665423203; bh=pitq57k3xQLLB3p0hzEY5XESU1yZjwMqr/stW6Su0iI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Dk/3nu9H1V3Ebrg5xvPUozEtqSczbNtyEElkyRJAeVmWS1AxYZyuR/4QW+aq658yj R6p2859vEXkSUL86lRQsDa+J1dVOURfHFzkXULu4P1vL5lrvvQ8QuOu/qbkuaT2btj 3rauhbYK1FQfyb+/8gzgFc6TwzHk3K7TxdMyPZIs= To: libcamera devel Date: Mon, 10 Oct 2022 18:32:11 +0100 Message-Id: <20221010173214.3547133-3-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221010173214.3547133-1-kieran.bingham@ideasonboard.com> References: <20221010173214.3547133-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 2/5] meson: Shared Object version handling 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: , X-Patchwork-Original-From: Kieran Bingham via libcamera-devel From: Kieran Bingham Reply-To: Kieran Bingham Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" The libcamera project is not yet ready to declare ABI nor API stability, but it will benefit the community to be able to provide more regular release cycles to determine 'versioned' points of history. Ideally, these releases will be made at any ABI breakage, but can be made at arbitary time based points along the way. To support releases which may not be ABI stable, declare the soversion of both the libcamera and libcamera-base library to be dependant upon both the major and minor component of the project version. As part of this, introduce a new 'Versions' summary section to highlight the different version components that may become apparent within any given build. Reviewed-by: Jacopo Mondi Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- v3: - fix typo - Use libcamera_version directly for SONAME. - Fix ordering of EXCLUDE_PATTERNS - Use meson.project_version() in the event the git versions are incorrect. - No need to present libcamera_version anymore - Guaranteed to be the same as 'project_version' Signed-off-by: Kieran Bingham --- Documentation/Doxyfile.in | 4 +++- meson.build | 23 +++++++++++++++++++++++ src/libcamera/base/meson.build | 1 + src/libcamera/meson.build | 1 + 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/Documentation/Doxyfile.in b/Documentation/Doxyfile.in index 88dfcddaebf6..e87bb2b42c5e 100644 --- a/Documentation/Doxyfile.in +++ b/Documentation/Doxyfile.in @@ -51,7 +51,9 @@ EXCLUDE_PATTERNS = @TOP_BUILDDIR@/include/libcamera/ipa/*_serializer.h \ @TOP_BUILDDIR@/include/libcamera/ipa/ipu3_*.h \ @TOP_BUILDDIR@/include/libcamera/ipa/raspberrypi_*.h \ @TOP_BUILDDIR@/include/libcamera/ipa/rkisp1_*.h \ - @TOP_BUILDDIR@/include/libcamera/ipa/vimc_*.h + @TOP_BUILDDIR@/include/libcamera/ipa/vimc_*.h \ + @TOP_BUILDDIR@/src/libcamera/libcamera.so* \ + @TOP_BUILDDIR@/src/libcamera/base/libcamera-base.so* EXCLUDE_SYMBOLS = libcamera::BoundMethodArgs \ libcamera::BoundMethodBase \ diff --git a/meson.build b/meson.build index 2c6173b4f97e..3e2bcc0de2c3 100644 --- a/meson.build +++ b/meson.build @@ -26,6 +26,29 @@ endif libcamera_version = libcamera_git_version.split('+')[0] +# A shallow clone, or a clone without a reachable tag equivalent to the +# meson.project_version() could leave the project in a mis-described state. +# Produce a warning in this event, and fix to a best effort. +if libcamera_version != meson.project_version() + warning('The sources disagree about the version: ' + + libcamera_version + ' != ' + meson.project_version()) + + libcamera_version = meson.project_version() + libcamera_git_version = libcamera_version + '+' + libcamera_git_version.split('+')[1] + summary({'Source version override': true}, section : 'Versions') +endif + +# Until we make ABI compatible releases, the full libcamera version is used as +# the soname. +libcamera_soversion = libcamera_version + +summary({ + 'project': meson.project_version(), + 'sources': libcamera_git_version, + 'soname': libcamera_soversion, + }, + section : 'Versions') + # This script generates the .tarball-version file on a 'meson dist' command. meson.add_dist_script('utils/run-dist.sh') diff --git a/src/libcamera/base/meson.build b/src/libcamera/base/meson.build index 7a75914ab2a8..7a7fd7e4ca87 100644 --- a/src/libcamera/base/meson.build +++ b/src/libcamera/base/meson.build @@ -51,6 +51,7 @@ libcamera_base_args = [ '-DLIBCAMERA_BASE_PRIVATE' ] libcamera_base_lib = shared_library('libcamera-base', [libcamera_base_sources, libcamera_base_headers], version : libcamera_version, + soversion : libcamera_soversion, name_prefix : '', install : true, cpp_args : libcamera_base_args, diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build index 7fcbb2ddc9e7..5f39d2e2c60a 100644 --- a/src/libcamera/meson.build +++ b/src/libcamera/meson.build @@ -161,6 +161,7 @@ libcamera_deps = [ libcamera = shared_library('libcamera', libcamera_sources, version : libcamera_version, + soversion : libcamera_soversion, name_prefix : '', install : true, include_directories : includes, From patchwork Mon Oct 10 17:32:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 17575 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 06896C3286 for ; Mon, 10 Oct 2022 17:33:27 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B703C62D74; Mon, 10 Oct 2022 19:33:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1665423205; bh=iKF7hVX4aG4kN3XqEUDmcYAjFD9id9/C90oaFzXYYZU=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=aMqLz61FOAZk+Ct73VrGOgLvOY5Ik6MmKAc0o1pnHiWyuWtsXVFkTpjXmRB8mc0jX aV7mWPq/tqvp3mR9iPOxFjynegOa5YTAFqgu1WtdrwdGwx2fLIIKE8d1D2zJZ+VAla 9F7yWI4ddXtLnFTJgX0gTPwAbLvCrZS/K9ntuXDRtF23W5R+XCKfh1auWK/y1IO1Wx 1/Wht7yU46wYemRn6DoVvIRpO884DfdR3vxwWKlyuJKcTGU/T+EVt2KmWSCNN9emkI 3blsQ/lczr+dDrmd4qoPOQ1rmo7z+xTTeQUO1zjttoW82t9JSk7QR8xQoAE1yVANxq Fyp9KCM86ERJg== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id F194462272 for ; Mon, 10 Oct 2022 19:33:23 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="RYZNvFsw"; dkim-atps=neutral Received: from Monstersaurus.ksquared.org.uk.beta.tailscale.net (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 787E211C1; Mon, 10 Oct 2022 19:33:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1665423203; bh=iKF7hVX4aG4kN3XqEUDmcYAjFD9id9/C90oaFzXYYZU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RYZNvFsw5Juc0chw5FxriL2iaHHbFeSaLqMxp0InCyNK2ztcU2Cw2lsPsmADfxGMh mLoaAmZQT6M9BOAf+97H7jt/nwyyWd2C6ktIDo24t9zuzg76gFwAHpHoLCxEnNlmex OTatbcidf/fgZdC2Q2WBZ7QoN6qrno5ffgoQANA4= To: libcamera devel Date: Mon, 10 Oct 2022 18:32:12 +0100 Message-Id: <20221010173214.3547133-4-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221010173214.3547133-1-kieran.bingham@ideasonboard.com> References: <20221010173214.3547133-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 3/5] utils: semver: Add version helper 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: , X-Patchwork-Original-From: Kieran Bingham via libcamera-devel From: Kieran Bingham Reply-To: Kieran Bingham Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Provide the semver utility from [0] to make use of it with our versioning and release scripts. [0] https://github.com/fsaintjacques/semver-tool/commit/cac039e8b73bc6fdf2f328437ed40f52abf0d05a Reviewed-by: Laurent Pinchart Signed-off-by: Kieran Bingham Reviewed-by: Jacopo Mondi --- utils/semver | 419 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 419 insertions(+) create mode 100755 utils/semver diff --git a/utils/semver b/utils/semver new file mode 100755 index 000000000000..5b25f40ba48c --- /dev/null +++ b/utils/semver @@ -0,0 +1,419 @@ +#!/usr/bin/env bash + +set -o errexit -o nounset -o pipefail + +NAT='0|[1-9][0-9]*' +ALPHANUM='[0-9]*[A-Za-z-][0-9A-Za-z-]*' +IDENT="$NAT|$ALPHANUM" +FIELD='[0-9A-Za-z-]+' + +SEMVER_REGEX="\ +^[vV]?\ +($NAT)\\.($NAT)\\.($NAT)\ +(\\-(${IDENT})(\\.(${IDENT}))*)?\ +(\\+${FIELD}(\\.${FIELD})*)?$" + +PROG=semver +PROG_VERSION="3.3.0" + +USAGE="\ +Usage: + $PROG bump (major|minor|patch|release|prerel []|build ) + $PROG compare + $PROG diff + $PROG get (major|minor|patch|release|prerel|build) + $PROG validate + $PROG --help + $PROG --version + +Arguments: + A version must match the following regular expression: + \"${SEMVER_REGEX}\" + In English: + -- The version must match X.Y.Z[-PRERELEASE][+BUILD] + where X, Y and Z are non-negative integers. + -- PRERELEASE is a dot separated sequence of non-negative integers and/or + identifiers composed of alphanumeric characters and hyphens (with + at least one non-digit). Numeric identifiers must not have leading + zeros. A hyphen (\"-\") introduces this optional part. + -- BUILD is a dot separated sequence of identifiers composed of alphanumeric + characters and hyphens. A plus (\"+\") introduces this optional part. + + See definition. + + A string as defined by PRERELEASE above. Or, it can be a PRERELEASE + prototype string (or empty) followed by a dot. + + A string as defined by BUILD above. + +Options: + -v, --version Print the version of this tool. + -h, --help Print this help message. + +Commands: + bump Bump by one of major, minor, patch; zeroing or removing + subsequent parts. \"bump prerel\" sets the PRERELEASE part and + removes any BUILD part. A trailing dot in the argument + introduces an incrementing numeric field which is added or + bumped. If no argument is provided, an incrementing numeric + field is introduced/bumped. \"bump build\" sets the BUILD part. + \"bump release\" removes any PRERELEASE or BUILD parts. + The bumped version is written to stdout. + + compare Compare with , output to stdout the + following values: -1 if is newer, 0 if equal, 1 if + older. The BUILD part is not used in comparisons. + + diff Compare with , output to stdout the + difference between two versions by the release type (MAJOR, MINOR, + PATCH, PRERELEASE, BUILD). + + get Extract given part of , where part is one of major, minor, + patch, prerel, build, or release. + + validate Validate if follows the SEMVER pattern (see + definition). Print 'valid' to stdout if the version is valid, otherwise + print 'invalid'. + +See also: + https://semver.org -- Semantic Versioning 2.0.0" + +function error { + echo -e "$1" >&2 + exit 1 +} + +function usage_help { + error "$USAGE" +} + +function usage_version { + echo -e "${PROG}: $PROG_VERSION" + exit 0 +} + +function validate_version { + local version=$1 + if [[ "$version" =~ $SEMVER_REGEX ]]; then + # if a second argument is passed, store the result in var named by $2 + if [ "$#" -eq "2" ]; then + local major=${BASH_REMATCH[1]} + local minor=${BASH_REMATCH[2]} + local patch=${BASH_REMATCH[3]} + local prere=${BASH_REMATCH[4]} + local build=${BASH_REMATCH[8]} + eval "$2=(\"$major\" \"$minor\" \"$patch\" \"$prere\" \"$build\")" + else + echo "$version" + fi + else + error "version $version does not match the semver scheme 'X.Y.Z(-PRERELEASE)(+BUILD)'. See help for more information." + fi +} + +function is_nat { + [[ "$1" =~ ^($NAT)$ ]] +} + +function is_null { + [ -z "$1" ] +} + +function order_nat { + [ "$1" -lt "$2" ] && { echo -1 ; return ; } + [ "$1" -gt "$2" ] && { echo 1 ; return ; } + echo 0 +} + +function order_string { + [[ $1 < $2 ]] && { echo -1 ; return ; } + [[ $1 > $2 ]] && { echo 1 ; return ; } + echo 0 +} + +# given two (named) arrays containing NAT and/or ALPHANUM fields, compare them +# one by one according to semver 2.0.0 spec. Return -1, 0, 1 if left array ($1) +# is less-than, equal, or greater-than the right array ($2). The longer array +# is considered greater-than the shorter if the shorter is a prefix of the longer. +# +function compare_fields { + local l="$1[@]" + local r="$2[@]" + local leftfield=( "${!l}" ) + local rightfield=( "${!r}" ) + local left + local right + + local i=$(( -1 )) + local order=$(( 0 )) + + while true + do + [ $order -ne 0 ] && { echo $order ; return ; } + + : $(( i++ )) + left="${leftfield[$i]}" + right="${rightfield[$i]}" + + is_null "$left" && is_null "$right" && { echo 0 ; return ; } + is_null "$left" && { echo -1 ; return ; } + is_null "$right" && { echo 1 ; return ; } + + is_nat "$left" && is_nat "$right" && { order=$(order_nat "$left" "$right") ; continue ; } + is_nat "$left" && { echo -1 ; return ; } + is_nat "$right" && { echo 1 ; return ; } + { order=$(order_string "$left" "$right") ; continue ; } + done +} + +# shellcheck disable=SC2206 # checked by "validate"; ok to expand prerel id's into array +function compare_version { + local order + validate_version "$1" V + validate_version "$2" V_ + + # compare major, minor, patch + + local left=( "${V[0]}" "${V[1]}" "${V[2]}" ) + local right=( "${V_[0]}" "${V_[1]}" "${V_[2]}" ) + + order=$(compare_fields left right) + [ "$order" -ne 0 ] && { echo "$order" ; return ; } + + # compare pre-release ids when M.m.p are equal + + local prerel="${V[3]:1}" + local prerel_="${V_[3]:1}" + local left=( ${prerel//./ } ) + local right=( ${prerel_//./ } ) + + # if left and right have no pre-release part, then left equals right + # if only one of left/right has pre-release part, that one is less than simple M.m.p + + [ -z "$prerel" ] && [ -z "$prerel_" ] && { echo 0 ; return ; } + [ -z "$prerel" ] && { echo 1 ; return ; } + [ -z "$prerel_" ] && { echo -1 ; return ; } + + # otherwise, compare the pre-release id's + + compare_fields left right +} + +# render_prerel -- return a prerel field with a trailing numeric string +# usage: render_prerel numeric [prefix-string] +# +function render_prerel { + if [ -z "$2" ] + then + echo "${1}" + else + echo "${2}${1}" + fi +} + +# extract_prerel -- extract prefix and trailing numeric portions of a pre-release part +# usage: extract_prerel prerel prerel_parts +# The prefix and trailing numeric parts are returned in "prerel_parts". +# +PREFIX_ALPHANUM='[.0-9A-Za-z-]*[.A-Za-z-]' +DIGITS='[0-9][0-9]*' +EXTRACT_REGEX="^(${PREFIX_ALPHANUM})*(${DIGITS})$" + +function extract_prerel { + local prefix; local numeric; + + if [[ "$1" =~ $EXTRACT_REGEX ]] + then # found prefix and trailing numeric parts + prefix="${BASH_REMATCH[1]}" + numeric="${BASH_REMATCH[2]}" + else # no numeric part + prefix="${1}" + numeric= + fi + + eval "$2=(\"$prefix\" \"$numeric\")" +} + +# bump_prerel -- return the new pre-release part based on previous pre-release part +# and prototype for bump +# usage: bump_prerel proto previous +# +function bump_prerel { + local proto; local prev_prefix; local prev_numeric; + + # case one: no trailing dot in prototype => simply replace previous with proto + if [[ ! ( "$1" =~ \.$ ) ]] + then + echo "$1" + return + fi + + proto="${1%.}" # discard trailing dot marker from prototype + + extract_prerel "${2#-}" prerel_parts # extract parts of previous pre-release +# shellcheck disable=SC2154 + prev_prefix="${prerel_parts[0]}" + prev_numeric="${prerel_parts[1]}" + + # case two: bump or append numeric to previous pre-release part + if [ "$proto" == "+" ] # dummy "+" indicates no prototype argument provided + then + if [ -n "$prev_numeric" ] + then + : $(( ++prev_numeric )) # previous pre-release is already numbered, bump it + render_prerel "$prev_numeric" "$prev_prefix" + else + render_prerel 1 "$prev_prefix" # append starting number + fi + return + fi + + # case three: set, bump, or append using prototype prefix + if [ "$prev_prefix" != "$proto" ] + then + render_prerel 1 "$proto" # proto not same pre-release; set and start at '1' + elif [ -n "$prev_numeric" ] + then + : $(( ++prev_numeric )) # pre-release is numbered; bump it + render_prerel "$prev_numeric" "$prev_prefix" + else + render_prerel 1 "$prev_prefix" # start pre-release at number '1' + fi +} + +function command_bump { + local new; local version; local sub_version; local command; + + case $# in + 2) case $1 in + major|minor|patch|prerel|release) command=$1; sub_version="+."; version=$2;; + *) usage_help;; + esac ;; + 3) case $1 in + prerel|build) command=$1; sub_version=$2 version=$3 ;; + *) usage_help;; + esac ;; + *) usage_help;; + esac + + validate_version "$version" parts + # shellcheck disable=SC2154 + local major="${parts[0]}" + local minor="${parts[1]}" + local patch="${parts[2]}" + local prere="${parts[3]}" + local build="${parts[4]}" + + case "$command" in + major) new="$((major + 1)).0.0";; + minor) new="${major}.$((minor + 1)).0";; + patch) new="${major}.${minor}.$((patch + 1))";; + release) new="${major}.${minor}.${patch}";; + prerel) new=$(validate_version "${major}.${minor}.${patch}-$(bump_prerel "$sub_version" "$prere")");; + build) new=$(validate_version "${major}.${minor}.${patch}${prere}+${sub_version}");; + *) usage_help ;; + esac + + echo "$new" + exit 0 +} + +function command_compare { + local v; local v_; + + case $# in + 2) v=$(validate_version "$1"); v_=$(validate_version "$2") ;; + *) usage_help ;; + esac + + set +u # need unset array element to evaluate to null + compare_version "$v" "$v_" + exit 0 +} + +function command_diff { + validate_version "$1" v1_parts + # shellcheck disable=SC2154 + local v1_major="${v1_parts[0]}" + local v1_minor="${v1_parts[1]}" + local v1_patch="${v1_parts[2]}" + local v1_prere="${v1_parts[3]}" + local v1_build="${v1_parts[4]}" + + validate_version "$2" v2_parts + # shellcheck disable=SC2154 + local v2_major="${v2_parts[0]}" + local v2_minor="${v2_parts[1]}" + local v2_patch="${v2_parts[2]}" + local v2_prere="${v2_parts[3]}" + local v2_build="${v2_parts[4]}" + + if [ "${v1_major}" != "${v2_major}" ]; then + echo "major" + elif [ "${v1_minor}" != "${v2_minor}" ]; then + echo "minor" + elif [ "${v1_patch}" != "${v2_patch}" ]; then + echo "patch" + elif [ "${v1_prere}" != "${v2_prere}" ]; then + echo "prerelease" + elif [ "${v1_build}" != "${v2_build}" ]; then + echo "build" + fi +} + +# shellcheck disable=SC2034 +function command_get { + local part version + + if [[ "$#" -ne "2" ]] || [[ -z "$1" ]] || [[ -z "$2" ]]; then + usage_help + exit 0 + fi + + part="$1" + version="$2" + + validate_version "$version" parts + local major="${parts[0]}" + local minor="${parts[1]}" + local patch="${parts[2]}" + local prerel="${parts[3]:1}" + local build="${parts[4]:1}" + local release="${major}.${minor}.${patch}" + + case "$part" in + major|minor|patch|release|prerel|build) echo "${!part}" ;; + *) usage_help ;; + esac + + exit 0 +} + +function command_validate { + if [[ "$#" -ne "1" ]]; then + usage_help + fi + + if [[ "$1" =~ $SEMVER_REGEX ]]; then + echo "valid" + else + echo "invalid" + fi + + exit 0 +} + +case $# in + 0) echo "Unknown command: $*"; usage_help;; +esac + +case $1 in + --help|-h) echo -e "$USAGE"; exit 0;; + --version|-v) usage_version ;; + bump) shift; command_bump "$@";; + get) shift; command_get "$@";; + compare) shift; command_compare "$@";; + diff) shift; command_diff "$@";; + validate) shift; command_validate "$@";; + *) echo "Unknown arguments: $*"; usage_help;; +esac From patchwork Mon Oct 10 17:32:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 17576 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 161A8C0DA4 for ; Mon, 10 Oct 2022 17:33:29 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BFC0662D7E; Mon, 10 Oct 2022 19:33:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1665423208; bh=55MOMCzDFs2miad2G/Ve2cFOS/FFluePc6sLCG7JaOw=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=NXdvt7tmyuxBojPdybLSKz+CmowB/Awg+WjKxYgZDSW5iA2tR6ivvt3quI36BvCNN bm6SJVuRcddae1HdY8D8rdxyNVDbUMoofTa6JaJgU/7GJKfKEUAT23SDUSQ8/scl23 zTWRe5G9aTMPz7jQSXe2LVLWhdM1fyV9BcRFRYHgygfEBeOjPbge3bNZWGf0HqCXDd iracI86+1fmYKFmOmctRMtSvE4K0hO2a4W7QVI8vrUykjCqXUBH/A1ADGjqSWLSv/I Zm5x4GzC6vVQrQ0rfCTS9Sax5gPRfiuZ6+nw/A9XrOtBCZZrCa8Nn8Li9fIQKdmRue Y2dqGztfJYsAA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 534FA62D68 for ; Mon, 10 Oct 2022 19:33:24 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="KPDYTri/"; dkim-atps=neutral Received: from Monstersaurus.ksquared.org.uk.beta.tailscale.net (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id CBFA8E3A; Mon, 10 Oct 2022 19:33:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1665423204; bh=55MOMCzDFs2miad2G/Ve2cFOS/FFluePc6sLCG7JaOw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KPDYTri/nfpsVox5zjot4hQpS2EadLZ65qwvKoJ1psiW7O2w9Pac78G5wnCWHfmit z7OXzd9fqIyJ1zav8WcUVRU5YB9pdHkuCxKmgUg+pPz7QzE7LdB30aWjzgEBBrD+eV 13bNgqj22QA3EgiaWN6VkD3X86TWgJ/YBg+yiK8w= To: libcamera devel Date: Mon, 10 Oct 2022 18:32:13 +0100 Message-Id: <20221010173214.3547133-5-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221010173214.3547133-1-kieran.bingham@ideasonboard.com> References: <20221010173214.3547133-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 4/5] utils: semver: Document licence and source 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: , X-Patchwork-Original-From: Kieran Bingham via libcamera-devel From: Kieran Bingham Reply-To: Kieran Bingham Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add the SPDX header, and a reference to the upstream source for this helper script. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart Reviewed-by: Jacopo Mondi --- v3: - Match upstream proposal for SPDX header. - Remove reference to upstream source. Signed-off-by: Kieran Bingham --- utils/semver | 1 + 1 file changed, 1 insertion(+) diff --git a/utils/semver b/utils/semver index 5b25f40ba48c..ee16087335e5 100755 --- a/utils/semver +++ b/utils/semver @@ -1,4 +1,5 @@ #!/usr/bin/env bash +# SPDX-License-Identifier: Apache-2.0 set -o errexit -o nounset -o pipefail From patchwork Mon Oct 10 17:32:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 17577 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 906FCC3287 for ; Mon, 10 Oct 2022 17:33:29 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 4943D62D77; Mon, 10 Oct 2022 19:33:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1665423209; bh=IZrxl9jbE6qf0uXqz/uMRLuoPIyzIBAZmJ+Q1Ninstk=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=FA2G2cxNWLSmT49BXNyJFNEz+ANC7Yhw0Pt9LjFHSsAWZ0asA413GN88TK/VeU+u/ lschx8JAnNaTypdi3KlK8GIGUVEENmmlfEwIM4xgzyoZcJg3+4UM7TtHwOfokg8lJ+ s5pwF6AAu/aiattx2926yPA/CM+obPXuXd4gYkmnNxJYWrD6JTw6E0cozs0sMlWIuF vj/yUTvqCfdAmF2nLzqBmYuqQnbCFByED2Pq5DYBRLBa6XqPdpiK4qY5fL3m0cecFp WNtn83YqgK9EJbW3ffM1+dump8ucNcSKLTl/3fX+qhV7lYKIR54BqXHn0bScILpNZD ++urbsLtqGaaw== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A101E62D72 for ; Mon, 10 Oct 2022 19:33:24 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="rLVCpJ2M"; dkim-atps=neutral Received: from Monstersaurus.ksquared.org.uk.beta.tailscale.net (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 376DBBB0; Mon, 10 Oct 2022 19:33:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1665423204; bh=IZrxl9jbE6qf0uXqz/uMRLuoPIyzIBAZmJ+Q1Ninstk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rLVCpJ2MUshl2G8Ht28z5U4vVehahh4hHg1K/YPePE+6xsLQWdSQ/4TXvp2E3qWCw 077UlG8keGA9DHfLBpUlsTv2yRi5BBKFoJUtmzPEJsOBIBk/DnNPRvobh6lkoK7IVV FbSK42VUW9T6nZHfzRL57J8P8Fis30lFmxXPBEJM= To: libcamera devel Date: Mon, 10 Oct 2022 18:32:14 +0100 Message-Id: <20221010173214.3547133-6-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221010173214.3547133-1-kieran.bingham@ideasonboard.com> References: <20221010173214.3547133-1-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 5/5] utils: Provide a release script 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: , X-Patchwork-Original-From: Kieran Bingham via libcamera-devel From: Kieran Bingham Reply-To: Kieran Bingham Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Support making releases of libcamera by introducing a helper script which will facilitate the increment of any release version, along with generating an associated tag. Reviewed-by: Jacopo Mondi Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- v3 - Improve error message - Remove redundant git add Signed-off-by: Kieran Bingham --- utils/release.sh | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100755 utils/release.sh diff --git a/utils/release.sh b/utils/release.sh new file mode 100755 index 000000000000..14d62aa6005f --- /dev/null +++ b/utils/release.sh @@ -0,0 +1,44 @@ +#!/bin/sh + +# SPDX-License-Identifier: GPL-2.0-or-later +# Prepare a project release + +# Abort if we are not within the project root or the tree is not clean. +if [ ! -e utils/gen-version.sh ] || [ ! -e .git ]; then + echo "This release script must be run from the root of libcamera git tree." + exit 1 +fi + +if ! git diff-index --quiet HEAD; then + echo "Tree must be clean to release." + exit 1 +fi + +# Identify current version components +version=$(./utils/gen-version.sh) + +# Decide if we are here to bump major, minor, or patch release. +case $1 in + major|minor|patch) + bump=$1; + ;; + *) + echo "You must specify the version bump level: (major, minor, patch)" + exit 1 + ;; +esac + +new_version=$(./utils/semver bump "$bump" "$version") + +echo "Bumping $bump" +echo " Existing version is: $version" +echo " New version is : $new_version" + +# Patch in the version to our meson.build +sed -i -E "s/ version : '.*',/ version : '$new_version',/" meson.build + +# Commit the update +git commit meson.build -sm "libcamera v$new_version" + +# Create a tag +git tag "v$new_version" -asm "libcamera v$new_version"