Merge branch 'org.openembedded.dev' of ssh+git://git@git.openembedded.net/openembedde...
[openembedded.git] / classes / nylon-helpers.bbclass
1 # ############################################################################
2 # Helper functions for building packages from the trunk or branches. To use
3 # this .bbclass simply inherit from it in your conf/local.conf.
4 #
5 # - get_branch() helps to construct the package name when fetching by 
6 #   extracting the directory name above the "build" directory containing the
7 #   oe environment and bitbake. That directory name is usually the branch in
8 #   which the package is located in the svn with one exception: "unstable"
9 #   is synonymous for "trunk". In the package you can then use the ${BRANCH}
10 #   variable within the svn (or cvs) url for the package.
11 #
12 # - get_tomorrow() makes sure the latest version of a package is fetched. To
13 #   use it, set the SRCDATE to ${TOMORROW}.
14 # ############################################################################
15
16 def get_branch():
17         import commands, re
18         build = re.sub(r'/sources$', '', commands.getoutput('pwd'))
19         build = re.sub(r'/tmp/work.*$', '', build)
20         build = re.sub(r'/packages\.4g.*$', '', build)
21         if re.search(r'/trunk/[^/]+/?$', build):
22                 return 'trunk'
23         if re.search(r'/unstable$', build):
24                 return 'trunk'
25         if re.search(r'/testing$', build):
26                 return 'testing'
27         return re.sub(r'^.*/([^/]+/[^/]+)/[^/]+/?$', r'\1', build)
28
29 # end of get_branch
30
31 def get_tomorrow():
32         import time
33         return time.strftime('%Y%m%d', time.gmtime(time.time() + 3600*24))
34
35 # end of get_tomorrow