From 2a40c3a8679f1a02d88c48f0424fa41df09203a8 Mon Sep 17 00:00:00 2001 From: George Joseph Date: Wed, 16 Nov 2016 11:05:43 -0700 Subject: pjproject_bundled: Improve reliability of pjproject download The download process now has a timeout which will cause wget to retry if it stops retrieving data for 5 seconds and fetch and curl to timeout if the whole retrieval take smore than 30 seconds. If the tarball retrieval works, the MD5SUM file is retrieved from the downloads site and the md5 checksum is verified. If either the tarball retrieval or MD5SUM retrieval fails, or the checksums don't match, the entire process is retried once. If it fails again, any incomplete tarball is deleted. .DELETE_ON_ERROR: was also added to the Makefile. Not only does this delete the tarball on failure, it till also delete corrupted library files from the pjproject source directory should they fail to build correctly. Tested all the way back to FreeBSD 9, CentOS 6, Debian 6 and Ubuntu 14. Change-Id: Iea7d33b96a31622ab1b6e54baebaf271959514e1 --- third-party/pjproject/Makefile | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'third-party/pjproject/Makefile') diff --git a/third-party/pjproject/Makefile b/third-party/pjproject/Makefile index 106938b6c..ff3266c16 100644 --- a/third-party/pjproject/Makefile +++ b/third-party/pjproject/Makefile @@ -75,14 +75,31 @@ include ../Makefile.rules include Makefile.rules ECHO_PREFIX := $(ECHO_PREFIX) echo '[pjproject] ' +SHELL_ECHO_PREFIX := echo '[pjproject] ' _all: $(TARGETS) +define download_from_pjproject + ($(SHELL_ECHO_PREFIX) Downloading $(PJPROJECT_URL)/$(@F) to $@ ;\ + $(DOWNLOAD_TO_STDOUT) $(call DOWNLOAD_TIMEOUT,5,10) $(PJPROJECT_URL)/$(@F) > $@ &&\ + $(SHELL_ECHO_PREFIX) Downloading $(PJPROJECT_URL)/MD5SUM to $(PJMD5SUM) &&\ + $(DOWNLOAD_TO_STDOUT) $(call DOWNLOAD_TIMEOUT,5,10) $(PJPROJECT_URL)/MD5SUM.TXT > $(PJMD5SUM) &&\ + ($(SHELL_ECHO_PREFIX) Verifying $@ &&\ + tarball_sum=$$($(CAT) $@ | $(MD5) | $(SED) -n -r -e "s/^([^ ]+)\s+.*/\1/gp") ;\ + required_sum=$$($(SED) -n -r -e "s/^([^ ]+)\s+$(@F)/\1/gp" $(PJMD5SUM)) ;\ + if [ "$$tarball_sum" != "$$required_sum" ] ; then $(SHELL_ECHO_PREFIX) Verify failed ; exit 1 ; fi) &&\ + $(SHELL_ECHO_PREFIX) Verify successful ; exit 0) +endef + +.DELETE_ON_ERROR: + DOWNLOAD_DIR := $(or $(EXTERNALS_CACHE_DIR),$(TMPDIR),$(wildcard /tmp),.) +TARBALL = $(DOWNLOAD_DIR)/pjproject-$(PJPROJECT_VERSION).tar.bz2 +PJMD5SUM = $(patsubst %.tar.bz2,%.md5,$(TARBALL)) -$(DOWNLOAD_DIR)/pjproject-$(PJPROJECT_VERSION).tar.bz2: ../versions.mak - $(ECHO_PREFIX) Downloading $(PJPROJECT_URL)/$(@F) to $@ - $(CMD_PREFIX) $(DOWNLOAD_TO_STDOUT) $(PJPROJECT_URL)/$(@F) > $@ +$(TARBALL): ../versions.mak + $(CMD_PREFIX) $(download_from_pjproject) || (rm -rf $@ ;\ + $(SHELL_ECHO_PREFIX) Retrying download ; sleep 3 ; $(download_from_pjproject)) source/.unpacked: $(DOWNLOAD_DIR)/pjproject-$(PJPROJECT_VERSION).tar.bz2 $(ECHO_PREFIX) Unpacking $< -- cgit v1.2.3