130 lines
3.2 KiB
Bash
Executable File
130 lines
3.2 KiB
Bash
Executable File
#!/usr/bin/env sh
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
# SPDX-FileCopyrightText: 2020,2021,2023 Leah Rowe <leah@libreboot.org>
|
|
|
|
[ "x${DEBUG+set}" = 'xset' ] && set -v
|
|
set -u -e
|
|
|
|
. "include/err.sh"
|
|
|
|
read projectname < projectname
|
|
|
|
trees_fetch_list="coreboot u-boot seabios"
|
|
simple_fetch_list="flashrom grub memtest86plus me_cleaner uefitool"
|
|
simple_fetch_list="${simple_fetch_list} bios_extract biosutilities"
|
|
download_only_list="pico-serprog stm32-vserprog"
|
|
|
|
dirlist="config util script include util-fw"
|
|
linklist="build update handle" # symlinks in main directory, to script: lbmk
|
|
filelist="lbmk README.md COPYING version versiondate projectname checkgit"
|
|
filelist="${filelist} checkversion"
|
|
|
|
version="version-unknown"
|
|
versiondate="version-date-unknown"
|
|
eval "$(setvars "" reldir dirname srcdir)"
|
|
|
|
printf "Building source code archive, version %s\n" "${version}"
|
|
|
|
main()
|
|
{
|
|
[ -f version ] && read version < version
|
|
[ -f versiondate ] && read versiondate < versiondate
|
|
|
|
create_release_directory
|
|
download_modules
|
|
copy_files
|
|
purge_files
|
|
|
|
create_release_archive
|
|
printf "Source code archive available at %s.tar.xz\n\n" "${srcdir}"
|
|
}
|
|
|
|
create_release_directory()
|
|
{
|
|
reldir="release/${version}"
|
|
dirname="${projectname}-${version}_src"
|
|
srcdir="${reldir}/${dirname}"
|
|
|
|
[ -d "release/" ] || x_ mkdir -p release/
|
|
[ -d "${reldir}/" ] || x_ mkdir -p "${reldir}/"
|
|
[ ! -d "${srcdir}/" ] || x_ rm -Rf "${srcdir}/"
|
|
[ ! -f "${srcdir}.tar.xz" ] || \
|
|
x_ rm -f "${srcdir}.tar.xz/"
|
|
|
|
x_ mkdir -p "${srcdir}/"
|
|
x_ printf "%s" "${version}" > "${srcdir}"/version
|
|
}
|
|
|
|
download_modules()
|
|
{
|
|
for modname in ${trees_fetch_list}; do
|
|
[ -d "${modname}" ] || x_ ./update project trees ${modname}
|
|
done
|
|
for modname in ${simple_fetch_list} ${download_only_list}; do
|
|
[ -d "${modname}/" ] || x_ ./update project repo ${modname}
|
|
done
|
|
}
|
|
|
|
copy_files()
|
|
{
|
|
for dir in ${trees_fetch_list}; do
|
|
[ -d "${dir}" ] || continue
|
|
for subdir in "${dir}"/*; do
|
|
[ -d "${subdir}" ] || continue
|
|
[ "${subdir##*/}" = "${dir}" ] && continue
|
|
x_ mkdir -p "${srcdir}/${dir}"
|
|
[ ! -d "${srcdir}/${dir}/${subdir##*/}" ] || \
|
|
x_ rm -Rf "${srcdir}/${dir}/${subdir##*/}"
|
|
x_ cp -R "${subdir}" "${srcdir}/${dir}/${subdir##*/}"
|
|
done
|
|
done
|
|
for dir in ${simple_fetch_list} ${dirlist}; do
|
|
x_ cp -R "${dir}/" "${srcdir}/"
|
|
done
|
|
|
|
for i in ${filelist}; do
|
|
if [ ! -f "${i}" ]; then
|
|
x_ rm -Rf "${srcdir}"
|
|
err "copy_files: file '${i}' does not exist"
|
|
fi
|
|
x_ cp "${i}" "${srcdir}/"
|
|
done
|
|
(
|
|
x_ cd "${srcdir}/"
|
|
for i in ${linklist}; do
|
|
x_ ln -s lbmk "${i}"
|
|
done
|
|
)
|
|
}
|
|
|
|
purge_files()
|
|
{
|
|
(
|
|
x_ cd "${srcdir}/"
|
|
[ ! -d "coreboot/default/util/kbc1126" ] || \
|
|
x_ ./handle make file -c "coreboot/default/util/kbc1126"
|
|
x_ ./handle make config -x coreboot
|
|
for p in u-boot seabios coreboot; do
|
|
x_ ./handle make config -c "${p}"
|
|
done
|
|
x_ ./handle make file -c bios_extract flashrom grub uefitool \
|
|
util-fw/stm32-vserprog util-fw/stm32-vserprog/libopencm3 \
|
|
memtest86plus/build* util/* \
|
|
|
|
x_ rm -Rf .git* */.git* */*/.git* */*/*/.git* */*/*/*/.git* \
|
|
*/*/*/*/*/.git* */*/*/*/*/*/.git* */*/*/*/*/*/*/.git*
|
|
x_ rm -Rf cbutils elf util-fw/rp2040/pico-serprog/build
|
|
)
|
|
}
|
|
|
|
create_release_archive()
|
|
{
|
|
(
|
|
x_ cd "${reldir}/"
|
|
x_ tar -c "${dirname}/" | xz -T0 -9e >"${dirname}.tar.xz"
|
|
x_ rm -Rf "${dirname}/"
|
|
)
|
|
}
|
|
|
|
main $@
|