From: Peter Korsgaard <peter@korsgaard.com>
To: buildroot@buildroot.org
Cc: "Yann E . MORIN" <yann.morin.1998@free.fr>,
Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
Subject: Re: [Buildroot] [PATCH] utils/add-custom-hashes: add script to manage global patch dir hashes
Date: Tue, 07 Nov 2023 14:29:58 +0100 [thread overview]
Message-ID: <87wmutwv1l.fsf@48ers.dk> (raw)
In-Reply-To: <20231107124439.4105974-1-peter@korsgaard.com> (Peter Korsgaard's message of "Tue, 7 Nov 2023 13:44:38 +0100")
>>>>> "Peter" == Peter Korsgaard <peter@korsgaard.com> writes:
> Add a script to manage the .hash files in the BR2_GLOBAL_PATCH_DIR for
> packages using custom versions.
> To use it, run in a configured Buildroot directory, E.G.
> make foo_defconfig; ./utils/add-custom-hashes
> We support multiple patch directories in BR2_GLOBAL_PATCH_DIR. If multiple
> directories are specified then use the last one as that is likely to be the
> most specific one.
> Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
> ---
> docs/manual/customize-patches.adoc | 2 +
> utils/add-custom-hashes | 103 +++++++++++++++++++++++++++++
> 2 files changed, 105 insertions(+)
> create mode 100755 utils/add-custom-hashes
> diff --git a/docs/manual/customize-patches.adoc b/docs/manual/customize-patches.adoc
> index 72e87c3c04..f33bbcdde7 100644
> --- a/docs/manual/customize-patches.adoc
> +++ b/docs/manual/customize-patches.adoc
> @@ -79,3 +79,5 @@ the first file to exist is used to check a package download:
> * +<global-patch-dir>/<packagename>/<packageversion>/<packagename>.hash+
> * +<global-patch-dir>/<packagename>/<packagename>.hash+
> +
> +The +utils/add-custom-hashes+ script can be used to generate these files.
> diff --git a/utils/add-custom-hashes b/utils/add-custom-hashes
> new file mode 100755
> index 0000000000..857ca3dd4c
> --- /dev/null
> +++ b/utils/add-custom-hashes
> @@ -0,0 +1,103 @@
> +#!/usr/bin/env bash
> +set -e
> +
> +# Add hash files for packages with custom versions for
> +# BR2_DOWNLOAD_FORCE_CHECK_HASHES=y
> +#
> +# Run in a configured Buildroot directory, E.G.
> +# make foo_defconfig; ./utils/add-custom-hashes
> +
> +# print BR-style message
> +# message <info message>
> +message() {
> + tput smso 2>/dev/null
> + echo "$*"
> + tput rmso 2>/dev/null
> +}
> +
> +# print error message and exit
> +# die <error message>
> +die() {
> + echo "Error: $*" >&2
> + exit 1
> +}
> +
> +# get package(s) for download file, if any
> +# get_pkgs <json> <file>
> +get_pkgs() {
> + jq --arg file "$2" -r \
> + 'to_entries[] | select(.value.downloads[0].source == $file) | .key | strings' "$1"
> +}
> +
> +# get download dir for package
> +# get_pkg_dl_dir <json> <package>
> +get_pkg_dl_dir() {
> + jq --arg pkg "$2" -r '.[$pkg].dl_dir | strings' "$1"
> +}
> +
> +# generate hash file for download file
> +# gen_hash <dir> <file>
> +gen_hash() {
> + (
> + cd "$1" && printf '# Locally calculated\nsha256 ' && sha256sum "$2"
> + )
> +}
> +
> +command -v jq || die 'Script needs jq'
Ups, this was a last minute addition, the stdout of command -v should be
redirected to /dev/null.
--
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
next prev parent reply other threads:[~2023-11-07 13:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-07 12:44 [Buildroot] [PATCH] utils/add-custom-hashes: add script to manage global patch dir hashes Peter Korsgaard
2023-11-07 13:29 ` Peter Korsgaard [this message]
2023-11-12 10:59 ` Peter Korsgaard
2023-11-13 18:54 ` Peter Korsgaard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87wmutwv1l.fsf@48ers.dk \
--to=peter@korsgaard.com \
--cc=buildroot@buildroot.org \
--cc=thomas.de_schampheleire@nokia.com \
--cc=yann.morin.1998@free.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox