Buildcache: Need to check the binary is not a Mach-o binary in a linux package or an ELF binary in a macOS package. (#18670)

* Need to check the binary is not a Mach-o binary in a linux package or an ELF binary in a macOS package.

* use sys.platform

* Darwin -> darwin for sys.platform
This commit is contained in:
Patrick Gartung 2020-10-01 12:39:59 -05:00 committed by GitHub
parent e0c7f5ae3d
commit a380ceb139
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,6 +6,7 @@
import codecs
import os
import re
import sys
import tarfile
import shutil
import tempfile
@ -460,7 +461,11 @@ def write_buildinfo_file(spec, workdir, rel=False):
tty.warn(msg)
if relocate.needs_binary_relocation(m_type, m_subtype):
if not filename.endswith('.o'):
if ((m_subtype in ('x-executable', 'x-sharedlib')
and sys.platform != 'darwin') or
(m_subtype in ('x-mach-binary')
and sys.platform == 'darwin') or
(not filename.endswith('.o'))):
rel_path_name = os.path.relpath(path_name, prefix)
binary_to_relocate.append(rel_path_name)
if relocate.needs_text_relocation(m_type, m_subtype):