diff mbox

[3/9,v3] support/download: convert localfiles to use the wrapper

Message ID 05b08895dc36985d013b09ce3e05f67c1bfd1396.1405895896.git.yann.morin.1998@free.fr
State Changes Requested
Headers show

Commit Message

Yann E. MORIN July 20, 2014, 10:42 p.m. UTC
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>
---
 package/pkg-download.mk |  4 ++--
 support/download/cp     | 20 +++++---------------
 2 files changed, 7 insertions(+), 17 deletions(-)

Comments

Thomas De Schampheleire Aug. 3, 2014, 7:56 a.m. UTC | #1
On Mon, Jul 21, 2014 at 12:42 AM, Yann E. MORIN <yann.morin.1998@free.fr> wrote:
> 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>
> ---
>  package/pkg-download.mk |  4 ++--
>  support/download/cp     | 20 +++++---------------
>  2 files changed, 7 insertions(+), 17 deletions(-)
>
> diff --git a/package/pkg-download.mk b/package/pkg-download.mk
> index 6320338..94febab 100644
> --- a/package/pkg-download.mk
> +++ b/package/pkg-download.mk
> @@ -205,8 +205,8 @@ 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
>
> diff --git a/support/download/cp b/support/download/cp
> index 8f6bc06..4945c56 100755
> --- a/support/download/cp
> +++ b/support/download/cp
> @@ -5,22 +5,12 @@ set -e

Here you didn't make the comment change command->unexpected before set -e.

Best regards,
Thomas
Yann E. MORIN Aug. 3, 2014, 5:06 p.m. UTC | #2
Thomas, All,

On 2014-08-03 09:56 +0200, Thomas De Schampheleire spake thusly:
> On Mon, Jul 21, 2014 at 12:42 AM, Yann E. MORIN <yann.morin.1998@free.fr> wrote:
> > 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>
> > ---
> >  package/pkg-download.mk |  4 ++--
> >  support/download/cp     | 20 +++++---------------
> >  2 files changed, 7 insertions(+), 17 deletions(-)
> >
> > diff --git a/package/pkg-download.mk b/package/pkg-download.mk
> > index 6320338..94febab 100644
> > --- a/package/pkg-download.mk
> > +++ b/package/pkg-download.mk
> > @@ -205,8 +205,8 @@ 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
> >
> > diff --git a/support/download/cp b/support/download/cp
> > index 8f6bc06..4945c56 100755
> > --- a/support/download/cp
> > +++ b/support/download/cp
> > @@ -5,22 +5,12 @@ set -e
> 
> Here you didn't make the comment change command->unexpected before set -e.

Yep, will do.

Regards,
Yann E. MORIN.
Thomas De Schampheleire Aug. 3, 2014, 5:39 p.m. UTC | #3
On Mon, Jul 21, 2014 at 12:42 AM, Yann E. MORIN <yann.morin.1998@free.fr> wrote:
> 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>
> ---
>  package/pkg-download.mk |  4 ++--
>  support/download/cp     | 20 +++++---------------
>  2 files changed, 7 insertions(+), 17 deletions(-)
>
> diff --git a/package/pkg-download.mk b/package/pkg-download.mk
> index 6320338..94febab 100644
> --- a/package/pkg-download.mk
> +++ b/package/pkg-download.mk
> @@ -205,8 +205,8 @@ 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
>
> diff --git a/support/download/cp b/support/download/cp
> index 8f6bc06..4945c56 100755
> --- a/support/download/cp
> +++ b/support/download/cp
> @@ -5,22 +5,12 @@ set -e
>
>  # Download helper for cp
>  # Call it with:
> -#   $1: source file
> -#   $2: output file
> +#   $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}"
> --

Tested-by: Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
(Tested by setting BUSYBOX_SITE = file:///tmp and running 'make busybox-source')
diff mbox

Patch

diff --git a/package/pkg-download.mk b/package/pkg-download.mk
index 6320338..94febab 100644
--- a/package/pkg-download.mk
+++ b/package/pkg-download.mk
@@ -205,8 +205,8 @@  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
 
diff --git a/support/download/cp b/support/download/cp
index 8f6bc06..4945c56 100755
--- a/support/download/cp
+++ b/support/download/cp
@@ -5,22 +5,12 @@  set -e
 
 # Download helper for cp
 # Call it with:
-#   $1: source file
-#   $2: output file
+#   $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}"