summaryrefslogtreecommitdiffstats
path: root/meta/classes
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@linux.intel.com>2009-12-17 20:35:08 +0000
committerRichard Purdie <rpurdie@linux.intel.com>2009-12-18 11:41:43 +0000
commit22429b6137dd2d84dcc501d439dcebc407371304 (patch)
tree2c0235f8b5b533f849f735e9795d1ea2d876f0e3 /meta/classes
parentb28aa01ac86f7d2393308bac950b31b116f0786c (diff)
downloadpoky-22429b6137dd2d84dcc501d439dcebc407371304.tar.gz
base.bbclass: Partially sync branch/scm handling functions with OE.dev
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'meta/classes')
-rw-r--r--meta/classes/base.bbclass72
1 files changed, 38 insertions, 34 deletions
diff --git a/meta/classes/base.bbclass b/meta/classes/base.bbclass
index ff0e42a4ff..3639320906 100644
--- a/meta/classes/base.bbclass
+++ b/meta/classes/base.bbclass
@@ -720,14 +720,44 @@ python base_do_unpack() {
720 raise bb.build.FuncFailed() 720 raise bb.build.FuncFailed()
721} 721}
722 722
723METADATA_BRANCH ?= "${@base_detect_branch(d)}"
724METADATA_REVISION ?= "${@base_detect_revision(d)}"
725
726def base_detect_revision(d):
727 path = base_get_scmbasepath(d)
728
729 scms = [base_get_metadata_git_revision, \
730 base_get_metadata_svn_revision]
731
732 for scm in scms:
733 rev = scm(path, d)
734 if rev <> "<unknown>":
735 return rev
736
737 return "<unknown>"
738
739def base_detect_branch(d):
740 path = base_get_scmbasepath(d)
741
742 scms = [base_get_metadata_git_branch]
743
744 for scm in scms:
745 rev = scm(path, d)
746 if rev <> "<unknown>":
747 return rev.strip()
748
749 return "<unknown>"
750
751
752
723def base_get_scmbasepath(d): 753def base_get_scmbasepath(d):
724 path_to_bbfiles = bb.data.getVar( 'BBFILES', d, 1 ).split() 754 path_to_bbfiles = bb.data.getVar( 'BBFILES', d, 1 ).split()
725 return path_to_bbfiles[0][:path_to_bbfiles[0].rindex( "packages" )] 755 return path_to_bbfiles[0][:path_to_bbfiles[0].rindex( "packages" )]
726 756
727def base_get_metadata_monotone_branch(d): 757def base_get_metadata_monotone_branch(path, d):
728 monotone_branch = "<unknown>" 758 monotone_branch = "<unknown>"
729 try: 759 try:
730 monotone_branch = file( "%s/_MTN/options" % base_get_scmbasepath(d) ).read().strip() 760 monotone_branch = file( "%s/_MTN/options" % path ).read().strip()
731 if monotone_branch.startswith( "database" ): 761 if monotone_branch.startswith( "database" ):
732 monotone_branch_words = monotone_branch.split() 762 monotone_branch_words = monotone_branch.split()
733 monotone_branch = monotone_branch_words[ monotone_branch_words.index( "branch" )+1][1:-1] 763 monotone_branch = monotone_branch_words[ monotone_branch_words.index( "branch" )+1][1:-1]
@@ -735,10 +765,10 @@ def base_get_metadata_monotone_branch(d):
735 pass 765 pass
736 return monotone_branch 766 return monotone_branch
737 767
738def base_get_metadata_monotone_revision(d): 768def base_get_metadata_monotone_revision(path, d):
739 monotone_revision = "<unknown>" 769 monotone_revision = "<unknown>"
740 try: 770 try:
741 monotone_revision = file( "%s/_MTN/revision" % base_get_scmbasepath(d) ).read().strip() 771 monotone_revision = file( "%s/_MTN/revision" % path ).read().strip()
742 if monotone_revision.startswith( "format_version" ): 772 if monotone_revision.startswith( "format_version" ):
743 monotone_revision_words = monotone_revision.split() 773 monotone_revision_words = monotone_revision.split()
744 monotone_revision = monotone_revision_words[ monotone_revision_words.index( "old_revision" )+1][1:-1] 774 monotone_revision = monotone_revision_words[ monotone_revision_words.index( "old_revision" )+1][1:-1]
@@ -746,16 +776,16 @@ def base_get_metadata_monotone_revision(d):
746 pass 776 pass
747 return monotone_revision 777 return monotone_revision
748 778
749def base_get_metadata_svn_revision(d): 779def base_get_metadata_svn_revision(path, d):
750 revision = "<unknown>" 780 revision = "<unknown>"
751 try: 781 try:
752 revision = file( "%s/.svn/entries" % base_get_scmbasepath(d) ).readlines()[3].strip() 782 revision = file( "%s/.svn/entries" % path ).readlines()[3].strip()
753 except IOError: 783 except IOError:
754 pass 784 pass
755 return revision 785 return revision
756 786
757def base_get_metadata_git_branch(d): 787def base_get_metadata_git_branch(path, d):
758 branch = os.popen('cd %s; git branch | grep "^* " | tr -d "* "' % base_get_scmbasepath(d)).read() 788 branch = os.popen('cd %s; git branch | grep "^* " | tr -d "* "' % path).read()
759 789
760 if len(branch) != 0: 790 if len(branch) != 0:
761 return branch 791 return branch
@@ -767,32 +797,6 @@ def base_get_metadata_git_revision(d):
767 return rev 797 return rev
768 return "<unknown>" 798 return "<unknown>"
769 799
770def base_detect_revision(d):
771 scms = [base_get_metadata_git_revision, \
772 base_get_metadata_svn_revision]
773
774 for scm in scms:
775 rev = scm(d)
776 if rev <> "<unknown>":
777 return rev
778
779 return "<unknown>"
780
781def base_detect_branch(d):
782 scms = [base_get_metadata_git_branch]
783
784 for scm in scms:
785 rev = scm(d)
786 if rev <> "<unknown>":
787 return rev.strip()
788
789 return "<unknown>"
790
791
792
793METADATA_BRANCH ?= "${@base_detect_branch(d)}"
794METADATA_REVISION ?= "${@base_detect_revision(d)}"
795
796GIT_CONFIG = "${STAGING_DIR_NATIVE}/usr/etc/gitconfig" 800GIT_CONFIG = "${STAGING_DIR_NATIVE}/usr/etc/gitconfig"
797 801
798def generate_git_config(e): 802def generate_git_config(e):