mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-22 14:11:07 +02:00
build_library: support multi-arch in generate_au_zip
To be able to support arm64 native SDK without cross builds, we should make generate_au_zip support both architectures, amd64 and arm64. Without doing that, `build_image` fails with `ERROR : Required WHITE_LIST items ld-linux-x86-64.so.2 not found!!!`, because the script recognizes only amd64 libs in WHITE_LIST. We should first determine the architecture in build_image, before running generate_au_zip, and pass the architecture, either amd64 or arm64. Also add allow_list and ld_linux parameters to necessary functions.
This commit is contained in:
parent
a7f251da44
commit
34cb6d305a
@ -83,7 +83,7 @@ zip_update_tools() {
|
|||||||
# Make sure some vars this script needs are exported
|
# Make sure some vars this script needs are exported
|
||||||
export REPO_MANIFESTS_DIR SCRIPTS_DIR
|
export REPO_MANIFESTS_DIR SCRIPTS_DIR
|
||||||
"${BUILD_LIBRARY_DIR}/generate_au_zip.py" \
|
"${BUILD_LIBRARY_DIR}/generate_au_zip.py" \
|
||||||
--output-dir "${BUILD_DIR}" --zip-name "${update_zip}"
|
--arch "$(get_sdk_arch)" --output-dir "${BUILD_DIR}" --zip-name "${update_zip}"
|
||||||
|
|
||||||
upload_image "${BUILD_DIR}/${update_zip}"
|
upload_image "${BUILD_DIR}/${update_zip}"
|
||||||
}
|
}
|
||||||
|
@ -32,6 +32,9 @@ DYNAMIC_EXECUTABLES = ['/usr/bin/delta_generator',
|
|||||||
'/usr/bin/bsdiff',
|
'/usr/bin/bsdiff',
|
||||||
'/usr/bin/bspatch']
|
'/usr/bin/bspatch']
|
||||||
|
|
||||||
|
LD_LINUX_AMD64 = 'ld-linux-x86-64.so.2'
|
||||||
|
LD_LINUX_ARM64 = 'ld-linux-aarch64.so.1'
|
||||||
|
|
||||||
# These files will be ignored when present in the dependancy list.
|
# These files will be ignored when present in the dependancy list.
|
||||||
DENY_LIST = [
|
DENY_LIST = [
|
||||||
# This library does not exist on disk, but is inserted into the
|
# This library does not exist on disk, but is inserted into the
|
||||||
@ -40,9 +43,14 @@ DENY_LIST = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
# These files MUST be present in the dependancy list.
|
# These files MUST be present in the dependancy list.
|
||||||
ALLOW_LIST = [
|
# Update WrapExecutableFiles if this file changes names.
|
||||||
# Update WrapExecutableFiles if this file changes names
|
# Each architecture requires different allow list libs.
|
||||||
'ld-linux-x86-64.so.2',
|
ALLOW_LIST_AMD64 = [
|
||||||
|
LD_LINUX_AMD64,
|
||||||
|
]
|
||||||
|
|
||||||
|
ALLOW_LIST_ARM64 = [
|
||||||
|
LD_LINUX_ARM64,
|
||||||
]
|
]
|
||||||
|
|
||||||
LIB_DIR = 'lib.so'
|
LIB_DIR = 'lib.so'
|
||||||
@ -93,7 +101,7 @@ def _SplitAndStrip(data):
|
|||||||
return return_list
|
return return_list
|
||||||
|
|
||||||
|
|
||||||
def DepsToCopy(ldd_files):
|
def DepsToCopy(ldd_files, allow_list):
|
||||||
"""Returns a list of deps for a given dynamic executables list.
|
"""Returns a list of deps for a given dynamic executables list.
|
||||||
Args:
|
Args:
|
||||||
ldd_files: List of dynamic files that needs to have the deps evaluated
|
ldd_files: List of dynamic files that needs to have the deps evaluated
|
||||||
@ -130,11 +138,11 @@ def DepsToCopy(ldd_files):
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
result = _ExcludeDenylist(list(libs), DENY_LIST)
|
result = _ExcludeDenylist(list(libs), DENY_LIST)
|
||||||
_EnforceAllowList(list(libs), ALLOW_LIST)
|
_EnforceAllowList(list(libs), allow_list=allow_list)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
def CopyRequiredFiles(dest_files_root):
|
def CopyRequiredFiles(dest_files_root, allow_list):
|
||||||
"""Generates a list of files that are required for au-generator zip file
|
"""Generates a list of files that are required for au-generator zip file
|
||||||
Args:
|
Args:
|
||||||
dest_files_root: location of the directory where we should copy the files
|
dest_files_root: location of the directory where we should copy the files
|
||||||
@ -161,7 +169,7 @@ def CopyRequiredFiles(dest_files_root):
|
|||||||
logging.exception("Copying '%s' to %s failed", file_name, dest_files_root)
|
logging.exception("Copying '%s' to %s failed", file_name, dest_files_root)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
libraries = DepsToCopy(ldd_files=DYNAMIC_EXECUTABLES)
|
libraries = DepsToCopy(ldd_files=DYNAMIC_EXECUTABLES, allow_list=allow_list)
|
||||||
lib_dir = os.path.join(dest_files_root, LIB_DIR)
|
lib_dir = os.path.join(dest_files_root, LIB_DIR)
|
||||||
os.mkdir(lib_dir)
|
os.mkdir(lib_dir)
|
||||||
for file_name in libraries:
|
for file_name in libraries:
|
||||||
@ -188,7 +196,7 @@ def CopyRequiredFiles(dest_files_root):
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
def WrapExecutableFiles(dest_files_root):
|
def WrapExecutableFiles(dest_files_root, ld_linux):
|
||||||
"""Our dynamically linked executalbes have to be invoked use the library
|
"""Our dynamically linked executalbes have to be invoked use the library
|
||||||
versions they were linked with inside the chroot (from libc on), as well
|
versions they were linked with inside the chroot (from libc on), as well
|
||||||
as the dynamic linker they were built with inside the chroot.
|
as the dynamic linker they were built with inside the chroot.
|
||||||
@ -209,10 +217,10 @@ def WrapExecutableFiles(dest_files_root):
|
|||||||
script.write('# Auto-generated wrapper script\n')
|
script.write('# Auto-generated wrapper script\n')
|
||||||
script.write('thisdir="$(dirname "$0")"\n')
|
script.write('thisdir="$(dirname "$0")"\n')
|
||||||
script.write('LD_LIBRARY_PATH=\n')
|
script.write('LD_LIBRARY_PATH=\n')
|
||||||
script.write('exec "$thisdir/%s/ld-linux-x86-64.so.2"'
|
script.write('exec "$thisdir/%s/%s"'
|
||||||
' --library-path "$thisdir/%s"'
|
' --library-path "$thisdir/%s"'
|
||||||
' "$thisdir/%s.bin" "$@"\n' %
|
' "$thisdir/%s.bin" "$@"\n' %
|
||||||
(LIB_DIR, LIB_DIR, base_exec))
|
(LIB_DIR, ld_linux, LIB_DIR, base_exec))
|
||||||
|
|
||||||
|
|
||||||
def CleanUp(temp_dir):
|
def CleanUp(temp_dir):
|
||||||
@ -335,6 +343,8 @@ def main():
|
|||||||
default='au-generator.zip', help='Name of the zip file')
|
default='au-generator.zip', help='Name of the zip file')
|
||||||
parser.add_option('-k', '--keep-temp', dest='keep_temp', default=False,
|
parser.add_option('-k', '--keep-temp', dest='keep_temp', default=False,
|
||||||
action='store_true', help='Keep the temp files...',)
|
action='store_true', help='Keep the temp files...',)
|
||||||
|
parser.add_option('-a', '--arch', dest='arch',
|
||||||
|
default='amd64', help='Arch amd64/arm64. Default: amd64',)
|
||||||
|
|
||||||
(options, args) = parser.parse_args()
|
(options, args) = parser.parse_args()
|
||||||
if options.debug:
|
if options.debug:
|
||||||
@ -345,8 +355,16 @@ def main():
|
|||||||
temp_dir = CreateTempDir()
|
temp_dir = CreateTempDir()
|
||||||
dest_files_root = os.path.join(temp_dir, 'au-generator')
|
dest_files_root = os.path.join(temp_dir, 'au-generator')
|
||||||
os.makedirs(dest_files_root)
|
os.makedirs(dest_files_root)
|
||||||
CopyRequiredFiles(dest_files_root=dest_files_root)
|
|
||||||
WrapExecutableFiles(dest_files_root=dest_files_root)
|
if options.arch == 'arm64':
|
||||||
|
ld_linux = LD_LINUX_ARM64
|
||||||
|
allow_list = ALLOW_LIST_ARM64
|
||||||
|
else:
|
||||||
|
ld_linux = LD_LINUX_AMD64
|
||||||
|
allow_list = ALLOW_LIST_AMD64
|
||||||
|
|
||||||
|
CopyRequiredFiles(dest_files_root=dest_files_root, allow_list=allow_list)
|
||||||
|
WrapExecutableFiles(dest_files_root=dest_files_root, ld_linux=ld_linux)
|
||||||
zip_file_name = os.path.join(temp_dir, options.zip_name)
|
zip_file_name = os.path.join(temp_dir, options.zip_name)
|
||||||
GenerateZipFile(zip_file_name, dest_files_root)
|
GenerateZipFile(zip_file_name, dest_files_root)
|
||||||
CopyZipToFinalDestination(options.output_dir, zip_file_name)
|
CopyZipToFinalDestination(options.output_dir, zip_file_name)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user