diff mbox series

[meta-swupdate] Fix build without network

Message ID 1513428933-10902-1-git-send-email-sbabic@denx.de
State Accepted
Headers show
Series [meta-swupdate] Fix build without network | expand

Commit Message

Stefano Babic Dec. 16, 2017, 12:55 p.m. UTC
bitbake runs git ls-remote if a recipe contains AUTOREV as SRCREV.
This forbids to build SWUpdate without network (setting BB_NO_NETWORK),
because the git version uses the last commit via AUTOREV.

Add a function to provide SRCREV for swupdate_git. This returns a fix
commit if the git version is not chosen, or AUTOREV if swupdate_git is selected.

Signed-off-by: Stefano Babic <sbabic@denx.de>
Reported-by: Diaz de Grenu, Jose <Jose.DiazdeGrenu@digi.com>
---
 recipes-support/swupdate/swupdate.inc    |  2 --
 recipes-support/swupdate/swupdate_git.bb | 16 ++++++++++++++++
 2 files changed, 16 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/recipes-support/swupdate/swupdate.inc b/recipes-support/swupdate/swupdate.inc
index 1431d15..7175848 100644
--- a/recipes-support/swupdate/swupdate.inc
+++ b/recipes-support/swupdate/swupdate.inc
@@ -16,8 +16,6 @@  SRC_URI = "git://github.com/sbabic/swupdate.git;protocol=https \
      file://swupdate-progress.service \
      "
 
-SRCREV = "${AUTOREV}"
-
 INSANE_SKIP_${PN} = "ldflags"
 PACKAGES =+ "${PN}-www"
 
diff --git a/recipes-support/swupdate/swupdate_git.bb b/recipes-support/swupdate/swupdate_git.bb
index 6aff30c..4fc15ad 100644
--- a/recipes-support/swupdate/swupdate_git.bb
+++ b/recipes-support/swupdate/swupdate_git.bb
@@ -2,3 +2,19 @@  require swupdate.inc
 require swupdate_tools.inc
 
 DEFAULT_PREFERENCE = "-1"
+
+# If a recipe sets SRCREV to ${AUTOREV}, bitbake tries
+# a git ls-remote. This breaks when a mirror is built
+# and BB_NO_NETWORK is set.
+# To work-around the issue, sets the revision for the git
+# version to a fix commit (not relevant)
+# In casethe _git version is chosen, sets the revision
+# to TOT to test with last commit-id.
+def version_git(d):
+    version = d.getVar("PREFERRED_VERSION_%s" % d.getVar('PN'))
+    if version is not None and "git" in version:
+        return d.getVar("AUTOREV")
+    else:
+        return "c0fec16b3fc82b0db12d8ac58be7055ed1b8d439"
+
+SRCREV ?= '${@version_git(d)}'