summaryrefslogtreecommitdiffstats
path: root/meta/classes/base.bbclass
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@linux.intel.com>2009-01-02 11:09:04 +0000
committerRichard Purdie <rpurdie@linux.intel.com>2009-01-02 11:09:04 +0000
commit3ab2ff7668229f8f103043aaaad9310d607510bb (patch)
tree55c61b7cd19c1657ac278baa4c1784a00d2091f3 /meta/classes/base.bbclass
parent1d89595e2b99c645f7529cf9868e3aae7f4d70f1 (diff)
downloadpoky-3ab2ff7668229f8f103043aaaad9310d607510bb.tar.gz
base.bbclass: Add metadata revision handling for git (from OE)
Diffstat (limited to 'meta/classes/base.bbclass')
-rw-r--r--meta/classes/base.bbclass56
1 files changed, 53 insertions, 3 deletions
diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
index 8e6284c532..0edd4127c8 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -714,6 +714,17 @@ def base_get_scmbasepath(d):
714 path_to_bbfiles = bb.data.getVar( 'BBFILES', d, 1 ).split() 714 path_to_bbfiles = bb.data.getVar( 'BBFILES', d, 1 ).split()
715 return path_to_bbfiles[0][:path_to_bbfiles[0].rindex( "packages" )] 715 return path_to_bbfiles[0][:path_to_bbfiles[0].rindex( "packages" )]
716 716
717def base_get_metadata_monotone_branch(d):
718 monotone_branch = "<unknown>"
719 try:
720 monotone_branch = file( "%s/_MTN/options" % base_get_scmbasepath(d) ).read().strip()
721 if monotone_branch.startswith( "database" ):
722 monotone_branch_words = monotone_branch.split()
723 monotone_branch = monotone_branch_words[ monotone_branch_words.index( "branch" )+1][1:-1]
724 except:
725 pass
726 return monotone_branch
727
717def base_get_metadata_monotone_revision(d): 728def base_get_metadata_monotone_revision(d):
718 monotone_revision = "<unknown>" 729 monotone_revision = "<unknown>"
719 try: 730 try:
@@ -733,6 +744,47 @@ def base_get_metadata_svn_revision(d):
733 pass 744 pass
734 return revision 745 return revision
735 746
747def base_get_metadata_git_branch(d):
748 import os
749 branch = os.popen('cd %s; git branch | grep "^* " | tr -d "* "' % base_get_scmbasepath(d)).read()
750
751 if len(branch) != 0:
752 return branch
753 return "<unknown>"
754
755def base_get_metadata_git_revision(d):
756 import os
757 rev = os.popen("cd %s; git log -n 1 --pretty=oneline --" % base_get_scmbasepath(d)).read().split(" ")[0]
758 if len(rev) != 0:
759 return rev
760 return "<unknown>"
761
762def base_detect_revision(d):
763 scms = [base_get_metadata_git_revision, \
764 base_get_metadata_svn_revision]
765
766 for scm in scms:
767 rev = scm(d)
768 if rev <> "<unknown>":
769 return rev
770
771 return "<unknown>"
772
773def base_detect_branch(d):
774 scms = [base_get_metadata_git_branch]
775
776 for scm in scms:
777 rev = scm(d)
778 if rev <> "<unknown>":
779 return rev.strip()
780
781 return "<unknown>"
782
783
784
785METADATA_BRANCH ?= "${@base_detect_branch(d)}"
786METADATA_REVISION ?= "${@base_detect_revision(d)}"
787
736GIT_CONFIG = "${STAGING_DIR_NATIVE}/usr/etc/gitconfig" 788GIT_CONFIG = "${STAGING_DIR_NATIVE}/usr/etc/gitconfig"
737 789
738def generate_git_config(e): 790def generate_git_config(e):
@@ -756,8 +808,6 @@ def generate_git_config(e):
756 f.write(proxy_command) 808 f.write(proxy_command)
757 f.close 809 f.close
758 810
759METADATA_REVISION ?= "${@base_get_metadata_monotone_revision(d)}"
760
761addhandler base_eventhandler 811addhandler base_eventhandler
762python base_eventhandler() { 812python base_eventhandler() {
763 from bb import note, error, data 813 from bb import note, error, data
@@ -792,7 +842,7 @@ python base_eventhandler() {
792 842
793 if name.startswith("BuildStarted"): 843 if name.startswith("BuildStarted"):
794 bb.data.setVar( 'BB_VERSION', bb.__version__, e.data ) 844 bb.data.setVar( 'BB_VERSION', bb.__version__, e.data )
795 statusvars = ['BB_VERSION', 'METADATA_REVISION', 'TARGET_ARCH', 'TARGET_OS', 'MACHINE', 'DISTRO', 'DISTRO_VERSION','TARGET_FPU'] 845 statusvars = ['BB_VERSION', 'METADATA_BRANCH', 'METADATA_REVISION', 'TARGET_ARCH', 'TARGET_OS', 'MACHINE', 'DISTRO', 'DISTRO_VERSION','TARGET_FPU']
796 statuslines = ["%-17s = \"%s\"" % (i, bb.data.getVar(i, e.data, 1) or '') for i in statusvars] 846 statuslines = ["%-17s = \"%s\"" % (i, bb.data.getVar(i, e.data, 1) or '') for i in statusvars]
797 statusmsg = "\nOE Build Configuration:\n%s\n" % '\n'.join(statuslines) 847 statusmsg = "\nOE Build Configuration:\n%s\n" % '\n'.join(statuslines)
798 print statusmsg 848 print statusmsg