From eb387f9a5775ec603a2a156afc27af1f1746d2e6 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Tue, 22 Nov 2011 14:07:20 +0100 Subject: [PATCH] dual mirror --- Makefile | 59 +++++++++++++++++++++++++++++++++----------------------- 1 file changed, 35 insertions(+), 24 deletions(-) diff --git a/Makefile b/Makefile index 8afad8e..9c88af1 100644 --- a/Makefile +++ b/Makefile @@ -1,33 +1,44 @@ -# $Id$ - +# WEBFETCH := wget -SHA1SUM = sha1sum - -# default - overridden by the build -SPECFILE = pyOpenSSL.spec - -main.URL := http://build.planet-lab.org/third-party/pyOpenSSL-0.9.tar.gz -main.SHA1SUM := d39eeb26c73e4b96804e1e403e2136062910b6c2 -main.FILE := $(notdir $(main.URL)) - -# Thierry - when called from within the build, PWD is /build -SOURCEFILES := $(main.FILE) - -$(main.FILE): #FORCE - @if [ ! -e "$@" ] ; then echo "$(WEBFETCH) $(main.URL)" ; $(WEBFETCH) $(main.URL) ; fi - @if [ ! -e "$@" ] ; then echo "Could not download source file: $@ does not exist" ; exit 1 ; fi - @if test "$$(sha1sum $@ | awk '{print $$1}')" != "$(main.SHA1SUM)" ; then \ - echo "sha1sum of the downloaded $@ does not match the one from 'sources' file" ; \ - echo "Local copy: $$(sha1sum $@)" ; \ - echo "In sources: $$(grep $@ sources)" ; \ - exit 1 ; \ +SHA1SUM := sha1sum + +ALL += pyopenssl +pyopenssl-URL1 := http://build.planet-lab.org/third-party/pyOpenSSL-0.9.tar.gz +pyopenssl-URL2 := http://mirror.onelab.eu/third-party/pyOpenSSL-0.9.tar.gz +pyopenssl-SHA1SUM := d39eeb26c73e4b96804e1e403e2136062910b6c2 +pyopenssl-FILE := $(notdir $(pyopenssl-URL1)) + +all: $(ALL) +.PHONY: all + +############################## +define download_target +$(1): $($(1)) +.PHONY: $(1) +$($(1)): + @if [ ! -e "$($(1))" ] ; then \ + { echo Using primary; echo "$(WEBFETCH) $($(1)-URL1)" ; $(WEBFETCH) $($(1)-URL1) ; } || \ + { echo Using secondary; echo "$(WEBFETCH) $($(1)-URL2)" ; $(WEBFETCH) $($(1)-URL2) ; } ; fi + @if [ ! -e "$($(1))" ] ; then echo "Could not download source file: $($(1)) does not exist" ; exit 1 ; fi + @if test "$$$$($(SHA1SUM) $($(1)) | awk '{print $$$$1}')" != "$($(1)-SHA1SUM)" ; then \ + echo "sha1sum of the downloaded $($(1)) does not match the one from 'Makefile'" ; \ + echo "Local copy: $$$$($(SHA1SUM) $($(1)))" ; \ + echo "In Makefile: $($(1)-SHA1SUM)" ; \ + false ; \ else \ - ls -l $@ ; \ + ls -l $($(1)) ; \ fi +endef -sources: $(SOURCEFILES) +$(eval $(call download_target,pyopenssl)) + +sources: $(ALL) .PHONY: sources +#################### +# default - overridden by the build +SPECFILE = pyOpenSSL.spec + PWD=$(shell pwd) PREPARCH ?= noarch RPMDIRDEFS = --define "_sourcedir $(PWD)" --define "_builddir $(PWD)" --define "_srcrpmdir $(PWD)" --define "_rpmdir $(PWD)" -- 2.43.0