setlocalversion (a23e1966932464e1c5226cb9ac4ce1d5fc10ba22) | setlocalversion (523f3dbc187a9618d4fd80c2b438e4d490705dcd) |
---|---|
1#!/bin/sh 2# SPDX-License-Identifier: GPL-2.0 3# 4# This scripts adds local version information from the version 5# control system git. 6# 7# If something goes wrong, send a mail the kernel build mailinglist 8# (see MAINTAINERS) and CC Nico Schottelius --- 16 unchanged lines hidden (view full) --- 25if test $# -gt 0; then 26 srctree=$1 27 shift 28fi 29if test $# -gt 0 -o ! -d "$srctree"; then 30 usage 31fi 32 | 1#!/bin/sh 2# SPDX-License-Identifier: GPL-2.0 3# 4# This scripts adds local version information from the version 5# control system git. 6# 7# If something goes wrong, send a mail the kernel build mailinglist 8# (see MAINTAINERS) and CC Nico Schottelius --- 16 unchanged lines hidden (view full) --- 25if test $# -gt 0; then 26 srctree=$1 27 shift 28fi 29if test $# -gt 0 -o ! -d "$srctree"; then 30 usage 31fi 32 |
33try_tag() { 34 tag="$1" 35 36 # Is $tag an annotated tag? 37 [ "$(git cat-file -t "$tag" 2> /dev/null)" = tag ] || return 1 38 39 # Is it an ancestor of HEAD, and if so, how many commits are in $tag..HEAD? 40 # shellcheck disable=SC2046 # word splitting is the point here 41 set -- $(git rev-list --count --left-right "$tag"...HEAD 2> /dev/null) 42 43 # $1 is 0 if and only if $tag is an ancestor of HEAD. Use 44 # string comparison, because $1 is empty if the 'git rev-list' 45 # command somehow failed. 46 [ "$1" = 0 ] || return 1 47 48 # $2 is the number of commits in the range $tag..HEAD, possibly 0. 49 count="$2" 50 51 return 0 52} 53 |
|
33scm_version() 34{ 35 local short=false 36 local no_dirty=false 37 local tag 38 39 while [ $# -gt 0 ]; 40 do --- 15 unchanged lines hidden (view full) --- 56 if ! head=$(git rev-parse --verify HEAD 2>/dev/null); then 57 return 58 fi 59 60 # mainline kernel: 6.2.0-rc5 -> v6.2-rc5 61 # stable kernel: 6.1.7 -> v6.1.7 62 version_tag=v$(echo "${KERNELVERSION}" | sed -E 's/^([0-9]+\.[0-9]+)\.0(.*)$/\1\2/') 63 | 54scm_version() 55{ 56 local short=false 57 local no_dirty=false 58 local tag 59 60 while [ $# -gt 0 ]; 61 do --- 15 unchanged lines hidden (view full) --- 77 if ! head=$(git rev-parse --verify HEAD 2>/dev/null); then 78 return 79 fi 80 81 # mainline kernel: 6.2.0-rc5 -> v6.2-rc5 82 # stable kernel: 6.1.7 -> v6.1.7 83 version_tag=v$(echo "${KERNELVERSION}" | sed -E 's/^([0-9]+\.[0-9]+)\.0(.*)$/\1\2/') 84 |
85 # try_tag initializes count if the tag is usable. 86 count= 87 |
|
64 # If a localversion* file exists, and the corresponding 65 # annotated tag exists and is an ancestor of HEAD, use 66 # it. This is the case in linux-next. | 88 # If a localversion* file exists, and the corresponding 89 # annotated tag exists and is an ancestor of HEAD, use 90 # it. This is the case in linux-next. |
67 tag=${file_localversion#-} 68 desc= 69 if [ -n "${tag}" ]; then 70 desc=$(git describe --match=$tag 2>/dev/null) | 91 if [ -n "${file_localversion#-}" ] ; then 92 try_tag "${file_localversion#-}" |
71 fi 72 73 # Otherwise, if a localversion* file exists, and the tag 74 # obtained by appending it to the tag derived from 75 # KERNELVERSION exists and is an ancestor of HEAD, use 76 # it. This is e.g. the case in linux-rt. | 93 fi 94 95 # Otherwise, if a localversion* file exists, and the tag 96 # obtained by appending it to the tag derived from 97 # KERNELVERSION exists and is an ancestor of HEAD, use 98 # it. This is e.g. the case in linux-rt. |
77 if [ -z "${desc}" ] && [ -n "${file_localversion}" ]; then 78 tag="${version_tag}${file_localversion}" 79 desc=$(git describe --match=$tag 2>/dev/null) | 99 if [ -z "${count}" ] && [ -n "${file_localversion}" ]; then 100 try_tag "${version_tag}${file_localversion}" |
80 fi 81 82 # Otherwise, default to the annotated tag derived from KERNELVERSION. | 101 fi 102 103 # Otherwise, default to the annotated tag derived from KERNELVERSION. |
83 if [ -z "${desc}" ]; then 84 tag="${version_tag}" 85 desc=$(git describe --match=$tag 2>/dev/null) | 104 if [ -z "${count}" ]; then 105 try_tag "${version_tag}" |
86 fi 87 | 106 fi 107 |
88 # If we are at the tagged commit, we ignore it because the version is 89 # well-defined. 90 if [ "${tag}" != "${desc}" ]; then | 108 # If we are at the tagged commit, we ignore it because the 109 # version is well-defined. If none of the attempted tags exist 110 # or were usable, $count is still empty. 111 if [ -z "${count}" ] || [ "${count}" -gt 0 ]; then |
91 92 # If only the short version is requested, don't bother 93 # running further git commands 94 if $short; then 95 echo "+" 96 return 97 fi | 112 113 # If only the short version is requested, don't bother 114 # running further git commands 115 if $short; then 116 echo "+" 117 return 118 fi |
119 |
|
98 # If we are past the tagged commit, we pretty print it. 99 # (like 6.1.0-14595-g292a089d78d3) | 120 # If we are past the tagged commit, we pretty print it. 121 # (like 6.1.0-14595-g292a089d78d3) |
100 if [ -n "${desc}" ]; then 101 echo "${desc}" | awk -F- '{printf("-%05d", $(NF-1))}' | 122 if [ -n "${count}" ]; then 123 printf "%s%05d" "-" "${count}" |
102 fi 103 104 # Add -g and exactly 12 hex chars. | 124 fi 125 126 # Add -g and exactly 12 hex chars. |
105 printf '%s%s' -g "$(echo $head | cut -c1-12)" | 127 printf '%s%.12s' -g "$head" |
106 fi 107 108 if ${no_dirty}; then 109 return 110 fi 111 112 # Check for uncommitted changes. 113 # This script must avoid any write attempt to the source tree, which --- 73 unchanged lines hidden --- | 128 fi 129 130 if ${no_dirty}; then 131 return 132 fi 133 134 # Check for uncommitted changes. 135 # This script must avoid any write attempt to the source tree, which --- 73 unchanged lines hidden --- |