support/download: convert localfiles to use the wrapper
authorYann E. MORIN <yann.morin.1998@free.fr>
Sun, 3 Aug 2014 17:53:36 +0000 (19:53 +0200)
committerThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Mon, 4 Aug 2014 18:12:24 +0000 (20:12 +0200)
This drastically simplifies the localfiles helper, as it no longer has
to deal with atomically saving the downloaded archive.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Tested-by: Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
(Tested by setting BUSYBOX_SITE = file:///tmp and running 'make busybox-source')
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
package/pkg-download.mk
support/download/cp

index 0c9397a56a6a9e5588d4dc082317e4298892248a..f10aad8a34376f0cd8c077085e54201b0e09a9cd 100644 (file)
@@ -209,8 +209,9 @@ endef
 
 define DOWNLOAD_LOCALFILES
        test -e $(DL_DIR)/$(2) || \
-       $(EXTRA_ENV) support/download/cp $(call stripurischeme,$(call qstrip,$(1))) \
-                                        $(DL_DIR)/$(2) && \
+       $(EXTRA_ENV) support/download/wrapper cp \
+               $(DL_DIR)/$(2) \
+               $(call stripurischeme,$(call qstrip,$(1))) && \
        $(call VERIFY_HASH,$(PKGDIR)/$($(PKG)_NAME).hash,$(DL_DIR)/$(2))
 endef
 
index 8f6bc06f4548ebd5eff644590a88807f70b3a781..264f5dc522620d72a0644eaabccdc3090719331b 100755 (executable)
@@ -1,26 +1,16 @@
 #!/bin/bash
 
-# We want to catch any command failure, and exit immediately
+# We want to catch any unexpected failure, and exit immediately
 set -e
 
-# Download helper for cp
-# Call it with:
-#   $1: source file
-#   $2: output file
+# Download helper for cp, to be called from the download wrapper script
+# Expected arguments:
+#   $1: output file
+#   $2: source file
 # And this environment:
 #   LOCALFILES: the cp command to call
 
-source="${1}"
-output="${2}"
+output="${1}"
+source="${2}"
 
-tmp_output="$( mktemp "${output}.XXXXXX" )"
-
-ret=1
-if ${LOCALFILES} "${source}" "${tmp_output}"; then
-    mv "${tmp_output}" "${output}"
-    ret=0
-fi
-
-# Cleanup
-rm -f "${tmp_output}"
-exit ${ret}
+${LOCALFILES} "${source}" "${output}"