1 # This file defines function used for unpacking the .bin file downloaded over
2 # the http and display EULA.
3 # BINFILE - name of the install jammer .bin file
4 # TARFILE - name of the tar file inside the install jammer
5 # TI_BIN_UNPK_CMDS - contains list of commands separated with colon to be
6 # passed while unpacking the bin file. The keyword
7 # workdir expands to WORKDIR and commands are appendded
8 # with '\n'. Eg. TI_BIN_UNPK_CMDS="Y:Y: qY:workdir"
9 # TI_BIN_UNPK_WDEXT - This variable extends workdir path, if user wants to put
10 # the output in some internal directory
12 python do_unpack () {
13 bb.build.exec_func('base_do_unpack', d)
14 bb.build.exec_func('ti_bin_do_unpack', d)
15 }
17 TI_BIN_UNPK_WDEXT += ""
18 python ti_bin_do_unpack() {
20 import os
22 # InstallJammer requires 32bit version of glibc
23 lib32path = '/lib'
24 if os.path.exists('/lib64') and (os.path.islink('/lib64') or os.path.islink('/lib') or os.path.exists('/lib32')):
25 lib32path = '/lib32'
26 if not os.path.exists('%s/libc.so.6' % lib32path):
27 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 localdata = bb.data.createCopy(d)
30 bb.data.update_data(localdata)
32 binfile = bb.data.getVar('BINFILE', localdata)
33 binfile = bb.data.expand(binfile, localdata)
35 # Change to the working directory
36 save_cwd = os.getcwd()
37 workdir = bb.data.getVar('WORKDIR', localdata)
38 workdir = bb.data.expand(workdir, localdata)
39 os.chdir(workdir)
41 # Get unpack commands
42 cmd_string = bb.data.getVar('TI_BIN_UNPK_CMDS', localdata)
43 cmd_list = cmd_string.split( ":" )
45 # Make the InstallJammer binary executable so we can run it
46 os.chmod(binfile, 0755)
48 # Run the InstallJammer binary and accept the EULA
49 filename = "HOME=%s ./%s --mode console" % (workdir, binfile)
51 # Test executable by printing installer version or help screen (--version currently broken for some installers)
52 # - this is currently broken in some IJ installers - comment out for now
53 #if os.system(filename + " --version") != 0:
54 # print "ERROR: ti-eula-unpack: failed to execute binary installer"
55 # raise bb.build.FuncFailed()
57 f = os.popen(filename,'w')
58 for cmd in cmd_list:
59 if cmd == "workdir":
60 wdext = bb.data.getVar('TI_BIN_UNPK_WDEXT', localdata)
61 wdext = bb.data.expand(wdext, localdata)
62 cmd = workdir+wdext
63 print >>f, cmd
64 f.close()
66 # Expand the tarball that was created if required
67 tarfile = bb.data.getVar('TARFILE', localdata)
68 if bool(tarfile) == True:
69 tarfile = bb.data.expand(tarfile, localdata)
70 tcmd = 'tar x --no-same-owner -f %s -C %s' % (tarfile, workdir)
71 if os.system(tcmd) != 0:
72 print "ERROR: ti-eula-unpack: failed to extract tarfile"
73 raise bb.build.FuncFailed()
75 # Return to the previous directory
76 os.chdir(save_cwd)
77 }