#!/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
	else
		usage
	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 test -z "$(git rev-parse --show-cdup 2>/dev/null)" &&
	   head=$(git rev-parse --verify HEAD 2>/dev/null); then

		if [ -n "$android_release" ] && [ -n "$kmi_generation" ]; then
			printf '%s' "-$android_release-$kmi_generation"
		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 test -d .hg && 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

echo "$res"
