diff --git a/data/tmpfiles.d/toolbox.conf b/data/tmpfiles.d/toolbox.conf index bdffe7c..0ddb1f0 100644 --- a/data/tmpfiles.d/toolbox.conf +++ b/data/tmpfiles.d/toolbox.conf @@ -1 +1,2 @@ d /run/media 0755 root root - - +L /run/host - - - - ../ diff --git a/meson.build b/meson.build index b580c10..ae228ee 100644 --- a/meson.build +++ b/meson.build @@ -1,17 +1,13 @@ project( 'toolbox', - 'c', version: '0.0.99.2', license: 'ASL 2.0', - meson_version: '>= 0.42.0', + meson_version: '>= 0.53.0', ) -cc = meson.get_compiler('c') -add_project_arguments('-pthread', language: 'c') -add_project_link_arguments('-pthread', language: 'c') - go = find_program('go') go_md2man = find_program('go-md2man') +patchelf = find_program('patchelf') shellcheck = find_program('shellcheck', required: false) skopeo = find_program('skopeo', required: false) diff --git a/playbooks/setup-env.yaml b/playbooks/setup-env.yaml index 5644f1a..7ac9b46 100644 --- a/playbooks/setup-env.yaml +++ b/playbooks/setup-env.yaml @@ -13,6 +13,7 @@ - golang-github-cpuguy83-md2man - meson - ninja-build + - patchelf - podman - skopeo - systemd diff --git a/src/go-build-wrapper b/src/go-build-wrapper index 0d27120..677dca9 100755 --- a/src/go-build-wrapper +++ b/src/go-build-wrapper @@ -16,9 +16,9 @@ # -if [ "$#" -ne 4 ]; then +if [ "$#" -ne 3 ]; then echo "go-build-wrapper: wrong arguments" >&2 - echo "Usage: go-build-wrapper [SOURCE DIR] [OUTPUT DIR] [VERSION] [libc-wrappers.a]" >&2 + echo "Usage: go-build-wrapper [SOURCE DIR] [OUTPUT DIR] [VERSION]" >&2 exit 1 fi @@ -27,5 +27,16 @@ if ! cd "$1"; then exit 1 fi -go build -trimpath -ldflags "-extldflags '-Wl,--wrap,pthread_sigmask $4' -linkmode external -X github.com/containers/toolbox/pkg/version.currentVersion=$3" -o "$2/toolbox" +go build -trimpath -ldflags "-extldflags '-Wl,-rpath,/run/host/usr/lib -Wl,-rpath,/run/host/usr/lib64' -linkmode external -X github.com/containers/toolbox/pkg/version.currentVersion=$3" -o "$2/toolbox" + +if ! interpreter=$(patchelf --print-interpreter "$2/toolbox"); then + echo "go-build-wrapper: failed to read PT_INTERP from $2/toolbox" >&2 + exit 1 +fi + +if ! patchelf --set-interpreter "/run/host$interpreter" "$2/toolbox"; then + echo "go-build-wrapper: failed to change PT_INTERP of $2/toolbox to /run/host$interpreter" >&2 + exit 1 +fi + exit "$?" diff --git a/src/libc-wrappers/libc-wrappers.c b/src/libc-wrappers/libc-wrappers.c deleted file mode 100644 index 7b402bc..0000000 --- a/src/libc-wrappers/libc-wrappers.c +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright © 2020 – 2021 Red Hat Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -#include - - -#if defined __aarch64__ -__asm__(".symver pthread_sigmask,pthread_sigmask@GLIBC_2.17"); -#elif defined __arm__ -__asm__(".symver pthread_sigmask,pthread_sigmask@GLIBC_2.4"); -#elif defined __i386__ -__asm__(".symver pthread_sigmask,pthread_sigmask@GLIBC_2.0"); -#elif defined __powerpc64__ && _CALL_ELF == 2 /* ppc64le */ -__asm__(".symver pthread_sigmask,pthread_sigmask@GLIBC_2.17"); -#elif defined __s390x__ -__asm__(".symver pthread_sigmask,pthread_sigmask@GLIBC_2.2"); -#elif defined __x86_64__ -__asm__(".symver pthread_sigmask,pthread_sigmask@GLIBC_2.2.5"); -#else -#error "Please specify symbol version for pthread_sigmask" -#endif - - -int -__wrap_pthread_sigmask (int how, const sigset_t *set, sigset_t *oldset) -{ - return pthread_sigmask (how, set, oldset); -} diff --git a/src/libc-wrappers/meson.build b/src/libc-wrappers/meson.build deleted file mode 100644 index 3984ce4..0000000 --- a/src/libc-wrappers/meson.build +++ /dev/null @@ -1,8 +0,0 @@ -sources = files( - 'libc-wrappers.c', -) - -libc_wrappers = static_library( - 'c-wrappers', - sources, -) diff --git a/src/meson.build b/src/meson.build index f76606d..759db1f 100644 --- a/src/meson.build +++ b/src/meson.build @@ -1,5 +1,3 @@ -subdir('libc-wrappers') - go_build_wrapper_file = files('go-build-wrapper') go_build_wrapper_program = find_program('go-build-wrapper') @@ -28,9 +26,7 @@ custom_target( meson.current_source_dir(), meson.current_build_dir(), meson.project_version(), - libc_wrappers.full_path(), ], - depends: libc_wrappers, input: sources, install: true, install_dir: get_option('bindir'),