diff mbox

[4/4,v3] core/pkg-infra: download git submodules if the package wants them

Message ID b9061693f4d7a2c7030190efd686c988c1278e43.1467363623.git.yann.morin.1998@free.fr
State Accepted
Commit ec3e057f79117d851c37f19316a3b9b5e2470550
Headers show

Commit Message

Yann E. MORIN July 1, 2016, 9:01 a.m. UTC
Add a new package variable that packages can set to specify that they
need git submodules.

Only accept this option if the download method is git, as we can not get
submodules via an http download (via wget).

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Aleksandar Simeonov <aleksandar@barix.com>
Tested-by: Matt Weber <matt@thewebers.ws>
Reviewed-by: Matt Weber <matt@thewebers.ws>
Tested-By: Nicolas Cavallari <nicolas.cavallari@green-communications.fr>

---
Changes v1 -> v2:
  - properly accept the -r in the download wrapper  (Aleksandar)
---
 package/pkg-download.mk     | 1 +
 package/pkg-generic.mk      | 8 ++++++++
 support/download/dl-wrapper | 7 ++++---
 3 files changed, 13 insertions(+), 3 deletions(-)

Comments

Peter Korsgaard July 2, 2016, 5:11 p.m. UTC | #1
>>>>> "Yann" == Yann E MORIN <yann.morin.1998@free.fr> writes:

 > Add a new package variable that packages can set to specify that they
 > need git submodules.

 > Only accept this option if the download method is git, as we can not get
 > submodules via an http download (via wget).

 > Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
 > Cc: Aleksandar Simeonov <aleksandar@barix.com>
 > Tested-by: Matt Weber <matt@thewebers.ws>
 > Reviewed-by: Matt Weber <matt@thewebers.ws>
 > Tested-By: Nicolas Cavallari <nicolas.cavallari@green-communications.fr>

 > ---
 > Changes v1 -> v2:
 >   - properly accept the -r in the download wrapper  (Aleksandar)

Committed, thanks.

Will you also send a patch to update the user manual?
Yann E. MORIN July 2, 2016, 11:40 p.m. UTC | #2
Peter, All,

On 2016-07-02 19:11 +0200, Peter Korsgaard spake thusly:
> >>>>> "Yann" == Yann E MORIN <yann.morin.1998@free.fr> writes:
>  > Add a new package variable that packages can set to specify that they
>  > need git submodules.
[--SNIP--]
> Will you also send a patch to update the user manual?

Say "please", and I'll see what I can do... ;-)

Regards,
Yann E. MORIN.
Peter Korsgaard July 2, 2016, 11:55 p.m. UTC | #3
>>>>> "Yann" == Yann E MORIN <yann.morin.1998@free.fr> writes:

 > Peter, All,
 > On 2016-07-02 19:11 +0200, Peter Korsgaard spake thusly:
 >> >>>>> "Yann" == Yann E MORIN <yann.morin.1998@free.fr> writes:
 >> > Add a new package variable that packages can set to specify that they
 >> > need git submodules.
 > [--SNIP--]
 >> Will you also send a patch to update the user manual?

 > Say "please", and I'll see what I can do... ;-)

Pretty please with sugar on top! ;)
diff mbox

Patch

diff --git a/package/pkg-download.mk b/package/pkg-download.mk
index a0f694d..315203f 100644
--- a/package/pkg-download.mk
+++ b/package/pkg-download.mk
@@ -76,6 +76,7 @@  export BR_NO_CHECK_HASH_FOR =
 define DOWNLOAD_GIT
 	$(EXTRA_ENV) $(DL_WRAPPER) -b git \
 		-o $(DL_DIR)/$($(PKG)_SOURCE) \
+		$(if $($(PKG)_GIT_SUBMODULES),-r) \
 		$(QUIET) \
 		-- \
 		$($(PKG)_SITE) \
diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk
index b712c31..fa404ca 100644
--- a/package/pkg-generic.mk
+++ b/package/pkg-generic.mk
@@ -468,6 +468,14 @@  ifndef $(2)_SITE_METHOD
  endif
 endif
 
+# Do not accept to download git submodule if not using the git method
+ifneq ($$($(2)_GIT_SUBMODULES),)
+ ifneq ($$($(2)_SITE_METHOD),git)
+  $$(error $(2) declares having git sub-modules, but does not use the \
+	   'git' method (uses '$$($(2)_SITE_METHOD)' instead))
+ endif
+endif
+
 ifeq ($$($(2)_SITE_METHOD),local)
 ifeq ($$($(2)_OVERRIDE_SRCDIR),)
 $(2)_OVERRIDE_SRCDIR = $$($(2)_SITE)
diff --git a/support/download/dl-wrapper b/support/download/dl-wrapper
index ef2d872..f944b71 100755
--- a/support/download/dl-wrapper
+++ b/support/download/dl-wrapper
@@ -21,15 +21,16 @@  set -e
 
 main() {
     local OPT OPTARG
-    local backend output hfile quiet
+    local backend output hfile recurse quiet
 
     # Parse our options; anything after '--' is for the backend
-    while getopts :hb:o:H:q OPT; do
+    while getopts :hb:o:H:rq OPT; do
         case "${OPT}" in
         h)  help; exit 0;;
         b)  backend="${OPTARG}";;
         o)  output="${OPTARG}";;
         H)  hfile="${OPTARG}";;
+        r)  recurse="-r";;
         q)  quiet="-q";;
         :)  error "option '%s' expects a mandatory argument\n" "${OPTARG}";;
         \?) error "unknown option '%s'\n" "${OPTARG}";;
@@ -82,7 +83,7 @@  main() {
     # If the backend fails, we can just remove the temporary directory to
     # remove all the cruft it may have left behind. Then we just exit in
     # error too.
-    if ! "${OLDPWD}/support/download/${backend}" ${quiet} "${tmpf}" "${@}"; then
+    if ! "${OLDPWD}/support/download/${backend}" ${quiet} ${recurse} "${tmpf}" "${@}"; then
         rm -rf "${tmpd}"
         exit 1
     fi