summaryrefslogtreecommitdiff
path: root/third-party
diff options
context:
space:
mode:
authorGeorge Joseph <gjoseph@digium.com>2016-11-16 11:05:43 -0700
committerGeorge Joseph <gjoseph@digium.com>2016-11-18 08:01:30 -0500
commit6d34d0ab3674c36390382b76658c9b2957ffa151 (patch)
tree535dc1be88cc0c188565f17ea6cf044892b62ee7 /third-party
parent7a665c5c6e59002cc42b8ea5bb0fec383afcc8ea (diff)
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
Diffstat (limited to 'third-party')
-rw-r--r--third-party/Makefile.rules4
-rw-r--r--third-party/pjproject/Makefile23
-rw-r--r--third-party/pjproject/configure.m48
3 files changed, 31 insertions, 4 deletions
diff --git a/third-party/Makefile.rules b/third-party/Makefile.rules
index 4f804dd0e..f8b72ba6d 100644
--- a/third-party/Makefile.rules
+++ b/third-party/Makefile.rules
@@ -26,4 +26,8 @@ export TAR
export PATCH
export SED
export NM
+export MD5
+export CAT
export DOWNLOAD
+export DOWNLOAD_TO_STDOUT
+export DOWNLOAD_TIMEOUT
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 $<
diff --git a/third-party/pjproject/configure.m4 b/third-party/pjproject/configure.m4
index 7c60c2a02..8294d8ef9 100644
--- a/third-party/pjproject/configure.m4
+++ b/third-party/pjproject/configure.m4
@@ -28,8 +28,14 @@ AC_DEFUN([_PJPROJECT_CONFIGURE],
if test "${NM}" = ":" ; then
AC_MSG_ERROR(nm is required to build bundled pjproject)
fi
+ if test "${MD5}" = ":" ; then
+ AC_MSG_ERROR(md5sum is required to build bundled pjproject)
+ fi
+ if test "${CAT}" = ":" ; then
+ AC_MSG_ERROR(cat is required to build bundled pjproject)
+ fi
- export TAR PATCH SED NM EXTERNALS_CACHE_DIR DOWNLOAD_TO_STDOUT
+ export TAR PATCH SED NM EXTERNALS_CACHE_DIR DOWNLOAD_TO_STDOUT DOWNLOAD_TIMEOUT DOWNLOAD MD5 CAT
${GNU_MAKE} --quiet --no-print-directory -C ${PJPROJECT_DIR} EXTERNALS_CACHE_DIR=${EXTERNALS_CACHE_DIR} configure
if test $? -ne 0 ; then
AC_MSG_RESULT(failed)