lbmk scripts: general code cleanup
Signed-off-by: Leah Rowe <leah@libreboot.org>9020vga
parent
38a7aa3196
commit
b4ab30577f
|
@ -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=""; version_=""; versiondate=""; versiondate_=""; projectname=""; _nogit=""
|
version=""; versiondate=""; projectname=""; _nogit=""
|
||||||
|
|
||||||
x_() {
|
x_() {
|
||||||
[ $# -lt 1 ] || ${@} || err_exit err ${@}
|
[ $# -lt 1 ] || ${@} || err_exit err ${@}
|
||||||
|
|
|
@ -40,7 +40,7 @@ mkvdir()
|
||||||
{
|
{
|
||||||
mkdir -p "${vdir}" || err "mkvdir: !mkdir -p \"${vdir}\""
|
mkdir -p "${vdir}" || err "mkvdir: !mkdir -p \"${vdir}\""
|
||||||
git clone . "${srcdir}" || err "mkdir: !gitclone \"${srcdir}\""
|
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()
|
build_release()
|
||||||
|
@ -53,7 +53,7 @@ build_release()
|
||||||
) || err "can't create release files"
|
) || err "can't create release files"
|
||||||
(
|
(
|
||||||
cd "${srcdir%/*}" || err "${_xm}: mktarball \"${srcdir}\""
|
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"
|
) || err "can't create src tarball"
|
||||||
[ "${mode}" = "src" ] && return 0
|
[ "${mode}" = "src" ] && return 0
|
||||||
|
|
||||||
|
@ -78,8 +78,8 @@ fetch_trees()
|
||||||
err "!rm -Rf \"src/${xp}/${xp}\""
|
err "!rm -Rf \"src/${xp}/${xp}\""
|
||||||
done
|
done
|
||||||
|
|
||||||
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 .git
|
x_ rm -Rf tmp .git
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ handle_rom_archive()
|
||||||
|
|
||||||
romdir="${romdir}/bin/${target}"
|
romdir="${romdir}/bin/${target}"
|
||||||
mkdir -p "${romdir}" || err "!mkdir -p romdir, handle_rom_archive"
|
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
|
nukerom
|
||||||
|
|
||||||
|
@ -128,7 +128,8 @@ handle_rom_archive()
|
||||||
insert_version_files "${romdir}" || \
|
insert_version_files "${romdir}" || \
|
||||||
err "mkrom_tarball ${romdir}: versionfile"
|
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
|
mkrom_tarball
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,7 +143,8 @@ nukerom()
|
||||||
touch "${romdir}/vendorhashes" || err "!touch ${romdir}/vendorhashes"
|
touch "${romdir}/vendorhashes" || err "!touch ${romdir}/vendorhashes"
|
||||||
(
|
(
|
||||||
cd "${romdir}" || err "!cd romdir ${romdir}, nukerom"
|
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"
|
) || err "can't create vendor hashes"
|
||||||
|
|
||||||
for romfile in "${romdir}"/*.rom; do
|
for romfile in "${romdir}"/*.rom; do
|
||||||
|
@ -159,9 +161,11 @@ insert_copying_files()
|
||||||
# copy licenses to rom image archive, for completion
|
# copy licenses to rom image archive, for completion
|
||||||
cp "src/grub/COPYING" "${l}/COPYING.grub" || return 1
|
cp "src/grub/COPYING" "${l}/COPYING.grub" || return 1
|
||||||
cp "src/coreboot/default/COPYING" "${l}/COPYING.coreboot" || 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" "${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
|
cp -R "src/u-boot/default/Licenses" "${l}/COPYING.u-boot" || return 1
|
||||||
printf "Multiple licenses. Check corresponding %s source archive\n" \
|
printf "Multiple licenses. Check corresponding %s source archive\n" \
|
||||||
"${projectname}" > "${1}/COPYING" || return 1
|
"${projectname}" > "${1}/COPYING" || return 1
|
||||||
|
@ -173,11 +177,11 @@ mkrom_tarball()
|
||||||
f="release/${version}/roms/${archivename}"
|
f="release/${version}/roms/${archivename}"
|
||||||
mkdir -p "${f%/*}" || err "mkrom_tarball: !mkdir -p ${f%/*}"
|
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"
|
mktarball "bin/${target}" "${archivename}.tar.xz"
|
||||||
) || err "can't create rom tarball"
|
) || err "can't create rom tarball"
|
||||||
mv "${romdir%"/bin/${target}"}/${archivename}.tar.xz"* "${f%/*}" || \
|
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"
|
printf "Created ROM archive: %s" "${f%/*}/${archivename}.tar.xz"
|
||||||
}
|
}
|
||||||
|
@ -194,14 +198,15 @@ mktarball()
|
||||||
# preserve timestamps for reproducible tarballs
|
# preserve timestamps for reproducible tarballs
|
||||||
tar_implementation=$(tar --version | head -n1) || :
|
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
|
if [ "${tar_implementation% *}" = "tar (GNU tar)" ]; then
|
||||||
tar --sort=name --owner=root:0 --group=root:0 \
|
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}"
|
err "mktarball 1, ${1}"
|
||||||
else
|
else
|
||||||
# TODO: reproducible tarballs on non-GNU systems
|
# 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
|
fi
|
||||||
(
|
(
|
||||||
[ "${2%/*}" != "${2}" ] && x_ cd "${2%/*}"
|
[ "${2%/*}" != "${2}" ] && x_ cd "${2%/*}"
|
||||||
|
|
|
@ -153,7 +153,7 @@ handle_src_tree()
|
||||||
if [ ! -d "${codedir}" ]; then
|
if [ ! -d "${codedir}" ]; then
|
||||||
if [ "${mode}" = "distclean" ] || \
|
if [ "${mode}" = "distclean" ] || \
|
||||||
[ "${mode}" = "crossgcc-clean" ]; then
|
[ "${mode}" = "crossgcc-clean" ]; then
|
||||||
printf "Directory %s doesn't exist; skipping clean\n" \
|
printf "Directory %s missing; skipping clean\n" \
|
||||||
"${codedir}" 1>&2
|
"${codedir}" 1>&2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
@ -233,7 +233,8 @@ run_make_command()
|
||||||
[ -f "${codedir}/Makefile" ] || [ -f "${codedir}/makefile" ] || \
|
[ -f "${codedir}/Makefile" ] || [ -f "${codedir}/makefile" ] || \
|
||||||
[ -f "${codedir}/GNUmakefile" ] || return 1
|
[ -f "${codedir}/GNUmakefile" ] || return 1
|
||||||
[ "${project}" = "coreboot" ] && [ -z "${mode}" ] && \
|
[ "${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}"
|
x_ make ${mode} -j$(nproc) -C "${codedir}"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue