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
This commit is contained in:
George Joseph
2016-11-16 11:05:43 -07:00
parent 98b3b500dc
commit d3f070c7a2
6 changed files with 137 additions and 6 deletions

View File

@@ -75,14 +75,31 @@ include ../Makefile.rules
include Makefile.rules
ECHO_PREFIX := $(ECHO_PREFIX) echo '[pjproject] '
SHELL_ECHO_PREFIX := echo '[pjproject] '
_all: $(TARGETS)
DOWNLOAD_DIR := $(or $(EXTERNALS_CACHE_DIR),$(TMPDIR),$(wildcard /tmp),.)
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
$(DOWNLOAD_DIR)/pjproject-$(PJPROJECT_VERSION).tar.bz2: ../versions.mak
$(ECHO_PREFIX) Downloading $(PJPROJECT_URL)/$(@F) to $@
$(CMD_PREFIX) $(DOWNLOAD_TO_STDOUT) $(PJPROJECT_URL)/$(@F) > $@
.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))
$(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 $<

View File

@@ -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)