@@ -18,10 +18,26 @@ BAZEL ?= "${BAZEL_DIR}/bazel"
do_prepare_recipe_sysroot[postfuncs] += "do_install_bazel"
do_install_bazel() {
- mkdir -p ${BAZEL_DIR}
- install -m 0755 ${STAGING_BINDIR_NATIVE}/bazel ${BAZEL_DIR}
- create_cmdline_wrapper ${BAZEL} \$BAZEL_STARTUP_OPTIONS
- zip -A ${BAZEL}.real
+ mkdir -p "${BAZEL_DIR}"
+ install -m 0755 "${STAGING_BINDIR_NATIVE}/bazel" "${BAZEL_DIR}"
+ create_cmdline_wrapper "${BAZEL}" \$BAZEL_STARTUP_OPTIONS
+
+ if which patchelf-uninative; then
+ # Uninative is disabled in bazel-native, bazel will fail if interpreter path has changed
+ # patchelf may break self-extracting executable archive, let's set interpreter only for executable part
+ cp "${BAZEL}.real" "${BAZEL}.real.non-sfx"
+ # Strip SFX stub from the archive
+ zip --junk-sfx "${BAZEL}.real.non-sfx"
+ # Save all but the last x bytes, which are compressed data, to get SFX stub
+ head --bytes=-"$(wc --bytes "${BAZEL}.real.non-sfx" | cut -d' ' -f1)" "${BAZEL}.real" > "${BAZEL}.real.sfx-stub"
+ # Change the dynamic loader of executable part only
+ patchelf-uninative --set-interpreter "${UNINATIVE_LOADER}" "${BAZEL}.real.sfx-stub"
+ # Merge back executable and compressed data
+ cat "${BAZEL}.real.sfx-stub" "${BAZEL}.real.non-sfx" > "${BAZEL}.real"
+ rm "${BAZEL}.real.sfx-stub" "${BAZEL}.real.non-sfx"
+ fi
+
+ zip -A "${BAZEL}.real"
}
def bazel_get_target_flags(d):