From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=lgut.eu Authentication-Results: passt.top; dkim=pass (2048-bit key; unprotected) header.d=lgut-eu.20230601.gappssmtp.com header.i=@lgut-eu.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=gJRw5sGk; dkim-atps=neutral Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by passt.top (Postfix) with ESMTPS id 883C55A0276 for ; Wed, 18 Sep 2024 12:17:06 +0200 (CEST) Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-42cbaf9bfdbso45224885e9.0 for ; Wed, 18 Sep 2024 03:17:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lgut-eu.20230601.gappssmtp.com; s=20230601; t=1726654626; x=1727259426; darn=passt.top; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=GeHOeILRHEbb9/a/HNZhdkQq8YStcU25KRQxsUoB4dk=; b=gJRw5sGkEvrWzmfQyK8uw/F/X8REjWFv0LVzk3JTu7nwMMxiltynvgH4sj+W6qr2Dm yqnhFZwCHzUYISGIXJ+2SAaf1CxVF0cGTYzbsCbf9JIo9hEFZMxlnwn9i0J+suZbw6KR lMTCkXCxWAybbwrrIb0YFS5LpMQuxFJEamaobVBIGPj9Dhv9oNmaA71WtT2h9UUNxMja s2E3n9mNAYHjO/aMrgRlr0ne0iANaoSbt95MnvCoX8AjxJS/3kBmI667oHJLbPpaXC9G VcmhpLxFnLMX6ED3YswHSxXYfQ23GcNhh0j4bHa/XQbcayxk1QEro4hZOUAlpirEgeqE NHLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726654626; x=1727259426; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GeHOeILRHEbb9/a/HNZhdkQq8YStcU25KRQxsUoB4dk=; b=Au70Wih8Ra7o2OyNreDUAOt1iNFfShdBD+6YkWkdjcjxQY4ODiMLW/aCmypizkOonG b40aDtFsaW1863k8me+vjh60ktfDkYxkqvbzumUabErvgyRAQVx2T9pYFMpaERkuMoeG JfN+7YMFqWWkjhKYMTZxKgLGA2LBujoiF+uqUSHCKrrJFlPg1fISDAFJHr+HYL88dnY9 JKO6+duOXJLHB83maMU23/QsxAlzHEMOyZIG3SBy2L7crB1oittzaBr51Kgl+lc5gj3i d+4wLnc/6mpxQ1toRmUUrhw1iTdh0mLU5ErGxnf6Nlk5OjCUZs1bXCjK35KzSJLLzPYE 8G9A== X-Forwarded-Encrypted: i=1; AJvYcCXXA/XCELyxH+jGFBt5XkkRuZrXdIt7JcWh0r03700UcVIOwYsF14akPZNfEZUYp9SVQF1wt76SV8g=@passt.top X-Gm-Message-State: AOJu0YyTFeVdTbSkgx87nQJIi4839NIyExjzDcppfB7uBtWCtR3k5vrr Xz8n3Ugx+G8wwTl6yZARBynmkI36KcIXGTPBUK8/aBq2sv+/axPaO6Zb8gLtO0M= X-Google-Smtp-Source: AGHT+IEZ0eslSLxkKHiJq7EhMXsdLJ37AES5cK93qTNYPrwRLQqVeEohtr7QRna3KdhLztvfu2+weQ== X-Received: by 2002:adf:e647:0:b0:374:ae04:c7c5 with SMTP id ffacd0b85a97d-378d6241dacmr8858327f8f.36.1726654625870; Wed, 18 Sep 2024 03:17:05 -0700 (PDT) Received: from localhost.localdomain (ip-046-005-002-171.um12.pools.vodafone-ip.de. [46.5.2.171]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-378e73f99a4sm11863660f8f.57.2024.09.18.03.17.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Sep 2024 03:17:05 -0700 (PDT) From: Lukasz Gut To: sbrivio@redhat.com Subject: [PATCH v2 4/4] mbuto: Automatically add links related to linker Date: Wed, 18 Sep 2024 12:12:59 +0200 Message-ID: <20240918101532.85299-6-lgut@lgut.eu> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20240918101532.85299-1-lgut@lgut.eu> References: <20240918101532.85299-1-lgut@lgut.eu> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: C43PTVJMZOXUWUJ4BENHTODQTKJUHUGH X-Message-ID-Hash: C43PTVJMZOXUWUJ4BENHTODQTKJUHUGH X-MailFrom: lgut@lgut.eu X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: sevinj.aghayeva@gmail.com, passt-dev@passt.top, Lukasz Gut X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Fix dynamic linking on Arch Linux by adding (some of) missing links. The ldd reports linker in many ways: ldd /usr/lib/libreadline.so.8 /usr/lib64/ld-linux-x86-64.so.2 (0x000071244211c000) ldd /bin/sh /lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x000077457d5ec000) ldd /usr/lib/libc.so.6 /usr/lib/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x000075d218b8b000) This patch looks at the left side and determines if there is a link there, then adds it. Signed-off-by: Lukasz Gut --- mbuto | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/mbuto b/mbuto index 4f860cd..7d67160 100755 --- a/mbuto +++ b/mbuto @@ -668,6 +668,27 @@ libs_dlopen_copy() { done } +# libs_add_links() - Rebuild alternate links to ld as they appear on the host +# $1: String returned by ldd in form 's => d' describing location of ld +libs_add_links() { + __ld_path="${1##*=> }" + __ld_link="${1%%=>*}" + [ -z "${__ld_link}" ] && return + [ "${__ld_path}" = "${__ld_link}" ] && return + while [ "${__ld_link}" != "/" ]; do + if [ -L "${__ld_link}" ]; then + __target="$("${READLINK}" -f "${__ld_link}")" + __link="$("${REALPATH}" -s "${__ld_link}" --relative-to "/")" + __link="${wd}"/"${__link}" + [ -L "${__link}" ] && break + __destdir="$("${DIRNAME}" "${__link}")" + "${MKDIR}" -p "${__destdir}" + "${LN}" -s "${__target}" "${__link}" + fi + __ld_link="$("${DIRNAME}" "${__ld_link}")" + done +} + # __libs_copy() - Recursively copy shared dependencies for programs, libraries # $1: Host path to program or library __libs_copy() { @@ -716,8 +737,13 @@ __libs_copy() { if [ -n "${__ld_path}" ]; then libs_copy_ld_so "${__ld_path}" - libs_path_add "${__ld_path##${wd}}" + libs_path_add "${__ld_path##"${wd}"}" fi + + # On Arch Linux, to execute /bin/sh, the system expects the linker + # to be under /lib64. Linker is located in /usr/lib, and there is + # a link /lib64 => /usr/lib. + libs_add_links "${__ld_so}" } # libs_copy() - Call __libs_copy with tabs and newlines as IFS -- 2.46.1