toolchain/external: do not fail on missing hash for custom downloaded toolchain (branch yem/dl-hash-toolchains)
v2 cover toolchain/external: do not fail on missing hash for custom downloaded toolchain (branch yem/dl-hash-toolchains)
Hello All!
This series makes it so we can download custom external toolchains, and still have mandatory checks of hashes.
It also fixes a slightly annoying warning message when downloading from a repository.
Changes v1 -> v2:
- fix a few typoes
Regards,
Yann E. MORIN.
The following changes since commit 6b0aea1b6cff5a9d3898e5a4eb1f79044b77ebed:
python-coherence: fix legal-info (2015-04-05 21:28:15 +0200)
are available in the git repository at:
git://git.busybox.net/~ymorin/git/buildroot yem/dl-hash-toolchains
for you to fetch changes up to 43e395ce9736f82fb6574be4d9ddba48f242753e:
support/download: do not warn about missing hash file for repositories (2015-04-05 22:53:38 +0200)
----------------------------------------------------------------
Yann E. MORIN (4):
support/download: add possibility to not fail on missing hash toolchain/external: ignore missing hash for custom downloaded toolchain support/download: restore mandatory check of hashes support/download: do not warn about missing hash file for repositories
package/pkg-download.mk | 4 ++++ support/download/check-hash | 12 ++++++++++-- toolchain/toolchain-external/toolchain-external.mk | 2 ++ 3 files changed, 16 insertions(+), 2 deletions(-)
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'
PATCH v2 1/4 support/download: add possibility to not fail on missing hash
In very constrained cases, it might be needed to not fail if a hash is missing. This is notably the case for custom external toolchains to be downloaded, because we do have a .hash file for external toolchains, but we oviously can not have hashes for all existing cutom toolchains (he, "custom"!).
So, add a way to avoid failing in that case.
We use a magic value depending on the file to be downloaded, instead of yes/no, to avoid any accidental use. We also do not document it, because we do not want users to use it, and even more, to rely on it, since we still have hopes to get rid of that in the future.
---
Changes v1 -> v2:
- fix typoes in commit log
--- package/pkg-download.mk | 4 ++++ support/download/check-hash | 4 ++++ 2 files changed, 8 insertions(+)
package/pkg-download.mk +4 -0
@@ -60,6 +60,10 @@ domainseparator = $(if $(1),$(1),/) # github(user,package,version): returns site of GitHub repository github = https://github.com/$(1)/$(2)/archive/$(3) +# Compute magic value to ignore a missing hash +# $1: filename, without path components +ignore-missing-hash-magic = $(shell sha1sum <<<"$(1)" |cut -d ' ' -f 1) + ################################################################################ # The DOWNLOAD_* helpers are in charge of getting a working copy # of the source repository for their corresponding SCM,
support/download/check-hash +4 -0
@@ -95,6 +95,10 @@ while read t h f; do done <"${h_file}" if [ ${nb_checks} -eq 0 ]; then + if [ "${BR_MISSING_HASH_OK}" = "$(sha1sum <<<"${base}" |cut -d ' ' -f 1)" ]; then + printf "WARNING: ignored missing hash for %s\n" "${base}" >&2 + exit 0 + fi printf "ERROR: No hash found for %s\n" "${base}" >&2 exit 0 fi
Signature · 1 line
1.9.1
PATCH v2 2/4 toolchain/external: ignore missing hash for custom downloaded toolchain
In reply to Yann E. MORINWe will *always* be missing a hash file for custom external toolchains that are downloaded.
So, just ignore that failure.
---
Changes v1 -> v2:
- fix typoes in title
--- toolchain/toolchain-external/toolchain-external.mk | 2 ++ 1 file changed, 2 insertions(+)
toolchain/toolchain-external/toolchain-external.mk +2 -0
@@ -400,6 +400,8 @@ else # Custom toolchain TOOLCHAIN_EXTERNAL_SITE = $(dir $(call qstrip,$(BR2_TOOLCHAIN_EXTERNAL_URL))) TOOLCHAIN_EXTERNAL_SOURCE = $(notdir $(call qstrip,$(BR2_TOOLCHAIN_EXTERNAL_URL))) +# Magic value to tell the download helper to avoid failling on missing hash +export BR_MISSING_HASH_OK := $(call ignore-missing-hash-magic,$(TOOLCHAIN_EXTERNAL_SOURCE)) endif # In fact, we don't need to download the toolchain, since it is already
Signature · 1 line
1.9.1
PATCH v2 3/4 support/download: restore mandatory check of hashes
In reply to Yann E. MORINNow that custom external toolchains to be downloaded proprely instruct to not fail on a missing hash, restore the mandatory hash check for everything else.
--- support/download/check-hash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
support/download/check-hash +1 -1
@@ -100,5 +100,5 @@ if [ ${nb_checks} -eq 0 ]; then exit 0 fi printf "ERROR: No hash found for %s\n" "${base}" >&2 - exit 0 + exit 3 fi
Signature · 1 line
1.9.1
PATCH v2 4/4 support/download: do not warn about missing hash file for repositories
In reply to Yann E. MORINWhen downloading from a repository, we explicitly pass no hash file, because we can't check hashes in that case.
However, we're still printing a message that there is a missign hash file.
Beside being a bit annoying (since we can't do anything about it), it may also be wrong, especially for packages for which we support multiple versions, with some being downloaded via a git clone and others as tarballs.
Just print no warning when the path to the hash file is empty.
---
Changes v1 -> v2;
- fix typoes in commit log
--- support/download/check-hash | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
support/download/check-hash +5 -1
@@ -31,8 +31,12 @@ h_file="${1}" file="${2}" base="${3}" +# Bail early if no hash to check +if [ -z "${h_file}" ]; then + exit 0 +fi # Does the hash-file exist? -if [ -z "${h_file}" -o ! -f "${h_file}" ]; then +if [ ! -f "${h_file}" ]; then printf "WARNING: no hash file for %s\n" "${base}" >&2 exit 0 fi
Signature · 1 line
1.9.1