download/u-boot: Prepare files per board instead of per revision

The U-Boot download script is designed to help with releasing
u-boot-libre and it can only prepare a generic U-Boot v2021.07 tree.
However, we will need to build board-specific versions of U-Boot to be
able to use it as a coreboot payload effectively.

As a first step toward that, make the download script prepare per-board
copies of U-Boot v2021.07. Then, add a 'v2021.07' pseudo-board for the
u-boot-libre release script to work on.

The u-boot-libre deblob script hash ends up chaning due to copying my
author attribution from the download script, update its hash.

Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
fsdg20230625
Alper Nebi Yasak 2022-08-25 18:33:23 +03:00
parent d8da9b51e2
commit 8dd1a24504
4 changed files with 80 additions and 63 deletions

View File

@ -102,7 +102,7 @@ release_deblobbed_uboot()
"${tarball}.xz" "${tarball}.xz"
mkdir -p "$(dirname ${tmpdir})" mkdir -p "$(dirname ${tmpdir})"
cp -R "u-boot/u-boot/" "${tmpdir}" cp -R "u-boot/v${version}/" "${tmpdir}"
rm -rf ${tmpdir}/.git ${tmpdir}/.gitignore rm -rf ${tmpdir}/.git ${tmpdir}/.gitignore
make -C ${tmpdir} distclean make -C ${tmpdir} distclean

View File

@ -4,6 +4,7 @@
# #
# Copyright (C) 2014, 2015, 2016, 2020, 2021 Leah Rowe <info@minifree.org> # Copyright (C) 2014, 2015, 2016, 2020, 2021 Leah Rowe <info@minifree.org>
# Copyright (C) 2021 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> # Copyright (C) 2021 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
# Copyright (C) 2022 Alper Nebi Yasak <alpernebiyasak@gmail.com>
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -32,33 +33,38 @@ deleteblobs="true"
# This script handles the internet, and Git. Both are inherently unreliable. # This script handles the internet, and Git. Both are inherently unreliable.
[[ -f build_error ]] && rm -f build_error [[ -f build_error ]] && rm -f build_error
# Make sure that older revision are first as code uses that order to list_supported_boards() {
# find the latest supported revision. for board in resources/u-boot/*; do
supported_uboot_revisions=" \ if [ -d ${board} ]; then
v2021.07 \ echo "${board#resources/u-boot/}"
" fi
done
}
downloadfor() { downloadfor() {
board="${1}"
ubtree="u-boot/${board}"
uboot_revision="v2021.07" uboot_revision="v2021.07"
uboot_dir="u-boot/u-boot" if [ -d "${ubtree}" ]; then
if [ -d "${uboot_dir}" ]; then
printf \ printf \
"REMARK: '%s' directory already exists. Skipping setup.\n" \ "REMARK: '%s' directory already exists. Skipping setup.\n" \
"${uboot_dir}" "${ubtree}"
return 0 return 0
fi fi
if [ ! -d "${uboot_dir}" ]; then if [ ! -d "u-boot" ]; then
mkdir -p "${uboot_dir}" mkdir -p "u-boot"
fi fi
if [ ! -d "${uboot_dir}" ]; then if [ ! -d "u-boot" ]; then
printf \ printf \
"ERROR: '%s' directory not created. Check file system permissions\n" \ "ERROR: '%s' directory not created. Check file system permissions\n" \
"${uboot_dir}" "u-boot"
return 1 return 1
fi fi
uboot_dir="u-boot/u-boot"
if [ ! -d "${uboot_dir}/.git" ] && [ -d "${uboot_dir}" ]; then if [ ! -d "${uboot_dir}/.git" ] && [ -d "${uboot_dir}" ]; then
rm -Rf "${uboot_dir}" rm -Rf "${uboot_dir}"
fi fi
@ -84,12 +90,20 @@ downloadfor() {
fi fi
fi fi
git -C "${uboot_dir}" reset --hard ${uboot_revision} || \ cp -R "${uboot_dir}" "${ubtree}" || touch build_error
if [ -f build_error ]; then
printf "ERROR: %s: Unable to copy directory. Check file system permissions or free space.\n" \
"download/u-boot"
rm -Rf "${ubtree}/"
return 1
fi
git -C "${ubtree}" reset --hard ${uboot_revision} || \
touch build_error touch build_error
if [ -f build_error ]; then if [ -f build_error ]; then
printf \ printf \
"ERROR: %s: Unable to reset to commit ID/tag '%s' for board '%s' on tree '%s'\n" \ "ERROR: %s: Unable to reset to commit ID/tag '%s' for board '%s' on tree '%s'\n" \
"download/u-boot" "${uboot_revision}" "${1}" "${uboot_dir}" "download/u-boot" "${uboot_revision}" "${1}" "${ubtree}"
return 1 return 1
fi fi
} }
@ -162,53 +176,54 @@ usage()
printf "Usage:\n" printf "Usage:\n"
printf "\t%s # %s\n" \ printf "\t%s # %s\n" \
"${progname}" \ "${progname}" \
"Download latest u-boot git revision and deblob it" "Download and deblob u-boot for all boards"
printf "\t%s [revision] # %s\n" \ printf "\t%s [board] # %s\n" \
"${progname}" \ "${progname}" \
"Download given u-boot git revision and deblob it" "Download and deblob u-boot for the given board"
printf "\t%s --blobs-list # %s\n" \ printf "\t%s --blobs-list # %s\n" \
"${progname}" \ "${progname}" \
"Print the path of the blobs.list file for the latest supported u-boot revision" "Print the path of the generic blobs.list file"
printf "\t%s --blobs-list [revision] # %s\n" \ printf "\t%s --blobs-list [board] # %s\n" \
"${progname}" \ "${progname}" \
"Print the path of the blobs.list file for the given u-boot revision" "Print the path of the blobs.list file for the given board"
printf "\t%s --gen-deblob-script # %s\n" \ printf "\t%s --gen-deblob-script # %s\n" \
"${progname}" \ "${progname}" \
"Print the path of the generated deblob script for the latest supported u-boot revision" "Print the path of a generated generic deblob script"
printf "\t%s --gen-deblob-script [revision] # %s\n" \ printf "\t%s --gen-deblob-script [board] # %s\n" \
"${progname}" \ "${progname}" \
"Print the path of the generated deblob script for the given u-boot revision" "Print the path of a generated deblob script for the given board"
printf "\t%s --list-revisions # %s\n" \ printf "\t%s --list-boards # %s\n" \
"${progname}" \ "${progname}" \
"List supported u-boot revisions" "List supported boards"
printf "\t%s --help # %s\n" \ printf "\t%s --help # %s\n" \
"${progname}" \ "${progname}" \
"Prints this help" "Prints this help"
} }
download_uboot_revision() download_uboot_board()
{ {
git_revision="$1" board="${1}"
ubtree="u-boot/${board}"
printf "Downloading u-boot " printf "Downloading u-boot "
printf "and (if exist in build system) applying patches\n" printf "and (if exist in build system) applying patches\n"
downloadfor "${git_revision}" downloadfor "${board}"
rm -f "build_error" rm -f "build_error"
printf "\n\n" printf "\n\n"
if [ "${deleteblobs}" = "true" ]; then if [ "${deleteblobs}" = "true" ]; then
blobslist="resources/u-boot/default/blobs.list" blobslist="$(print_blobs_list_path "${board}")"
for blob_path in $(strip_comments "${blobslist}"); do for blob_path in $(strip_comments "${blobslist}"); do
if echo "${blob_path}" | \ if echo "${blob_path}" | \
grep '/$' 2>&1 >/dev/null ; then grep '/$' 2>&1 >/dev/null ; then
printf "Deleting blob directory: '%s/%s'\n" \ printf "Deleting blob directory: '%s/%s'\n" \
"${uboot_dir}" "${blob_path}" "${ubtree}" "${blob_path}"
rm -rf "${uboot_dir}/${blob_path}" rm -rf "${ubtree}/${blob_path}"
else else
printf "Deleting blob file: '%s/%s'\n" \ printf "Deleting blob file: '%s/%s'\n" \
"${uboot_dir}" "${blob_path}" "${ubtree}" "${blob_path}"
rm -f "${uboot_dir}/${blob_path}" rm -f "${ubtree}/${blob_path}"
fi fi
done done
fi fi
@ -216,72 +231,74 @@ download_uboot_revision()
print_blobs_list_path() print_blobs_list_path()
{ {
printf "resources/u-boot/default/blobs.list\n" board="$1"
if [ -f "resources/u-boot/${board}/blobs.list" ]; then
printf "resources/u-boot/${board}/blobs.list\n"
else
printf "resources/u-boot/default/blobs.list\n"
fi
} }
print_deblob_script_path() print_deblob_script_path()
{ {
version="$1" board="$1"
path="$(mktemp)" path="$(mktemp)"
generate_deblob_script "$(print_blobs_list_path ${version})" "${path}" generate_deblob_script "$(print_blobs_list_path ${board})" "${path}"
printf "%s\n" ${path} printf "%s\n" ${path}
} }
if [ $# -eq 0 ] ; then if [ $# -eq 0 ] ; then
latest_revision="$(echo ${supported_uboot_revisions} | tail -n1)" for board in $(list_supported_boards); do
download_uboot_revision "${latest_revision}" download_uboot_board "${board}"
done
exit 0 exit 0
elif [ $# -eq 1 -a "$1" == "--help" ] ; then elif [ $# -eq 1 -a "$1" == "--help" ] ; then
usage usage
exit 0 exit 0
elif [ $# -eq 1 -a "$1" == "--list-revisions" ] ; then elif [ $# -eq 1 -a "$1" == "--list-boards" ] ; then
for revision in ${supported_uboot_revisions} ; do list_supported_boards
printf "${revision}\n"
done
exit 0 exit 0
elif [ $# -eq 1 -a "$1" == "--blobs-list" ] ; then elif [ $# -eq 1 -a "$1" == "--blobs-list" ] ; then
latest_revision="$(echo ${supported_uboot_revisions} | tail -n1)" print_blobs_list_path "default"
print_blobs_list_path "${latest_revision}"
exit 0 exit 0
elif [ $# -eq 2 -a "$1" == "--blobs-list" ] ; then elif [ $# -eq 2 -a "$1" == "--blobs-list" ] ; then
found=0 found=0
for revision in ${supported_uboot_revisions} ; do for board in $(list_supported_boards) ; do
if [ "${revision}" = "$2" ] ; then if [ "${board}" = "$2" ] ; then
print_blobs_list_path "$2" print_blobs_list_path "$2"
exit 0 exit 0
fi fi
done done
printf "Error: Revision '${1}' is not supported\n" printf "Error: Board '${2}' is not supported\n"
exit 1 exit 1
elif [ $# -eq 1 -a "$1" == "--gen-deblob-script" ] ; then elif [ $# -eq 1 -a "$1" == "--gen-deblob-script" ] ; then
latest_revision="$(echo ${supported_uboot_revisions} | tail -n1)" print_deblob_script_path "default"
print_deblob_script_path "${latest_revision}"
exit 0 exit 0
elif [ $# -eq 2 -a "$1" == "--gen-deblob-script" ] ; then elif [ $# -eq 2 -a "$1" == "--gen-deblob-script" ] ; then
found=0 found=0
for revision in ${supported_uboot_revisions} ; do for board in $(list_supported_boards) ; do
if [ "${revision}" = "$2" ] ; then if [ "$board" = "$2" ] ; then
print_deblob_script_path "$2" print_deblob_script_path "$2"
exit 0 exit 0
fi fi
done done
printf "Error: Revision '${1}' is not supported\n" printf "Error: Board '${2}' is not supported\n"
exit 1 exit 1
elif [ $# -eq 1 ] ; then elif [ $# -eq 1 ] ; then
found=0 for board in $(list_supported_boards) ; do
for revision in ${supported_uboot_revisions} ; do if [ "$board" = "$1" ] ; then
if [ "${revision}" = "$1" ] ; then download_uboot_board "$1"
download_uboot_revision "$1"
exit 0 exit 0
fi fi
done done
printf "Error: Revision '${1}' is not supported\n" printf "Error: Board '${1}' is not supported\n"
exit 1 exit 1
fi fi

View File

View File

@ -1,9 +1,9 @@
a112ad84028728ed377f8dd6fc230ecf33b2e6d21ff8152ce6f45234ce34f1a63f7eec384391b59a5b81a4e0e0532444c0bd70254f3c211dfec5851126cb463b release/u-boot-libre/2021.07-r2/blobs-2021.07-r2.list a112ad84028728ed377f8dd6fc230ecf33b2e6d21ff8152ce6f45234ce34f1a63f7eec384391b59a5b81a4e0e0532444c0bd70254f3c211dfec5851126cb463b release/u-boot-libre/2021.07-r2/blobs-2021.07-r2.list
143a10d3bc19af201035ce6381f513f6f85f22c99b1aa677c191261468bfc8299ac32717fe93e0f8fabdc5f0cf14f80d1afe8276a1c587978f044abea020e78e release/u-boot-libre/2021.07-r2/blobs-2021.07-r2.list.lz 143a10d3bc19af201035ce6381f513f6f85f22c99b1aa677c191261468bfc8299ac32717fe93e0f8fabdc5f0cf14f80d1afe8276a1c587978f044abea020e78e release/u-boot-libre/2021.07-r2/blobs-2021.07-r2.list.lz
4ca0fb326c84c738b7759c0077f3ac1bafc5cc593efacaf63a9db9875020a9fbac3f44d9b03a6e65c939ca4f9b85d0fa9af8735b5e3672a8cc6ac2037ebad4cb release/u-boot-libre/2021.07-r2/blobs-2021.07-r2.list.xz 4ca0fb326c84c738b7759c0077f3ac1bafc5cc593efacaf63a9db9875020a9fbac3f44d9b03a6e65c939ca4f9b85d0fa9af8735b5e3672a8cc6ac2037ebad4cb release/u-boot-libre/2021.07-r2/blobs-2021.07-r2.list.xz
40ca7f25e2fd6139199be0d6d36ebd4b5eddf4e385b5cb8de8ca89df424e698efc1c31939c3d507b873620043bc4276e88942f78d1231177a5a0d1ccfc40a172 release/u-boot-libre/2021.07-r2/deblob-2021.07-r2.sh 66417687240cc2242105b608922d768784dfbf873525e8784371032b1e733a787f5cc476529a719f08fcc0d3d0293d01d31fdd8a74b8810b9f2ca8cda5ab34f7 release/u-boot-libre/2021.07-r2/deblob-2021.07-r2.sh
cd5b7a2a7bf7fba92e79bc432183ba8f48dc80fa05ceb1f978be33f22b497090377c434ba9fe0278b3ab82f23ef337c6d0bf1240fed0887e0e2292a463d5e49c release/u-boot-libre/2021.07-r2/deblob-2021.07-r2.sh.lz e19cbe5e70441a899b18e602bb8f16d9e459ea3c0f8e989d4e581b9ac926bc401b5f876dee189485cb95ae8cb3c92a9107fe69c6b6f491a3408bb0f992f15278 release/u-boot-libre/2021.07-r2/deblob-2021.07-r2.sh.lz
0a1663fe2eac28c17d28c0bf343c6f57841d1b33f847074419699028d52f4216f77d6ebab06a57dc1ae86f87070791868709898085e4f1bff377fcf1039e4e31 release/u-boot-libre/2021.07-r2/deblob-2021.07-r2.sh.xz 62a36e15a923b46b45cc519807bd24fe39bee3f12c2421b116c40e29f6199277509de70772ea2739abb52a0962b4ec1302d93f53b2adb42e3afc42bc95390a1c release/u-boot-libre/2021.07-r2/deblob-2021.07-r2.sh.xz
67c40068f03538f17444000edaffed2e4ef788c84f3f6a34a0501c396a123207f62e59d4669210c701a73bbcf7f8f970a4e11c7bec0511f5ee460b109a95c398 release/u-boot-libre/2021.07-r2/u-boot-libre-2021.07-r2.tar 67c40068f03538f17444000edaffed2e4ef788c84f3f6a34a0501c396a123207f62e59d4669210c701a73bbcf7f8f970a4e11c7bec0511f5ee460b109a95c398 release/u-boot-libre/2021.07-r2/u-boot-libre-2021.07-r2.tar
d920ce9a4b2f601557f82d187835185586c3bd01a8570217a32989c6ae2cdda87d0348d7c51843af30a369e9bad0741e45d2cb72e2947ec94475342bb66161aa release/u-boot-libre/2021.07-r2/u-boot-libre-2021.07-r2.tar.lz d920ce9a4b2f601557f82d187835185586c3bd01a8570217a32989c6ae2cdda87d0348d7c51843af30a369e9bad0741e45d2cb72e2947ec94475342bb66161aa release/u-boot-libre/2021.07-r2/u-boot-libre-2021.07-r2.tar.lz
ab3bb25e1ac7d59fea2e4a70a0bebed8002322678870161908bf247cacabed8b12be8bf2ea2fa92ac64820887b26af7dbf8ff682b46d3276765385dd567cc19a release/u-boot-libre/2021.07-r2/u-boot-libre-2021.07-r2.tar.xz ab3bb25e1ac7d59fea2e4a70a0bebed8002322678870161908bf247cacabed8b12be8bf2ea2fa92ac64820887b26af7dbf8ff682b46d3276765385dd567cc19a release/u-boot-libre/2021.07-r2/u-boot-libre-2021.07-r2.tar.xz