diff --git a/resources/scripts/build/release/u-boot-libre b/resources/scripts/build/release/u-boot-libre index 3a6aaca..39767bc 100755 --- a/resources/scripts/build/release/u-boot-libre +++ b/resources/scripts/build/release/u-boot-libre @@ -102,7 +102,7 @@ release_deblobbed_uboot() "${tarball}.xz" mkdir -p "$(dirname ${tmpdir})" - cp -R "u-boot/u-boot/" "${tmpdir}" + cp -R "u-boot/v${version}/" "${tmpdir}" rm -rf ${tmpdir}/.git ${tmpdir}/.gitignore make -C ${tmpdir} distclean diff --git a/resources/scripts/download/u-boot b/resources/scripts/download/u-boot index bd0258c..7bd8e86 100755 --- a/resources/scripts/download/u-boot +++ b/resources/scripts/download/u-boot @@ -4,6 +4,7 @@ # # Copyright (C) 2014, 2015, 2016, 2020, 2021 Leah Rowe # Copyright (C) 2021 Denis 'GNUtoo' Carikli +# Copyright (C) 2022 Alper Nebi Yasak # # 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 @@ -32,33 +33,38 @@ deleteblobs="true" # This script handles the internet, and Git. Both are inherently unreliable. [[ -f build_error ]] && rm -f build_error -# Make sure that older revision are first as code uses that order to -# find the latest supported revision. -supported_uboot_revisions=" \ - v2021.07 \ -" +list_supported_boards() { + for board in resources/u-boot/*; do + if [ -d ${board} ]; then + echo "${board#resources/u-boot/}" + fi + done +} downloadfor() { + board="${1}" + + ubtree="u-boot/${board}" uboot_revision="v2021.07" - uboot_dir="u-boot/u-boot" - if [ -d "${uboot_dir}" ]; then + if [ -d "${ubtree}" ]; then printf \ "REMARK: '%s' directory already exists. Skipping setup.\n" \ - "${uboot_dir}" + "${ubtree}" return 0 fi - if [ ! -d "${uboot_dir}" ]; then - mkdir -p "${uboot_dir}" + if [ ! -d "u-boot" ]; then + mkdir -p "u-boot" fi - if [ ! -d "${uboot_dir}" ]; then - printf \ - "ERROR: '%s' directory not created. Check file system permissions\n" \ - "${uboot_dir}" + if [ ! -d "u-boot" ]; then + printf \ + "ERROR: '%s' directory not created. Check file system permissions\n" \ + "u-boot" return 1 fi + uboot_dir="u-boot/u-boot" if [ ! -d "${uboot_dir}/.git" ] && [ -d "${uboot_dir}" ]; then rm -Rf "${uboot_dir}" fi @@ -84,12 +90,20 @@ downloadfor() { 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 if [ -f build_error ]; then printf \ "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 fi } @@ -162,53 +176,54 @@ usage() printf "Usage:\n" printf "\t%s # %s\n" \ "${progname}" \ - "Download latest u-boot git revision and deblob it" - printf "\t%s [revision] # %s\n" \ + "Download and deblob u-boot for all boards" + printf "\t%s [board] # %s\n" \ "${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" \ "${progname}" \ - "Print the path of the blobs.list file for the latest supported u-boot revision" - printf "\t%s --blobs-list [revision] # %s\n" \ + "Print the path of the generic blobs.list file" + printf "\t%s --blobs-list [board] # %s\n" \ "${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" \ "${progname}" \ - "Print the path of the generated deblob script for the latest supported u-boot revision" - printf "\t%s --gen-deblob-script [revision] # %s\n" \ + "Print the path of a generated generic deblob script" + printf "\t%s --gen-deblob-script [board] # %s\n" \ "${progname}" \ - "Print the path of the generated deblob script for the given u-boot revision" - printf "\t%s --list-revisions # %s\n" \ + "Print the path of a generated deblob script for the given board" + printf "\t%s --list-boards # %s\n" \ "${progname}" \ - "List supported u-boot revisions" + "List supported boards" printf "\t%s --help # %s\n" \ "${progname}" \ "Prints this help" } -download_uboot_revision() +download_uboot_board() { - git_revision="$1" + board="${1}" + ubtree="u-boot/${board}" printf "Downloading u-boot " printf "and (if exist in build system) applying patches\n" - downloadfor "${git_revision}" + downloadfor "${board}" rm -f "build_error" printf "\n\n" 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 if echo "${blob_path}" | \ grep '/$' 2>&1 >/dev/null ; then printf "Deleting blob directory: '%s/%s'\n" \ - "${uboot_dir}" "${blob_path}" - rm -rf "${uboot_dir}/${blob_path}" + "${ubtree}" "${blob_path}" + rm -rf "${ubtree}/${blob_path}" else printf "Deleting blob file: '%s/%s'\n" \ - "${uboot_dir}" "${blob_path}" - rm -f "${uboot_dir}/${blob_path}" + "${ubtree}" "${blob_path}" + rm -f "${ubtree}/${blob_path}" fi done fi @@ -216,72 +231,74 @@ download_uboot_revision() 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() { - version="$1" + board="$1" path="$(mktemp)" - generate_deblob_script "$(print_blobs_list_path ${version})" "${path}" + generate_deblob_script "$(print_blobs_list_path ${board})" "${path}" printf "%s\n" ${path} } if [ $# -eq 0 ] ; then - latest_revision="$(echo ${supported_uboot_revisions} | tail -n1)" - download_uboot_revision "${latest_revision}" + for board in $(list_supported_boards); do + download_uboot_board "${board}" + done exit 0 elif [ $# -eq 1 -a "$1" == "--help" ] ; then usage exit 0 -elif [ $# -eq 1 -a "$1" == "--list-revisions" ] ; then - for revision in ${supported_uboot_revisions} ; do - printf "${revision}\n" - done +elif [ $# -eq 1 -a "$1" == "--list-boards" ] ; then + list_supported_boards exit 0 elif [ $# -eq 1 -a "$1" == "--blobs-list" ] ; then - latest_revision="$(echo ${supported_uboot_revisions} | tail -n1)" - print_blobs_list_path "${latest_revision}" + print_blobs_list_path "default" exit 0 elif [ $# -eq 2 -a "$1" == "--blobs-list" ] ; then found=0 - for revision in ${supported_uboot_revisions} ; do - if [ "${revision}" = "$2" ] ; then + for board in $(list_supported_boards) ; do + if [ "${board}" = "$2" ] ; then print_blobs_list_path "$2" exit 0 fi done - printf "Error: Revision '${1}' is not supported\n" + printf "Error: Board '${2}' is not supported\n" exit 1 elif [ $# -eq 1 -a "$1" == "--gen-deblob-script" ] ; then - latest_revision="$(echo ${supported_uboot_revisions} | tail -n1)" - print_deblob_script_path "${latest_revision}" + print_deblob_script_path "default" exit 0 elif [ $# -eq 2 -a "$1" == "--gen-deblob-script" ] ; then found=0 - for revision in ${supported_uboot_revisions} ; do - if [ "${revision}" = "$2" ] ; then + for board in $(list_supported_boards) ; do + if [ "$board" = "$2" ] ; then print_deblob_script_path "$2" exit 0 fi done - printf "Error: Revision '${1}' is not supported\n" + printf "Error: Board '${2}' is not supported\n" exit 1 elif [ $# -eq 1 ] ; then - found=0 - for revision in ${supported_uboot_revisions} ; do - if [ "${revision}" = "$1" ] ; then - download_uboot_revision "$1" + for board in $(list_supported_boards) ; do + if [ "$board" = "$1" ] ; then + download_uboot_board "$1" exit 0 fi done - printf "Error: Revision '${1}' is not supported\n" + printf "Error: Board '${1}' is not supported\n" exit 1 fi diff --git a/resources/u-boot/v2021.07/.gitkeep b/resources/u-boot/v2021.07/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/tests/u-boot-libre.sha512 b/tests/u-boot-libre.sha512 index 5301c36..1f4e5cc 100644 --- a/tests/u-boot-libre.sha512 +++ b/tests/u-boot-libre.sha512 @@ -1,9 +1,9 @@ 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 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 -cd5b7a2a7bf7fba92e79bc432183ba8f48dc80fa05ceb1f978be33f22b497090377c434ba9fe0278b3ab82f23ef337c6d0bf1240fed0887e0e2292a463d5e49c 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 +66417687240cc2242105b608922d768784dfbf873525e8784371032b1e733a787f5cc476529a719f08fcc0d3d0293d01d31fdd8a74b8810b9f2ca8cda5ab34f7 release/u-boot-libre/2021.07-r2/deblob-2021.07-r2.sh +e19cbe5e70441a899b18e602bb8f16d9e459ea3c0f8e989d4e581b9ac926bc401b5f876dee189485cb95ae8cb3c92a9107fe69c6b6f491a3408bb0f992f15278 release/u-boot-libre/2021.07-r2/deblob-2021.07-r2.sh.lz +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 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