From patchwork Wed May 13 10:52:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tremer X-Patchwork-Id: 3079 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail01.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 49MWk00ytVz3xQr for ; Wed, 13 May 2020 10:53:28 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail02.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 49MWjy61rXz1D6; Wed, 13 May 2020 10:53:26 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 49MWjx6gVfz2yRZ; Wed, 13 May 2020 10:53:25 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail01.haj.ipfire.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 49MWjw3ln3z2yCC for ; Wed, 13 May 2020 10:53:24 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) by mail01.ipfire.org (Postfix) with ESMTPSA id 49MWjv5qnFz1D6; Wed, 13 May 2020 10:53:23 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1589367203; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=cDDgNAb4TEPJYg3BpAg15ce6vvwhQIKmqmVQtMjR8aE=; b=RjCOneH5Hw+UXq4otaXheWZKCVfXwxfJd7IVnwtinxUxi2D5rW+FWUaTITVCt7axQkeb2s CTUux4FYFt/73RBg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1589367203; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=cDDgNAb4TEPJYg3BpAg15ce6vvwhQIKmqmVQtMjR8aE=; b=Bh8fkMH0zqzyJvwkv3Mg/8x3DC5095zqt7IHfK2ZIOPsGAUeGCkm6ArXIQPZmWKkyWdvmy zvcfqXCj3xlLkhvYna1wwOOPFq13cwou2C5eb3Vfjqb0YPATHM5i5nkwy3xo4EDpZt3Vsn e7gt8ZQAX65YoS/Tymu21ReexdTwfPAkBOZWcjKBJqLRPcjeWx4UrODemG6Nsi7/bNp9YI Zw7K2GkwZGkwo/C/TmD26FAV6xJcRoGwIaVbADa/vyklT3I0Ra/XMRO6MZfjCcSSMRRDci 37/gBsIh010PRHohnDkZFn9IqACY4gvHeFe7ilbEBV86/NI4FI2ZJKVkR38K8w== From: Michael Tremer To: development@lists.ipfire.org Subject: [PATCH] make.sh: Add command to find dependencies Date: Wed, 13 May 2020 11:52:59 +0100 Message-Id: <20200513105259.28975-1-michael.tremer@ipfire.org> In-Reply-To: <112CD7FD-306C-4D86-9C7B-1809A11B0D63@ipfire.org> References: <112CD7FD-306C-4D86-9C7B-1809A11B0D63@ipfire.org> Authentication-Results: mail01.ipfire.org; auth=pass smtp.mailfrom=michael.tremer@ipfire.org X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michael Tremer Errors-To: development-bounces@lists.ipfire.org Sender: "Development" Signed-off-by: Michael Tremer --- make.sh | 6 +++++- tools/find-dependencies | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100755 tools/find-dependencies diff --git a/make.sh b/make.sh index 78c4edc90..4acce807f 100755 --- a/make.sh +++ b/make.sh @@ -1993,8 +1993,12 @@ lang) update-contributors) update_contributors ;; +find-dependencies) + shift + exec "${BASEDIR}/tools/find-dependencies" "${BASEDIR}/build" "$@" + ;; *) - echo "Usage: $0 {build|changelog|clean|gettoolchain|downloadsrc|shell|sync|toolchain|update-contributors}" + echo "Usage: $0 {build|changelog|clean|gettoolchain|downloadsrc|shell|sync|toolchain|update-contributors|find-dependencies}" cat doc/make.sh-usage ;; esac diff --git a/tools/find-dependencies b/tools/find-dependencies new file mode 100755 index 000000000..25e6cddea --- /dev/null +++ b/tools/find-dependencies @@ -0,0 +1,32 @@ +#!/bin/bash + +main() { + if [ $# -lt 2 ]; then + echo "${0}: Usage: PATH LIBRARY ..." + return 2 + fi + + local root="${1}" + shift + + if [ ! -d "${root}" ]; then + echo "${0}: ${root}: No such file or directory" + return 1 + fi + + local libraries="$@" + + # Build the regex filter + local filter="(${libraries[*]// /|})" + + local file + for file in $(find "${root}" -xdev -type f -executable); do + if readelf -d "${file}" 2>/dev/null | grep -qE "NEEDED.*\[${filter}\]$"; then + echo "${file}" + fi + done + + return 0 +} + +main "$@" || exit $?