summaryrefslogtreecommitdiffstats
path: root/package
diff options
context:
space:
mode:
authorArnout Vandecappelle <arnout@mind.be>2012-06-30 11:43:03 +0000
committerPeter Korsgaard <jacmet@sunsite.dk>2012-07-01 00:26:37 +0200
commit96885ca7eb4a05e65986334d6138e1fe6afa46fc (patch)
tree6cde8b9ced1d92c64716bfd5df250dfb3a39cd81 /package
parent9910eba33adb2b783b0df5d90a857816e82fbd55 (diff)
downloadbuildroot-novena-96885ca7eb4a05e65986334d6138e1fe6afa46fc.tar.gz
buildroot-novena-96885ca7eb4a05e65986334d6138e1fe6afa46fc.zip
pkg-download: handle interrupted wget downloads
When a wget download is interrupted, the downloaded file is still created. It will therefore not be re-downloaded in the next build, and the extraction will fail. To avoid this, download to a temporary file first and rename when the download is successful. The existing mechanism doesn't work for interrupted downloads because the whole sub-shell is interrupted, so the rm-part never gets executed. Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be> Signed-off-by: Peter Korsgaard <jacmet@sunsite.dk>
Diffstat (limited to 'package')
-rw-r--r--package/pkg-download.mk9
1 files changed, 6 insertions, 3 deletions
diff --git a/package/pkg-download.mk b/package/pkg-download.mk
index 7d1e54375..79837060b 100644
--- a/package/pkg-download.mk
+++ b/package/pkg-download.mk
@@ -158,11 +158,14 @@ endef
# Download a file using wget. Only download the file if it doesn't
# already exist in the download directory. If the download fails,
# remove the file (because wget -O creates a 0-byte file even if the
-# download fails).
+# download fails). To handle an interrupted download as well, download
+# to a temporary file first. The temporary file will be overwritten
+# the next time the download is tried.
define DOWNLOAD_WGET
test -e $(DL_DIR)/$(2) || \
- $(WGET) -O $(DL_DIR)/$(2) '$(call qstrip,$(1))' || \
- (rm -f $(DL_DIR)/$(2) ; exit 1)
+ ($(WGET) -O $(DL_DIR)/$(2).tmp '$(call qstrip,$(1))' && \
+ mv $(DL_DIR)/$(2).tmp $(DL_DIR)/$(2)) || \
+ (rm -f $(DL_DIR)/$(2).tmp ; exit 1)
endef
define SOURCE_CHECK_WGET