diff options
Diffstat (limited to 'meta/classes')
| -rw-r--r-- | meta/classes/base.bbclass | 72 |
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 | ||
| 723 | METADATA_BRANCH ?= "${@base_detect_branch(d)}" | ||
| 724 | METADATA_REVISION ?= "${@base_detect_revision(d)}" | ||
| 725 | |||
| 726 | def 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 | |||
| 739 | def 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 | |||
| 723 | def base_get_scmbasepath(d): | 753 | def 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 | ||
| 727 | def base_get_metadata_monotone_branch(d): | 757 | def 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 | ||
| 738 | def base_get_metadata_monotone_revision(d): | 768 | def 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 | ||
| 749 | def base_get_metadata_svn_revision(d): | 779 | def 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 | ||
| 757 | def base_get_metadata_git_branch(d): | 787 | def 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 | ||
| 770 | def 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 | |||
| 781 | def 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 | |||
| 793 | METADATA_BRANCH ?= "${@base_detect_branch(d)}" | ||
| 794 | METADATA_REVISION ?= "${@base_detect_revision(d)}" | ||
| 795 | |||
| 796 | GIT_CONFIG = "${STAGING_DIR_NATIVE}/usr/etc/gitconfig" | 800 | GIT_CONFIG = "${STAGING_DIR_NATIVE}/usr/etc/gitconfig" |
| 797 | 801 | ||
| 798 | def generate_git_config(e): | 802 | def generate_git_config(e): |
