Browse Source

Setting of version variable now works if project added as a git submodule

- Issue: #MEN-3475

Changelog: Title

Signed-off-by: Dell Green <dell.green@ideaworks.co.uk>
2.1.x
Dell Green 5 years ago
parent
commit
726f5f03f4
  1. 6
      docker-mender-convert
  2. 8
      mender-convert
  3. 22
      modules/git.sh

6
docker-mender-convert

@ -16,10 +16,15 @@
set -e
. modules/git.sh
IMAGE_NAME=${IMAGE_NAME:-mender-convert}
MENDER_CONVERT_DIR="$(pwd)"
#Pass in version in-case we are added as a git submodule
MENDER_CONVERT_VERSION=$(git_mender_convert_version)
docker run \
--rm \
-v $MENDER_CONVERT_DIR:/mender-convert \
@ -28,4 +33,5 @@ docker run \
-v /dev:/dev \
-v /lib/modules:/lib/modules:ro \
--env MENDER_ARTIFACT_NAME=${MENDER_ARTIFACT_NAME} \
--env MENDER_CONVERT_VERSION=${MENDER_CONVERT_VERSION} \
$IMAGE_NAME "$@"

8
mender-convert

@ -14,8 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
MENDER_CONVERT_VERSION=$(git describe --tags --dirty --exact-match 2>/dev/null || git rev-parse --short HEAD)
function show_help() {
cat << EOF
mender-convert
@ -60,6 +58,12 @@ function trap_term() {
trap trap_term INT TERM
trap trap_exit EXIT
source modules/git.sh
if [ -z "$MENDER_CONVERT_VERSION" ];then
MENDER_CONVERT_VERSION=$(git_mender_convert_version)
fi
# We only handle a selection of the arguments here, the rest are passed on
# to the sub-scripts.
while (("$#")); do

22
modules/git.sh

@ -0,0 +1,22 @@
#!/usr/bin/env bash
#
# Copyright 2019 Northern.tech AS
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Print the mender convert version
#
git_mender_convert_version() {
git describe --tags --dirty --exact-match 2>/dev/null || git rev-parse --short HEAD
}
Loading…
Cancel
Save