summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2023-12-24 06:32:19 +0000
committerLeah Rowe <leah@libreboot.org>2023-12-24 06:32:19 +0000
commitb4ab30577ffd2c3b5908b8d599091982acce8f9c (patch)
tree993089a01d8c0e0cc556c0c27fbb94c48c1efeee
parent38a7aa3196e25627df2d9e089b00421b9194f7b6 (diff)
lbmk scripts: general code cleanup
Signed-off-by: Leah Rowe <leah@libreboot.org>
-rwxr-xr-xinclude/err.sh2
-rwxr-xr-xscript/update/release33
-rwxr-xr-xscript/update/trees5
3 files changed, 23 insertions, 17 deletions
diff --git a/include/err.sh b/include/err.sh
index b7a273a6..1aeebcbb 100755
--- a/include/err.sh
+++ b/include/err.sh
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: 2022, 2023 Leah Rowe <leah@libreboot.org>
-version=""; version_=""; versiondate=""; versiondate_=""; projectname=""; _nogit=""
+version=""; versiondate=""; projectname=""; _nogit=""
x_() {
[ $# -lt 1 ] || ${@} || err_exit err ${@}
diff --git a/script/update/release b/script/update/release
index c242c9ce..fd20d0ee 100755
--- a/script/update/release
+++ b/script/update/release
@@ -40,7 +40,7 @@ mkvdir()
{
mkdir -p "${vdir}" || err "mkvdir: !mkdir -p \"${vdir}\""
git clone . "${srcdir}" || err "mkdir: !gitclone \"${srcdir}\""
- insert_version_files "${srcdir}" || err "mkvdir ${srcdir}: versionfile"
+ insert_version_files "$srcdir" || err "mkvdir $srcdir: versionfile"
}
build_release()
@@ -53,7 +53,7 @@ build_release()
) || err "can't create release files"
(
cd "${srcdir%/*}" || err "${_xm}: mktarball \"${srcdir}\""
- mktarball "${srcdir##*/}" "${srcdir##*/}.tar.xz" || err "${_xm}: mksrc"
+ mktarball "${srcdir##*/}" "${srcdir##*/}.tar.xz" || err "$_xm: mksrc"
) || err "can't create src tarball"
[ "${mode}" = "src" ] && return 0
@@ -78,8 +78,8 @@ fetch_trees()
err "!rm -Rf \"src/${xp}/${xp}\""
done
- find . -name ".git" -exec rm -Rf {} + || err "${_xm}: rm .git"
- find . -name ".gitmodules" -exec rm -Rf {} + || err "${_xm}: rm .gitmod"
+ find . -name ".git" -exec rm -Rf {} + || err "$_xm: rm .git"
+ find . -name ".gitmodules" -exec rm -Rf {} + || err "$_xm: rm .gitmod"
x_ rm -Rf tmp .git
}
@@ -119,7 +119,7 @@ handle_rom_archive()
romdir="${romdir}/bin/${target}"
mkdir -p "${romdir}" || err "!mkdir -p romdir, handle_rom_archive"
- cp "${builddir}/"* "${romdir}" || err "!cp romdir, handle_rom_archive"
+ cp "$builddir/"* "$romdir" || err "!cp romdir, handle_rom_archive"
nukerom
@@ -128,7 +128,8 @@ handle_rom_archive()
insert_version_files "${romdir}" || \
err "mkrom_tarball ${romdir}: versionfile"
- insert_copying_files "$romdir" || err "!insert copy, handle 2, $romdir"
+ insert_copying_files "$romdir" || \
+ err "!insert copy, handle 2, $romdir"
mkrom_tarball
}
@@ -142,7 +143,8 @@ nukerom()
touch "${romdir}/vendorhashes" || err "!touch ${romdir}/vendorhashes"
(
cd "${romdir}" || err "!cd romdir ${romdir}, nukerom"
- sha512sum ./*.rom >> vendorhashes || err "!create vendorhashes, nukerom"
+ sha512sum ./*.rom >> vendorhashes || \
+ err "!create vendorhashes, nukerom"
) || err "can't create vendor hashes"
for romfile in "${romdir}"/*.rom; do
@@ -159,9 +161,11 @@ insert_copying_files()
# copy licenses to rom image archive, for completion
cp "src/grub/COPYING" "${l}/COPYING.grub" || return 1
cp "src/coreboot/default/COPYING" "${l}/COPYING.coreboot" || return 1
- cp -R "src/coreboot/default/LICENSES" "${l}/LICENSES.coreboot" || return 1
+ cp -R "src/coreboot/default/LICENSES" "${l}/LICENSES.coreboot" || \
+ return 1
cp "src/seabios/default/COPYING" "${l}/COPYING.coreboot" || return 1
- cp "src/seabios/default/COPYING.LESSER" "${l}/COPYING.LESSER.seabios" || return 1
+ cp "src/seabios/default/COPYING.LESSER" "$l/COPYING.LESSER.seabios" \
+ || return 1
cp -R "src/u-boot/default/Licenses" "${l}/COPYING.u-boot" || return 1
printf "Multiple licenses. Check corresponding %s source archive\n" \
"${projectname}" > "${1}/COPYING" || return 1
@@ -173,11 +177,11 @@ mkrom_tarball()
f="release/${version}/roms/${archivename}"
mkdir -p "${f%/*}" || err "mkrom_tarball: !mkdir -p ${f%/*}"
(
- cd "${romdir%"/bin/${target}"}" || err "!cd ${romdir%"/bin/${target}"}"
+ cd "${romdir%"/bin/$target"}" || err "!cd ${romdir%"/bin/$target"}"
mktarball "bin/${target}" "${archivename}.tar.xz"
) || err "can't create rom tarball"
mv "${romdir%"/bin/${target}"}/${archivename}.tar.xz"* "${f%/*}" || \
- err "!mktarball, rom, ${f%/*}/${romdir%"/bin/${target}"}/${archivename}.tar.xz"
+ err "mktar ${f%/*}/${romdir%"/bin/$target"}/$archivename.tar.xz"
printf "Created ROM archive: %s" "${f%/*}/${archivename}.tar.xz"
}
@@ -194,14 +198,15 @@ mktarball()
# preserve timestamps for reproducible tarballs
tar_implementation=$(tar --version | head -n1) || :
- [ "${2%/*}" = "${2}" ] || mkdir -p "${2%/*}" || err "mk, !mkdir -p \"${2%/*}\""
+ [ "${2%/*}" = "${2}" ] || \
+ mkdir -p "${2%/*}" || err "mk, !mkdir -p \"${2%/*}\""
if [ "${tar_implementation% *}" = "tar (GNU tar)" ]; then
tar --sort=name --owner=root:0 --group=root:0 \
- --mtime="UTC 2023-11-06" -c "${1}" | xz -T0 -9e > "${2}" || \
+ --mtime="UTC 2023-11-06" -c "$1" | xz -T0 -9e > "$2" || \
err "mktarball 1, ${1}"
else
# TODO: reproducible tarballs on non-GNU systems
- tar -c "${1}" | xz -T0 -9e > "${2}" || err "mktarball 2, ${1}"
+ tar -c "$1" | xz -T0 -9e > "$2" || err "mktarball 2, $1"
fi
(
[ "${2%/*}" != "${2}" ] && x_ cd "${2%/*}"
diff --git a/script/update/trees b/script/update/trees
index 08a86f61..70fa208e 100755
--- a/script/update/trees
+++ b/script/update/trees
@@ -153,7 +153,7 @@ handle_src_tree()
if [ ! -d "${codedir}" ]; then
if [ "${mode}" = "distclean" ] || \
[ "${mode}" = "crossgcc-clean" ]; then
- printf "Directory %s doesn't exist; skipping clean\n" \
+ printf "Directory %s missing; skipping clean\n" \
"${codedir}" 1>&2
return 1
fi
@@ -233,7 +233,8 @@ run_make_command()
[ -f "${codedir}/Makefile" ] || [ -f "${codedir}/makefile" ] || \
[ -f "${codedir}/GNUmakefile" ] || return 1
[ "${project}" = "coreboot" ] && [ -z "${mode}" ] && \
- x_ printf "%s\n" "${version%%-*}" >"$codedir/.coreboot-version"
+ x_ printf "%s\n" "${version%%-*}" \
+ > "${codedir}/.coreboot-version"
x_ make ${mode} -j$(nproc) -C "${codedir}"