merge of '3b04f9d33d900f95c8814c78ad7693a4bd404ded'
[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 OPIE_CVS_PV ?= "1.2.2+cvs${SRCDATE}"
19
20 DEPENDS_prepend = "${@["libopie2 ", ""][(bb.data.getVar('PN', d, 1) == 'libopie2')]}"
21
22 # to be consistent, put all targets into workdir
23 # NOTE: leave one space at the end, other files are expecting that
24 EXTRA_QMAKEVARS_POST += " DESTDIR=${S} "
25 EXTRA_QMAKEVARS_POST += " DEFINES+=OPIE_BINDIR='\"${bindir}\"' DEFINES+=OPIE_LIBDIR='\"${libdir}/opie/lib\"' DEFINES+=OPIE_QTDIR='\"${libdir}/opie\"' "
26
27 # Opie standard TAG value
28 TAG = "${@'v' + bb.data.getVar('PV',d,1).replace('.', '_')}"
29
30 # plan for later:
31 # add common scopes for opie applications, see qmake-native/common.pro
32 # qmake should care about all the details then. qmake can do that, i know it :)
33 #
34
35 python opie_do_opie_install() {
36         import os, shutil
37         section = bb.data.getVar( "SECTION", d ).split( '/' )[1] or "Applications"
38         section = section.title()
39         if section in ( "Base", "Libs" ):
40                 bb.note( "Section = Base or Libs. Target won't be installed automatically." )
41                 return
42
43         #               SECTION         : BINDIR                        DESKTOPDIR
44         dirmap = {      "Applets"       : ( "/plugins/applets",         None                    ),
45                         "Applications"  : ( "<BINDIR>",                 "/apps/Applications"    ),
46                         "Multimedia"    : ( "<BINDIR>",                 "/apps/Applications"    ),
47                         "Games"         : ( "<BINDIR>",                 "/apps/Games"           ),
48                         "Settings"      : ( "<BINDIR>",                 "/apps/Settings"        ),
49                         "Pim"           : ( "<BINDIR>",                 "/apps/1Pim"            ),
50                         "Examples"      : ( "<BINDIR>",                 "/apps/Examples"        ),
51                         "Shell"         : ( "/bin",                     "/apps/Opie-SH"         ),
52                         "Codecs"        : ( "/plugins/codecs",          None                    ),
53                         "Decorations"   : ( "/plugins/decorations",     None                    ),
54                         "Inputmethods"  : ( "/plugins/inputmethods",    None                    ),
55                         "Fontfactories" : ( "/plugins/fontfactories",   None                    ),
56                         "Security"      : ( "/plugins/security",        None                    ),
57                         "Styles"        : ( "/plugins/styles",          None                    ),
58                         "Today"         : ( "/plugins/today",           None                    ),
59                         "Datebook"      : ( "/plugins/holidays",        None                    ),
60                 "Networksettings"       : ( "/plugins/networksettings", None                    ) }
61
62         if section not in dirmap:
63                 raise ValueError, "Unknown section '%s'. Valid sections are: %s" % ( section, dirmap.keys() )
64         
65         bindir, desktopdir = dirmap[section]
66         APPNAME = bb.data.getVar( "APPNAME", d, True ) or bb.data.getVar( "PN", d, True )
67         APPTYPE = bb.data.getVar( "APPTYPE", d, True )
68         if not APPTYPE:
69                 if bindir == "<BINDIR>":
70                         APPTYPE = "quicklaunch"
71                 else:
72                         APPTYPE = "plugin"
73
74         appmap = { "binary":"/bin", "quicklaunch":"/plugins/application" }
75         if bindir == "<BINDIR>": bindir = appmap[APPTYPE]
76         
77         bb.note( "Section='%s', bindir='%s', desktopdir='%s', name='%s', type='%s'" %
78                ( section, bindir, desktopdir, APPNAME, APPTYPE ) )
79
80         S = bb.data.getVar( "S", d, 1 )
81         D = "%s/image" % bb.data.getVar( "WORKDIR", d, True )
82         WORKDIR = bb.data.getVar( "WORKDIR", d, True )
83         palmtopdir = bb.data.getVar( "palmtopdir", d, True )
84         gnubindir = bb.data.getVar( "bindir", d, True )
85         APPDESKTOP = bb.data.getVar( "APPDESKTOP", d, True ) or "%s/%s" % ( WORKDIR, desktopdir )
86
87         if desktopdir is not None:
88                 os.system( "install -d %s%s%s/" % ( D, palmtopdir, desktopdir ) )
89                 os.system( "install -m 0644 %s/%s.desktop %s%s%s/" % ( APPDESKTOP, APPNAME, D, palmtopdir, desktopdir ) )
90
91         os.system( "install -d %s%s%s/" % ( D, palmtopdir, bindir ) )
92
93         if APPTYPE == "binary":
94                 os.system( "install -d %s%s/" % ( D, gnubindir ) )
95                 os.system( "install -m 0755 %s/%s %s%s/" % ( S, APPNAME, D, gnubindir ) )
96         elif APPTYPE == "quicklaunch":
97                 os.system( "install -m 0755 %s/lib%s.so %s%s%s/" % ( S, APPNAME, D, palmtopdir, bindir ) )
98                 os.system( "install -d %s%s/" % ( D, gnubindir ) )
99                 os.system( "ln -sf %s/quicklauncher %s%s/%s" % ( gnubindir, D, gnubindir, APPNAME ) )
100         elif APPTYPE == "plugin":
101                 os.system( "install -m 0755 %s/lib%s.so %s%s%s/" % ( S, APPNAME, D, palmtopdir, bindir ) )
102 }
103
104 EXPORT_FUNCTIONS do_opie_install
105 addtask opie_install after do_compile before do_package