always re-generate .git in lbmk

in release archives, .git is excluded but the version
and versiondate files are included. from these, the
git history is re-created with the exact date (but not
taking into account timezone, at present).

in this way, lbmk will have git history in a release
archive. some build systems, like coreboot, prefer that
there be git history available, so this is a nice
workaround on those build systems.

Signed-off-by: Leah Rowe <leah@libreboot.org>
btrfsvols
Leah Rowe 2023-10-20 11:16:25 +01:00
parent 52c9416b19
commit 54a05fc167
3 changed files with 18 additions and 22 deletions

1
build
View File

@ -46,6 +46,7 @@ main()
check_git check_git
check_project "fail" check_project "fail"
git_init xx_ fail
execute_command $@ execute_command $@
lbmk_exit 0 lbmk_exit 0

View File

@ -1,7 +1,7 @@
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: 2022, 2023 Leah Rowe <leah@libreboot.org> # SPDX-FileCopyrightText: 2022, 2023 Leah Rowe <leah@libreboot.org>
version=""; versiondate=""; projectname="" version=""; versiondate=""; projectname=""; _nogit=""
x_() { x_() {
[ $# -lt 1 ] || ${@} || err_exit err ${@} [ $# -lt 1 ] || ${@} || err_exit err ${@}
@ -27,6 +27,20 @@ check_git()
git_err "git config --global user.email \"john.doe@example.com\"" git_err "git config --global user.email \"john.doe@example.com\""
} }
# release archives contain .gitignore, but not .git.
# lbmk can be run from lbmk.git, or an archive.
git_init()
{
[ -L ".git" ] && ${2} "Reference .git is a symlink"
[ -e ".git" ] && return 0
eval "$(setvars "$(date -Rd @${versiondate})" cdate _nogit)"
${1} git init
${1} git add -A .
${1} git commit -m "${projectname} ${version}" --date "${cdate}"
${1} git tag -a "${version}" -m "${projectname} ${version}"
}
git_err() git_err()
{ {
printf "You need to set git name/email, like so:\n%s\n\n" "${1}" 1>&2 printf "You need to set git name/email, like so:\n%s\n\n" "${1}" 1>&2

View File

@ -8,7 +8,7 @@ set -u -e
. "include/err.sh" . "include/err.sh"
. "include/option.sh" . "include/option.sh"
eval "$(setvars "" vdir relname src_dirname srcdir _nogit _xm target romdir \ eval "$(setvars "" vdir relname src_dirname srcdir _xm target romdir \
microcode_required mode)" microcode_required mode)"
main() main()
@ -37,29 +37,10 @@ main()
mkvdir() mkvdir()
{ {
mkdir -p "${vdir}" || err "mkvdir: !mkdir -p \"${vdir}\"" mkdir -p "${vdir}" || err "mkvdir: !mkdir -p \"${vdir}\""
git_init || err "mkvdir: !git_init \"${vdir}\""
git clone . "${srcdir}" || err "mkdir: !gitclone \"${srcdir}\"" git clone . "${srcdir}" || err "mkdir: !gitclone \"${srcdir}\""
[ -z "${_nogit}" ] || x_ rm -Rf ".git"
rm -Rf "${srcdir}/.git" || err "mkvdir: !rm -Rf ${srcdir}/.git"
insert_version_files "${srcdir}" || err "mkvdir ${srcdir}: versionfile" insert_version_files "${srcdir}" || err "mkvdir ${srcdir}: versionfile"
} }
# release archives contain .gitignore, but not .git.
# this script can be run from lbmk.git, or an archive.
git_init()
{
[ -L ".git" ] && err "Reference .git is a symlink"
[ -e ".git" ] && return 0
eval "$(setvars "$(date -Rd @${versiondate})" cdate _nogit)"
git init || return 1
git add -A . || return 1
git commit -m "${projectname} ${version}" --date "${cdate}" || return 1
git tag -a "${version}" -m "${projectname} ${version}" || return 1
}
build_release() build_release()
{ {
_xm="build_release ${vdir}" _xm="build_release ${vdir}"
@ -94,7 +75,7 @@ fetch_trees()
find . -name ".git" -exec rm -Rf {} + || err "${_xm}: rm .git" find . -name ".git" -exec rm -Rf {} + || err "${_xm}: rm .git"
find . -name ".gitmodules" -exec rm -Rf {} + || err "${_xm}: rm .gitmod" find . -name ".gitmodules" -exec rm -Rf {} + || err "${_xm}: rm .gitmod"
x_ rm -Rf tmp x_ rm -Rf tmp .git
} }
mkrom_images() mkrom_images()