#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
#
# This scripts adds local version information from the version
# control systems git, mercurial (hg) and subversion (svn).
#
# If something goes wrong, send a mail the kernel build mailinglist
# (see MAINTAINERS) and CC Nico Schottelius
# <nico-linuxsetlocalversion -at- schottelius.org>.
#
#

usage() {
	echo "Usage: $0 [--save-scmversion] [srctree] [branch] [kmi-generation]" >&2
	exit 1
}

scm_only=false
srctree=.
android_release=
kmi_generation=
if test "$1" = "--save-scmversion"; then
	scm_only=true
	shift
fi
if test $# -gt 0; then
	srctree=$1
	shift
fi
if test $# -gt 0; then
	# Extract the Android release version. If there is no match, then return 255
	# and clear the var $android_release
	android_release=`echo "$1" | sed -e '/android[0-9]\{2,\}/!{q255}; \
		s/^\(android[0-9]\{2,\}\)-.*/\1/'`
	if test $? -ne 0; then
		android_release=
	fi
	shift

	if test $# -gt 0; then
		kmi_generation=$1
		[ $(expr $kmi_generation : '^[0-9]\+$') -eq 0 ] && usage
		shift
	fi
fi
if test $# -gt 0 -o ! -d "$srctree"; then
	usage
fi

scm_version()
{
	local short
	short=false

	cd "$srctree"
	if test -e .scmversion; then
		cat .scmversion
		return
	fi
	if test "$1" = "--short"; then
		short=true
	fi

	# Check for git and a git repo.
	if head=$(git rev-parse --verify HEAD 2>/dev/null); then

		if [ -n "$android_release" ] && [ -n "$kmi_generation" ]; then
			printf '%s' "-$android_release-$kmi_generation"
		elif [ -n "$android_release" ]; then
			printf '%s' "-$android_release"
		fi

		# If we are at a tagged commit (like "v2.6.30-rc6"), we ignore
		# it, because this version is defined in the top level Makefile.
		if [ -z "$(git describe --exact-match 2>/dev/null)" ]; then

			# If only the short version is requested, don't bother
			# running further git commands
			if $short; then
				echo "+"
				return
			fi
			# If we are past a tagged commit (like
			# "v2.6.30-rc5-302-g72357d5"), we pretty print it.
			#
			# Ensure the abbreviated sha1 has exactly 12
			# hex characters, to make the output
			# independent of git version, local
			# core.abbrev settings and/or total number of
			# objects in the current repository - passing
			# --abbrev=12 ensures a minimum of 12, and the
			# awk substr() then picks the 'g' and first 12
			# hex chars.
			if atag="$(git describe --abbrev=12 2>/dev/null)"; then
				echo "$atag" | awk -F- '{printf("-%05d-%s", $(NF-1),substr($(NF),0,13))}'

			# If we don't have a tag at all we print -g{commitish},
			# again using exactly 12 hex chars.
			else
				head="$(echo $head | cut -c1-12)"
				printf '%s%s' -g $head
			fi
		fi

		# Is this git on svn?
		if git config --get svn-remote.svn.url >/dev/null; then
			printf -- '-svn%s' "$(git svn find-rev $head)"
		fi

		# Check for uncommitted changes.
		# First, with git-status, but --no-optional-locks is only
		# supported in git >= 2.14, so fall back to git-diff-index if
		# it fails. Note that git-diff-index does not refresh the
		# index, so it may give misleading results. See
		# git-update-index(1), git-diff-index(1), and git-status(1).
		if {
			git --no-optional-locks status -uno --porcelain 2>/dev/null ||
			git diff-index --name-only HEAD
		} | grep -qvE '^(.. )?scripts/package'; then
			printf '%s' -dirty
		fi

		# All done with git
		return
	fi

	# Check for mercurial and a mercurial repo.
	if hgid=$(hg id 2>/dev/null); then
		# Do we have an tagged version?  If so, latesttagdistance == 1
		if [ "$(hg log -r . --template '{latesttagdistance}')" = "1" ]; then
			id=$(hg log -r . --template '{latesttag}')
			printf '%s%s' -hg "$id"
		else
			tag=$(printf '%s' "$hgid" | cut -d' ' -f2)
			if [ -z "$tag" -o "$tag" = tip ]; then
				id=$(printf '%s' "$hgid" | sed 's/[+ ].*//')
				printf '%s%s' -hg "$id"
			fi
		fi

		# Are there uncommitted changes?
		# These are represented by + after the changeset id.
		case "$hgid" in
			*+|*+\ *) printf '%s' -dirty ;;
		esac

		# All done with mercurial
		return
	fi

	# Check for svn and a svn repo.
	if rev=$(LANG= LC_ALL= LC_MESSAGES=C svn info 2>/dev/null | grep '^Last Changed Rev'); then
		rev=$(echo $rev | awk '{print $NF}')
		printf -- '-svn%s' "$rev"

		# All done with svn
		return
	fi
}

collect_files()
{
	local file res=

	for file; do
		case "$file" in
		*\~*)
			continue
			;;
		esac
		if test -e "$file"; then
			res="$res$(cat "$file")"
		fi
	done
	echo "$res"
}

if $scm_only; then
	if test ! -e .scmversion; then
		res=$(scm_version)
		echo "$res" >.scmversion
	fi
	exit
fi

if test -e include/config/auto.conf; then
	. include/config/auto.conf
else
	echo "Error: kernelrelease not valid - run 'make prepare' to update it" >&2
	exit 1
fi

# localversion* files in the build and source directory
res="$(collect_files localversion*)"
if test ! "$srctree" -ef .; then
	res="$res$(collect_files "$srctree"/localversion*)"
fi

# CONFIG_LOCALVERSION and LOCALVERSION (if set)
res="${res}${CONFIG_LOCALVERSION}${LOCALVERSION}"

# scm version string if not at a tagged commit
if test "$CONFIG_LOCALVERSION_AUTO" = "y"; then
	# full scm version string
	res="$res$(scm_version)"
else
	# append a plus sign if the repository is not in a clean
	# annotated or signed tagged state (as git describe only
	# looks at signed or annotated tags - git tag -a/-s) and
	# LOCALVERSION= is not specified
	if test "${LOCALVERSION+set}" != "set"; then
		scm=$(scm_version --short)
		res="$res${scm:++}"
	fi
fi

# finally, add the abXXX number if BUILD_NUMBER is set
if test -n "${BUILD_NUMBER}"; then
	res="$res-ab${BUILD_NUMBER}"
fi

echo "$res"
