Skip to content
Snippets Groups Projects
Commit 31268e0a authored by George Joseph's avatar George Joseph
Browse files

pjproject_bundled: Retry download if previously saved tarball is bad

If a tarball is corrupted during download, the makefile will attempt to
download it again. If the tarball somehow gets corrupted after it's
downloaded however, the makefile was just failing.  We now
retry the download.

ASTERISK-26653 #close

Change-Id: I1b24d454852d80186f60c5a65dc4624ea8a1c359
parent 2a4b24cc
No related branches found
No related tags found
No related merge requests found
...@@ -87,29 +87,37 @@ SHELL_ECHO_PREFIX := echo '[pjproject] ' ...@@ -87,29 +87,37 @@ SHELL_ECHO_PREFIX := echo '[pjproject] '
_all: $(TARGETS) _all: $(TARGETS)
define verify_tarball
($(SHELL_ECHO_PREFIX) Verifying $(TARBALL) &&\
tarball_sum=$$($(CAT) $(TARBALL) | $(MD5) | $(SED) -n -r -e "s/^([^ ]+)\s+.*/\1/gp") ;\
required_sum=$$($(SED) -n -r -e "s/^([^ ]+)\s+$(TARBALL_FILE)/\1/gp" $(PJMD5SUM)) ;\
if [ "$$tarball_sum" != "$$required_sum" ] ; then $(SHELL_ECHO_PREFIX) Verify failed ; exit 1 ;\
else $(SHELL_ECHO_PREFIX) Verify successful ; exit 0 ; fi; )
endef
define download_from_pjproject define download_from_pjproject
($(SHELL_ECHO_PREFIX) Downloading $(PJPROJECT_URL)/$(@F) to $@ ;\ ($(SHELL_ECHO_PREFIX) Downloading $(TARBALL_URL) to $(TARBALL) ;\
$(DOWNLOAD_TO_STDOUT) $(call DOWNLOAD_TIMEOUT,5,10) $(PJPROJECT_URL)/$(@F) > $@ &&\ $(DOWNLOAD_TO_STDOUT) $(call DOWNLOAD_TIMEOUT,5,10) $(TARBALL_URL) > $(TARBALL) &&\
$(SHELL_ECHO_PREFIX) Downloading $(PJPROJECT_URL)/MD5SUM to $(PJMD5SUM) &&\ $(SHELL_ECHO_PREFIX) Downloading $(PJPROJECT_URL)/MD5SUM to $(PJMD5SUM) &&\
$(DOWNLOAD_TO_STDOUT) $(call DOWNLOAD_TIMEOUT,5,10) $(PJPROJECT_URL)/MD5SUM.TXT > $(PJMD5SUM) &&\ $(DOWNLOAD_TO_STDOUT) $(call DOWNLOAD_TIMEOUT,5,10) $(PJPROJECT_URL)/MD5SUM.TXT > $(PJMD5SUM) &&\
($(SHELL_ECHO_PREFIX) Verifying $@ &&\ $(verify_tarball))
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 endef
.DELETE_ON_ERROR: .DELETE_ON_ERROR:
DOWNLOAD_DIR := $(or $(EXTERNALS_CACHE_DIR),$(TMPDIR),$(wildcard /tmp),.) DOWNLOAD_DIR := $(or $(EXTERNALS_CACHE_DIR),$(TMPDIR),$(wildcard /tmp),.)
TARBALL = $(DOWNLOAD_DIR)/pjproject-$(PJPROJECT_VERSION).tar.bz2 TARBALL_FILE = pjproject-$(PJPROJECT_VERSION).tar.bz2
TARBALL = $(DOWNLOAD_DIR)/$(TARBALL_FILE)
TARBALL_URL = $(PJPROJECT_URL)/$(TARBALL_FILE)
PJMD5SUM = $(patsubst %.tar.bz2,%.md5,$(TARBALL)) PJMD5SUM = $(patsubst %.tar.bz2,%.md5,$(TARBALL))
$(TARBALL): ../versions.mak $(TARBALL): ../versions.mak
$(CMD_PREFIX) $(download_from_pjproject) || (rm -rf $@ ;\ $(CMD_PREFIX) $(download_from_pjproject) || (rm -rf $@ ;\
$(SHELL_ECHO_PREFIX) Retrying download ; sleep 3 ; $(download_from_pjproject)) $(SHELL_ECHO_PREFIX) Retrying download ; $(download_from_pjproject))
source/.unpacked: $(DOWNLOAD_DIR)/pjproject-$(PJPROJECT_VERSION).tar.bz2 source/.unpacked: $(DOWNLOAD_DIR)/pjproject-$(PJPROJECT_VERSION).tar.bz2
($(verify_tarball)) || (rm -rf $@ ;\
$(SHELL_ECHO_PREFIX) Retrying download ; $(download_from_pjproject))
$(ECHO_PREFIX) Unpacking $< $(ECHO_PREFIX) Unpacking $<
-@rm -rf source pjproject-* >/dev/null 2>&1 -@rm -rf source pjproject-* >/dev/null 2>&1
$(CMD_PREFIX) $(TAR) -xjf $< $(CMD_PREFIX) $(TAR) -xjf $<
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment