[{"id":2206,"web_url":"https://patchwork.libcamera.org/comment/2206/","msgid":"<c01dd0ad-1ce0-69c5-56ee-674b1a690117@ideasonboard.com>","date":"2019-07-10T20:32:31","subject":"Re: [libcamera-devel] [PATCH v2] libcamera: skip auto version\n\tgeneration when building for Chromium OS","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Hi Paul,\n\nOn 10/07/2019 15:23, Paul Elder wrote:\n> Commit b817bcec6b53 (\"libcamera: Auto generate version information\")\n> causes the build to fail in the Chromium OS build environment, because\n> git update-index tries to take a lock (ie. write) in the git repo that\n> is outside of the build directory.\n\nouch ...\n\n> The solution is to simply skip git update-index if we are building in\n> the Chromium OS build environment, and this decision is made if the\n> build directory is not a subdirectory of the source directory.\n\nThanks for looking into a fix,\n\nRunning shellcheck highlights a few improvements on this patch\n\n> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> ---\n> Changes in v2:\n> - add quotes around variable accessess, and the string matcher\n> - make the two path arguments to gen-version.sh required\n> - actually run gen-version.sh from the needed place in meson\n> \n>  meson.build               |  3 ++-\n>  src/libcamera/meson.build |  2 +-\n>  utils/gen-version.sh      | 14 +++++++++++---\n>  3 files changed, 14 insertions(+), 5 deletions(-)\n> \n> diff --git a/meson.build b/meson.build\n> index 8f3d0ce..99a3a80 100644\n> --- a/meson.build\n> +++ b/meson.build\n> @@ -15,7 +15,8 @@ project('libcamera', 'c', 'cpp',\n>  # git version tag, the build metadata (e.g. +211-c94a24f4) is omitted from\n>  # libcamera_git_version.\n>  libcamera_git_version = run_command('utils/gen-version.sh',\n> -                                    meson.source_root()).stdout().strip()\n> +                                    meson.source_root(),\n> +                                    meson.build_root()).stdout().strip()\n>  if libcamera_git_version == ''\n>      libcamera_git_version = meson.project_version()\n>  endif\n> diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\n> index 97ff86e..4c442b9 100644\n> --- a/src/libcamera/meson.build\n> +++ b/src/libcamera/meson.build\n> @@ -81,7 +81,7 @@ libcamera_sources += control_types_cpp\n>  \n>  gen_version = join_paths(meson.source_root(), 'utils', 'gen-version.sh')\n>  \n> -version_cpp = vcs_tag(command : [gen_version, meson.source_root()],\n> +version_cpp = vcs_tag(command : [gen_version, meson.source_root(), meson.build_root()],\n>                        input : 'version.cpp.in',\n>                        output : 'version.cpp',\n>                        fallback : meson.project_version())\n> diff --git a/utils/gen-version.sh b/utils/gen-version.sh\n> index 708c01d..5005db9 100755\n> --- a/utils/gen-version.sh\n> +++ b/utils/gen-version.sh\n> @@ -3,11 +3,16 @@\n>  # SPDX-License-Identifier: GPL-2.0-or-later\n>  # Generate a version string using git describe\n>  \n> -if [ -n \"$1\" ]\n> +src_dir=\"$1\"\n> +build_dir=\"$2\"\n> +\n> +if [ -z \"$src_dir\" -o -z \"$build_dir\" ]\n\nShellcheck reports the following:\n\nIn utils/gen-version.sh line 9:\nif [ -z \"$src_dir\" -o -z \"$build_dir\" ]\n                   ^-- SC2166: Prefer [ p ] || [ q ] as [ p -o q ] is\nnot well defined.\n\nSo perhaps this line could be:\n\n if [ -z \"$src_dir\" ] || [ -z \"$build_dir\" ]\n\n>  then\n> -\tcd \"$1\" 2>/dev/null || exit 1\n> +\texit\n>  fi\n\nIt's a shame that we can't just run the command from the source tree any\nmore to get the output, but as that's just really for testing and\ndevelopment, that's not a real issue.\n\n\n\n>  \n> +cd \"$src_dir\" 2>/dev/null || exit 1\n> +\n>  # Bail out if the directory isn't under git control\n>  git rev-parse --git-dir >/dev/null 2>&1 || exit 1\n>  \n> @@ -24,7 +29,10 @@ fi\n>  \n>  # Append a '-dirty' suffix if the working tree is dirty. Prevent false\n>  # positives due to changed timestamps by running git update-index.\n> -git update-index --refresh > /dev/null 2>&1\n> +if [ -n \"$(echo \"$build_dir\" | grep \"$src_dir\")\" ]\n\nShellcheck reports:\n\nIn utils/gen-version.sh line 32:\nif [ -n \"$(echo \"$build_dir\" | grep \"$src_dir\")\" ]\n     ^-- SC2143: Use grep -q instead of comparing output with [ -n .. ].\n\nPerhaps this line could be:\n\n if (echo \"$build_dir\" | grep -vq \"$src_dir\")\n\n\n\nWith shellcheck running cleanly on utils/gen-version.sh:\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n\n> +then\n> +\tgit update-index --refresh > /dev/null 2>&1\n> +fi\n>  git diff-index --quiet HEAD || version=\"$version-dirty\"\n>  \n>  # Replace first '-' with a '+' to denote build metadata, strip the 'g' in from\n>","headers":{"Return-Path":"<kieran.bingham@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id DE7B96156E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 10 Jul 2019 22:32:34 +0200 (CEST)","from [192.168.0.20]\n\t(cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 4ABEA31C;\n\tWed, 10 Jul 2019 22:32:34 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1562790754;\n\tbh=YpHI3ZiOnqgZFrG+8dD/3Qb9v2cNDUp7eCmjLRXhEsM=;\n\th=Reply-To:Subject:To:References:From:Date:In-Reply-To:From;\n\tb=EmnFPybwC3UMwg1Pb0zcpPyOzdgfp0et+PvQXLin18s1z3eFfH5UkXGKbK5UHd9ni\n\tR5owC05o+9UuvEVhmZfWBIYVe7iddSobNlewzBkf0r5IN0d1S8PCjS2xHDvmEQhOsl\n\tIbexc+YFMzyGrPfN9Pz8JNHUBs/M2QVQEac9d8j0=","Reply-To":"kieran.bingham@ideasonboard.com","To":"Paul Elder <paul.elder@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20190710142301.16340-1-paul.elder@ideasonboard.com>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","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QqF9drZuw=","Organization":"Ideas on Board","Message-ID":"<c01dd0ad-1ce0-69c5-56ee-674b1a690117@ideasonboard.com>","Date":"Wed, 10 Jul 2019 21:32:31 +0100","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101\n\tThunderbird/60.7.2","MIME-Version":"1.0","In-Reply-To":"<20190710142301.16340-1-paul.elder@ideasonboard.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-GB","Content-Transfer-Encoding":"8bit","Subject":"Re: [libcamera-devel] [PATCH v2] libcamera: skip auto version\n\tgeneration when building for Chromium OS","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Wed, 10 Jul 2019 20:32:35 -0000"}},{"id":2207,"web_url":"https://patchwork.libcamera.org/comment/2207/","msgid":"<20190711022317.GA5247@pendragon.ideasonboard.com>","date":"2019-07-11T02:23:17","subject":"Re: [libcamera-devel] [PATCH v2] libcamera: skip auto version\n\tgeneration when building for Chromium OS","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Kieran,\n\nOn Wed, Jul 10, 2019 at 09:32:31PM +0100, Kieran Bingham wrote:\n> On 10/07/2019 15:23, Paul Elder wrote:\n> > Commit b817bcec6b53 (\"libcamera: Auto generate version information\")\n> > causes the build to fail in the Chromium OS build environment, because\n> > git update-index tries to take a lock (ie. write) in the git repo that\n> > is outside of the build directory.\n> \n> ouch ...\n> \n> > The solution is to simply skip git update-index if we are building in\n> > the Chromium OS build environment, and this decision is made if the\n> > build directory is not a subdirectory of the source directory.\n> \n> Thanks for looking into a fix,\n> \n> Running shellcheck highlights a few improvements on this patch\n> \n> > Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n> > ---\n> > Changes in v2:\n> > - add quotes around variable accessess, and the string matcher\n> > - make the two path arguments to gen-version.sh required\n> > - actually run gen-version.sh from the needed place in meson\n> > \n> >  meson.build               |  3 ++-\n> >  src/libcamera/meson.build |  2 +-\n> >  utils/gen-version.sh      | 14 +++++++++++---\n> >  3 files changed, 14 insertions(+), 5 deletions(-)\n> > \n> > diff --git a/meson.build b/meson.build\n> > index 8f3d0ce..99a3a80 100644\n> > --- a/meson.build\n> > +++ b/meson.build\n> > @@ -15,7 +15,8 @@ project('libcamera', 'c', 'cpp',\n> >  # git version tag, the build metadata (e.g. +211-c94a24f4) is omitted from\n> >  # libcamera_git_version.\n> >  libcamera_git_version = run_command('utils/gen-version.sh',\n> > -                                    meson.source_root()).stdout().strip()\n> > +                                    meson.source_root(),\n> > +                                    meson.build_root()).stdout().strip()\n> >  if libcamera_git_version == ''\n> >      libcamera_git_version = meson.project_version()\n> >  endif\n> > diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\n> > index 97ff86e..4c442b9 100644\n> > --- a/src/libcamera/meson.build\n> > +++ b/src/libcamera/meson.build\n> > @@ -81,7 +81,7 @@ libcamera_sources += control_types_cpp\n> >  \n> >  gen_version = join_paths(meson.source_root(), 'utils', 'gen-version.sh')\n> >  \n> > -version_cpp = vcs_tag(command : [gen_version, meson.source_root()],\n> > +version_cpp = vcs_tag(command : [gen_version, meson.source_root(), meson.build_root()],\n> >                        input : 'version.cpp.in',\n> >                        output : 'version.cpp',\n> >                        fallback : meson.project_version())\n> > diff --git a/utils/gen-version.sh b/utils/gen-version.sh\n> > index 708c01d..5005db9 100755\n> > --- a/utils/gen-version.sh\n> > +++ b/utils/gen-version.sh\n> > @@ -3,11 +3,16 @@\n> >  # SPDX-License-Identifier: GPL-2.0-or-later\n> >  # Generate a version string using git describe\n> >  \n> > -if [ -n \"$1\" ]\n> > +src_dir=\"$1\"\n> > +build_dir=\"$2\"\n> > +\n> > +if [ -z \"$src_dir\" -o -z \"$build_dir\" ]\n> \n> Shellcheck reports the following:\n> \n> In utils/gen-version.sh line 9:\n> if [ -z \"$src_dir\" -o -z \"$build_dir\" ]\n>                    ^-- SC2166: Prefer [ p ] || [ q ] as [ p -o q ] is\n> not well defined.\n> \n> So perhaps this line could be:\n> \n>  if [ -z \"$src_dir\" ] || [ -z \"$build_dir\" ]\n> \n> >  then\n> > -\tcd \"$1\" 2>/dev/null || exit 1\n> > +\texit\n> >  fi\n> \n> It's a shame that we can't just run the command from the source tree any\n> more to get the output, but as that's just really for testing and\n> development, that's not a real issue.\n\nWe could drop the src_dir argument as the script is always run from the\nsource directory by meson. Then we can make build_dir optional, as it's\nonly needed to skip git update-index.\n\n> > +cd \"$src_dir\" 2>/dev/null || exit 1\n> > +\n> >  # Bail out if the directory isn't under git control\n> >  git rev-parse --git-dir >/dev/null 2>&1 || exit 1\n> >  \n> > @@ -24,7 +29,10 @@ fi\n> >  \n> >  # Append a '-dirty' suffix if the working tree is dirty. Prevent false\n> >  # positives due to changed timestamps by running git update-index.\n> > -git update-index --refresh > /dev/null 2>&1\n> > +if [ -n \"$(echo \"$build_dir\" | grep \"$src_dir\")\" ]\n> \n> Shellcheck reports:\n> \n> In utils/gen-version.sh line 32:\n> if [ -n \"$(echo \"$build_dir\" | grep \"$src_dir\")\" ]\n>      ^-- SC2143: Use grep -q instead of comparing output with [ -n .. ].\n> \n> Perhaps this line could be:\n> \n>  if (echo \"$build_dir\" | grep -vq \"$src_dir\")\n\nWon't the ( ... ) create a subshell that prevents the status to be\nreported up ?\n\n> With shellcheck running cleanly on utils/gen-version.sh:\n> \n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> \n> > +then\n> > +\tgit update-index --refresh > /dev/null 2>&1\n> > +fi\n> >  git diff-index --quiet HEAD || version=\"$version-dirty\"\n> >  \n> >  # Replace first '-' with a '+' to denote build metadata, strip the 'g' in from","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1AAD760E41\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 11 Jul 2019 04:23:46 +0200 (CEST)","from pendragon.ideasonboard.com (softbank126163157105.bbtec.net\n\t[126.163.157.105])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 618A531C;\n\tThu, 11 Jul 2019 04:23:43 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1562811825;\n\tbh=zeNgZ9DTPX7uucwDpPLT2RxHlRLNhu2UFGQjghnufGE=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=qXjSkwbMIHAlJzXqi1B5T3ChDM4BkmdggR/DKT647Sn+MJKq5z5zmqLkFT1ml1ySI\n\tRFcRcHwOal5cnYndlH2MDAEAizYDL0drZ6o3+nluVdtiCjqFhIfLJLGwNgDekWS+ao\n\t5KFmxxjX1Q1rJwzS2WL6mODOJ5jTexPM3neeyfeg=","Date":"Thu, 11 Jul 2019 05:23:17 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"Paul Elder <paul.elder@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Message-ID":"<20190711022317.GA5247@pendragon.ideasonboard.com>","References":"<20190710142301.16340-1-paul.elder@ideasonboard.com>\n\t<c01dd0ad-1ce0-69c5-56ee-674b1a690117@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<c01dd0ad-1ce0-69c5-56ee-674b1a690117@ideasonboard.com>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v2] libcamera: skip auto version\n\tgeneration when building for Chromium OS","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Thu, 11 Jul 2019 02:23:46 -0000"}},{"id":2223,"web_url":"https://patchwork.libcamera.org/comment/2223/","msgid":"<2361564a-2f26-5dea-81a3-760c92d43fd2@ideasonboard.com>","date":"2019-07-11T07:46:57","subject":"Re: [libcamera-devel] [PATCH v2] libcamera: skip auto version\n\tgeneration when building for Chromium OS","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Hi Laurent,\n\nOn 11/07/2019 03:23, Laurent Pinchart wrote:\n> Hi Kieran,\n> \n> On Wed, Jul 10, 2019 at 09:32:31PM +0100, Kieran Bingham wrote:\n>> On 10/07/2019 15:23, Paul Elder wrote:\n>>> Commit b817bcec6b53 (\"libcamera: Auto generate version information\")\n>>> causes the build to fail in the Chromium OS build environment, because\n>>> git update-index tries to take a lock (ie. write) in the git repo that\n>>> is outside of the build directory.\n>>\n>> ouch ...\n>>\n>>> The solution is to simply skip git update-index if we are building in\n>>> the Chromium OS build environment, and this decision is made if the\n>>> build directory is not a subdirectory of the source directory.\n>>\n>> Thanks for looking into a fix,\n>>\n>> Running shellcheck highlights a few improvements on this patch\n>>\n>>> Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>\n>>> ---\n>>> Changes in v2:\n>>> - add quotes around variable accessess, and the string matcher\n>>> - make the two path arguments to gen-version.sh required\n>>> - actually run gen-version.sh from the needed place in meson\n>>>\n>>>  meson.build               |  3 ++-\n>>>  src/libcamera/meson.build |  2 +-\n>>>  utils/gen-version.sh      | 14 +++++++++++---\n>>>  3 files changed, 14 insertions(+), 5 deletions(-)\n>>>\n>>> diff --git a/meson.build b/meson.build\n>>> index 8f3d0ce..99a3a80 100644\n>>> --- a/meson.build\n>>> +++ b/meson.build\n>>> @@ -15,7 +15,8 @@ project('libcamera', 'c', 'cpp',\n>>>  # git version tag, the build metadata (e.g. +211-c94a24f4) is omitted from\n>>>  # libcamera_git_version.\n>>>  libcamera_git_version = run_command('utils/gen-version.sh',\n>>> -                                    meson.source_root()).stdout().strip()\n>>> +                                    meson.source_root(),\n>>> +                                    meson.build_root()).stdout().strip()\n>>>  if libcamera_git_version == ''\n>>>      libcamera_git_version = meson.project_version()\n>>>  endif\n>>> diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build\n>>> index 97ff86e..4c442b9 100644\n>>> --- a/src/libcamera/meson.build\n>>> +++ b/src/libcamera/meson.build\n>>> @@ -81,7 +81,7 @@ libcamera_sources += control_types_cpp\n>>>  \n>>>  gen_version = join_paths(meson.source_root(), 'utils', 'gen-version.sh')\n>>>  \n>>> -version_cpp = vcs_tag(command : [gen_version, meson.source_root()],\n>>> +version_cpp = vcs_tag(command : [gen_version, meson.source_root(), meson.build_root()],\n>>>                        input : 'version.cpp.in',\n>>>                        output : 'version.cpp',\n>>>                        fallback : meson.project_version())\n>>> diff --git a/utils/gen-version.sh b/utils/gen-version.sh\n>>> index 708c01d..5005db9 100755\n>>> --- a/utils/gen-version.sh\n>>> +++ b/utils/gen-version.sh\n>>> @@ -3,11 +3,16 @@\n>>>  # SPDX-License-Identifier: GPL-2.0-or-later\n>>>  # Generate a version string using git describe\n>>>  \n>>> -if [ -n \"$1\" ]\n>>> +src_dir=\"$1\"\n>>> +build_dir=\"$2\"\n>>> +\n>>> +if [ -z \"$src_dir\" -o -z \"$build_dir\" ]\n>>\n>> Shellcheck reports the following:\n>>\n>> In utils/gen-version.sh line 9:\n>> if [ -z \"$src_dir\" -o -z \"$build_dir\" ]\n>>                    ^-- SC2166: Prefer [ p ] || [ q ] as [ p -o q ] is\n>> not well defined.\n>>\n>> So perhaps this line could be:\n>>\n>>  if [ -z \"$src_dir\" ] || [ -z \"$build_dir\" ]\n>>\n>>>  then\n>>> -\tcd \"$1\" 2>/dev/null || exit 1\n>>> +\texit\n>>>  fi\n>>\n>> It's a shame that we can't just run the command from the source tree any\n>> more to get the output, but as that's just really for testing and\n>> development, that's not a real issue.\n> \n> We could drop the src_dir argument as the script is always run from the\n> source directory by meson. Then we can make build_dir optional, as it's\n> only needed to skip git update-index.\n\nEither route is fine with me, I'm not worried about this part at the\nmoment. We're in control of the calling parameters at the points that we\nneed this.\n\n\n>>> +cd \"$src_dir\" 2>/dev/null || exit 1\n>>> +\n>>>  # Bail out if the directory isn't under git control\n>>>  git rev-parse --git-dir >/dev/null 2>&1 || exit 1\n>>>  \n>>> @@ -24,7 +29,10 @@ fi\n>>>  \n>>>  # Append a '-dirty' suffix if the working tree is dirty. Prevent false\n>>>  # positives due to changed timestamps by running git update-index.\n>>> -git update-index --refresh > /dev/null 2>&1\n>>> +if [ -n \"$(echo \"$build_dir\" | grep \"$src_dir\")\" ]\n>>\n>> Shellcheck reports:\n>>\n>> In utils/gen-version.sh line 32:\n>> if [ -n \"$(echo \"$build_dir\" | grep \"$src_dir\")\" ]\n>>      ^-- SC2143: Use grep -q instead of comparing output with [ -n .. ].\n>>\n>> Perhaps this line could be:\n>>\n>>  if (echo \"$build_dir\" | grep -vq \"$src_dir\")\n> \n> Won't the ( ... ) create a subshell that prevents the status to be\n> reported up ?\n\nThe subshell should return the status should it not?\n\nHere's a basic test to verify this:\n\n\n~~~~~~~~~~~~~ check-subshell.sh ~~~~~~~~~~~~~\nsrcdir=/path/to/src\nintreebuild=/path/to/src/build\nouttreebuild=/path/to/build\n\n# '-vq' is a quiet negated search.\n# True if needle is not found in haystack\n# (the logic our script wants)\nif (echo \"$outtreebuild\" | grep -vq \"$srcdir\");\nthen\n  echo \"OutOfTree\";\n  echo \"Test Pass\";\nelse\n  echo \"InTree\";\n  echo \"TEST FAIL\";\nfi\n\n\nif (echo \"$intreebuild\" | grep -vq \"$srcdir\");\nthen\n  echo \"OutOfTree\";\n  echo \"TEST FAIL\";\nelse\n  echo \"InTree\";\n  echo \"Test Pass\";\nfi\n~~~~~~~~~~~~~ check-subshell.sh ~~~~~~~~~~~~~\n\n\n$ /bin/bash ./check-subshell.sh\nOutOfTree\nTest Pass\nInTree\nTest Pass\n\n$ /bin/dash ./check-subshell.sh\nOutOfTree\nTest Pass\nInTree\nTest Pass\n\n\n\n\n\n> \n>> With shellcheck running cleanly on utils/gen-version.sh:\n>>\n>> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n>>\n>>> +then\n>>> +\tgit update-index --refresh > /dev/null 2>&1\n>>> +fi\n>>>  git diff-index --quiet HEAD || version=\"$version-dirty\"\n>>>  \n>>>  # Replace first '-' with a '+' to denote build metadata, strip the 'g' in from\n>","headers":{"Return-Path":"<kieran.bingham@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8B38961570\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 11 Jul 2019 09:47:00 +0200 (CEST)","from [192.168.0.20]\n\t(cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id DE0EE31C;\n\tThu, 11 Jul 2019 09:46:59 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1562831220;\n\tbh=hE7ditI8ES7M/2e3vW3Le3ldU3ws2aUa3chG0e0rPDA=;\n\th=Reply-To:Subject:To:Cc:References:From:Date:In-Reply-To:From;\n\tb=E3YUUR5uRTolAPG4SBXTVcujeg1hVrHCus88GqWA5jf3kdy3RoQNs0QaZmog6pc3n\n\tSh3EbeUUo9/r8G3Zzqoi6r+pqw4KoQfacoF8c/+enrG4ZcWX/DmvHCZKT1kkZ5w44e\n\tzacDq1zottQRHBzx9OIdU/ALqNif9PNkdwwayNmw=","Reply-To":"kieran.bingham@ideasonboard.com","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"Paul Elder <paul.elder@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20190710142301.16340-1-paul.elder@ideasonboard.com>\n\t<c01dd0ad-1ce0-69c5-56ee-674b1a690117@ideasonboard.com>\n\t<20190711022317.GA5247@pendragon.ideasonboard.com>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Openpgp":"preference=signencrypt","Autocrypt":"addr=kieran.bingham@ideasonboard.com; keydata=\n\tmQINBFYE/WYBEACs1PwjMD9rgCu1hlIiUA1AXR4rv2v+BCLUq//vrX5S5bjzxKAryRf0uHat\n\tV/zwz6hiDrZuHUACDB7X8OaQcwhLaVlq6byfoBr25+hbZG7G3+5EUl9cQ7dQEdvNj6V6y/SC\n\trRanWfelwQThCHckbobWiQJfK9n7rYNcPMq9B8e9F020LFH7Kj6YmO95ewJGgLm+idg1Kb3C\n\tpotzWkXc1xmPzcQ1fvQMOfMwdS+4SNw4rY9f07Xb2K99rjMwZVDgESKIzhsDB5GY465sCsiQ\n\tcSAZRxqE49RTBq2+EQsbrQpIc8XiffAB8qexh5/QPzCmR4kJgCGeHIXBtgRj+nIkCJPZvZtf\n\tKr2EAbc6tgg6DkAEHJb+1okosV09+0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pcar6g5m4xGqa+Xfzi9tRkwC29KMCoQOag1BhHChgqYaUH3yo\n\tUzaPwT/fY75iVI+yD0ih/e6j8qYvP8pvGwMQfrmN9YB0zB39YzCSdaUaNrWGD3iCBxg6lwSO\n\tLKeRhxxfiXCIYEf3vwOsP3YMx2JkD5doseXmWBGW1U0T/oJF+DVfKB6mv5UfsTzpVhJRgee7\n\t4jkjqFq4qsUGxcvF2xtRkfHFpZDbRgRlVmiWkqDkT4qMA+4q1y/dWwshSKi/uwVZNycuLsz+\n\t+OD8xPNCsMTqeUkAKfbD8xW4LCay3r/dD2ckoxRxtMD9eOAyu5wYzo/ydIPTh1QEj9SYyvp8\n\tO0g6CpxEwyHUQtF5oh15O018z3ZLztFJKR3RD42VKVsrnNDKnoY0f4U0z7eJv2NeF8xHMuiU\n\tRCIzqxX1GVYaNkKTnb/Qja8hnYnkUzY1Lc+OtwiGmXTwYsPZjjAaDX35J/RSKAoy5wGo/YFA\n\tJxB1gWThL4kOTbsqqXj9GLcyOImkW0lJGGR3o/fV91Zh63S5TKnf2YGGGzxki+ADdxVQAm+Q\n\tsbsRB8KNNvVXBOVNwko86rQqF9drZuw=","Organization":"Ideas on Board","Message-ID":"<2361564a-2f26-5dea-81a3-760c92d43fd2@ideasonboard.com>","Date":"Thu, 11 Jul 2019 08:46:57 +0100","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101\n\tThunderbird/60.7.2","MIME-Version":"1.0","In-Reply-To":"<20190711022317.GA5247@pendragon.ideasonboard.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-GB","Content-Transfer-Encoding":"8bit","Subject":"Re: [libcamera-devel] [PATCH v2] libcamera: skip auto version\n\tgeneration when building for Chromium OS","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","X-List-Received-Date":"Thu, 11 Jul 2019 07:47:00 -0000"}}]