summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2023-08-27 17:57:30 +0100
committerLeah Rowe <leah@libreboot.org>2023-08-27 18:17:31 +0100
commit4a280c629fca886547eb0f4ebbe6319b75b240d7 (patch)
tree39ec0a077c77e7a40507b8edc1339b6f036768a0
parent355eb765ff47b0855a6f5655312608d3264e70bf (diff)
.gitcheck: re-write entirely. force global config.
the way the old script worked was extremely hacky it's cleaner just to make the user configure git i haven't used anything from the old .gitcheck script, which is now deleted. i completely re-wrote this, in a much simpler way. this is less maintenance now, when things change in the upstream projects. coreboot makes heavy use of git within its build system Signed-off-by: Leah Rowe <leah@libreboot.org>
-rwxr-xr-x.gitcheck81
-rwxr-xr-xcheckgit27
-rwxr-xr-xfetch1
-rwxr-xr-xfetch_trees1
-rwxr-xr-xlbmk5
-rw-r--r--resources/git/revisions5
6 files changed, 33 insertions, 87 deletions
diff --git a/.gitcheck b/.gitcheck
deleted file mode 100755
index b3405a9c..00000000
--- a/.gitcheck
+++ /dev/null
@@ -1,81 +0,0 @@
-#!/usr/bin/env sh
-# SPDX-FileCopyrightText: 2022 Caleb La Grange <thonkpeasant@protonmail.com>
-# SPDX-FileCopyrightText: 2023 Leah Rowe <leah@libreboot.org>
-# SPDX-License-Identifier: GPL-3.0-only
-
-. "include/err.sh"
-
-git_name="lbmkplaceholder"
-git_email="placeholder@lbmkplaceholder.com"
-
-main()
-{
- [ "$(id -u)" = "0" ] && return 0
-
- if [ $# -gt 0 ]; then
- if [ "${1}" = "clean" ]; then
- clean 1> /dev/null
- else
- err "unsupported argument, \"${1}\""
- fi
- else
- set_placeholders 1> /dev/null
- fi
-}
-
-set_placeholders()
-{
- set_git_credentials
-
- # Check coreboot as well to prevent errors during building
- [ -d coreboot ] || return 0
- for x in coreboot/*; do
- [ -d "${x}" ] || continue
- [ -e "${x}/.git" ] || continue
- (
- cd "${x}"
- set_git_credentials
- )
- done
-}
-
-set_git_credentials()
-{
- # Check if username and or email is set.
- if ! git config user.name || git config user.email ; then
- git config user.name || git config user.name "${git_name}" || \
- err "cannot set local git user.name"
- git config user.email || git config user.email "${git_email}" \
- || err "cannot set local git user.email"
- fi
-}
-
-clean()
-{
- unset_placeholders
-
- [ -d coreboot ] || return 0
- for x in coreboot/*; do
- [ -d "${x}" ] || continue
- [ -e "${x}/.git" ] || continue
- (
- cd "${x}"
- unset_placeholders
- )
- done
-}
-
-unset_placeholders()
-{
- if [ "$(git config user.name)" = "${git_name}" ]; then
- git config --unset user.name || \
- err "cannot unset local git user.name"
- fi
-
- if [ "$(git config user.email)" = "${git_email}" ]; then
- git config --unset user.email || \
- err "cannot unset local git user.email"
- fi
-}
-
-main $@
diff --git a/checkgit b/checkgit
new file mode 100755
index 00000000..eb97dcae
--- /dev/null
+++ b/checkgit
@@ -0,0 +1,27 @@
+#!/usr/bin/env sh
+# SPDX-FileCopyrightText: 2023 Leah Rowe <leah@libreboot.org>
+# SPDX-License-Identifier: MIT
+
+. "include/err.sh"
+
+projectname="$(cat projectname)"
+
+main()
+{
+ which git 1>/dev/null 2>/dev/null || \
+ fail "git not installed. please install git-scm."
+ git config --global user.name 1>/dev/null 2>/dev/null || \
+ fail "git config --global user.name \"John Doe\""
+ git config --global user.email 1>/dev/null 2>/dev/null || \
+ fail "git config --global user.email \"john.doe@example.com\""
+}
+
+fail()
+{
+ printf "You must configure Git, before using %s's build system. Do:\n" \
+ "${projectname}" 1>&2
+ printf "%s\n\n" "${1}"
+ err "Misconfigured git-scm"
+}
+
+main $@
diff --git a/fetch b/fetch
index 5bc0e56b..bcd46af9 100755
--- a/fetch
+++ b/fetch
@@ -22,6 +22,7 @@ main()
if [ "$(id -u)" = "0" ]; then
fail "running lbmk as root as not permitted"
fi
+ ./checkgit || err "Please read: https://libreboot.org/docs/build/"
[ $# -gt 0 ] || fail "no argument given"
diff --git a/fetch_trees b/fetch_trees
index 3c33beb0..be5d4d86 100755
--- a/fetch_trees
+++ b/fetch_trees
@@ -39,6 +39,7 @@ main()
if [ "$(id -u)" = "0" ]; then
err "running lbmk as root as not permitted"
fi
+ ./checkgit || err "Please read: https://libreboot.org/docs/build/"
rm -f "${cfgsdir}"/*/seen || err_rm_seen "main 1"
diff --git a/lbmk b/lbmk
index 496d7145..0d5addc2 100755
--- a/lbmk
+++ b/lbmk
@@ -44,9 +44,10 @@ main()
err "running lbmk as root as not permitted"
fi
+ ./checkgit || err "Please read: https://libreboot.org/docs/build/"
+
buildpath="./script/${0##*/}"
- ./.gitcheck || err "/.gitcheck call from main, in /lbmk"
[ "${mode}" = "help" ] && usage ${0} && exit 0
[ "${mode}" = "list" ] && ./build command options "${buildpath}" && \
exit 0
@@ -84,8 +85,6 @@ main()
fi
"${buildpath}/${mode}/${option}" $@ || err "lbmk error"
esac
-
- ./.gitcheck clean || err "/.gitcheck clean call from main, in /lbmk"
}
install_dependencies()
diff --git a/resources/git/revisions b/resources/git/revisions
index c3a7fe72..eec8d038 100644
--- a/resources/git/revisions
+++ b/resources/git/revisions
@@ -2,9 +2,8 @@
# for various git projects used by lbmk.
# Project name is enclosed by curly braces '{}' information about the
# project relevant to lbmk is stored between the subsequent curly
-# braces. This file is used by the gitcheck script as well as the
-# fetch script. Each entry must include: revision 'rev', location
-# 'loc', and the git url 'url'. Bkup_url is optional.
+# braces. This file is used by the fetch script. Each entry must include:
+# revision 'rev', 'location', 'loc', and the git url 'url'. Optional: 'bkup_url'
{coreboot}{
rev: HEAD