.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>btrfsvols
parent
355eb765ff
commit
4a280c629f
81
.gitcheck
81
.gitcheck
|
@ -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 $@
|
|
@ -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 $@
|
1
fetch
1
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"
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
||||
|
|
5
lbmk
5
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()
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue