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') ):
25 lib32path = '/lib32'
26 if not os.path.exists('%s/libc.so.6' % lib32path):
27 raise bb.build.FuncFailed, \
28 "\nTI installer requires 32bit glibc libraries for proper operation\n\trun 'yum install glibc.i686' on Fedora or 'apt-get install ia32-libs' on Ubuntu/Debian"
30 localdata = bb.data.createCopy(d)
31 bb.data.update_data(localdata)
33 binfile = bb.data.getVar('BINFILE', localdata)
34 binfile = bb.data.expand(binfile, localdata)
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)
42 # Get unpack commands
43 cmd_string = bb.data.getVar('TI_BIN_UNPK_CMDS', localdata)
44 cmd_list = cmd_string.split( ":" )
46 # Make the InstallJammer binary executable so we can run it
47 os.chmod(binfile, 0755)
49 # Run the InstallJammer binary and accept the EULA
50 filename = "HOME=%s ./%s --mode console" % (workdir, binfile)
52 # Test executable by printing installer version or help screen (--version currently broken for some installers)
53 # - this is currently broken in some IJ installers - comment out for now
54 #if os.system(filename + " --version") != 0:
55 # print "ERROR: ti-eula-unpack: failed to execute binary installer"
56 # raise bb.build.FuncFailed()
58 f = os.popen(filename,'w')
59 for cmd in cmd_list:
60 if cmd == "workdir":
61 wdext = bb.data.getVar('TI_BIN_UNPK_WDEXT', localdata)
62 wdext = bb.data.expand(wdext, localdata)
63 cmd = workdir+wdext
64 print >>f, cmd
65 f.close()
67 # Expand the tarball that was created if required
68 tarfile = bb.data.getVar('TARFILE', localdata)
69 if bool(tarfile) == True:
70 tarfile = bb.data.expand(tarfile, localdata)
71 tcmd = 'tar x --no-same-owner -f %s -C %s' % (tarfile, workdir)
72 if os.system(tcmd) != 0:
73 print "ERROR: ti-eula-unpack: failed to extract tarfile"
74 raise bb.build.FuncFailed()
76 # Return to the previous directory
77 os.chdir(save_cwd)
78 }