1def base_detect_revision(d): 2 path = base_get_scmbasepath(d) 3 return base_get_metadata_git_revision(path, d) 4 5def base_detect_branch(d): 6 path = base_get_scmbasepath(d) 7 return base_get_metadata_git_branch(path, d) 8 9def base_get_scmbasepath(d): 10 return os.path.join(d.getVar('COREBASE'), 'meta') 11 12def base_get_metadata_svn_revision(path, d): 13 # This only works with older subversion. For newer versions 14 # this function will need to be fixed by someone interested 15 revision = "<unknown>" 16 try: 17 with open("%s/.svn/entries" % path) as f: 18 revision = f.readlines()[3].strip() 19 except (IOError, IndexError): 20 pass 21 return revision 22 23def base_get_metadata_git_branch(path, d): 24 import bb.process 25 26 try: 27 rev, _ = bb.process.run('git rev-parse --abbrev-ref HEAD', cwd=path) 28 except bb.process.ExecutionError: 29 rev = '<unknown>' 30 return rev.strip() 31 32def base_get_metadata_git_revision(path, d): 33 import bb.process 34 35 try: 36 rev, _ = bb.process.run('git rev-parse HEAD', cwd=path) 37 except bb.process.ExecutionError: 38 rev = '<unknown>' 39 return rev.strip() 40 41METADATA_BRANCH := "${@base_detect_branch(d)}" 42METADATA_BRANCH[vardepvalue] = "${METADATA_BRANCH}" 43METADATA_REVISION := "${@base_detect_revision(d)}" 44METADATA_REVISION[vardepvalue] = "${METADATA_REVISION}" 45