Merge bk://oe-devel.bkbits.net/openembedded
[vuplus_openembedded] / classes / opie.bbclass
1 #
2 # This oeclass takes care about some of the itchy details of installing parts
3 # of Opie applications. Depending on quicklaunch or not, plugin or not, the
4 # TARGET is either a shared object, a shared object with a link to quicklauncher,
5 # or a usual binary.
6
7 # You have to provide two things: 1.) A proper SECTION field, and 2.) a proper APPNAME
8 # Then opie.oeclass will:
9 #    * create the directory for the binary and install the binary file(s)
10 #    * for applications: create the directory for the .desktop and install the .desktop file
11 #    * for quicklauncher applications: create the startup symlink to the quicklauncher
12 # You can override the automatic detection of APPTYPE, valid values are 'quicklaunch', 'binary', 'plugin'
13 # You can override the default location of APPDESKTOP (<workdir>/apps/<section>/)
14 #
15
16 inherit palmtop
17
18 DEPENDS_prepend = "${@["libopie2 ", ""][(bb.data.getVar('PN', d, 1) == 'libopie2')]}"
19
20 # to be consistent, put all targets into workdir
21 EXTRA_QMAKEVARS_POST_append = " DESTDIR=${S}"
22
23 # plan for later:
24 # add common scopes for opie applications, see qmake-native/common.pro
25 # qmake should care about all the details then. qmake can do that, i know it :)
26 #
27
28 python opie_do_opie_install() {
29         import os, shutil
30         section = bb.data.getVar( "SECTION", d ).split( '/' )[1] or "Applications"
31         section = section.title()
32         if section in ( "Base", "Libs" ):
33                 bb.note( "Section = Base or Libs. Target won't be installed automatically." )
34                 return
35
36         #               SECTION         : BINDIR                        DESKTOPDIR
37         dirmap = {      "Applets"       : ( "/plugins/applets",         None                    ),
38                         "Applications"  : ( "<BINDIR>",                 "/apps/Applications"    ),
39                         "Multimedia"    : ( "<BINDIR>",                 "/apps/Applications"    ),
40                         "Games"         : ( "<BINDIR>",                 "/apps/Games"           ),
41                         "Settings"      : ( "<BINDIR>",                 "/apps/Settings"        ),
42                         "Pim"           : ( "<BINDIR>",                 "/apps/1Pim"            ),
43                         "Examples"      : ( "<BINDIR>",                 "/apps/Examples"        ),
44                         "Shell"         : ( "/bin",                     "/apps/Opie-SH"         ),
45                         "Codecs"        : ( "/plugins/codecs",          None                    ),
46                         "Decorations"   : ( "/plugins/decorations",     None                    ),
47                         "Inputmethods"  : ( "/plugins/inputmethods",    None                    ),
48                         "Fontfactories" : ( "/plugins/fontfactories",   None                    ),
49                         "Security"      : ( "/plugins/security",        None                    ),
50                         "Styles"        : ( "/plugins/styles",          None                    ),
51                         "Today"         : ( "/plugins/today",           None                    ),
52                 "Networksettings"       : ( "/plugins/networksettings", None                    ) }
53
54         if section not in dirmap:
55                 raise ValueError, "Unknown section '%s'. Valid sections are: %s" % ( section, dirmap.keys() )
56         
57         bindir, desktopdir = dirmap[section]
58         APPNAME = bb.data.getVar( "APPNAME", d, True ) or bb.data.getVar( "PN", d, True )
59         APPTYPE = bb.data.getVar( "APPTYPE", d, True )
60         if not APPTYPE:
61                 if bindir == "<BINDIR>":
62                         APPTYPE = "quicklaunch"
63                 else:
64                         APPTYPE = "plugin"
65
66         appmap = { "binary":"/bin", "quicklaunch":"/plugins/application" }
67         if bindir == "<BINDIR>": bindir = appmap[APPTYPE]
68         
69         bb.note( "Section='%s', bindir='%s', desktopdir='%s', name='%s', type='%s'" %
70                ( section, bindir, desktopdir, APPNAME, APPTYPE ) )
71
72         S = bb.data.getVar( "S", d, 1 )
73         D = "%s/image" % bb.data.getVar( "WORKDIR", d, True )
74         WORKDIR = bb.data.getVar( "WORKDIR", d, True )
75         palmtopdir = bb.data.getVar( "palmtopdir", d )
76         APPDESKTOP = bb.data.getVar( "APPDESKTOP", d, True ) or "%s/%s" % ( WORKDIR, desktopdir )
77
78         if desktopdir is not None:
79                 os.system( "install -d %s%s%s/" % ( D, palmtopdir, desktopdir ) )
80                 os.system( "install -m 0644 %s/%s.desktop %s%s%s/" % ( APPDESKTOP, APPNAME, D, palmtopdir, desktopdir ) )
81
82         os.system( "install -d %s%s%s/" % ( D, palmtopdir, bindir ) )
83
84         if APPTYPE == "binary":
85                 os.system( "install -m 0755 %s/%s %s%s%s/" % ( S, APPNAME, D, palmtopdir, bindir ) )
86         elif APPTYPE == "quicklaunch":
87                 os.system( "install -m 0755 %s/lib%s.so %s%s%s/" % ( S, APPNAME, D, palmtopdir, bindir ) )
88                 os.system( "install -d %s%s/bin/" % ( D, palmtopdir ) )
89                 os.system( "ln -sf %s/bin/quicklauncher %s%s/bin/%s" % ( palmtopdir, D, palmtopdir, APPNAME ) )
90         elif APPTYPE == "plugin":
91                 os.system( "install -m 0755 %s/lib%s.so %s%s%s/" % ( S, APPNAME, D, palmtopdir, bindir ) )
92 }
93
94 EXPORT_FUNCTIONS do_opie_install
95 addtask opie_install after do_compile before do_populate_staging