diff mbox

Add support for plain URL in $(PKG)_PATCH variable

Message ID 1359585462-1314-2-git-send-email-jezz@sysmic.org
State Superseded
Headers show

Commit Message

Jérôme Pouiller Jan. 30, 2013, 10:37 p.m. UTC
Until now, $(PKG)_PATCH allow only to download patches from same URL than tarball.
This patch allow to detect when plain URL are used in $(PKG)_PATCH and correctly
handle them.

Downloaded patches are named $(PKG_NAME)-$(PKG_VERSION)-$(PKG_PATCH_FILENAME).patch

Signed-off-by: Jérôme Pouiller <jezz@sysmic.org>
---
 package/pkg-generic.mk |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Yann E. MORIN Jan. 30, 2013, 10:54 p.m. UTC | #1
Jérôme, All,

On Wednesday 30 January 2013 Jérôme Pouiller wrote:
> Until now, $(PKG)_PATCH allow only to download patches from same URL than tarball.
> This patch allow to detect when plain URL are used in $(PKG)_PATCH and correctly
> handle them.
> 
> Downloaded patches are named $(PKG_NAME)-$(PKG_VERSION)-$(PKG_PATCH_FILENAME).patch

Well, I meant: $(PKG_NAME)-$(PKG_VERSION)-$(PKG_PATCH_FILENAME)
We should keep the original filename (in case it is compresed).

