From nobody Thu Nov 13 14:53:09 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1580721044921559.7028015237743; Mon, 3 Feb 2020 01:10:44 -0800 (PST) Received: from localhost ([::1]:36552 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyXkh-0008El-Lz for importer@patchew.org; Mon, 03 Feb 2020 04:10:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47641) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iyXje-0006Rx-Gf for qemu-devel@nongnu.org; Mon, 03 Feb 2020 04:09:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iyXjd-0000kR-FU for qemu-devel@nongnu.org; Mon, 03 Feb 2020 04:09:38 -0500 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]:39238) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iyXjd-0000in-9O for qemu-devel@nongnu.org; Mon, 03 Feb 2020 04:09:37 -0500 Received: by mail-wr1-x430.google.com with SMTP id y11so16895623wrt.6 for ; Mon, 03 Feb 2020 01:09:37 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id y8sm21941926wma.10.2020.02.03.01.09.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Feb 2020 01:09:34 -0800 (PST) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 83FB71FF8F; Mon, 3 Feb 2020 09:09:32 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bJVPdPbPDIO3CTMf6DLXKYbai7SRpNMMODbXla883Mo=; b=XokhQpBEFKzmF8nRsZ9RJY1J/AQyd26oqfHgx+wbyUV1Oh0dSPdxdjzUJM4DsgmFK7 8py4dQapULoyZWQ2k+oZSdZ5tQKu0jyulFU1/BbicZqe2nPq5HcysUMkT+ZfmZZPCEBR sWFuQuPeakm/vD2+40FsZ6waFS2LoSqKhOxPxl4K38pg/yc7ZxNiFUILGf5Erzf0MiL2 9rww/xocFSEkxoIWgY+hspoNvsPbnddWJbXYloBFWCyCTUFgJj9MOggwl+meOUKMsJYn jLnHi2LoVqK8fO4FSAUybb25TqkcMwej8DGy5R1VDVGVEnep9bJNqXkDFwlAYvZR6Eoz e/zQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bJVPdPbPDIO3CTMf6DLXKYbai7SRpNMMODbXla883Mo=; b=JbOxgSqES9UPYqpNuXq8w8D8mpP7vAKJr04d6OERIPLoBLHyQixTE/iB4QMoSFTEi8 Kd+n1p549RdT02WOYqDoPJuInMX/C+Ohsn7cI1Yz4qki4mciQqFz33nvsmr9pDRLL38N xSbLjEMBCAO69eGBxrOgqeieTSI09Hx8cKOxUWW46mn+Pr8V4W8xkGjUWDAFjjawqGfn WYwe2HpS5kv5ZNKDyWi7mNkcM6P+t8Y5J0Tywm3FqcvcdtnFobnHXNsK0VB7AMc6YMrI zulde+ba31DoRxJOCPIoqyD1IfQcfTcqJwxs93FprD1dO0wp+YgPhDWVQYi45w8xPhGi nd/Q== X-Gm-Message-State: APjAAAVa4whmiZvEVEgAn7WKzZknEM2IoN5GfvTgKz4CITN4ZcwwfadZ Q/kYSzfiHK6fX40aQzS06n+kuA== X-Google-Smtp-Source: APXvYqy2JhCJlYK10qraXWswULM98zKzuU64pAam0tPUrXbb5Iv6qse7SHz2eqLneujum4IGCYGaGQ== X-Received: by 2002:adf:ea8a:: with SMTP id s10mr13469585wrm.278.1580720976318; Mon, 03 Feb 2020 01:09:36 -0800 (PST) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: qemu-devel@nongnu.org Subject: [PATCH v3 02/17] tests/docker: better handle symlinked libs Date: Mon, 3 Feb 2020 09:09:17 +0000 Message-Id: <20200203090932.19147-3-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200203090932.19147-1-alex.bennee@linaro.org> References: <20200203090932.19147-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::430 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: fam@euphon.net, berrange@redhat.com, stefanb@linux.vnet.ibm.com, =?UTF-8?q?Alex=20Benn=C3=A9e?= , richard.henderson@linaro.org, f4bug@amsat.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , cota@braap.org, stefanha@redhat.com, marcandre.lureau@redhat.com, pbonzini@redhat.com, aurelien@aurel32.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) When we are copying we want to ensure we grab the first resolution (the found in path section). However even that binary might be a symlink so lets make sure we chase the symlinks to copy the right binary to where it can be found. Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 --- v3 - fix comment - fix grouping extraction - try/except on IndexError --- tests/docker/docker.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/tests/docker/docker.py b/tests/docker/docker.py index 31d8adf836e..d8268c11117 100755 --- a/tests/docker/docker.py +++ b/tests/docker/docker.py @@ -106,18 +106,19 @@ def _get_so_libs(executable): """Return a list of libraries associated with an executable. =20 The paths may be symbolic links which would need to be resolved to - ensure theright data is copied.""" + ensure the right data is copied.""" =20 libs =3D [] - ldd_re =3D re.compile(r"(/.*/)(\S*)") + ldd_re =3D re.compile(r"(?:\S+ =3D> )?(\S*) \(:?0x[0-9a-f]+\)") try: ldd_output =3D subprocess.check_output(["ldd", executable]).decode= ('utf-8') for line in ldd_output.split("\n"): search =3D ldd_re.search(line) - if search and len(search.groups()) =3D=3D 2: - so_path =3D search.groups()[0] - so_lib =3D search.groups()[1] - libs.append("%s/%s" % (so_path, so_lib)) + if search: + try: + libs.append(s.group(1)) + except IndexError: + pass except subprocess.CalledProcessError: print("%s had no associated libraries (static build?)" % (executab= le)) =20 @@ -145,7 +146,8 @@ def _copy_binary_with_libs(src, bin_dest, dest_dir): if libs: for l in libs: so_path =3D os.path.dirname(l) - _copy_with_mkdir(l, dest_dir, so_path) + real_l =3D os.path.realpath(l) + _copy_with_mkdir(real_l, dest_dir, so_path) =20 =20 def _check_binfmt_misc(executable): --=20 2.20.1