diff options
author | Jacob Stiffler <j-stiffler@ti.com> | 2015-02-05 21:28:28 +0000 |
---|---|---|
committer | Denys Dmytriyenko <denys@ti.com> | 2015-02-20 12:27:30 -0500 |
commit | b06623fa2a2245f7914a120b99edf4152ec7aea5 (patch) | |
tree | dce61bd37309830792237b5f35f74670f04e06b8 /recipes-ti/includes/ti-unpack.inc | |
parent | 7f762b9fe5324b01864685a870b6eab7c34e5eb9 (diff) | |
download | meta-ti-b06623fa2a2245f7914a120b99edf4152ec7aea5.tar.gz |
ti-eula-unpack: Add support for general binary installers.
* ti-unpack.inc has been created to allow support for general binary
installers by creating a variable which is used to pass arbitrary
arguments to the executable.
* ti-eula-unpack.inc sets the default arguments to retain support for
recipes which still use this feature.
Signed-off-by: Jacob Stiffler <j-stiffler@ti.com>
Signed-off-by: Denys Dmytriyenko <denys@ti.com>
Diffstat (limited to 'recipes-ti/includes/ti-unpack.inc')
-rw-r--r-- | recipes-ti/includes/ti-unpack.inc | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/recipes-ti/includes/ti-unpack.inc b/recipes-ti/includes/ti-unpack.inc new file mode 100644 index 00000000..c19c78ca --- /dev/null +++ b/recipes-ti/includes/ti-unpack.inc | |||
@@ -0,0 +1,83 @@ | |||
1 | # This file defines function used for unpacking the .bin file downloaded over | ||
2 | # the http. | ||
3 | # BINFILE - name of the install jammer .bin file | ||
4 | # TARFILE - name of the tar file inside the install jammer | ||
5 | # TI_BIN_UNPK_ARGS - contains the arguments to be passed to the bin file. | ||
6 | # TI_BIN_UNPK_CMDS - contains list of commands separated with colon to be | ||
7 | # passed while unpacking the bin file. The keyword | ||
8 | # workdir expands to WORKDIR and commands are appendded | ||
9 | # with '\n'. Eg. TI_BIN_UNPK_CMDS="Y:Y: qY:workdir" | ||
10 | # TI_BIN_UNPK_WDEXT - This variable extends workdir path, if user wants to put | ||
11 | # the output in some internal directory | ||
12 | |||
13 | python do_unpack () { | ||
14 | bb.build.exec_func('base_do_unpack', d) | ||
15 | bb.build.exec_func('ti_bin_do_unpack', d) | ||
16 | } | ||
17 | |||
18 | TI_BIN_UNPK_WDEXT ?= "" | ||
19 | python ti_bin_do_unpack() { | ||
20 | |||
21 | import os | ||
22 | |||
23 | # InstallJammer requires 32bit version of glibc | ||
24 | lib32path = '/lib' | ||
25 | if os.path.exists('/lib64') and (os.path.islink('/lib64') or os.path.islink('/lib') or os.path.exists('/lib32')): | ||
26 | lib32path = '/lib32' | ||
27 | if not os.path.exists('%s/libc.so.6' % lib32path): | ||
28 | bb.warn("TI installer requires 32bit glibc libraries for proper operation\nrun 'yum install glibc.i686' on Fedora or 'apt-get install ia32-libs' on Ubuntu/Debian") | ||
29 | |||
30 | localdata = bb.data.createCopy(d) | ||
31 | bb.data.update_data(localdata) | ||
32 | |||
33 | binfile = bb.data.getVar('BINFILE', localdata) | ||
34 | binfile = bb.data.expand(binfile, localdata) | ||
35 | |||
36 | # Change to the working directory | ||
37 | save_cwd = os.getcwd() | ||
38 | workdir = bb.data.getVar('WORKDIR', localdata) | ||
39 | workdir = bb.data.expand(workdir, localdata) | ||
40 | os.chdir(workdir) | ||
41 | |||
42 | # Get unpack args | ||
43 | arg_string = bb.data.getVar('TI_BIN_UNPK_ARGS', localdata) | ||
44 | arg_string = bb.data.expand(arg_string, localdata) | ||
45 | |||
46 | # Get unpack commands | ||
47 | cmd_string = bb.data.getVar('TI_BIN_UNPK_CMDS', localdata) | ||
48 | cmd_list = cmd_string.split( ":" ) | ||
49 | |||
50 | # Make the InstallJammer binary executable so we can run it | ||
51 | os.chmod(binfile, 0755) | ||
52 | |||
53 | # Run the InstallJammer binary and accept the EULA | ||
54 | filename = "HOME=%s ./%s %s" % (workdir, binfile, arg_string) | ||
55 | |||
56 | # Test executable by printing installer version or help screen (--version currently broken for some installers) | ||
57 | # - this is currently broken in some IJ installers - comment out for now | ||
58 | #if os.system(filename + " --version") != 0: | ||
59 | # print "ERROR: ti-eula-unpack: failed to execute binary installer" | ||
60 | # raise bb.build.FuncFailed() | ||
61 | |||
62 | f = os.popen(filename,'w') | ||
63 | for cmd in cmd_list: | ||
64 | if cmd == "workdir": | ||
65 | wdext = bb.data.getVar('TI_BIN_UNPK_WDEXT', localdata) | ||
66 | wdext = bb.data.expand(wdext, localdata) | ||
67 | cmd = workdir+wdext | ||
68 | f.write(cmd+'\n'); | ||
69 | f.close() | ||
70 | |||
71 | # Expand the tarball that was created if required | ||
72 | tarfile = bb.data.getVar('TARFILE', localdata) | ||
73 | if bool(tarfile) == True: | ||
74 | tarfile = bb.data.expand(tarfile, localdata) | ||
75 | tcmd = 'tar x --no-same-owner -f %s -C %s' % (tarfile, workdir) | ||
76 | if os.system(tcmd) != 0: | ||
77 | print "ERROR: ti-eula-unpack: failed to extract tarfile" | ||
78 | raise bb.build.FuncFailed() | ||
79 | |||
80 | # Return to the previous directory | ||
81 | os.chdir(save_cwd) | ||
82 | } | ||
83 | |||