1# Common code for recipes that create IPMI provider libraries
2
3inherit obmc-phosphor-utils
4
5# This LIBDIR is searched for the libraries.
6LIBDIR = "${D}/${libdir}/ipmid-providers/"
7
8# The symlinks are installed in the following directories depending on the
9# variable.
10HOSTIPMI_LIBDIR = "${D}/${libdir}/host-ipmid/"
11NETIPMI_LIBDIR = "${D}/${libdir}/net-ipmid/"
12BLOBIPMI_LIBDIR = "${D}/${libdir}/blob-ipmid/"
13
14python symlink_create_postinstall() {
15    def install_symlink(d, libname, install_dir):
16        import glob;
17
18        if not os.path.exists(install_dir):
19            os.makedirs(install_dir)
20
21        lib_dir = d.getVar('LIBDIR', True)
22
23        # find the library extension libxxx.so.?
24        install_file = lib_dir + libname + ".?"
25
26        filelist = glob.glob(install_file);
27
28        # get the library name
29        path, file = os.path.split(filelist[0])
30        source = "../ipmid-providers/" + file
31
32        # create the symlink
33        os.symlink(source, os.path.join(install_dir, file))
34
35    for libname in listvar_to_list(d, 'HOSTIPMI_PROVIDER_LIBRARY'):
36        install_dir = d.getVar('HOSTIPMI_LIBDIR', True)
37        install_symlink(d, libname, install_dir)
38
39    for libname in listvar_to_list(d, 'NETIPMI_PROVIDER_LIBRARY'):
40        install_dir = d.getVar('NETIPMI_LIBDIR', True)
41        install_symlink(d, libname, install_dir)
42
43    for libname in listvar_to_list(d, 'BLOBIPMI_PROVIDER_LIBRARY'):
44        install_dir = d.getVar('BLOBIPMI_LIBDIR', True)
45        install_symlink(d, libname, install_dir)
46}
47do_install[postfuncs] += "symlink_create_postinstall"
48