Skip to contentSkip to conversation

git-download: Fix downloading of specific revisions from github.

PATCH New Sven Neumann 4 participants 4 messages Jun 26, 2018 – Aug 19, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 git-download: Fix downloading of specific revisions from github.

From: Oliver Tappe <[email protected]>

Github has recently dropped support for the archive-URLs that we used to use.

They do provide another URL where archives can be fetched from, but not as git shallow clone, but direcly as tarball. Adjust the URL to be used and adjust the git download script to use wget when trying to download from github.

---
 package/pkg-download.mk | 2 +-
 support/download/git    | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)
package/pkg-download.mk +1 -1
index 2ca6ccf44d..2e3b734f97 100644
@@ -56,7 +56,7 @@ notdomain = $(patsubst $(call domain,$(1),$(2))$(call domainseparator,$(2))%,%,$
 domainseparator = $(if $(1),$(1),/)
 
 # github(user,package,version): returns site of GitHub repository
-github = https://github.com/$(1)/$(2)/archive/$(3)
+github = https://api.github.com/repos/$(1)/$(2)/tarball/$(3)
 
 # Expressly do not check hashes for those files
 # Exported variables default to immediately expanded in some versions of
support/download/git +6 -0
index 11bb52c1e1..1efde4fcdc 100755
@@ -75,6 +75,12 @@ _git() {
     eval GIT_DIR="${git_cache}/.git" ${GIT} "${@}"
 }
 
+# If the URL contains github, simply fetch the archive via wget:
+if [[ $repo == https://api.github.com/* ]]; then
+    wget -O $output $repo
+    exit 0
+fi
+
 # Create a warning file, that the user should not use the git cache.
 # It's ours. Our precious.
 cat <<-_EOF_ >"${dl_dir}/git.readme"
Signature · 1 line
2.14.4
#1 lore raw

PATCH 1/1 git-download: Fix downloading of specific revisions from github.

Hello,

support/download/git _git() { · line 82

Quoted 13 lines · Sven Neumann
support/download/git +5 -0
index 11bb52c1e1..1efde4fcdc 100755
@@ -75,6 +75,12 @@ _git() {
     eval GIT_DIR="${git_cache}/.git" ${GIT} "${@}"
 }
 
+# If the URL contains github, simply fetch the archive via wget:
+if [[ $repo == https://api.github.com/* ]]; then
+    wget -O $output $repo
+    exit 0
+fi

This looks weird. Why would downloads from https://<something> end up in the Git download helper ?

If the URL starts with https://, unless the SITE_METHOD is forced to Git, then it's the wget download helper that gets used.

Downloads that use the $(call github,...,...) macro today already use wget, not git.

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com
#2 lore raw

PATCH 1/1 git-download: Fix downloading of specific revisions from github.

In reply to Sven Neumann
Quoted 4 lines · Sven Neumann

From: Oliver Tappe <[email protected]>

Github has recently dropped support for the archive-URLs that we used to use.

Could you explain what exactly fails? I tried existing packages and your new
wampcc with the old pattern, and it just works (same hash).

Quoted 2 lines

They do provide another URL where archives can be fetched from, but not as git shallow clone, but direcly as tarball.

AFAIK there never was any specific URL from which you could get a shallow
clone, just the archive URL or the plain (git-over-https) URL (which would allow shallow clones for tags).

Quoted 16 lines

Adjust the URL to
be used and adjust the git download script to use wget when trying to download from github.

---
 package/pkg-download.mk | 2 +-
 support/download/git    | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)
package/pkg-download.mk +0 -0
index 2ca6ccf44d..2e3b734f97 100644

package/pkg-download.mk notdomain = $(patsubst $(call domain,$(1),$(2))$(call domainseparator,$(2))%,%,$ · line 59

Quoted 5 lines
package/pkg-download.mk +1 -1
@@ -56,7 +56,7 @@ notdomain = $(patsubst $(call domain,$(1),$(2))$(call domainseparator,$(2))%,%,$
 domainseparator = $(if $(1),$(1),/)
 
 # github(user,package,version): returns site of GitHub repository
-github = https://github.com/$(1)/$(2)/archive/$(3)
+github = https://api.github.com/repos/$(1)/$(2)/tarball/$(3)

This actually gives me a 404 for the wampcc package...

Regards,
Arnout

Quoted 21 lines
package/pkg-download.mk +0 -0
 # Expressly do not check hashes for those files
 # Exported variables default to immediately expanded in some versions of
support/download/git +6 -0
index 11bb52c1e1..1efde4fcdc 100755
@@ -75,6 +75,12 @@ _git() {
     eval GIT_DIR="${git_cache}/.git" ${GIT} "${@}"
 }
 
+# If the URL contains github, simply fetch the archive via wget:
+if [[ $repo == https://api.github.com/* ]]; then
+    wget -O $output $repo
+    exit 0
+fi
+
 # Create a warning file, that the user should not use the git cache.
 # It's ours. Our precious.
 cat <<-_EOF_ >"${dl_dir}/git.readme"
Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#3 lore raw

PATCH 1/1 git-download: Fix downloading of specific revisions from github.

Am Tue, 26 Jun 2018 23:38:18 +0200 schrieb Arnout Vandecappelle:

Quoted 9 lines · Sven Neumann
Quoted 4 lines

From: Oliver Tappe <[email protected]>

Github has recently dropped support for the archive-URLs that we used to use.

Could you explain what exactly fails? I tried existing packages and your new
wampcc with the old pattern, and it just works (same hash).

Hi,

I did not test the patch but a problem when downloading from github does exist, for example:

$ LC_ALL=C make libsrtp
Quoted 1 line
Quoted 1 line
Quoted 1 line

libsrtp v1.5.4 Downloading

[...]

--2018-08-19 11:37:59-- https://github.com/cisco/libsrtp/archive/v1.5.4/
libsrtp-v1.5.4.tar.gz
Resolving github.com (github.com)... 192.30.253.113, 192.30.253.112 Connecting to github.com (github.com)|192.30.253.113|:443... connected. HTTP request sent, awaiting response... 302 Found
Location: https://codeload.github.com/cisco/libsrtp/tar.gz/v1.5.4/libsrtp-
v1.5.4 [following]
--2018-08-19 11:37:59-- https://codeload.github.com/cisco/libsrtp/tar.gz/
v1.5.4/libsrtp-v1.5.4
Resolving codeload.github.com (codeload.github.com)... 192.30.253.120, 192.30.253.121
Connecting to codeload.github.com (codeload.github.com)|192.30.253.120|:
443... connected.
HTTP request sent, awaiting response... 404 Not Found

2018-08-19 11:38:00 ERROR 404: Not Found.

--2018-08-19 11:38:00-- http://sources.buildroot.net/libsrtp/libsrtp-
v1.5.4.tar.gz
Resolving sources.buildroot.net (sources.buildroot.net)... 104.25.210.19, 104.25.211.19, 2400:cb00:2048:1::6819:d313, ...
Connecting to sources.buildroot.net (sources.buildroot.net)| 104.25.210.19|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1646184 (1.6M) [application/x-gtar-compressed]

[...]

libsrtp-v1.5.4.tar.gz: OK (sha256:
56a7b521c25134f48faff26b0b1e3d4378a14986a2d3d7bc6fefb48987304ff0)

Regards, Bernd