Skip to contentSkip to conversation

toolchain/external: do not fail on missig hash for custom downloaded toolchain (branch yem/dl-hash-toolchains)

PATCH Superseded Yann E. MORIN 1 participant 5 messages Apr 3, 2015

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover toolchain/external: do not fail on missig 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.

Regards,
Yann E. MORIN.

The following changes since commit 0eb659d04e7854a25be09c5358212a7bfcc39b2b:

config: Add defconfig for Freescale i.MX28 EVK (2015-04-03 17:26:00 +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 b3d829351f7593b214a93a3503b789113d3d63ca:

support/download: do not warn about missing hash file for repositories (2015-04-03 19:08:46 +0200)

----------------------------------------------------------------
Yann E. MORIN (4):
support/download: add possibility to not fail on missing hash toolchain/external: ginore missig 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.  |
'------------------------------^-------^------------------^--------------------'
#1 lore raw

PATCH 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 existign 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, sicne we still have hopes to get rid of that in the future.

Cc Thomas Petazzoni <[email protected]>
Cc Gustavo Zacarias <[email protected]>
---
 package/pkg-download.mk     | 4 ++++
 support/download/check-hash | 4 ++++
 2 files changed, 8 insertions(+)
package/pkg-download.mk +4 -0
index e274712..1e080e5 100644
@@ -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
index 67c1780..1276290 100755
@@ -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
#2 lore raw

PATCH 2/4 toolchain/external: ginore missig hash for custom downloaded toolchain

In reply to Yann E. MORIN

We will *always* be missing a hash file for custom external toolchains that are downloaded.

So, just ignore that failure.

Cc Thomas Petazzoni <[email protected]>
Cc Gustavo Zacarias <[email protected]>
---
 toolchain/toolchain-external/toolchain-external.mk | 2 ++
 1 file changed, 2 insertions(+)
toolchain/toolchain-external/toolchain-external.mk +2 -0
index c0429bb..3659511 100644
@@ -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
#3 lore raw

PATCH 3/4 support/download: restore mandatory check of hashes

In reply to Yann E. MORIN

Now that custom external toolchains to be downloaded proprely instruct to not fail on a missing hash, restore the mandatory hash check for everything else.

Cc Thomas Petazzoni <[email protected]>
Cc Gustavo Zacarias <[email protected]>
---
 support/download/check-hash | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
support/download/check-hash +1 -1
index 1276290..c24d26b 100755
@@ -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
#4 lore raw

PATCH 4/4 support/download: do not warn about missing hash file for repositories

In reply to Yann E. MORIN

When downloading froma repository, we explicitly pass no hash file, becasue 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 supportmultiple 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.

Cc Thomas Petazzoni <[email protected]>
---
 support/download/check-hash | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
support/download/check-hash +5 -1
index c24d26b..96d12a5 100755
@@ -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