[Buildroot] [PATCH 4/9 v2] pkg-infra: add support for GitHub as a forge

Yann E. MORIN yann.morin.1998 at free.fr
Sat Dec 6 11:13:54 UTC 2014

Our github helper currently uses a download scheme that is not
guaranteed to be stable over the long run. So, we have a github helper
that generates the correct _SITE value, so we can change it in a single
place, rather than touch all the packages.

This URL scheme is not stable, but GitHub publishes an API for dealing
with the content hosted on GitHub:

This API defines a stable end-point for downloading any abitrary commit
from a repository:

    GET /repos/:owner/:repo/:archive_format/:ref

Switching to using the API implies we can no longer use the github
helper, because all it can do is only return an URL. But the way the
GitHub API works means we have to set both FOO_UPSTREAM_SOURCE and
FOO_SITE for a package, because the remote name is only $(FOO_VERSION).

The only way to continue using our github helper would be to make it
generate Makefile code to set two variables. This is not nice, as this
would be the only thing in the package infra to rely on generating
Makefile code.

Also, the API is rate-limited, and allows only 60 un-authenticated
requests per hour. This is not acceptable for Buildroot, as a user may
well select more than 60 packages coming from GitHub (we currently have
111 GitHub-hosted packages).

Also, some other forges (like Gitorious, Google code...) may need a
download scheme that is closer to the GitHub API scheme (Gitorious) than
what we currently have with _SOURCE and _SITE, and thus require the use
of _UPSTREAM_SOURCE as well.

Introduce a "forge" as a new concept for specifying the upstream
location, whereby the package can tell the type of forge and the
forge-related path of the repository. This is in turned interpreted by
the package infrastructure, which uses it to internally set the
appropriate variables to the appropriate values:

    FOO_FORGE = forge-name
    FOO_FORGE_PATH = user/repository

This patch introduces GitHub as the first such "forge" we support.
Packages will be converted over in a subsequent patch.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998 at free.fr>
Cc: Maxime Hadjinlian <maxime.hadjinlian at gmail.com>
Cc: Samuel Martin <s.martin49 at gmail.com>
Cc: Thomas Petazzoni <thomas.petazzoni at free-electrons.com>
Cc: Peter Korsgaard <jacmet at uclibc.org>
Cc: Thomas De Schampheleire <patrickdepinguin at gmail.com>
Cc: Arnout Vandecappelle <arnout at mind.be>
 package/pkg-generic.mk | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk
index 30bce59..dd67b51 100644
--- a/package/pkg-generic.mk
+++ b/package/pkg-generic.mk
@@ -353,6 +353,12 @@ ifneq ($$($(2)_OVERRIDE_SRCDIR),)
 $(2)_VERSION = custom
+ifndef $(2)_SITE
+ifeq ($$($(2)_FORGE),github)
+$(2)_SITE = https://github.com/$$($(2)_FORGE_PATH)/archive/$$($(2)_VERSION)
+endif # github
 ifndef $(2)_SOURCE
  ifdef $(3)_SOURCE
   $(2)_SOURCE = $$($(3)_SOURCE)

More information about the buildroot mailing list