Matt DeVillier has uploaded this change for review. ( https://review.coreboot.org/24982
Change subject: ec/chromeec: Fix check for UHEPI support
......................................................................
ec/chromeec: Fix check for UHEPI support
Commit 1dfc2c3
[google/chromeec: Enable unified host event programming interface]
added support for UHEPI, but google_chromeec_is_uhepi_supported()
incorrect treats negative error return codes from
google_chromeec_check_feature() as supported. Fix this check to only
treat positive return values as supported, as per the original intent.
Test: boot google/lulu, verify cbmem console reports UHEPI not
supported even if feature check returns error code, verify lid/kb
wake events correct wake the device from S3/sleep.
Change-Id: I7846efb340bc1546b074e8502daf906c444bd146
Signed-off-by: Matt DeVillier <matt.devillier(a)gmail.com>
---
M src/ec/google/chromeec/ec.c
1 file changed, 1 insertion(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/82/24982/1
diff --git a/src/ec/google/chromeec/ec.c b/src/ec/google/chromeec/ec.c
index ef7a217..28625e4 100644
--- a/src/ec/google/chromeec/ec.c
+++ b/src/ec/google/chromeec/ec.c
@@ -224,7 +224,7 @@
if (!uhepi_support) {
uhepi_support = google_chromeec_check_feature
- (EC_FEATURE_UNIFIED_WAKE_MASKS) ? UHEPI_SUPPORTED :
+ (EC_FEATURE_UNIFIED_WAKE_MASKS) > 0 ? UHEPI_SUPPORTED :
UHEPI_NOT_SUPPORTED;
printk(BIOS_DEBUG, "Chrome EC: UHEPI %s\n",
uhepi_support == UHEPI_SUPPORTED ?
--
To view, visit https://review.coreboot.org/24982
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I7846efb340bc1546b074e8502daf906c444bd146
Gerrit-Change-Number: 24982
Gerrit-PatchSet: 1
Gerrit-Owner: Matt DeVillier <matt.devillier(a)gmail.com>
Alex Thiessen has abandoned this change. ( https://review.coreboot.org/24979 )
Change subject: util/gitconfig: support pre-v2.5.0 git
......................................................................
Abandoned
broken
--
To view, visit https://review.coreboot.org/24979
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: abandon
Gerrit-Change-Id: If48f22b382a43246bbb54e41d6afbb18cbfde23d
Gerrit-Change-Number: 24979
Gerrit-PatchSet: 1
Gerrit-Owner: Alex Thiessen <alex.thiessen.de+coreboot(a)gmail.com>
Alex Thiessen has abandoned this change. ( https://review.coreboot.org/24980 )
Change subject: util/gitconfig: support pre-v2.5.0 git
......................................................................
Abandoned
broken
--
To view, visit https://review.coreboot.org/24980
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: abandon
Gerrit-Change-Id: I4754fd51d6565960a756df852099dcf0bca72c71
Gerrit-Change-Number: 24980
Gerrit-PatchSet: 1
Gerrit-Owner: Alex Thiessen <alex.thiessen.de+coreboot(a)gmail.com>
Alex Thiessen has uploaded this change for review. ( https://review.coreboot.org/24981
Change subject: util/gitconfig: support pre-v2.5.0 git
......................................................................
util/gitconfig: support pre-v2.5.0 git
In commit fda071ca "Make gitconfig.sh support gitfile", the
`gitconfig.sh` was changed to use `git rev-parse --git-path hooks` to
determine the path to copy the hooks to. The `--git-path` option was
added only recently on 2014-11-30 in git v2.5.0-rc0 commit 557bd833
"git_path(): be aware of file relocation in $GIT_DIR". Hence, for users
of older distributions (e.g. Ubuntu 14.04) the `make gitconfig` stopped
working.
This commit adds a script that provides functions for comparing git
versions and modifies the `gitconfig.sh` script to use a simpler method
for `hooks` directory lookup when an older, pre-v2.5.0-rc0 git is
found installed.
Change-Id: I232499c51e30bee546994eedcd2534642cd534e6
Signed-off-by: Alex Thiessen <alex.thiessen.de+coreboot(a)gmail.com>
---
M util/gitconfig/gitconfig.sh
A util/scripts/git-version-compare.sh
2 files changed, 240 insertions(+), 3 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/81/24981/1
diff --git a/util/gitconfig/gitconfig.sh b/util/gitconfig/gitconfig.sh
index 5d6fe36..f0ef307 100755
--- a/util/gitconfig/gitconfig.sh
+++ b/util/gitconfig/gitconfig.sh
@@ -24,7 +24,15 @@
echo "Error: Not in root of a git repository"
exit 1
fi
-coreboot_hooks=$(git rev-parse --git-path hooks)
+
+source util/scripts/git-version-compare.sh
+# `rev-parse --git-path` was added in commit 557bd833 for v2.5.0-rc0
+if git_version_ge 2 5 0 0; then
+ coreboot_hooks=$(git rev-parse --git-path hooks)
+else
+ coreboot_hooks=$(git rev-parse --git-dir)/hooks
+fi
+
mkdir -p "${coreboot_hooks}"
for hook in commit-msg pre-commit ; do
if [ util/gitconfig/${hook} -nt "${coreboot_hooks}/${hook}" ] \
@@ -37,8 +45,13 @@
done
# Now set up the hooks for 3rdparty/
for submodule in 3rdparty/blobs libhwbase libgfxinit; do
- hooks=$(git -C "$(git config --file .gitmodules --get \
- submodule.${submodule}.path)" rev-parse --git-path hooks)
+ submodule_path=$(git config --file .gitmodules --get \
+ submodule.${submodule}.path)
+ if git_version_ge 2 5 0 0; then
+ hooks=$(git -C "${submodule_path}" rev-parse --git-path hooks)
+ else
+ hooks=$(git -C "${submodule_path}" rev-parse --git-dir)/hooks
+ fi
if [ -d "${hooks}" ]; then
if [ util/gitconfig/commit-msg -nt "${hooks}/commit-msg" ] \
|| [ ! -x "${hooks}/commit-msg" ]
diff --git a/util/scripts/git-version-compare.sh b/util/scripts/git-version-compare.sh
new file mode 100644
index 0000000..54f3de3
--- /dev/null
+++ b/util/scripts/git-version-compare.sh
@@ -0,0 +1,224 @@
+#!/bin/sh
+
+##
+## This file is part of the coreboot project.
+##
+## Copyright (C) 2003-2018 Alex Thiessen <alex.thiessen.de+coreboot(a)gmail.com>
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; version 3 or later of the License.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## SPDX-License-Identifier: GPL-3.0-or-later
+## <https://spdx.org/licenses/GPL-3.0-or-later.html>
+##
+
+# dependency check
+for dependency in cut false git grep true; do
+ if ! command -v "${dependency}" 1>/dev/null; then
+ echo "missing ${dependency}, please install first" >&2
+ fi
+done
+
+get_git_version_part() {
+ if ! [ ${#} -eq 1 ]; then
+ echo >&2 'usage: get_git_version_part <version part number>'
+ echo >&2 'i.e.: 2.5.0-rc1'
+ echo >&2 ' ^ ^ ^ ^'
+ echo >&2 ' 1 2 3 4 <version part number>'
+ false; return
+ fi
+ part_nr=${1}
+
+ if ! { [ 1 -le "${part_nr}" ] && [ "${part_nr}" -le 4 ]; }; then
+ echo 'version part number must be a number between 1 and 4' >&2
+ false; return
+ fi
+
+ git_version_output=$(git --version)
+ if [ ${?} -ne 0 ]; then
+ echo 'cannot determine `git" version' >&2
+ false; return
+ fi
+
+ git_version_dotted=$(echo "${git_version_output}" | cut -d' ' -f3)
+ if [ ${?} -ne 0 ]; then
+ echo 'cannot extract `git" version' >&2
+ false; return
+ fi
+
+ if [ "${part_nr}" -lt 3 ]; then
+ git_version_part=$(echo "${git_version_dotted}" \
+ | cut -d'.' -f"${part_nr}")
+ else # treat the release candidate part specially
+ git_version_part=$(echo "${git_version_dotted}" \
+ | cut -d'.' -f3)
+ if [ ${?} -ne 0 ]; then
+ echo 'cannot extract `git" version part' >&2
+ false; return
+ fi
+
+ if [ "${part_nr}" -eq 3 ]; then
+ git_version_part="$(echo "${git_version_part}" \
+ | cut -d'-' -f1)"
+ elif { echo "${git_version_part}" \
+ | grep -Eqx "[0-9]+-rc[0-9]+"; }; then
+ git_version_part="$(echo "${git_version_part}" \
+ | sed -E 's/^[0-9+]-rc([0-9]+)$/\1/')"
+ else # not a release candidate
+ git_version_part=""
+ fi
+ fi
+ if [ ${?} -ne 0 ]; then
+ echo 'cannot extract `git" version part' >&2
+ false; return
+ fi
+
+ echo "${git_version_part}"
+ true; return
+}
+
+git_version_lt() {
+ if ! { [ 3 -le ${#} ] && [ ${#} -le 4 ]; }; then
+ echo >&2 'compare installed git version to a specific one'
+ echo >&2 'usage: git_version_lt <version>'
+ echo >&2 'e.g.: git_version_lt 2 5 0 1'
+ echo >&2 ' ^ ^ ^ ^'
+ echo >&2 ' 2.5.0-rc1'
+ return 127
+ fi
+
+ for i in $(seq 1 4); do
+ git_version_part_lhs=$(get_git_version_part "${i}")
+ if ! [ ${?} -eq 0 ]; then
+ return 127;
+ fi
+
+ git_version_part_rhs=$(eval echo \$\{"${i}"\})
+ if ! [ ${?} -eq 0 ]; then
+ return 127;
+ fi
+
+ if [ "${i}" -eq 4 ]; then
+ # empty release candidate is greater than any other one
+ if [ -z "${git_version_part_lhs}" ]; then
+ false; return
+ elif [ -z "${git_version_part_rhs}" ]; then
+ true; return
+ else
+ [ "${git_version_part_lhs}" \
+ -lt "${git_version_part_rhs}" ]
+ return
+ fi
+ elif [ "${git_version_part_lhs}" \
+ -lt "${git_version_part_rhs}" ]; then
+ true; return
+ elif [ "${git_version_part_lhs}" \
+ -gt "${git_version_part_rhs}" ]; then
+ false; return
+ fi
+ done
+
+ # should not get here
+ return 127
+}
+
+git_version_ge() {
+ ! git_version_lt "${@}"; return
+}
+
+git_version_eq() {
+ if [ ${#} -lt 3 ]; then
+ echo >&2 'compare installed git version to a specific one'
+ echo >&2 'usage: git_version_eq <version>'
+ echo >&2 'e.g.: git_version_eq 2 5 0 1'
+ echo >&2 ' ^ ^ ^ ^'
+ echo >&2 ' 2.5.0-rc1'
+ return 127
+ fi
+
+ for i in $(seq 1 4); do
+ git_version_part_lhs=$(get_git_version_part "${i}")
+ if ! [ ${?} -eq 0 ]; then
+ return 127
+ fi
+
+ git_version_part_rhs=$(eval echo \$\{"${i}"\})
+ if ! [ ${?} -eq 0 ]; then
+ return 127
+ fi
+
+ if [ "${i}" -eq 4 ]; then
+ # special treatment of the release candidates
+ if [ -n "${git_version_part_lhs}" ]; then
+ if [ -z "${git_version_part_lhs}" ]; then
+ false; return
+ fi
+
+ [ "${git_version_part_lhs}" \
+ -eq "${git_version_part_rhs}" ]; return
+ else
+ [ -z "${git_version_part_rhs}" ]; return
+ fi
+ fi
+ done
+
+ # should not get here
+ return 127
+}
+
+git_version_le() {
+ git_version_lt "${@}" || git_version_eq "${@}"; return
+}
+
+git_version_gt() {
+ ! git_version_le "${@}"; return
+}
+
+test_git_version() {
+ git_real=$(command -v git)
+
+ git() {
+ if [ ${#} -eq 1 ] && [ "${1}" = "--version" ]; then
+ echo "${git_fake_version}"
+ else
+ "${git_real}" "${@}"
+ fi
+
+ return 0
+ }
+
+ git_fake_version="git version 1.23.4"
+
+ if ! get_git_version_part ; then echo ok; else echo nok; fi
+ if ! get_git_version_part 0; then echo ok; else echo nok; fi
+ if get_git_version_part 1; then echo ok; else echo nok; fi
+ if get_git_version_part 2; then echo ok; else echo nok; fi
+ if get_git_version_part 3; then echo ok; else echo nok; fi
+ if get_git_version_part 4; then echo ok; else echo nok; fi
+ if ! get_git_version_part 5; then echo ok; else echo nok; fi
+ if ! get_git_version_part x; then echo ok; else echo nok; fi
+
+ if ! git_version_lt 1 11 0 ; then echo ok; else echo nok; fi
+ if ! git_version_lt 1 23 4 1; then echo ok; else echo nok; fi
+ if ! git_version_lt 1 23 4 ; then echo ok; else echo nok; fi
+ if git_version_lt 1 23 5 ; then echo ok; else echo nok; fi
+
+ git_fake_version="git version 2.11.1-rc2"
+
+ if git_version_lt 2 12 0 ; then echo ok; else echo nok; fi
+ if git_version_lt 2 11 1 ; then echo ok; else echo nok; fi
+ if git_version_lt 2 11 1 3; then echo ok; else echo nok; fi
+ if ! git_version_lt 2 11 1 2; then echo ok; else echo nok; fi
+ if ! git_version_lt 2 11 1 1; then echo ok; else echo nok; fi
+ if ! git_version_lt 2 10 0 ; then echo ok; else echo nok; fi
+}
+
+if [ ${#} -eq 1 ] && [ "${1}" = "--test" ]; then
+ test_git_version
+fi
--
To view, visit https://review.coreboot.org/24981
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I232499c51e30bee546994eedcd2534642cd534e6
Gerrit-Change-Number: 24981
Gerrit-PatchSet: 1
Gerrit-Owner: Alex Thiessen <alex.thiessen.de+coreboot(a)gmail.com>
Alex Thiessen has uploaded this change for review. ( https://review.coreboot.org/24980
Change subject: util/gitconfig: support pre-v2.5.0 git
......................................................................
util/gitconfig: support pre-v2.5.0 git
In commit fda071ca "Make gitconfig.sh support gitfile", the
`gitconfig.sh` was changed to use `git rev-parse --git-path hooks` to
determine the path to copy the hooks to. The `--git-path` option was
added only recently on 2014-11-30 in git v2.5.0-rc0 commit 557bd833
"git_path(): be aware of file relocation in $GIT_DIR". Hence, for users
of older distributions (e.g. Ubuntu 14.04) the `make gitconfig` stopped
working.
This commit adds a script that provides functions for comparing git
versions and modifies the `gitconfig.sh` script to use a simpler method
for `hooks` directory lookup when an older, pre-v2.5.0-rc0 git is
found installed.
Change-Id: I4754fd51d6565960a756df852099dcf0bca72c71
Signed-off-by: Alex Thiessen <alex.thiessen.de+coreboot(a)gmail.com>
---
M util/gitconfig/gitconfig.sh
A util/scripts/git-version-compare.sh
2 files changed, 233 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/80/24980/1
diff --git a/util/gitconfig/gitconfig.sh b/util/gitconfig/gitconfig.sh
index 5d6fe36..4934dbd 100755
--- a/util/gitconfig/gitconfig.sh
+++ b/util/gitconfig/gitconfig.sh
@@ -24,7 +24,15 @@
echo "Error: Not in root of a git repository"
exit 1
fi
-coreboot_hooks=$(git rev-parse --git-path hooks)
+
+source util/scripts/git-version-compare.sh
+# `rev-parse --git-path` was added in commit 557bd833 for v2.5.0-rc0
+if git_version_ge 2 5 0 0; then
+ coreboot_hooks=$(git rev-parse --git-path hooks)
+else
+ coreboot_hooks=$(git rev-parse --git-dir)/hooks
+fi
+
mkdir -p "${coreboot_hooks}"
for hook in commit-msg pre-commit ; do
if [ util/gitconfig/${hook} -nt "${coreboot_hooks}/${hook}" ] \
diff --git a/util/scripts/git-version-compare.sh b/util/scripts/git-version-compare.sh
new file mode 100644
index 0000000..54f3de3
--- /dev/null
+++ b/util/scripts/git-version-compare.sh
@@ -0,0 +1,224 @@
+#!/bin/sh
+
+##
+## This file is part of the coreboot project.
+##
+## Copyright (C) 2003-2018 Alex Thiessen <alex.thiessen.de+coreboot(a)gmail.com>
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; version 3 or later of the License.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## SPDX-License-Identifier: GPL-3.0-or-later
+## <https://spdx.org/licenses/GPL-3.0-or-later.html>
+##
+
+# dependency check
+for dependency in cut false git grep true; do
+ if ! command -v "${dependency}" 1>/dev/null; then
+ echo "missing ${dependency}, please install first" >&2
+ fi
+done
+
+get_git_version_part() {
+ if ! [ ${#} -eq 1 ]; then
+ echo >&2 'usage: get_git_version_part <version part number>'
+ echo >&2 'i.e.: 2.5.0-rc1'
+ echo >&2 ' ^ ^ ^ ^'
+ echo >&2 ' 1 2 3 4 <version part number>'
+ false; return
+ fi
+ part_nr=${1}
+
+ if ! { [ 1 -le "${part_nr}" ] && [ "${part_nr}" -le 4 ]; }; then
+ echo 'version part number must be a number between 1 and 4' >&2
+ false; return
+ fi
+
+ git_version_output=$(git --version)
+ if [ ${?} -ne 0 ]; then
+ echo 'cannot determine `git" version' >&2
+ false; return
+ fi
+
+ git_version_dotted=$(echo "${git_version_output}" | cut -d' ' -f3)
+ if [ ${?} -ne 0 ]; then
+ echo 'cannot extract `git" version' >&2
+ false; return
+ fi
+
+ if [ "${part_nr}" -lt 3 ]; then
+ git_version_part=$(echo "${git_version_dotted}" \
+ | cut -d'.' -f"${part_nr}")
+ else # treat the release candidate part specially
+ git_version_part=$(echo "${git_version_dotted}" \
+ | cut -d'.' -f3)
+ if [ ${?} -ne 0 ]; then
+ echo 'cannot extract `git" version part' >&2
+ false; return
+ fi
+
+ if [ "${part_nr}" -eq 3 ]; then
+ git_version_part="$(echo "${git_version_part}" \
+ | cut -d'-' -f1)"
+ elif { echo "${git_version_part}" \
+ | grep -Eqx "[0-9]+-rc[0-9]+"; }; then
+ git_version_part="$(echo "${git_version_part}" \
+ | sed -E 's/^[0-9+]-rc([0-9]+)$/\1/')"
+ else # not a release candidate
+ git_version_part=""
+ fi
+ fi
+ if [ ${?} -ne 0 ]; then
+ echo 'cannot extract `git" version part' >&2
+ false; return
+ fi
+
+ echo "${git_version_part}"
+ true; return
+}
+
+git_version_lt() {
+ if ! { [ 3 -le ${#} ] && [ ${#} -le 4 ]; }; then
+ echo >&2 'compare installed git version to a specific one'
+ echo >&2 'usage: git_version_lt <version>'
+ echo >&2 'e.g.: git_version_lt 2 5 0 1'
+ echo >&2 ' ^ ^ ^ ^'
+ echo >&2 ' 2.5.0-rc1'
+ return 127
+ fi
+
+ for i in $(seq 1 4); do
+ git_version_part_lhs=$(get_git_version_part "${i}")
+ if ! [ ${?} -eq 0 ]; then
+ return 127;
+ fi
+
+ git_version_part_rhs=$(eval echo \$\{"${i}"\})
+ if ! [ ${?} -eq 0 ]; then
+ return 127;
+ fi
+
+ if [ "${i}" -eq 4 ]; then
+ # empty release candidate is greater than any other one
+ if [ -z "${git_version_part_lhs}" ]; then
+ false; return
+ elif [ -z "${git_version_part_rhs}" ]; then
+ true; return
+ else
+ [ "${git_version_part_lhs}" \
+ -lt "${git_version_part_rhs}" ]
+ return
+ fi
+ elif [ "${git_version_part_lhs}" \
+ -lt "${git_version_part_rhs}" ]; then
+ true; return
+ elif [ "${git_version_part_lhs}" \
+ -gt "${git_version_part_rhs}" ]; then
+ false; return
+ fi
+ done
+
+ # should not get here
+ return 127
+}
+
+git_version_ge() {
+ ! git_version_lt "${@}"; return
+}
+
+git_version_eq() {
+ if [ ${#} -lt 3 ]; then
+ echo >&2 'compare installed git version to a specific one'
+ echo >&2 'usage: git_version_eq <version>'
+ echo >&2 'e.g.: git_version_eq 2 5 0 1'
+ echo >&2 ' ^ ^ ^ ^'
+ echo >&2 ' 2.5.0-rc1'
+ return 127
+ fi
+
+ for i in $(seq 1 4); do
+ git_version_part_lhs=$(get_git_version_part "${i}")
+ if ! [ ${?} -eq 0 ]; then
+ return 127
+ fi
+
+ git_version_part_rhs=$(eval echo \$\{"${i}"\})
+ if ! [ ${?} -eq 0 ]; then
+ return 127
+ fi
+
+ if [ "${i}" -eq 4 ]; then
+ # special treatment of the release candidates
+ if [ -n "${git_version_part_lhs}" ]; then
+ if [ -z "${git_version_part_lhs}" ]; then
+ false; return
+ fi
+
+ [ "${git_version_part_lhs}" \
+ -eq "${git_version_part_rhs}" ]; return
+ else
+ [ -z "${git_version_part_rhs}" ]; return
+ fi
+ fi
+ done
+
+ # should not get here
+ return 127
+}
+
+git_version_le() {
+ git_version_lt "${@}" || git_version_eq "${@}"; return
+}
+
+git_version_gt() {
+ ! git_version_le "${@}"; return
+}
+
+test_git_version() {
+ git_real=$(command -v git)
+
+ git() {
+ if [ ${#} -eq 1 ] && [ "${1}" = "--version" ]; then
+ echo "${git_fake_version}"
+ else
+ "${git_real}" "${@}"
+ fi
+
+ return 0
+ }
+
+ git_fake_version="git version 1.23.4"
+
+ if ! get_git_version_part ; then echo ok; else echo nok; fi
+ if ! get_git_version_part 0; then echo ok; else echo nok; fi
+ if get_git_version_part 1; then echo ok; else echo nok; fi
+ if get_git_version_part 2; then echo ok; else echo nok; fi
+ if get_git_version_part 3; then echo ok; else echo nok; fi
+ if get_git_version_part 4; then echo ok; else echo nok; fi
+ if ! get_git_version_part 5; then echo ok; else echo nok; fi
+ if ! get_git_version_part x; then echo ok; else echo nok; fi
+
+ if ! git_version_lt 1 11 0 ; then echo ok; else echo nok; fi
+ if ! git_version_lt 1 23 4 1; then echo ok; else echo nok; fi
+ if ! git_version_lt 1 23 4 ; then echo ok; else echo nok; fi
+ if git_version_lt 1 23 5 ; then echo ok; else echo nok; fi
+
+ git_fake_version="git version 2.11.1-rc2"
+
+ if git_version_lt 2 12 0 ; then echo ok; else echo nok; fi
+ if git_version_lt 2 11 1 ; then echo ok; else echo nok; fi
+ if git_version_lt 2 11 1 3; then echo ok; else echo nok; fi
+ if ! git_version_lt 2 11 1 2; then echo ok; else echo nok; fi
+ if ! git_version_lt 2 11 1 1; then echo ok; else echo nok; fi
+ if ! git_version_lt 2 10 0 ; then echo ok; else echo nok; fi
+}
+
+if [ ${#} -eq 1 ] && [ "${1}" = "--test" ]; then
+ test_git_version
+fi
--
To view, visit https://review.coreboot.org/24980
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4754fd51d6565960a756df852099dcf0bca72c71
Gerrit-Change-Number: 24980
Gerrit-PatchSet: 1
Gerrit-Owner: Alex Thiessen <alex.thiessen.de+coreboot(a)gmail.com>
Alex Thiessen has uploaded this change for review. ( https://review.coreboot.org/24979
Change subject: util/gitconfig: support pre-v2.5.0 git
......................................................................
util/gitconfig: support pre-v2.5.0 git
In commit fda071ca "Make gitconfig.sh support gitfile", the
`gitconfig.sh` was changed to use `git rev-parse --git-path hooks` to
determine the path to copy the hooks to. The `--git-path` option was
added only recently on 2014-11-30 in git v2.5.0-rc0 commit 557bd833
"git_path(): be aware of file relocation in $GIT_DIR". Hence, for users
of older distributions (e.g. Ubuntu 14.04) the `make gitconfig` stopped
working.
This commit adds a script that provides functions for comparing git
versions and modifies the `gitconfig.sh` script to use a simpler method
for `hooks` directory lookup when an older, pre-v2.5.0-rc0 git is
found installed.
Change-Id: If48f22b382a43246bbb54e41d6afbb18cbfde23d
Signed-off-by: Alex Thiessen <alex.thiessen.de+coreboot(a)gmail.com>
---
M util/gitconfig/gitconfig.sh
A util/scripts/git-version-compare.sh
2 files changed, 233 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/79/24979/1
diff --git a/util/gitconfig/gitconfig.sh b/util/gitconfig/gitconfig.sh
index 5d6fe36..4934dbd 100755
--- a/util/gitconfig/gitconfig.sh
+++ b/util/gitconfig/gitconfig.sh
@@ -24,7 +24,15 @@
echo "Error: Not in root of a git repository"
exit 1
fi
-coreboot_hooks=$(git rev-parse --git-path hooks)
+
+source util/scripts/git-version-compare.sh
+# `rev-parse --git-path` was added in commit 557bd833 for v2.5.0-rc0
+if git_version_ge 2 5 0 0; then
+ coreboot_hooks=$(git rev-parse --git-path hooks)
+else
+ coreboot_hooks=$(git rev-parse --git-dir)/hooks
+fi
+
mkdir -p "${coreboot_hooks}"
for hook in commit-msg pre-commit ; do
if [ util/gitconfig/${hook} -nt "${coreboot_hooks}/${hook}" ] \
diff --git a/util/scripts/git-version-compare.sh b/util/scripts/git-version-compare.sh
new file mode 100644
index 0000000..54f3de3
--- /dev/null
+++ b/util/scripts/git-version-compare.sh
@@ -0,0 +1,224 @@
+#!/bin/sh
+
+##
+## This file is part of the coreboot project.
+##
+## Copyright (C) 2003-2018 Alex Thiessen <alex.thiessen.de+coreboot(a)gmail.com>
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; version 3 or later of the License.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+## GNU General Public License for more details.
+##
+## SPDX-License-Identifier: GPL-3.0-or-later
+## <https://spdx.org/licenses/GPL-3.0-or-later.html>
+##
+
+# dependency check
+for dependency in cut false git grep true; do
+ if ! command -v "${dependency}" 1>/dev/null; then
+ echo "missing ${dependency}, please install first" >&2
+ fi
+done
+
+get_git_version_part() {
+ if ! [ ${#} -eq 1 ]; then
+ echo >&2 'usage: get_git_version_part <version part number>'
+ echo >&2 'i.e.: 2.5.0-rc1'
+ echo >&2 ' ^ ^ ^ ^'
+ echo >&2 ' 1 2 3 4 <version part number>'
+ false; return
+ fi
+ part_nr=${1}
+
+ if ! { [ 1 -le "${part_nr}" ] && [ "${part_nr}" -le 4 ]; }; then
+ echo 'version part number must be a number between 1 and 4' >&2
+ false; return
+ fi
+
+ git_version_output=$(git --version)
+ if [ ${?} -ne 0 ]; then
+ echo 'cannot determine `git" version' >&2
+ false; return
+ fi
+
+ git_version_dotted=$(echo "${git_version_output}" | cut -d' ' -f3)
+ if [ ${?} -ne 0 ]; then
+ echo 'cannot extract `git" version' >&2
+ false; return
+ fi
+
+ if [ "${part_nr}" -lt 3 ]; then
+ git_version_part=$(echo "${git_version_dotted}" \
+ | cut -d'.' -f"${part_nr}")
+ else # treat the release candidate part specially
+ git_version_part=$(echo "${git_version_dotted}" \
+ | cut -d'.' -f3)
+ if [ ${?} -ne 0 ]; then
+ echo 'cannot extract `git" version part' >&2
+ false; return
+ fi
+
+ if [ "${part_nr}" -eq 3 ]; then
+ git_version_part="$(echo "${git_version_part}" \
+ | cut -d'-' -f1)"
+ elif { echo "${git_version_part}" \
+ | grep -Eqx "[0-9]+-rc[0-9]+"; }; then
+ git_version_part="$(echo "${git_version_part}" \
+ | sed -E 's/^[0-9+]-rc([0-9]+)$/\1/')"
+ else # not a release candidate
+ git_version_part=""
+ fi
+ fi
+ if [ ${?} -ne 0 ]; then
+ echo 'cannot extract `git" version part' >&2
+ false; return
+ fi
+
+ echo "${git_version_part}"
+ true; return
+}
+
+git_version_lt() {
+ if ! { [ 3 -le ${#} ] && [ ${#} -le 4 ]; }; then
+ echo >&2 'compare installed git version to a specific one'
+ echo >&2 'usage: git_version_lt <version>'
+ echo >&2 'e.g.: git_version_lt 2 5 0 1'
+ echo >&2 ' ^ ^ ^ ^'
+ echo >&2 ' 2.5.0-rc1'
+ return 127
+ fi
+
+ for i in $(seq 1 4); do
+ git_version_part_lhs=$(get_git_version_part "${i}")
+ if ! [ ${?} -eq 0 ]; then
+ return 127;
+ fi
+
+ git_version_part_rhs=$(eval echo \$\{"${i}"\})
+ if ! [ ${?} -eq 0 ]; then
+ return 127;
+ fi
+
+ if [ "${i}" -eq 4 ]; then
+ # empty release candidate is greater than any other one
+ if [ -z "${git_version_part_lhs}" ]; then
+ false; return
+ elif [ -z "${git_version_part_rhs}" ]; then
+ true; return
+ else
+ [ "${git_version_part_lhs}" \
+ -lt "${git_version_part_rhs}" ]
+ return
+ fi
+ elif [ "${git_version_part_lhs}" \
+ -lt "${git_version_part_rhs}" ]; then
+ true; return
+ elif [ "${git_version_part_lhs}" \
+ -gt "${git_version_part_rhs}" ]; then
+ false; return
+ fi
+ done
+
+ # should not get here
+ return 127
+}
+
+git_version_ge() {
+ ! git_version_lt "${@}"; return
+}
+
+git_version_eq() {
+ if [ ${#} -lt 3 ]; then
+ echo >&2 'compare installed git version to a specific one'
+ echo >&2 'usage: git_version_eq <version>'
+ echo >&2 'e.g.: git_version_eq 2 5 0 1'
+ echo >&2 ' ^ ^ ^ ^'
+ echo >&2 ' 2.5.0-rc1'
+ return 127
+ fi
+
+ for i in $(seq 1 4); do
+ git_version_part_lhs=$(get_git_version_part "${i}")
+ if ! [ ${?} -eq 0 ]; then
+ return 127
+ fi
+
+ git_version_part_rhs=$(eval echo \$\{"${i}"\})
+ if ! [ ${?} -eq 0 ]; then
+ return 127
+ fi
+
+ if [ "${i}" -eq 4 ]; then
+ # special treatment of the release candidates
+ if [ -n "${git_version_part_lhs}" ]; then
+ if [ -z "${git_version_part_lhs}" ]; then
+ false; return
+ fi
+
+ [ "${git_version_part_lhs}" \
+ -eq "${git_version_part_rhs}" ]; return
+ else
+ [ -z "${git_version_part_rhs}" ]; return
+ fi
+ fi
+ done
+
+ # should not get here
+ return 127
+}
+
+git_version_le() {
+ git_version_lt "${@}" || git_version_eq "${@}"; return
+}
+
+git_version_gt() {
+ ! git_version_le "${@}"; return
+}
+
+test_git_version() {
+ git_real=$(command -v git)
+
+ git() {
+ if [ ${#} -eq 1 ] && [ "${1}" = "--version" ]; then
+ echo "${git_fake_version}"
+ else
+ "${git_real}" "${@}"
+ fi
+
+ return 0
+ }
+
+ git_fake_version="git version 1.23.4"
+
+ if ! get_git_version_part ; then echo ok; else echo nok; fi
+ if ! get_git_version_part 0; then echo ok; else echo nok; fi
+ if get_git_version_part 1; then echo ok; else echo nok; fi
+ if get_git_version_part 2; then echo ok; else echo nok; fi
+ if get_git_version_part 3; then echo ok; else echo nok; fi
+ if get_git_version_part 4; then echo ok; else echo nok; fi
+ if ! get_git_version_part 5; then echo ok; else echo nok; fi
+ if ! get_git_version_part x; then echo ok; else echo nok; fi
+
+ if ! git_version_lt 1 11 0 ; then echo ok; else echo nok; fi
+ if ! git_version_lt 1 23 4 1; then echo ok; else echo nok; fi
+ if ! git_version_lt 1 23 4 ; then echo ok; else echo nok; fi
+ if git_version_lt 1 23 5 ; then echo ok; else echo nok; fi
+
+ git_fake_version="git version 2.11.1-rc2"
+
+ if git_version_lt 2 12 0 ; then echo ok; else echo nok; fi
+ if git_version_lt 2 11 1 ; then echo ok; else echo nok; fi
+ if git_version_lt 2 11 1 3; then echo ok; else echo nok; fi
+ if ! git_version_lt 2 11 1 2; then echo ok; else echo nok; fi
+ if ! git_version_lt 2 11 1 1; then echo ok; else echo nok; fi
+ if ! git_version_lt 2 10 0 ; then echo ok; else echo nok; fi
+}
+
+if [ ${#} -eq 1 ] && [ "${1}" = "--test" ]; then
+ test_git_version
+fi
--
To view, visit https://review.coreboot.org/24979
To unsubscribe, or for help writing mail filters, visit https://review.coreboot.org/settings
Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: If48f22b382a43246bbb54e41d6afbb18cbfde23d
Gerrit-Change-Number: 24979
Gerrit-PatchSet: 1
Gerrit-Owner: Alex Thiessen <alex.thiessen.de+coreboot(a)gmail.com>