summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorAbdoulaye Walsimou Gaye <awg@embtoolkit.org>2015-03-22 23:43:08 +0100
committerAbdoulaye Walsimou Gaye <awg@embtoolkit.org>2015-03-22 23:43:08 +0100
commit5a1e5876ff4ebc8221473be71d88d371aa8a5b06 (patch)
treed4939e5953a83a9d9cd238457d5bba9cce46a9b7 /core
parent224488c6540099195cdebed641765bc58c00a152 (diff)
downloadembtoolkit-5a1e5876ff4ebc8221473be71d88d371aa8a5b06.tar.gz
embtoolkit-5a1e5876ff4ebc8221473be71d88d371aa8a5b06.tar.bz2
embtoolkit-5a1e5876ff4ebc8221473be71d88d371aa8a5b06.tar.xz
Build system: give ability to check hash of downloaded package
Signed-off-by: Abdoulaye Walsimou Gaye <awg@embtoolkit.org>
Diffstat (limited to 'core')
-rw-r--r--core/mk/pkg-macros/download.mk28
-rw-r--r--core/mk/pkg-macros/vars.mk4
2 files changed, 30 insertions, 2 deletions
diff --git a/core/mk/pkg-macros/download.mk b/core/mk/pkg-macros/download.mk
index 0e77821..724d7d1 100644
--- a/core/mk/pkg-macros/download.mk
+++ b/core/mk/pkg-macros/download.mk
@@ -115,7 +115,7 @@ define __embtk_download_pkg_from_tarball
$(if $(__embtk_$(pkgv)_category),
$(call embtk_echo_blue,"\tCategory : $(__embtk_$(pkgv)_category)"))
$(call embtk_echo_blue,"\tDependency of : $(or $(__embtk_pkg_depof),N/A)")
- test -e $(__embtk_pkg_package_f) || \
+ test -e $(__embtk_pkg_package_f) && $(__embtk_checktarball_pkg) || \
$(foreach m,$(__embtk_pkg_site) $(__embtk_pkg_mirrors), \
$(call __embtk_download_pkg_tarball,$(1),$(m)) ||) \
$(call __embtk_download_pkg_exitfailure,$(__embtk_pkg_package_f))
@@ -129,8 +129,32 @@ endef
#
define __embtk_download_pkg_tarball
$(call embtk_wget, \
- $(__embtk_pkg_package),$(2),$(__embtk_pkg_package_remote))
+ $(__embtk_pkg_package),$(2),$(__embtk_pkg_package_remote)) && \
+ $(__embtk_checktarball_pkg)
endef
+define __embtk_checktarball_pkg
+ $(or $(__embtk_md5tarball_pkg),
+ $(__embtk_sha1tarball_pkg),
+ $(__embtk_sha256tarball_pkg),
+ $(__embtk_sha512tarball_pkg),
+ true)
+endef
+__embtk_md5tarball_pkg = $(if $(__embtk_pkg_md5),$(call __embtk_md5_cmd,$(__embtk_pkg_md5),$(__embtk_pkg_package_f)))
+__embtk_sha1tarball_pkg = $(if $(__embtk_pkg_sha1),$(call __embtk_sha1_cmd,$(__embtk_pkg_sha1),$(__embtk_pkg_package_f)))
+__embtk_sha256tarball_pkg = $(if $(__embtk_pkg_sha256),$(call __embtk_sha1_cmd,$(__embtk_pkg_sha256),$(__embtk_pkg_package_f)))
+__embtk_sha512tarball_pkg = $(if $(__embtk_pkg_sha512),$(call __embtk_sha1_cmd,$(__embtk_pkg_sha512),$(__embtk_pkg_package_f)))
+
+ifeq ($(embtk_buildhost-bsd),y)
+__embtk_md5_cmd = md5 -c $(1) $(2) >/dev/null 2>&1
+__embtk_sha1_cmd = sha1 -c $(1) $(2) >/dev/null 2>&1
+__embtk_sha256_cmd = sh256 -c $(1) $(2) >/dev/null 2>&1
+__embtk_sha512_cmd = sh512 -c $(1) $(2) >/dev/null 2>&1
+else
+__embtk_md5_cmd = printf 'MD5 ($(2)) = $(1)' | md5sum -c - >/dev/null 2>&1
+__embtk_sha1_cmd = printf 'SHA1 ($(2)) = $(1)' | sha1sum -c - >/dev/null 2>&1
+__embtk_sha256_cmd = printf 'SHA256 ($(2)) = $(1)' | sha256sum -c - >/dev/null 2>&1
+__embtk_sha512_cmd = printf 'SHA512 ($(2)) = $(1)' | sha512sum -c - >/dev/null 2>&1
+endif
__embtk_pkgdl_src = $(or $(__embtk_pkg_usegit),$(__embtk_pkg_usesvn),tarball)
define embtk_download_pkg
diff --git a/core/mk/pkg-macros/vars.mk b/core/mk/pkg-macros/vars.mk
index 9cb3506..16731ac 100644
--- a/core/mk/pkg-macros/vars.mk
+++ b/core/mk/pkg-macros/vars.mk
@@ -81,6 +81,10 @@ __embtk_pkg_tarball_tbz2 = $(if $(filter %.tbz2,$(__embtk_pkg_package)),tbz2)
__embtk_pkg_tarball_tarxz = $(if $(filter %.tar.xz,$(__embtk_pkg_package)),tar.xz)
__embtk_pkg_tarball_txz = $(if $(filter %.txz,$(__embtk_pkg_package)),txz)
__embtk_pkg_tarball_tar = $(if $(filter %.tar,$(__embtk_pkg_package)),tar)
+__embtk_pkg_md5 = $(call embtk_uquote,$(CONFIG_EMBTK_$(PKGV)_MD5))
+__embtk_pkg_sha1 = $(call embtk_uquote,$(CONFIG_EMBTK_$(PKGV)_SHA1))
+__embtk_pkg_sha256 = $(call embtk_uquote,$(CONFIG_EMBTK_$(PKGV)_SHA256))
+__embtk_pkg_sha512 = $(call embtk_uquote,$(CONFIG_EMBTK_$(PKGV)_SHA512))
__embtk_pkg_category = $(call embtk_uquote,$(CONFIG_EMBTK_$(PKGV)_CATEGORY))
# FIXME: drop __embtk_pkg_refspec in favor of __embtk_pkg_category