2023-09-30 00:31:40 +00:00
|
|
|
# SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
# SPDX-FileCopyrightText: 2022 Caleb La Grange <thonkpeasant@protonmail.com>
|
|
|
|
# SPDX-FileCopyrightText: 2022 Ferass El Hafidi <vitali64pmemail@protonmail.com>
|
2024-01-01 17:08:38 +00:00
|
|
|
# SPDX-FileCopyrightText: 2020-2024 Leah Rowe <leah@libreboot.org>
|
2023-08-27 13:14:49 +00:00
|
|
|
|
2024-05-06 21:54:55 +00:00
|
|
|
export LC_COLLATE=C
|
|
|
|
export LC_ALL=C
|
|
|
|
|
|
|
|
tmpdir_was_set="y"
|
2023-10-19 23:17:30 +00:00
|
|
|
vendir="vendorfiles"
|
2023-10-15 10:22:43 +00:00
|
|
|
appdir="${vendir}/app"
|
|
|
|
cbdir="src/coreboot/default"
|
|
|
|
cbcfgsdir="config/coreboot"
|
|
|
|
ifdtool="cbutils/default/ifdtool"
|
|
|
|
cbfstool="cbutils/default/cbfstool"
|
2023-12-30 13:08:29 +00:00
|
|
|
grubcfgsdir="config/grub"
|
|
|
|
layoutdir="/boot/grub/layouts"
|
|
|
|
. "${grubcfgsdir}/modules.list"
|
2024-01-01 15:02:34 +00:00
|
|
|
tmpgit="${PWD}/tmp/gitclone"
|
2024-05-06 21:54:55 +00:00
|
|
|
err="err_"
|
|
|
|
|
|
|
|
err_()
|
|
|
|
{
|
|
|
|
printf "ERROR %s: %s\n" "${0}" "${1}" 1>&2
|
|
|
|
exit 1
|
|
|
|
}
|
2023-10-15 10:22:43 +00:00
|
|
|
|
2024-05-06 21:54:55 +00:00
|
|
|
setvars()
|
|
|
|
{
|
|
|
|
_setvars=""
|
|
|
|
[ $# -lt 2 ] && $err "setvars: too few arguments"
|
|
|
|
val="${1}" && shift 1
|
|
|
|
for var in $@; do
|
|
|
|
_setvars="${var}=\"${val}\"; ${_setvars}"
|
|
|
|
done
|
|
|
|
printf "%s\n" "${_setvars% }"
|
|
|
|
}
|
2023-10-15 10:22:43 +00:00
|
|
|
eval "$(setvars "" CONFIG_BOARD_DELL_E6400 CONFIG_HAVE_MRC CONFIG_HAVE_ME_BIN \
|
2024-05-11 17:53:12 +00:00
|
|
|
CONFIG_ME_BIN_PATH CONFIG_KBC1126_FIRMWARE CONFIG_KBC1126_FW1 versiondate \
|
2023-10-15 10:22:43 +00:00
|
|
|
CONFIG_KBC1126_FW1_OFFSET CONFIG_KBC1126_FW2 CONFIG_KBC1126_FW2_OFFSET \
|
2024-05-11 17:53:12 +00:00
|
|
|
CONFIG_VGA_BIOS_FILE CONFIG_VGA_BIOS_ID CONFIG_GBE_BIN_PATH tmpdir _nogit \
|
|
|
|
CONFIG_INCLUDE_SMSC_SCH5545_EC_FW CONFIG_SMSC_SCH5545_EC_FW_FILE version \
|
2024-05-06 21:54:55 +00:00
|
|
|
CONFIG_IFD_BIN_PATH CONFIG_MRC_FILE _dest board boarddir lbmk_release \
|
2024-05-15 00:23:22 +00:00
|
|
|
CONFIG_HAVE_REFCODE_BLOB CONFIG_REFCODE_BLOB_FILE threads projectname \
|
|
|
|
relname)"
|
2024-05-06 21:54:55 +00:00
|
|
|
|
|
|
|
# if "y": a coreboot target won't be built if target.cfg says release="n"
|
|
|
|
# (this is used to exclude certain build targets from releases)
|
|
|
|
set | grep LBMK_RELEASE 1>/dev/null 2>/dev/null || lbmk_release="n" || :
|
|
|
|
[ -z "$lbmk_release" ] && lbmk_release="$LBMK_RELEASE"
|
|
|
|
[ "$lbmk_release" = "n" ] || [ "$lbmk_release" = "y" ] || lbmk_release="n"
|
|
|
|
export LBMK_RELEASE="$lbmk_release"
|
|
|
|
|
|
|
|
set | grep TMPDIR 1>/dev/null 2>/dev/null || tmpdir_was_set="n"
|
|
|
|
if [ "${tmpdir_was_set}" = "y" ]; then
|
|
|
|
[ "${TMPDIR%_*}" = "/tmp/lbmk" ] || tmpdir_was_set="n"
|
|
|
|
fi
|
|
|
|
if [ "${tmpdir_was_set}" = "n" ]; then
|
|
|
|
export TMPDIR="/tmp"
|
|
|
|
tmpdir="$(mktemp -d -t lbmk_XXXXXXXX)"
|
|
|
|
export TMPDIR="${tmpdir}"
|
|
|
|
else
|
|
|
|
export TMPDIR="${TMPDIR}"
|
|
|
|
tmpdir="${TMPDIR}"
|
|
|
|
fi
|
2023-10-15 10:22:43 +00:00
|
|
|
|
2024-04-28 16:31:16 +00:00
|
|
|
set | grep LBMK_THREADS 1>/dev/null 2>/dev/null && threads="$LBMK_THREADS"
|
|
|
|
[ -z "$threads" ] && threads=1
|
2024-03-27 07:14:47 +00:00
|
|
|
expr "X$threads" : "X-\{0,1\}[0123456789][0123456789]*$" \
|
|
|
|
1>/dev/null 2>/dev/null || threads=1 # user specified a non-integer
|
2024-04-28 16:31:16 +00:00
|
|
|
export LBMK_THREADS="$threads"
|
|
|
|
|
2023-10-19 22:36:56 +00:00
|
|
|
items()
|
2023-08-27 13:14:49 +00:00
|
|
|
{
|
2023-09-27 20:46:20 +00:00
|
|
|
rval=1
|
2023-12-19 02:31:44 +00:00
|
|
|
if [ ! -d "${1}" ]; then
|
2023-12-19 02:32:56 +00:00
|
|
|
printf "items: directory '%s' doesn't exist" "${1}" 1>&2
|
2023-12-19 02:31:44 +00:00
|
|
|
return 1
|
|
|
|
fi
|
2023-08-27 13:14:49 +00:00
|
|
|
for x in "${1}/"*; do
|
|
|
|
# -e used because this is for files *or* directories
|
|
|
|
[ -e "${x}" ] || continue
|
|
|
|
[ "${x##*/}" = "build.list" ] && continue
|
2023-09-09 22:15:17 +00:00
|
|
|
printf "%s\n" "${x##*/}" 2>/dev/null
|
2023-09-27 20:46:20 +00:00
|
|
|
rval=0
|
2023-08-27 13:14:49 +00:00
|
|
|
done
|
2023-09-27 20:46:20 +00:00
|
|
|
return ${rval}
|
2023-08-27 13:14:49 +00:00
|
|
|
}
|
2023-09-30 00:31:40 +00:00
|
|
|
|
|
|
|
scan_config()
|
|
|
|
{
|
|
|
|
awkstr=" /\{.*${1}.*}{/ {flag=1;next} /\}/{flag=0} flag { print }"
|
|
|
|
confdir="${2}"
|
2023-10-02 02:39:10 +00:00
|
|
|
revfile="$(mktemp -t sources.XXXXXXXXXX)"
|
2023-09-30 00:31:40 +00:00
|
|
|
cat "${confdir}/"* > "${revfile}" || \
|
safer, simpler error handling in lbmk
in shell scripts, a function named the same as a program included in
the $PATH will override that program. for example, you could make a
function called ls() and this would override the standand "ls".
in lbmk, a part of it was first trying to run the "fail" command,
deferring to "err", because some scripts call fail() which does
some minor cleanup before calling err.
in most cases, fail() is not defined, and it's possible that the user
could have a program called "fail" in their $PATH, the behaviour of
which we could not determine, and it could have disastrous effects.
lbmk error handling has been re-engineered in such a way that the
err function is defined in a variable, which defaults to err_ which
calls err_, so defined under include/err.sh.
in functions that require cleanup prior to error handling, a fail()
function is still defined, and err is overridden, thus:
err="fail"
this change has made xx_() obsolete, so now only x_ is used. the x_
function is a wrapper that can be used to run a command and exit with
non-zero status (from lbmk) if the command fails. the xx_ command
did the same thing, but called fail() which would have called err();
now everything is $err
example:
rm -f "$filename" || err "could not delete file"
this would now be:
rm -f "$filename" || $err "could not delete file"
overriding of err= must be done *after* including err.sh. for
example:
err="fail"
. "include/err.sh"
^ this is wrong. instead, one must do:
. "include/err.sh"
err="fail"
this is because err is set as a global variable under err.sh
the new error handling is much cleaner, and safer. it also reduces
the chance of mistakes such as: calling err when you meant to
call fail. this is because the standard way is now to call $err,
so you set err="fail" at the top of the script and all is well.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-03-27 01:19:39 +00:00
|
|
|
$err "scan_config ${confdir}: Cannot concatenate files"
|
2023-09-30 00:31:40 +00:00
|
|
|
while read -r line ; do
|
|
|
|
set ${line} 1>/dev/null 2>/dev/null || :
|
2023-12-19 02:34:54 +00:00
|
|
|
if [ "${1%:}" = "depend" ]; then
|
|
|
|
depend="${depend} ${2}"
|
2023-12-27 17:26:37 +00:00
|
|
|
else
|
|
|
|
eval "${1%:}=\"${2}\""
|
2023-12-19 02:34:54 +00:00
|
|
|
fi
|
2023-09-30 00:31:40 +00:00
|
|
|
done << EOF
|
|
|
|
$(eval "awk '${awkstr}' \"${revfile}\"")
|
|
|
|
EOF
|
safer, simpler error handling in lbmk
in shell scripts, a function named the same as a program included in
the $PATH will override that program. for example, you could make a
function called ls() and this would override the standand "ls".
in lbmk, a part of it was first trying to run the "fail" command,
deferring to "err", because some scripts call fail() which does
some minor cleanup before calling err.
in most cases, fail() is not defined, and it's possible that the user
could have a program called "fail" in their $PATH, the behaviour of
which we could not determine, and it could have disastrous effects.
lbmk error handling has been re-engineered in such a way that the
err function is defined in a variable, which defaults to err_ which
calls err_, so defined under include/err.sh.
in functions that require cleanup prior to error handling, a fail()
function is still defined, and err is overridden, thus:
err="fail"
this change has made xx_() obsolete, so now only x_ is used. the x_
function is a wrapper that can be used to run a command and exit with
non-zero status (from lbmk) if the command fails. the xx_ command
did the same thing, but called fail() which would have called err();
now everything is $err
example:
rm -f "$filename" || err "could not delete file"
this would now be:
rm -f "$filename" || $err "could not delete file"
overriding of err= must be done *after* including err.sh. for
example:
err="fail"
. "include/err.sh"
^ this is wrong. instead, one must do:
. "include/err.sh"
err="fail"
this is because err is set as a global variable under err.sh
the new error handling is much cleaner, and safer. it also reduces
the chance of mistakes such as: calling err when you meant to
call fail. this is because the standard way is now to call $err,
so you set err="fail" at the top of the script and all is well.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-03-27 01:19:39 +00:00
|
|
|
rm -f "$revfile" || $err "scan_config: Cannot remove tmpfile"
|
2023-09-30 00:31:40 +00:00
|
|
|
}
|
2023-10-07 04:16:46 +00:00
|
|
|
|
2023-10-15 10:22:43 +00:00
|
|
|
check_defconfig()
|
|
|
|
{
|
|
|
|
for x in "${1}"/config/*; do
|
2023-12-22 13:05:32 +00:00
|
|
|
[ -f "${x}" ] && return 1
|
2023-10-15 10:22:43 +00:00
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2023-10-07 04:16:46 +00:00
|
|
|
handle_coreboot_utils()
|
|
|
|
{
|
|
|
|
for util in cbfstool ifdtool; do
|
2023-10-19 23:17:30 +00:00
|
|
|
x_ ./update trees ${_f} "src/coreboot/${1}/util/${util}"
|
2023-10-07 04:36:52 +00:00
|
|
|
[ -z "${mode}" ] && [ ! -f "cbutils/${1}/${util}" ] && \
|
2023-10-07 04:16:46 +00:00
|
|
|
x_ mkdir -p "cbutils/${1}" && \
|
|
|
|
x_ cp "src/coreboot/${1}/util/${util}/${util}" \
|
|
|
|
"cbutils/${1}"
|
2023-10-20 03:10:50 +00:00
|
|
|
[ -z "${mode}" ] || x_ rm -Rf "cbutils/${1}"
|
2023-10-07 04:16:46 +00:00
|
|
|
done
|
|
|
|
}
|
2023-12-22 09:46:43 +00:00
|
|
|
|
|
|
|
remkdir()
|
|
|
|
{
|
safer, simpler error handling in lbmk
in shell scripts, a function named the same as a program included in
the $PATH will override that program. for example, you could make a
function called ls() and this would override the standand "ls".
in lbmk, a part of it was first trying to run the "fail" command,
deferring to "err", because some scripts call fail() which does
some minor cleanup before calling err.
in most cases, fail() is not defined, and it's possible that the user
could have a program called "fail" in their $PATH, the behaviour of
which we could not determine, and it could have disastrous effects.
lbmk error handling has been re-engineered in such a way that the
err function is defined in a variable, which defaults to err_ which
calls err_, so defined under include/err.sh.
in functions that require cleanup prior to error handling, a fail()
function is still defined, and err is overridden, thus:
err="fail"
this change has made xx_() obsolete, so now only x_ is used. the x_
function is a wrapper that can be used to run a command and exit with
non-zero status (from lbmk) if the command fails. the xx_ command
did the same thing, but called fail() which would have called err();
now everything is $err
example:
rm -f "$filename" || err "could not delete file"
this would now be:
rm -f "$filename" || $err "could not delete file"
overriding of err= must be done *after* including err.sh. for
example:
err="fail"
. "include/err.sh"
^ this is wrong. instead, one must do:
. "include/err.sh"
err="fail"
this is because err is set as a global variable under err.sh
the new error handling is much cleaner, and safer. it also reduces
the chance of mistakes such as: calling err when you meant to
call fail. this is because the standard way is now to call $err,
so you set err="fail" at the top of the script and all is well.
Signed-off-by: Leah Rowe <leah@libreboot.org>
2024-03-27 01:19:39 +00:00
|
|
|
rm -Rf "${1}" || $err "remkdir: !rm -Rf \"${1}\""
|
|
|
|
mkdir -p "${1}" || $err "remkdir: !mkdir -p \"${1}\""
|
2023-12-22 09:46:43 +00:00
|
|
|
}
|
2024-05-06 21:54:55 +00:00
|
|
|
|
|
|
|
x_() {
|
|
|
|
[ $# -lt 1 ] || ${@} || $err "Unhandled non-zero exit: $@"; return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
check_git()
|
|
|
|
{
|
|
|
|
which git 1>/dev/null 2>/dev/null || \
|
|
|
|
git_err "git not installed. please install git-scm."
|
|
|
|
git config --global user.name 1>/dev/null 2>/dev/null || \
|
|
|
|
git_err "git config --global user.name \"John Doe\""
|
|
|
|
git config --global user.email 1>/dev/null 2>/dev/null || \
|
|
|
|
git_err "git config --global user.email \"john.doe@example.com\""
|
|
|
|
}
|
|
|
|
|
|
|
|
git_err()
|
|
|
|
{
|
|
|
|
printf "You need to set git name/email, like so:\n%s\n\n" "$1" 1>&2
|
|
|
|
$err "Git name/email not configured"
|
|
|
|
}
|
|
|
|
|
|
|
|
check_project()
|
|
|
|
{
|
|
|
|
read -r projectname < projectname || :
|
|
|
|
|
|
|
|
[ ! -f version ] || read -r version < version || :
|
|
|
|
version_="${version}"
|
|
|
|
[ ! -e ".git" ] || version="$(git describe --tags HEAD 2>&1)" || \
|
|
|
|
version="git-$(git rev-parse HEAD 2>&1)" || version="${version_}"
|
|
|
|
|
|
|
|
[ ! -f versiondate ] || read -r versiondate < versiondate || :
|
|
|
|
versiondate_="${versiondate}"
|
|
|
|
[ ! -e ".git" ] || versiondate="$(git show --no-patch --no-notes \
|
|
|
|
--pretty='%ct' HEAD)" || versiondate="${versiondate_}"
|
|
|
|
|
|
|
|
for p in projectname version versiondate; do
|
|
|
|
eval "[ -n \"\$$p\" ] || $err \"$p unset\""
|
|
|
|
eval "x_ printf \"%s\\n\" \"\$$p\" > $p"
|
|
|
|
done
|
2024-05-15 00:23:22 +00:00
|
|
|
|
|
|
|
relname="${projectname}-${version}"
|
2024-05-06 21:54:55 +00:00
|
|
|
export LOCALVERSION="-${projectname}-${version%%-*}"
|
|
|
|
}
|
2024-05-14 22:17:22 +00:00
|
|
|
|
|
|
|
mktar_release()
|
|
|
|
{
|
2024-05-14 23:45:01 +00:00
|
|
|
printf "%s\n" "${version}" > "${1}/version" || return 1
|
|
|
|
printf "%s\n" "${versiondate}" > "${1}/versiondate" || return 1
|
|
|
|
printf "%s\n" "${projectname}" > "${1}/projectname" || return 1
|
|
|
|
|
2024-05-15 00:23:22 +00:00
|
|
|
mktarball "$1" "${1%/*}/${relname}_${1##*/}.tar.xz"
|
2024-05-14 22:17:22 +00:00
|
|
|
x_ rm -Rf "$1"
|
|
|
|
}
|
|
|
|
|
|
|
|
mktarball()
|
|
|
|
{
|
|
|
|
[ "${2%/*}" = "${2}" ] || \
|
|
|
|
mkdir -p "${2%/*}" || $err "mk, !mkdir -p \"${2%/*}\""
|
|
|
|
printf "\nCreating archive: %s\n\n" "$2"
|
2024-05-14 23:48:08 +00:00
|
|
|
tar -c "$1" | xz -T$threads -9e > "$2" || \
|
|
|
|
$err "mktarball 2, $1"
|
2024-05-14 23:37:12 +00:00
|
|
|
mksha512sum "${2}" "${2##*/}.sha512"
|
|
|
|
}
|
|
|
|
|
|
|
|
mksha512sum()
|
|
|
|
{
|
2024-05-14 22:17:22 +00:00
|
|
|
(
|
2024-05-14 23:37:12 +00:00
|
|
|
[ "${1%/*}" != "${1}" ] && x_ cd "${1%/*}"
|
|
|
|
sha512sum ./"${1##*/}" >> "${2}" || \
|
|
|
|
$err "!sha512sum \"${1}\" > \"${2}\""
|
2024-05-14 22:17:22 +00:00
|
|
|
) || $err "failed to create tarball checksum"
|
|
|
|
}
|