diff options
author | Richard Purdie <rpurdie@linux.intel.com> | 2009-01-02 11:09:04 +0000 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2009-01-02 11:09:04 +0000 |
commit | 3ab2ff7668229f8f103043aaaad9310d607510bb (patch) | |
tree | 55c61b7cd19c1657ac278baa4c1784a00d2091f3 | |
parent | 1d89595e2b99c645f7529cf9868e3aae7f4d70f1 (diff) | |
download | poky-3ab2ff7668229f8f103043aaaad9310d607510bb.tar.gz |
base.bbclass: Add metadata revision handling for git (from OE)
-rw-r--r-- | meta-moblin/conf/distro/moblin.conf | 5 | ||||
-rw-r--r-- | meta/classes/base.bbclass | 56 | ||||
-rw-r--r-- | meta/conf/distro/poky.conf | 4 |
3 files changed, 53 insertions, 12 deletions
diff --git a/meta-moblin/conf/distro/moblin.conf b/meta-moblin/conf/distro/moblin.conf index 41cb6dda16..d27aa96e0e 100644 --- a/meta-moblin/conf/distro/moblin.conf +++ b/meta-moblin/conf/distro/moblin.conf | |||
@@ -18,11 +18,6 @@ QA_LOGFILE = "${TMPDIR}/qa.log" | |||
18 | 18 | ||
19 | IMAGE_ROOTFS_SIZE_ext2 ?= "131072" | 19 | IMAGE_ROOTFS_SIZE_ext2 ?= "131072" |
20 | 20 | ||
21 | # Metadata is git based | ||
22 | #METADATA_REVISION = "${@base_get_metadata_git_revision(d)}" | ||
23 | #FIXME | ||
24 | METADATA_REVISION = "unknown" | ||
25 | |||
26 | #IPK_FEED_URIS += " \ | 21 | #IPK_FEED_URIS += " \ |
27 | # upgrades##http://openzaurus.org/official/unstable/${DISTRO_VERSION}/upgrades/ \ | 22 | # upgrades##http://openzaurus.org/official/unstable/${DISTRO_VERSION}/upgrades/ \ |
28 | #upgrades-${MACHINE}##http://openzaurus.org/official/unstable/${DISTRO_VERSION}/upgrades/${MACHINE} \ | 23 | #upgrades-${MACHINE}##http://openzaurus.org/official/unstable/${DISTRO_VERSION}/upgrades/${MACHINE} \ |
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 | ||
717 | def 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 | |||
717 | def base_get_metadata_monotone_revision(d): | 728 | def 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 | ||
747 | def 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 | |||
755 | def 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 | |||
762 | def 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 | |||
773 | def 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 | |||
785 | METADATA_BRANCH ?= "${@base_detect_branch(d)}" | ||
786 | METADATA_REVISION ?= "${@base_detect_revision(d)}" | ||
787 | |||
736 | GIT_CONFIG = "${STAGING_DIR_NATIVE}/usr/etc/gitconfig" | 788 | GIT_CONFIG = "${STAGING_DIR_NATIVE}/usr/etc/gitconfig" |
737 | 789 | ||
738 | def generate_git_config(e): | 790 | def 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 | ||
759 | METADATA_REVISION ?= "${@base_get_metadata_monotone_revision(d)}" | ||
760 | |||
761 | addhandler base_eventhandler | 811 | addhandler base_eventhandler |
762 | python base_eventhandler() { | 812 | python 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 |
diff --git a/meta/conf/distro/poky.conf b/meta/conf/distro/poky.conf index e7178f9a9a..774f101dab 100644 --- a/meta/conf/distro/poky.conf +++ b/meta/conf/distro/poky.conf | |||
@@ -23,10 +23,6 @@ QA_LOGFILE = "${TMPDIR}/qa.log" | |||
23 | 23 | ||
24 | IMAGE_ROOTFS_SIZE_ext2 ?= "131072" | 24 | IMAGE_ROOTFS_SIZE_ext2 ?= "131072" |
25 | 25 | ||
26 | # Poky is git based | ||
27 | # METADATA_REVISION = "${@base_get_metadata_svn_revision(d)}" | ||
28 | METADATA_REVISION = "none" | ||
29 | |||
30 | #IPK_FEED_URIS += " \ | 26 | #IPK_FEED_URIS += " \ |
31 | # upgrades##http://openzaurus.org/official/unstable/${DISTRO_VERSION}/upgrades/ \ | 27 | # upgrades##http://openzaurus.org/official/unstable/${DISTRO_VERSION}/upgrades/ \ |
32 | #upgrades-${MACHINE}##http://openzaurus.org/official/unstable/${DISTRO_VERSION}/upgrades/${MACHINE} \ | 28 | #upgrades-${MACHINE}##http://openzaurus.org/official/unstable/${DISTRO_VERSION}/upgrades/${MACHINE} \ |