summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--meta-moblin/conf/distro/moblin.conf5
-rw-r--r--meta/classes/base.bbclass56
-rw-r--r--meta/conf/distro/poky.conf4
3 files changed, 53 insertions, 12 deletions
diff --git a/meta-moblin/conf/distro/moblin.conf b/meta-moblin/conf/distro/moblin.conf
index 41cb6dda1..d27aa96e0 100644
--- a/meta-moblin/conf/distro/moblin.conf
+++ b/meta-moblin/conf/distro/moblin.conf
@@ -18,11 +18,6 @@ QA_LOGFILE = "${TMPDIR}/qa.log"
IMAGE_ROOTFS_SIZE_ext2 ?= "131072"
-# Metadata is git based
-#METADATA_REVISION = "${@base_get_metadata_git_revision(d)}"
-#FIXME
-METADATA_REVISION = "unknown"
-
#IPK_FEED_URIS += " \
# upgrades##http://openzaurus.org/official/unstable/${DISTRO_VERSION}/upgrades/ \
#upgrades-${MACHINE}##http://openzaurus.org/official/unstable/${DISTRO_VERSION}/upgrades/${MACHINE} \
diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
index 8e6284c53..0edd4127c 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -714,6 +714,17 @@ def base_get_scmbasepath(d):
path_to_bbfiles = bb.data.getVar( 'BBFILES', d, 1 ).split()
return path_to_bbfiles[0][:path_to_bbfiles[0].rindex( "packages" )]
+def base_get_metadata_monotone_branch(d):
+ monotone_branch = "<unknown>"
+ try:
+ monotone_branch = file( "%s/_MTN/options" % base_get_scmbasepath(d) ).read().strip()
+ if monotone_branch.startswith( "database" ):
+ monotone_branch_words = monotone_branch.split()
+ monotone_branch = monotone_branch_words[ monotone_branch_words.index( "branch" )+1][1:-1]
+ except:
+ pass
+ return monotone_branch
+
def base_get_metadata_monotone_revision(d):
monotone_revision = "<unknown>"
try:
@@ -733,6 +744,47 @@ def base_get_metadata_svn_revision(d):
pass
return revision
+def base_get_metadata_git_branch(d):
+ import os
+ branch = os.popen('cd %s; git branch | grep "^* " | tr -d "* "' % base_get_scmbasepath(d)).read()
+
+ if len(branch) != 0:
+ return branch
+ return "<unknown>"
+
+def base_get_metadata_git_revision(d):
+ import os
+ rev = os.popen("cd %s; git log -n 1 --pretty=oneline --" % base_get_scmbasepath(d)).read().split(" ")[0]
+ if len(rev) != 0:
+ return rev
+ return "<unknown>"
+
+def base_detect_revision(d):
+ scms = [base_get_metadata_git_revision, \
+ base_get_metadata_svn_revision]
+
+ for scm in scms:
+ rev = scm(d)
+ if rev <> "<unknown>":
+ return rev
+
+ return "<unknown>"
+
+def base_detect_branch(d):
+ scms = [base_get_metadata_git_branch]
+
+ for scm in scms:
+ rev = scm(d)
+ if rev <> "<unknown>":
+ return rev.strip()
+
+ return "<unknown>"
+
+
+
+METADATA_BRANCH ?= "${@base_detect_branch(d)}"
+METADATA_REVISION ?= "${@base_detect_revision(d)}"
+
GIT_CONFIG = "${STAGING_DIR_NATIVE}/usr/etc/gitconfig"
def generate_git_config(e):
@@ -756,8 +808,6 @@ def generate_git_config(e):
f.write(proxy_command)
f.close
-METADATA_REVISION ?= "${@base_get_metadata_monotone_revision(d)}"
-
addhandler base_eventhandler
python base_eventhandler() {
from bb import note, error, data
@@ -792,7 +842,7 @@ python base_eventhandler() {
if name.startswith("BuildStarted"):
bb.data.setVar( 'BB_VERSION', bb.__version__, e.data )
- statusvars = ['BB_VERSION', 'METADATA_REVISION', 'TARGET_ARCH', 'TARGET_OS', 'MACHINE', 'DISTRO', 'DISTRO_VERSION','TARGET_FPU']
+ statusvars = ['BB_VERSION', 'METADATA_BRANCH', 'METADATA_REVISION', 'TARGET_ARCH', 'TARGET_OS', 'MACHINE', 'DISTRO', 'DISTRO_VERSION','TARGET_FPU']
statuslines = ["%-17s = \"%s\"" % (i, bb.data.getVar(i, e.data, 1) or '') for i in statusvars]
statusmsg = "\nOE Build Configuration:\n%s\n" % '\n'.join(statuslines)
print statusmsg
diff --git a/meta/conf/distro/poky.conf b/meta/conf/distro/poky.conf
index e7178f9a9..774f101da 100644
--- a/meta/conf/distro/poky.conf
+++ b/meta/conf/distro/poky.conf
@@ -23,10 +23,6 @@ QA_LOGFILE = "${TMPDIR}/qa.log"
IMAGE_ROOTFS_SIZE_ext2 ?= "131072"
-# Poky is git based
-# METADATA_REVISION = "${@base_get_metadata_svn_revision(d)}"
-METADATA_REVISION = "none"
-
#IPK_FEED_URIS += " \
# upgrades##http://openzaurus.org/official/unstable/${DISTRO_VERSION}/upgrades/ \
#upgrades-${MACHINE}##http://openzaurus.org/official/unstable/${DISTRO_VERSION}/upgrades/${MACHINE} \