7c6e7b70cf0190e23ccb51a32e4eaf96a48712d1
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 localdata = bb.data.createCopy(d)
23 bb.data.update_data(localdata)
25 binfile = bb.data.getVar('BINFILE', localdata)
26 binfile = bb.data.expand(binfile, localdata)
28 # Change to the working directory
29 save_cwd = os.getcwd()
30 workdir = bb.data.getVar('WORKDIR', localdata)
31 workdir = bb.data.expand(workdir, localdata)
32 os.chdir(workdir)
34 # Get unpack commands
35 cmd_string = bb.data.getVar('TI_BIN_UNPK_CMDS', localdata)
36 cmd_list = cmd_string.split( ":" )
38 # Make the InstallJammer binary executable so we can run it
39 os.chmod(binfile, 0755)
41 # Run the InstallJammer binary and accept the EULA
42 filename = "HOME=%s ./%s --mode console" % (workdir, binfile)
44 # Test executable by printing installer version or help screen (--version currently broken for some installers)
45 # - this is currently broken in some IJ installers - comment out for now
46 #if os.system(filename + " --version") != 0:
47 # print "ERROR: ti-eula-unpack: failed to execute binary installer"
48 # raise bb.build.FuncFailed()
50 f = os.popen(filename,'w')
51 for cmd in cmd_list:
52 if cmd == "workdir":
53 wdext = bb.data.getVar('TI_BIN_UNPK_WDEXT', localdata)
54 wdext = bb.data.expand(wdext, localdata)
55 cmd = workdir+wdext
56 print >>f, cmd
57 f.close()
59 # Expand the tarball that was created if required
60 tarfile = bb.data.getVar('TARFILE', localdata)
61 if bool(tarfile) == True:
62 tarfile = bb.data.expand(tarfile, localdata)
63 tcmd = 'tar x --no-same-owner -f %s -C %s' % (tarfile, workdir)
64 if os.system(tcmd) != 0:
65 print "ERROR: ti-eula-unpack: failed to extract tarfile"
66 raise bb.build.FuncFailed()
68 # Return to the previous directory
69 os.chdir(save_cwd)
70 }