> Signed-off-by: Jérôme Pouiller <jezz@sysmic.org>
> ---
>  package/pkg-generic.mk |    9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk
> index b0eca0a..0afa72d 100644
> --- a/package/pkg-generic.mk
> +++ b/package/pkg-generic.mk
> @@ -40,7 +40,12 @@ ifeq ($(DL_MODE),DOWNLOAD)
>  	fi
>  endif
>  	$(if $($(PKG)_SOURCE),$(call DOWNLOAD,$($(PKG)_SITE)/$($(PKG)_SOURCE)))
> -	$(foreach p,$($(PKG)_PATCH),$(call DOWNLOAD,$($(PKG)_SITE)/$(p))$(sep))
> +	$(foreach p,$($(PKG)_PATCH),\
> +		$(if $(findstring ://,$(p)),\
> +			$(call DOWNLOAD,$(p),$($(PKG)_NAME)-$($(PKG)_VERSION)-$(basename $(notdir $(p)).patch)),\

forget 'basename', don;t add '.patch' (the file may be compressed, we
shouldnot rename it or we won;t be able to apply it.

> +			$(call DOWNLOAD,$($(PKG)_SITE)/$(p))\

The naming should also be applied for the 'plain-file' case, too.

> +		)\
> +	$(sep))
>  	$(foreach hook,$($(PKG)_POST_DOWNLOAD_HOOKS),$(call $(hook))$(sep))
>  ifeq ($(DL_MODE),DOWNLOAD)
>  	$(Q)mkdir -p $(@D)
> @@ -85,7 +90,7 @@ $(BUILD_DIR)/%/.stamp_patched: NAMEVER = $(RAWNAME)-$($(PKG)_VERSION)
>  $(BUILD_DIR)/%/.stamp_patched:
>  	@$(call MESSAGE,"Patching $($(PKG)_DIR_PREFIX)/$(RAWNAME)")
>  	$(foreach hook,$($(PKG)_PRE_PATCH_HOOKS),$(call $(hook))$(sep))
> -	$(foreach p,$($(PKG)_PATCH),support/scripts/apply-patches.sh $(@D) $(DL_DIR) $(p)$(sep))
> +	$(foreach p,$($(PKG)_PATCH),support/scripts/apply-patches.sh $(@D) $(DL_DIR) $(notdir $(p))$(sep))

Make that consistent with the above, please.

Also, here you're doing two indepndent changes:
  - change the downloaded file names
  - allow plain URLs

This should be two different patches (multiple URLs first, I'd suggest).

Regards,
Yann E. MORIN.
Jérôme Pouiller Jan. 30, 2013, 11:11 p.m. UTC | #2
On Wednesday 30 January 2013 23:54:23 Yann E. MORIN wrote:
> Jérôme, All,
> 
> On Wednesday 30 January 2013 Jérôme Pouiller wrote:
> > Until now, $(PKG)_PATCH allow only to download patches from same URL than
> > tarball. This patch allow to detect when plain URL are used in
> > $(PKG)_PATCH and correctly handle them.
> > 
> > Downloaded patches are named
> > $(PKG_NAME)-$(PKG_VERSION)-$(PKG_PATCH_FILENAME).patch
> Well, I meant: $(PKG_NAME)-$(PKG_VERSION)-$(PKG_PATCH_FILENAME)
> We should keep the original filename (in case it is compresed).
In this case, I think files ending with .diff will not work (and compressed 
patches are not supported without a HOOK).

[...]
> > +			$(call DOWNLOAD,$($(PKG)_SITE)/$(p))\
> 
> The naming should also be applied for the 'plain-file' case, too.
Sure.

[...]
Jérôme Pouiller Jan. 31, 2013, 8:20 a.m. UTC | #3
On Thursday 31 January 2013 00:11:08 Jérôme Pouiller wrote:
> On Wednesday 30 January 2013 23:54:23 Yann E. MORIN wrote:
> > Jérôme, All,
> > 
> > On Wednesday 30 January 2013 Jérôme Pouiller wrote:
> > > Until now, $(PKG)_PATCH allow only to download patches from same URL
> > > than
> > > tarball. This patch allow to detect when plain URL are used in
> > > $(PKG)_PATCH and correctly handle them.
> > > 
> > > Downloaded patches are named
> > > $(PKG_NAME)-$(PKG_VERSION)-$(PKG_PATCH_FILENAME).patch
> > 
> > Well, I meant: $(PKG_NAME)-$(PKG_VERSION)-$(PKG_PATCH_FILENAME)
> > We should keep the original filename (in case it is compresed).
> 
> In this case, I think files ending with .diff will not work (and compressed
> patches are not supported without a HOOK).
Forget this comment, I was tired.
diff mbox

Patch

diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk
index b0eca0a..0afa72d 100644
--- a/package/pkg-generic.mk
+++ b/package/pkg-generic.mk
@@ -40,7 +40,12 @@  ifeq ($(DL_MODE),DOWNLOAD)
 	fi
 endif
 	$(if $($(PKG)_SOURCE),$(call DOWNLOAD,$($(PKG)_SITE)/$($(PKG)_SOURCE)))
-	$(foreach p,$($(PKG)_PATCH),$(call DOWNLOAD,$($(PKG)_SITE)/$(p))$(sep))
+	$(foreach p,$($(PKG)_PATCH),\
+		$(if $(findstring ://,$(p)),\
+			$(call DOWNLOAD,$(p),$($(PKG)_NAME)-$($(PKG)_VERSION)-$(basename $(notdir $(p)).patch)),\
+			$(call DOWNLOAD,$($(PKG)_SITE)/$(p))\
+		)\
+	$(sep))
 	$(foreach hook,$($(PKG)_POST_DOWNLOAD_HOOKS),$(call $(hook))$(sep))
 ifeq ($(DL_MODE),DOWNLOAD)
 	$(Q)mkdir -p $(@D)
@@ -85,7 +90,7 @@  $(BUILD_DIR)/%/.stamp_patched: NAMEVER = $(RAWNAME)-$($(PKG)_VERSION)
 $(BUILD_DIR)/%/.stamp_patched:
 	@$(call MESSAGE,"Patching $($(PKG)_DIR_PREFIX)/$(RAWNAME)")
 	$(foreach hook,$($(PKG)_PRE_PATCH_HOOKS),$(call $(hook))$(sep))
-	$(foreach p,$($(PKG)_PATCH),support/scripts/apply-patches.sh $(@D) $(DL_DIR) $(p)$(sep))
+	$(foreach p,$($(PKG)_PATCH),support/scripts/apply-patches.sh $(@D) $(DL_DIR) $(notdir $(p))$(sep))
 	$(Q)( \
 	if test -d $($(PKG)_DIR_PREFIX)/$(RAWNAME); then \
 	  if test "$(wildcard $($(PKG)_DIR_PREFIX)/$(RAWNAME)/$(NAMEVER)*.patch*)"; then \