summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorJason Wessel <jason.wessel@windriver.com>2013-02-12 05:08:23 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-02-12 13:01:59 +0000
commite1d42db8749b0b965ddc6cfba4f3b93ee96ed4f4 (patch)
tree484576ca3f6397c415904e33ef5aa728beb79cef /scripts
parent0e6dd19b9736d2a8ae7c0f0ab124337d579b8f06 (diff)
downloadopenembedded-core-e1d42db8749b0b965ddc6cfba4f3b93ee96ed4f4.tar.gz
openembedded-core-e1d42db8749b0b965ddc6cfba4f3b93ee96ed4f4.tar.bz2
openembedded-core-e1d42db8749b0b965ddc6cfba4f3b93ee96ed4f4.zip
relocate_sdk.py: allow relocate_sdk.py to work with python 2.4.x
Avoid the chicken / egg problem of an SDK that provides a working python but requires that version of python to extract itself. The RHEL 5.x systems and some other enterprise Linux systems ship with python 2.4.x as the default python. We need to at least be able to extract work executables even if we never use the the host provided python again. Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/relocate_sdk.py26
1 files changed, 13 insertions, 13 deletions
diff --git a/scripts/relocate_sdk.py b/scripts/relocate_sdk.py
index 45d2c241c3..1d7bbb3849 100755
--- a/scripts/relocate_sdk.py
+++ b/scripts/relocate_sdk.py
@@ -55,22 +55,22 @@ def parse_elf_header():
if arch == 32:
# 32bit
- hdr_struct = struct.Struct("<HHILLLIHHHHHH")
+ hdr_fmt = "<HHILLLIHHHHHH"
hdr_size = 52
else:
# 64bit
- hdr_struct = struct.Struct("<HHIQQQIHHHHHH")
+ hdr_fmt = "<HHIQQQIHHHHHH"
hdr_size = 64
e_type, e_machine, e_version, e_entry, e_phoff, e_shoff, e_flags,\
e_ehsize, e_phentsize, e_phnum, e_shentsize, e_shnum, e_shstrndx =\
- hdr_struct.unpack(elf_header[16:hdr_size])
+ struct.unpack(hdr_fmt, elf_header[16:hdr_size])
def change_interpreter(elf_file_name):
if arch == 32:
- ph_struct = struct.Struct("<IIIIIIII")
+ ph_fmt = "<IIIIIIII"
else:
- ph_struct = struct.Struct("<IIQQQQQQ")
+ ph_fmt = "<IIQQQQQQ"
""" look for PT_INTERP section """
for i in range(0,e_phnum):
@@ -79,11 +79,11 @@ def change_interpreter(elf_file_name):
if arch == 32:
# 32bit
p_type, p_offset, p_vaddr, p_paddr, p_filesz,\
- p_memsz, p_flags, p_align = ph_struct.unpack(ph_hdr)
+ p_memsz, p_flags, p_align = struct.unpack(ph_fmt, ph_hdr)
else:
# 64bit
p_type, p_flags, p_offset, p_vaddr, p_paddr, \
- p_filesz, p_memsz, p_align = ph_struct.unpack(ph_hdr)
+ p_filesz, p_memsz, p_align = struct.unpack(ph_fmt, ph_hdr)
""" change interpreter """
if p_type == 3:
@@ -104,9 +104,9 @@ def change_interpreter(elf_file_name):
def change_dl_sysdirs():
if arch == 32:
- sh_struct = struct.Struct("<IIIIIIIIII")
+ sh_fmt = "<IIIIIIIIII"
else:
- sh_struct = struct.Struct("<IIQQQQIIQQ")
+ sh_fmt = "<IIQQQQIIQQ"
""" read section string table """
f.seek(e_shoff + e_shstrndx * e_shentsize)
@@ -127,7 +127,7 @@ def change_dl_sysdirs():
sh_hdr = f.read(e_shentsize)
sh_name, sh_type, sh_flags, sh_addr, sh_offset, sh_size, sh_link,\
- sh_info, sh_addralign, sh_entsize = sh_struct.unpack(sh_hdr)
+ sh_info, sh_addralign, sh_entsize = struct.unpack(sh_fmt, sh_hdr)
name = sh_strtab[sh_name:sh_strtab.find("\0", sh_name)]
@@ -181,7 +181,7 @@ def change_dl_sysdirs():
# MAIN
if len(sys.argv) < 4:
- exit(-1)
+ sys.exit(-1)
new_prefix = sys.argv[1]
new_dl_path = sys.argv[2]
@@ -196,14 +196,14 @@ for e in executables_list:
try:
f = open(e, "r+b")
- except IOError as ioex:
+ except IOError, ioex:
if ioex.errno == errno.ETXTBSY:
print("Could not open %s. File used by another process.\nPlease "\
"make sure you exit all processes that might use any SDK "\
"binaries." % e)
else:
print("Could not open %s: %s(%d)" % (e, ioex.strerror, ioex.errno))
- exit(-1)
+ sys.exit(-1)
arch = get_arch()
if arch: